]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cypherpunks.ru/nncp/cfg.go
Fix invalid -rx/-tx arguments processing
[nncp.git] / src / cypherpunks.ru / nncp / cfg.go
index 3400ed83a93e7d850f85da7b47653497592e14a9..3a642f68567ff4487630dab5e3b96b676d5cba34 100644 (file)
@@ -64,7 +64,7 @@ type NodeYAML struct {
 type CallYAML struct {
        Cron           string
        Nice           *int    `nice,omitempty`
-       Xx             *string `xx,omitempty`
+       Xx             string  `xx,omitempty`
        Addr           *string `addr,omitempty`
        OnlineDeadline *uint   `onlinedeadline,omitempty`
        MaxOnlineTime  *uint   `maxonlinetime,omitempty`
@@ -187,15 +187,14 @@ func NewNode(name string, yml NodeYAML) (*Node, error) {
                        nice = uint8(*callYml.Nice)
                }
                var xx TRxTx
-               if callYml.Xx != nil {
-                       switch *callYml.Xx {
-                       case "rx":
-                               xx = TRx
-                       case "tx":
-                               xx = TTx
-                       default:
-                               return nil, errors.New("xx field must be either \"rx\" or \"tx\"")
-                       }
+               switch callYml.Xx {
+               case "rx":
+                       xx = TRx
+               case "tx":
+                       xx = TTx
+               case "":
+               default:
+                       return nil, errors.New("xx field must be either \"rx\" or \"tx\"")
                }
                var addr *string
                if callYml.Addr != nil {
@@ -219,7 +218,7 @@ func NewNode(name string, yml NodeYAML) (*Node, error) {
                calls = append(calls, &Call{
                        Cron:           expr,
                        Nice:           nice,
-                       Xx:             &xx,
+                       Xx:             xx,
                        Addr:           addr,
                        OnlineDeadline: onlineDeadline,
                        MaxOnlineTime:  maxOnlineTime,