@example
$ nncp-daemon [options]
- [-maxconn INT] [-bind ADDR] [-inetd]
+ [-maxconn INT] [-bind ADDR] [-ucspi]
[-autotoss*] [-nock] [-mcd-once]
@end example
can handle. @option{-bind} option specifies @option{addr:port} it must
bind to and listen.
-It could be run as @command{inetd} service, by specifying
-@option{-inetd} option. Pay attention that because it uses
-@code{stdin}/@code{stdout}, it can not effectively work with IO timeouts
-and connection closing can propagate up to 5 minutes in practice.
-Example inetd-entry:
+It could be run as @url{http://cr.yp.to/ucspi-tcp.html, UCSPI-TCP}
+service, by specifying @option{-ucspi} option. Pay attention that
+because it uses @code{stdin}/@code{stdout}, it can not effectively work
+with IO timeouts and connection closing can propagate up to 5 minutes in
+practice. Example startup command:
@verbatim
-uucp stream tcp6 nowait nncpuser /usr/local/bin/nncp-daemon nncp-daemon -quiet -inetd
+tcpserver -DHR -l 0 ::0 uucp nncp-daemon -quiet -ucspi
+@end verbatim
+
+Also it is some kind of backward compatible with @command{inetd}
+interface, just lacking knowledge or remote's address:
+
+@verbatim
+uucp stream tcp6 nowait nncpuser /usr/local/bin/nncp-daemon nncp-daemon -quiet -ucspi
@end verbatim
@option{-autotoss} option runs tosser on node's spool every second
flag.PrintDefaults()
}
-type InetdConn struct {
+type UCSPIConn struct {
r *os.File
w *os.File
}
-func (c InetdConn) Read(p []byte) (n int, err error) {
+func (c UCSPIConn) Read(p []byte) (n int, err error) {
return c.r.Read(p)
}
-func (c InetdConn) Write(p []byte) (n int, err error) {
+func (c UCSPIConn) Write(p []byte) (n int, err error) {
return c.w.Write(p)
}
-func (c InetdConn) SetReadDeadline(t time.Time) error {
+func (c UCSPIConn) SetReadDeadline(t time.Time) error {
return c.r.SetReadDeadline(t)
}
-func (c InetdConn) SetWriteDeadline(t time.Time) error {
+func (c UCSPIConn) SetWriteDeadline(t time.Time) error {
return c.w.SetWriteDeadline(t)
}
-func (c InetdConn) Close() error {
+func (c UCSPIConn) Close() error {
if err := c.r.Close(); err != nil {
c.w.Close() // #nosec G104
return err
cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
niceRaw = flag.String("nice", nncp.NicenessFmt(255), "Minimal required niceness")
bind = flag.String("bind", "[::]:5400", "Address to bind to")
- inetd = flag.Bool("inetd", false, "Is it started as inetd service")
+ ucspi = flag.Bool("ucspi", false, "Is it started as UCSPI-TCP server")
+ inetd = flag.Bool("inetd", false, "Obsolete, use -ucspi")
maxConn = flag.Int("maxconn", 128, "Maximal number of simultaneous connections")
noCK = flag.Bool("nock", false, "Do no checksum checking")
mcdOnce = flag.Bool("mcd-once", false, "Send MCDs once and quit")
if err != nil {
log.Fatalln(err)
}
+ if *inetd {
+ *ucspi = true
+ }
ctx, err := nncp.CtxFromCmdline(
*cfgPath,
}
ctx.Umask()
- if *inetd {
+ if *ucspi {
os.Stderr.Close() // #nosec G104
- conn := &InetdConn{os.Stdin, os.Stdout}
+ conn := &UCSPIConn{os.Stdin, os.Stdout}
nodeIdC := make(chan *nncp.NodeId)
- go performSP(ctx, conn, "PIPE", nice, *noCK, nodeIdC)
+ addr := "PIPE"
+ if proto := os.Getenv("PROTO"); proto == "TCP" {
+ port := os.Getenv("TCPREMOTEPORT")
+ if host := os.Getenv("TCPREMOTEHOST"); host == "" {
+ addr = fmt.Sprintf("[%s]:%s", os.Getenv("TCPREMOTEIP"), port)
+ } else {
+ addr = fmt.Sprintf("%s:%s", host, port)
+ }
+ }
+ go performSP(ctx, conn, addr, nice, *noCK, nodeIdC)
nodeId := <-nodeIdC
var autoTossFinish chan struct{}
var autoTossBadCode chan bool