]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/call.go
Raise copyright years
[nncp.git] / src / call.go
index 1e20aa23f340a40549660de2878dfb1b97986c78..c52fc419ecafe6a75e45afaf9a14e99bd8c5a6ee 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
 
 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 <http://www.gnu.org/licenses/>.
 package nncp
 
 import (
+       "errors"
        "fmt"
        "net"
+       "os"
        "time"
 
        "github.com/dustin/go-humanize"
@@ -68,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)
                }
@@ -119,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