X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcall.go;h=c52fc419ecafe6a75e45afaf9a14e99bd8c5a6ee;hb=0367cce2741e1ce6a89a49fd5c4e9df6005c9744;hp=648190f22856e45bbc437a1d2a49e54e8522fb1d;hpb=0fad171c0d79ad583c0faf5427e22d1d62a0a52d;p=nncp.git diff --git a/src/call.go b/src/call.go index 648190f..c52fc41 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,8 +18,10 @@ along with this program. If not, see . package nncp import ( + "errors" "fmt" "net" + "os" "time" "github.com/dustin/go-humanize" @@ -45,6 +47,7 @@ type Call struct { AutoTossNoFreq bool AutoTossNoExec bool AutoTossNoTrns bool + AutoTossNoArea bool } func (ctx *Ctx) CallNode( @@ -67,6 +70,19 @@ 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 { conn, err = net.Dial("tcp", addr) } @@ -110,7 +126,7 @@ func (ctx *Ctx) CallNode( node.Name, int(state.Duration.Hours()), int(state.Duration.Minutes()), - int(state.Duration.Seconds()/60), + int(state.Duration.Seconds())%60, humanize.IBytes(uint64(state.RxBytes)), humanize.IBytes(uint64(state.RxSpeed)), humanize.IBytes(uint64(state.TxBytes)), @@ -118,13 +134,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