/*
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
"time"
"github.com/dustin/go-humanize"
- "go.cypherpunks.ru/nncp/v7"
+ "go.cypherpunks.ru/nncp/v8"
"golang.org/x/net/netutil"
)
bind = flag.String("bind", "[::]:5400", "Address to bind to")
ucspi = flag.Bool("ucspi", false, "Is it started as UCSPI-TCP server")
inetd = flag.Bool("inetd", false, "Obsolete, use -ucspi")
+ yggdrasil = flag.String("yggdrasil", "", "Start Yggdrasil listener: PRV;BIND[,...];[PUB,...];[PEER,...]")
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")
warranty = flag.Bool("warranty", false, "Print warranty information")
autoToss = flag.Bool("autotoss", false, "Toss after call is finished")
- autoTossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
+ autoTossDoSeen = flag.Bool("autotoss-seen", false, "Create seen/ files during tossing")
autoTossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
autoTossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
autoTossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
return
}
- cols := strings.Split(*bind, ":")
- port, err := strconv.Atoi(cols[len(cols)-1])
- if err != nil {
- log.Fatalln("Can not parse port:", err)
- }
+ var ln net.Listener
+ if *yggdrasil != "" {
+ ln, err = nncp.NewYggdrasilListener(ctx.YggdrasilAliases, *yggdrasil)
+ if err != nil {
+ log.Fatalln("Can not listen:", err)
+ }
+ } else {
+ cols := strings.Split(*bind, ":")
+ port, err := strconv.Atoi(cols[len(cols)-1])
+ if err != nil {
+ log.Fatalln("Can not parse port:", err)
+ }
- if *mcdOnce {
- for ifiName := range ctx.MCDTxIfis {
- if err = ctx.MCDTx(ifiName, port, 0); err != nil {
- log.Fatalln("Can not do MCD transmission:", err)
+ if *mcdOnce {
+ for ifiName := range ctx.MCDTxIfis {
+ if err = ctx.MCDTx(ifiName, port, 0); err != nil {
+ log.Fatalln("Can not do MCD transmission:", err)
+ }
}
+ return
}
- return
- }
- ln, err := net.Listen("tcp", *bind)
- if err != nil {
- log.Fatalln("Can not listen:", err)
- }
+ ln, err = net.Listen("tcp", *bind)
+ if err != nil {
+ log.Fatalln("Can not listen:", err)
+ }
- for ifiName, secs := range ctx.MCDTxIfis {
- if err = ctx.MCDTx(ifiName, port, time.Duration(secs)*time.Second); err != nil {
- log.Fatalln("Can not run MCD transmission:", err)
+ for ifiName, secs := range ctx.MCDTxIfis {
+ if err = ctx.MCDTx(ifiName, port, time.Duration(secs)*time.Second); err != nil {
+ log.Fatalln("Can not run MCD transmission:", err)
+ }
}
}