Repository: scionproto/scion
Pull request #3444 (2019-12-02 15:55:14)

sciond: do not use snet.Addr in config
sciond config needs only the listening IP address.
The IA is being taken from topo `itopo.Get().IA()`

This commit introduces a breaking change in the sciond config.
The public now should be of `<ip>:<port>`, not `ia,<ip>:port`


<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3444)
<!-- Reviewable:end -->


scrye: 



___
*[go/sciond/internal/config/sample.go, line 36 at r1](https://reviewable.io/reviews/scionproto/scion/3444#-LvEgH5k3mJrKS3RQVrL:-LvFrfnX7gpaXLlY7cpx:b-pp1by6) ([raw file](https://github.com/scionproto/scion/blob/8e7802e33c4e3ac3ee944390c1e0933d6a0f9028/go/sciond/internal/config/sample.go#L36)):*
<details><summary><i>Previously, lukedirtwalker (Lukas Vogel) wrote…</i></summary><blockquote>

Yeah that's true. But I don't know what the correct wording should be. Maybe ask @scrye 
</blockquote></details>

It's probably the "Local" word that's misleading. Maybe reword to:
```
Listening address to register with the local dispatcher 
```
?


<!-- Sent from Reviewable.io -->


Patch:
diff --git a/go/sciond/internal/config/BUILD.bazel b/go/sciond/internal/config/BUILD.bazel
index 95d19c9e3..0de9a303c 100644
--- a/go/sciond/internal/config/BUILD.bazel
+++ b/go/sciond/internal/config/BUILD.bazel
@@ -16,7 +16,6 @@ go_library(
         "//go/lib/pathstorage:go_default_library",
         "//go/lib/sciond:go_default_library",
         "//go/lib/serrors:go_default_library",
-        "//go/lib/snet:go_default_library",
         "//go/lib/truststorage:go_default_library",
         "//go/lib/util:go_default_library",
     ],
diff --git a/go/sciond/internal/config/config.go b/go/sciond/internal/config/config.go
index 08e94b595..f02616d13 100644
--- a/go/sciond/internal/config/config.go
+++ b/go/sciond/internal/config/config.go
@@ -26,7 +26,6 @@ import (
 	"github.com/scionproto/scion/go/lib/pathstorage"
 	"github.com/scionproto/scion/go/lib/sciond"
 	"github.com/scionproto/scion/go/lib/serrors"
-	"github.com/scionproto/scion/go/lib/snet"
 	"github.com/scionproto/scion/go/lib/truststorage"
 	"github.com/scionproto/scion/go/lib/util"
 )
@@ -107,10 +106,7 @@ type SDConfig struct {
 	DeleteSocket bool
 	// Public is the local address to listen on for SCION messages (if Bind is
 	// not set), and to send out messages to other nodes.
-	Public *snet.Addr
-	// If set, Bind is the preferred local address to listen on for SCION
-	// messages.
-	Bind *snet.Addr
+	Public string
 	// PathDB contains the configuration for the PathDB connection.
 	PathDB pathstorage.PathDBConf
 	// RevCache contains the configuration for the RevCache connection.
diff --git a/go/sciond/internal/config/sample.go b/go/sciond/internal/config/sample.go
index a328317f1..f69867c9e 100644
--- a/go/sciond/internal/config/sample.go
+++ b/go/sciond/internal/config/sample.go
@@ -31,13 +31,9 @@ SocketFileMode = "0770"
 # If set to True, the socket is removed before being created. (default false)
 DeleteSocket = false
 
-# Local address to listen on for SCION messages (if Bind is not set),
-# and to send out messages to other nodes. (required)
-Public = "1-ff00:0:110,[127.0.0.1]:0"
-
-# If set, Bind is the preferred local address to listen on for SCION
-# messages.
-# Bind = "1-ff00:0:110,[127.0.0.1]:0"
+# Listening address to register with the local dispatcher
+# in order to receive and send SCION messages to other nodes. (required)
+Public = "127.0.0.1:0"
 
 # The time after which segments for a destination are refetched. (default 5m)
 QueryInterval = "5m"
diff --git a/go/sciond/main.go b/go/sciond/main.go
index 6872e36cf..e0f00db61 100644
--- a/go/sciond/main.go
+++ b/go/sciond/main.go
@@ -118,9 +118,10 @@ func realMain() int {
 	defer trCloser.Close()
 	opentracing.SetGlobalTracer(tracer)
 
-	var publicIP *net.UDPAddr
-	if p := cfg.SD.Public; p != nil {
-		publicIP = p.ToNetUDPAddr()
+	publicIP, err := net.ResolveUDPAddr("udp", cfg.SD.Public)
+	if err != nil {
+		log.Crit("Unable to resolve listening address", "err", err, "addr", publicIP)
+		return 1
 	}
 
 	nc := infraenv.NetworkConfig{
diff --git a/python/topology/go.py b/python/topology/go.py
index cd9105073..c6d92e4ca 100755
--- a/python/topology/go.py
+++ b/python/topology/go.py
@@ -275,7 +275,7 @@ class GoGenerator(object):
             'sd': {
                 'Reliable': os.path.join(SCIOND_API_SOCKDIR, "%s.sock" % name),
                 'Unix': os.path.join(SCIOND_API_SOCKDIR, "%s.unix" % name),
-                'Public': '%s,[127.0.0.1]:0' % ia,
+                'Public': '127.0.0.1:0',
                 'pathDB': {
                     'Connection': os.path.join(self.db_dir, '%s.path.db' % name),
                 },


Test patch:
diff --git a/go/sciond/internal/config/config_test.go b/go/sciond/internal/config/config_test.go
index 0a77641ac..ddd33afe1 100644
--- a/go/sciond/internal/config/config_test.go
+++ b/go/sciond/internal/config/config_test.go
@@ -66,7 +66,7 @@ func CheckTestSDConfig(t *testing.T, cfg *SDConfig, id string) {
 	assert.Equal(t, sciond.DefaultSCIONDPath, cfg.Reliable)
 	assert.Equal(t, "/run/shm/sciond/default-unix.sock", cfg.Unix)
 	assert.Equal(t, sciond.DefaultSocketFileMode, int(cfg.SocketFileMode))
-	assert.Equal(t, "1-ff00:0:110,[127.0.0.1]:0", cfg.Public.String())
+	assert.Equal(t, "127.0.0.1:0", cfg.Public)
 	assert.Equal(t, DefaultQueryInterval, cfg.QueryInterval.Duration)
 	assert.False(t, cfg.DeleteSocket)
 }