]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cypherpunks.ru/nncp/cmd/nncp-daemon/main.go
Fix invalid -rx/-tx arguments processing
[nncp.git] / src / cypherpunks.ru / nncp / cmd / nncp-daemon / main.go
index b639d10446990059b7283096145cc59e10ec668f..e6ec2d385648ae1c84c8e959cc381addbc3d8e92 100644 (file)
@@ -73,6 +73,9 @@ func main() {
        if err != nil {
                log.Fatalln("Can not parse config:", err)
        }
+       if ctx.Self == nil {
+               log.Fatalln("Config lacks private keys")
+       }
        ctx.Quiet = *quiet
        ctx.Debug = *debug
 
@@ -88,12 +91,12 @@ func main() {
                }
                ctx.LogD("daemon", nncp.SDS{"addr": conn.RemoteAddr()}, "accepted")
                go func(conn net.Conn) {
-                       state, err := ctx.StartR(conn, nice, nil)
+                       state, err := ctx.StartR(conn, nice, "")
                        if err == nil {
-                               ctx.LogI("call-start", nncp.SDS{"node": state.NodeId}, "connected")
+                               ctx.LogI("call-start", nncp.SDS{"node": state.Node.Id}, "connected")
                                state.Wait()
                                ctx.LogI("call-finish", nncp.SDS{
-                                       "node":     state.NodeId,
+                                       "node":     state.Node.Id,
                                        "duration": strconv.FormatInt(int64(state.Duration.Seconds()), 10),
                                        "rxbytes":  strconv.FormatInt(state.RxBytes, 10),
                                        "txbytes":  strconv.FormatInt(state.TxBytes, 10),
@@ -101,11 +104,9 @@ func main() {
                                        "txspeed":  strconv.FormatInt(state.TxSpeed, 10),
                                }, "")
                        } else {
-                               var nodeId string
-                               if state == nil {
-                                       nodeId = "unknown"
-                               } else {
-                                       nodeId = state.NodeId.String()
+                               nodeId := "unknown"
+                               if state != nil && state.Node != nil {
+                                       nodeId = state.Node.Id.String()
                                }
                                ctx.LogE("call-start", nncp.SDS{"node": nodeId, "err": err}, "")
                        }