"log"
"net"
"os"
+ "strconv"
+ "strings"
"time"
"github.com/dustin/go-humanize"
state.Node.Name,
int(state.Duration.Hours()),
int(state.Duration.Minutes()),
- int(state.Duration.Seconds()),
+ int(state.Duration.Seconds()/60),
humanize.IBytes(uint64(state.RxBytes)),
humanize.IBytes(uint64(state.RxSpeed)),
humanize.IBytes(uint64(state.TxBytes)),
)
})
} else {
- nodeId := "unknown"
+ var nodeId string
+ var nodeName string
if state.Node == nil {
+ nodeId = "unknown"
+ nodeName = "unknown"
nodeIdC <- nil
} else {
- nodeIdC <- state.Node.Id
nodeId = state.Node.Id.String()
+ nodeName = state.Node.Name
+ nodeIdC <- state.Node.Id
}
ctx.LogI(
"call-started",
nncp.LEs{{K: "Node", V: nodeId}},
- func(les nncp.LEs) string { return "Connected to " + state.Node.Name },
+ func(les nncp.LEs) string { return "Connected to " + nodeName },
)
}
close(nodeIdC)
inetd = flag.Bool("inetd", false, "Is it started as inetd service")
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")
spoolPath = flag.String("spool", "", "Override path to spool")
logPath = flag.String("log", "", "Override path to logfile")
quiet = flag.Bool("quiet", false, "Print only errors")
autoTossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
autoTossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
)
+ log.SetFlags(log.Lshortfile)
flag.Usage = usage
flag.Parse()
if *warranty {
return
}
+ 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)
+ }
+ }
+ return
+ }
+
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)
+ }
+ }
+
ln = netutil.LimitListener(ln, *maxConn)
for {
conn, err := ln.Accept()