X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcall.go;h=295e7c8805c62eaee4cf0d3fd5051e4e86fb2251;hb=2e59e1d8da61bc5dee797d351e50e8ed114aa4c7;hp=5af47807250674d7e9ae4595c097e6a8d6da531f;hpb=6356b32e09f5dea51a9941fe1cd84014ebd0e524;p=nncp.git diff --git a/src/call.go b/src/call.go index 5af4780..295e7c8 100644 --- a/src/call.go +++ b/src/call.go @@ -1,6 +1,6 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2021 Sergey Matveev +Copyright (C) 2016-2022 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,12 +18,16 @@ along with this program. If not, see . package nncp import ( + "errors" "fmt" "net" + "os" + "strings" "time" "github.com/dustin/go-humanize" "github.com/gorhill/cronexpr" + nncpYggdrasil "go.cypherpunks.ru/nncp/v8/yggdrasil" ) type Call struct { @@ -45,6 +49,8 @@ type Call struct { AutoTossNoFreq bool AutoTossNoExec bool AutoTossNoTrns bool + AutoTossNoArea bool + AutoTossNoACK bool } func (ctx *Ctx) CallNode( @@ -67,11 +73,26 @@ func (ctx *Ctx) CallNode( var err error if addr[0] == '|' { conn, err = NewPipeConn(addr[1:]) + } else if addr == UCSPITCPClient { + ucspiConn := UCSPIConn{R: os.NewFile(6, "R"), W: os.NewFile(7, "W")} + if ucspiConn.R == nil { + err = errors.New("no 6 file descriptor") + } + if ucspiConn.W == nil { + err = errors.New("no 7 file descriptor") + } + conn = ucspiConn + addr = UCSPITCPRemoteAddr() + if addr == "" { + addr = UCSPITCPClient + } + } else if strings.HasPrefix(addr, "yggdrasilc://") { + conn, err = nncpYggdrasil.NewConn(ctx.YggdrasilAliases, addr) } else { conn, err = net.Dial("tcp", addr) } if err != nil { - ctx.LogD("calling", append(les, LE{"Err", err}), func(les LEs) string { + ctx.LogE("calling", les, err, func(les LEs) string { return fmt.Sprintf("Calling %s (%s)", node.Name, addr) }) continue @@ -118,13 +139,13 @@ func (ctx *Ctx) CallNode( ) }) isGood = true - conn.Close() // #nosec G104 + conn.Close() break } else { ctx.LogE("call-started", les, err, func(les LEs) string { return fmt.Sprintf("Connection to %s (%s)", node.Name, addr) }) - conn.Close() // #nosec G104 + conn.Close() } } return