Skip to content

Commit

Permalink
resolver_service: Make the service resolution port dynamic by default.
Browse files Browse the repository at this point in the history
If the service resolution address isn't configured, let it have a random port.

The dispatcher dynamically assigns a port and also registers it as the recipient of resolution requests. It appears that no knowledge of the port is required outside of that.
  • Loading branch information
jiceatscion committed Aug 18, 2023
1 parent 540e1e3 commit d8d9033
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions control/cmd/control/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ func realMain(ctx context.Context) error {
return err
}

// FIXME: readability would be improved if we could be consistent with address
// representations in NetworkConfig (string or cooked, chose one).
nc := infraenv.NetworkConfig{
IA: topo.IA(),
// Public: (Historical name) The TCP/IP:port address for the control service.
Expand Down
12 changes: 11 additions & 1 deletion private/app/appnet/infraenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ func (nc *NetworkConfig) QUICStack() (*QUICStack, error) {
if nc.QUIC.Address == "" {
nc.QUIC.Address = net.JoinHostPort(nc.Public.IP.String(), "0")
}
if nc.ServiceResolution == nil {
srAddr, err := net.ResolveUDPAddr("udp", net.JoinHostPort(nc.Public.IP.String(), "0"))
if err != nil {
return nil, serrors.WrapStr("parsing service_resolution QUIC address", err)
}
nc.ServiceResolution = srAddr
}

client, server, err := nc.initQUICSockets()
if err != nil {
return nil, err
Expand Down Expand Up @@ -268,9 +276,11 @@ func (nc *NetworkConfig) initSvcRedirect(quicAddress string) (func(), error) {
Dispatcher: packetDispatcher,
Metrics: nc.SCIONNetworkMetrics,
}

conn, err := network.Listen(context.Background(), "udp", nc.ServiceResolution, addr.SvcWildcard)
if err != nil {
return nil, serrors.WrapStr("listening on SCION", err, "addr", nc.Public)
log.Info("Listen failed", "err", err)
return nil, serrors.WrapStr("listening on SCION", err, "addr", nc.ServiceResolution)
}

ctx, cancel := context.WithCancel(context.Background())
Expand Down

0 comments on commit d8d9033

Please sign in to comment.