Repository: scionproto/scion
Pull request #3443 (2019-12-02 15:04:46)

Remove addr.AppAddr usage

Reduce addr.AppAddr usage

* Part of the effort to deprecate AppAddr.
* Use net.UDPAddr
* Remove snet.Localmachine as we deprecate bind.

Contributes to #3344


<!-- 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/3443)
<!-- Reviewable:end -->



Patch:
diff --git a/go/beacon_srv/internal/onehop/network.go b/go/beacon_srv/internal/onehop/network.go
index 7cbff02cb..953268133 100644
--- a/go/beacon_srv/internal/onehop/network.go
+++ b/go/beacon_srv/internal/onehop/network.go
@@ -31,7 +31,7 @@ type OHPPacketDispatcherService struct {
 	snet.PacketDispatcherService
 }
 
-func (s *OHPPacketDispatcherService) RegisterTimeout(ia addr.IA, public *addr.AppAddr,
+func (s *OHPPacketDispatcherService) RegisterTimeout(ia addr.IA, public *net.UDPAddr,
 	bind *net.UDPAddr, svc addr.HostSVC,
 	timeout time.Duration) (snet.PacketConn, uint16, error) {
 
diff --git a/go/beacon_srv/main.go b/go/beacon_srv/main.go
index 2d2ec7c0e..16d2642dc 100644
--- a/go/beacon_srv/main.go
+++ b/go/beacon_srv/main.go
@@ -194,7 +194,7 @@ func realMain() int {
 	// to contain the topo address.
 	ohpAddress := topo.PublicAddress(addr.SvcBS, cfg.General.ID)
 	ohpAddress.Port = 0
-	conn, _, err := pktDisp.RegisterTimeout(topo.IA(), addr.AppAddrFromUDP(ohpAddress), nil,
+	conn, _, err := pktDisp.RegisterTimeout(topo.IA(), ohpAddress, nil,
 		addr.SvcNone, time.Second)
 	if err != nil {
 		log.Crit("Unable to create SCION packet conn", "err", err)
diff --git a/go/integration/end2end/main.go b/go/integration/end2end/main.go
index 4d595eff0..32cfccd09 100644
--- a/go/integration/end2end/main.go
+++ b/go/integration/end2end/main.go
@@ -95,7 +95,8 @@ func (s server) run() {
 			sciond.RevHandler{Connector: integration.SDConn()},
 		),
 	}
-	conn, port, err := connFactory.RegisterTimeout(integration.Local.IA, integration.Local.Host,
+	conn, port, err := connFactory.RegisterTimeout(integration.Local.IA,
+		integration.Local.ToNetUDPAddr(),
 		nil, addr.SvcNone, 0)
 	if err != nil {
 		integration.LogFatal("Error listening", "err", err)
@@ -152,8 +153,8 @@ func (c client) run() int {
 	}
 
 	var err error
-	c.conn, c.port, err = connFactory.RegisterTimeout(integration.Local.IA, integration.Local.Host,
-		nil, addr.SvcNone, 0)
+	c.conn, c.port, err = connFactory.RegisterTimeout(integration.Local.IA,
+		integration.Local.ToNetUDPAddr(), nil, addr.SvcNone, 0)
 	if err != nil {
 		integration.LogFatal("Unable to listen", "err", err)
 	}
diff --git a/go/lib/infra/infraenv/infraenv.go b/go/lib/infra/infraenv/infraenv.go
index b4bf306a2..a1cf43c6e 100644
--- a/go/lib/infra/infraenv/infraenv.go
+++ b/go/lib/infra/infraenv/infraenv.go
@@ -150,10 +150,7 @@ func (nc *NetworkConfig) AddressRewriter(
 		Resolver: &svc.Resolver{
 			LocalIA:     nc.IA,
 			ConnFactory: connFactory,
-			Machine: snet.LocalMachine{
-				PublicIP:    nc.Public.IP,
-				InterfaceIP: nc.Public.IP,
-			},
+			LocalIP:     nc.Public.IP,
 			// Legacy control payloads have a 4-byte length prefix. A
 			// 0-value for the prefix is invalid, so SVC resolution-aware
 			// servers can use this to detect that the client is attempting
diff --git a/go/lib/snet/BUILD.bazel b/go/lib/snet/BUILD.bazel
index 79562c811..51d36f8fc 100644
--- a/go/lib/snet/BUILD.bazel
+++ b/go/lib/snet/BUILD.bazel
@@ -43,7 +43,6 @@ go_test(
         "addr_test.go",
         "export_test.go",
         "raw_test.go",
-        "router_test.go",
         "svcaddr_test.go",
         "udpaddr_test.go",
         "writer_test.go",
diff --git a/go/lib/snet/dispatcher.go b/go/lib/snet/dispatcher.go
index 570d4c1ad..118eecfbc 100644
--- a/go/lib/snet/dispatcher.go
+++ b/go/lib/snet/dispatcher.go
@@ -31,7 +31,7 @@ import (
 // PacketDispatcherService constructs SCION sockets where applications have
 // fine-grained control over header fields.
 type PacketDispatcherService interface {
-	RegisterTimeout(ia addr.IA, public *addr.AppAddr, bind *net.UDPAddr,
+	RegisterTimeout(ia addr.IA, public *net.UDPAddr, bind *net.UDPAddr,
 		svc addr.HostSVC, timeout time.Duration) (PacketConn, uint16, error)
 }
 
@@ -48,7 +48,7 @@ type DefaultPacketDispatcherService struct {
 	SCMPHandler SCMPHandler
 }
 
-func (s *DefaultPacketDispatcherService) RegisterTimeout(ia addr.IA, public *addr.AppAddr,
+func (s *DefaultPacketDispatcherService) RegisterTimeout(ia addr.IA, public *net.UDPAddr,
 	bind *net.UDPAddr, svc addr.HostSVC,
 	timeout time.Duration) (PacketConn, uint16, error) {
 
diff --git a/go/lib/snet/mock_snet/snet.go b/go/lib/snet/mock_snet/snet.go
index 5c3abab5e..f256e3eb6 100644
--- a/go/lib/snet/mock_snet/snet.go
+++ b/go/lib/snet/mock_snet/snet.go
@@ -266,7 +266,7 @@ func (m *MockPacketDispatcherService) EXPECT() *MockPacketDispatcherServiceMockR
 }
 
 // RegisterTimeout mocks base method
-func (m *MockPacketDispatcherService) RegisterTimeout(arg0 addr.IA, arg1 *addr.AppAddr, arg2 *net.UDPAddr, arg3 addr.HostSVC, arg4 time.Duration) (snet.PacketConn, uint16, error) {
+func (m *MockPacketDispatcherService) RegisterTimeout(arg0 addr.IA, arg1, arg2 *net.UDPAddr, arg3 addr.HostSVC, arg4 time.Duration) (snet.PacketConn, uint16, error) {
 	m.ctrl.T.Helper()
 	ret := m.ctrl.Call(m, "RegisterTimeout", arg0, arg1, arg2, arg3, arg4)
 	ret0, _ := ret[0].(snet.PacketConn)
diff --git a/go/lib/snet/router.go b/go/lib/snet/router.go
index e96fece4a..d53443205 100644
--- a/go/lib/snet/router.go
+++ b/go/lib/snet/router.go
@@ -16,7 +16,6 @@ package snet
 
 import (
 	"context"
-	"net"
 
 	"github.com/scionproto/scion/go/lib/addr"
 )
@@ -69,33 +68,3 @@ type IntraASPathQuerier struct {
 func (q IntraASPathQuerier) Query(_ context.Context, _ addr.IA) ([]Path, error) {
 	return []Path{&partialPath{destination: q.IA}}, nil
 }
-
-// LocalMachine describes aspects of the host system and its network.
-type LocalMachine struct {
-	// InterfaceIP is the default L3 address for connections originating from
-	// this machine. It should be an address configured on a host interface
-	// that is reachable from the network.
-	InterfaceIP net.IP
-	// If this machine is behind a NAT, PublicIP should be set to the public IP
-	// of the NAT. If the local IP is already public, PublicIP should be set to
-	// nil.
-	PublicIP net.IP
-}
-
-// AppAddress returns a public address for the local machine. The port is
-// set to 0.
-func (m *LocalMachine) AppAddress() *addr.AppAddr {
-	ip := m.InterfaceIP
-	if m.PublicIP != nil {
-		ip = m.PublicIP
-	}
-	return &addr.AppAddr{
-		L3: addr.HostFromIP(ip),
-	}
-}
-
-// BindAddress returns a bind address for the local machine. The port is
-// set to 0.
-func (m *LocalMachine) BindAddress() *net.UDPAddr {
-	return &net.UDPAddr{IP: m.InterfaceIP}
-}
diff --git a/go/lib/snet/snet.go b/go/lib/snet/snet.go
index 1336e403b..68ef382f0 100644
--- a/go/lib/snet/snet.go
+++ b/go/lib/snet/snet.go
@@ -209,8 +209,9 @@ func (n *SCIONNetwork) ListenSCIONWithBindSVC(network string, laddr, baddr *Addr
 				"expected", conn.scionNet.localIA, "actual", conn.baddr.IA, "type", "bind")
 		}
 	}
+	p := conn.laddr.ToNetUDPAddr()
 	packetConn, port, err := conn.scionNet.dispatcher.RegisterTimeout(conn.laddr.IA,
-		conn.laddr.Host, bindAddr, svc, timeout)
+		p, bindAddr, svc, timeout)
 	if err != nil {
 		return nil, err
 	}
diff --git a/go/lib/sock/BUILD.bazel b/go/lib/sock/BUILD.bazel
index 1fca2e735..e69de29bb 100644
--- a/go/lib/sock/BUILD.bazel
+++ b/go/lib/sock/BUILD.bazel
@@ -1,8 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-go_library(
-    name = "go_default_library",
-    srcs = ["udp.go"],
-    importpath = "github.com/scionproto/scion/go/lib/sock",
-    visibility = ["//visibility:public"],
-)
diff --git a/go/lib/sock/reliable/mock_reliable/reliable.go b/go/lib/sock/reliable/mock_reliable/reliable.go
index af36c76bd..e4d4c7140 100644
--- a/go/lib/sock/reliable/mock_reliable/reliable.go
+++ b/go/lib/sock/reliable/mock_reliable/reliable.go
@@ -36,7 +36,7 @@ func (m *MockDispatcher) EXPECT() *MockDispatcherMockRecorder {
 }
 
 // Register mocks base method
-func (m *MockDispatcher) Register(arg0 context.Context, arg1 addr.IA, arg2 *addr.AppAddr, arg3 addr.HostSVC) (net.PacketConn, uint16, error) {
+func (m *MockDispatcher) Register(arg0 context.Context, arg1 addr.IA, arg2 *net.UDPAddr, arg3 addr.HostSVC) (net.PacketConn, uint16, error) {
 	m.ctrl.T.Helper()
 	ret := m.ctrl.Call(m, "Register", arg0, arg1, arg2, arg3)
 	ret0, _ := ret[0].(net.PacketConn)
diff --git a/go/lib/sock/reliable/reconnect/network.go b/go/lib/sock/reliable/reconnect/network.go
index a8f37bee9..c05c7fdcb 100644
--- a/go/lib/sock/reliable/reconnect/network.go
+++ b/go/lib/sock/reliable/reconnect/network.go
@@ -44,13 +44,13 @@ func NewDispatcherService(dispatcher reliable.Dispatcher) *DispatcherService {
 	return &DispatcherService{dispatcher: dispatcher}
 }
 
-func (pn *DispatcherService) Register(ctx context.Context, ia addr.IA, public *addr.AppAddr,
+func (pn *DispatcherService) Register(ctx context.Context, ia addr.IA, public *net.UDPAddr,
 	svc addr.HostSVC) (net.PacketConn, uint16, error) {
 
 	return pn.RegisterTimeout(ctx, ia, public, svc)
 }
 
-func (pn *DispatcherService) RegisterTimeout(ctx context.Context, ia addr.IA, public *addr.AppAddr,
+func (pn *DispatcherService) RegisterTimeout(ctx context.Context, ia addr.IA, public *net.UDPAddr,
 	svc addr.HostSVC) (net.PacketConn, uint16, error) {
 
 	// Perform initial connection to allocate port. We use a reconnecter here
@@ -61,17 +61,23 @@ func (pn *DispatcherService) RegisterTimeout(ctx context.Context, ia addr.IA, pu
 	if err != nil {
 		return nil, 0, err
 	}
-	var newPublic *addr.AppAddr
-	if public != nil {
-		newPublic = public.Copy()
-		newPublic.L4 = port
+
+	updatePort := func(a *net.UDPAddr, port int) *net.UDPAddr {
+		if a == nil {
+			return nil
+		}
+		return &net.UDPAddr{
+			IP:   append(a.IP[:0:0], a.IP...),
+			Port: port,
+		}
 	}
+	newPublic := updatePort(public, int(port))
 	reconnecter = pn.newReconnecterFromListenArgs(ctx, ia, newPublic, svc)
 	return NewPacketConn(conn, reconnecter), port, nil
 }
 
 func (pn *DispatcherService) newReconnecterFromListenArgs(ctx context.Context, ia addr.IA,
-	public *addr.AppAddr, svc addr.HostSVC) *TickingReconnecter {
+	public *net.UDPAddr, svc addr.HostSVC) *TickingReconnecter {
 
 	// f represents individual connection attempts
 	f := func(timeout time.Duration) (net.PacketConn, uint16, error) {
diff --git a/go/lib/sock/reliable/reliable.go b/go/lib/sock/reliable/reliable.go
index b86dbd675..f303ed135 100644
--- a/go/lib/sock/reliable/reliable.go
+++ b/go/lib/sock/reliable/reliable.go
@@ -92,7 +92,7 @@ const (
 type Dispatcher interface {
 	// Register connects to a SCION Dispatcher's UNIX socket. Future messages for the address in AS
 	// ia which arrive at the dispatcher can be read by calling Read on the returned connection.
-	Register(ctx context.Context, ia addr.IA, address *addr.AppAddr,
+	Register(ctx context.Context, ia addr.IA, address *net.UDPAddr,
 		svc addr.HostSVC) (net.PacketConn, uint16, error)
 }
 
@@ -110,7 +110,7 @@ type dispatcherService struct {
 	Address string
 }
 
-func (d *dispatcherService) Register(ctx context.Context, ia addr.IA, public *addr.AppAddr,
+func (d *dispatcherService) Register(ctx context.Context, ia addr.IA, public *net.UDPAddr,
 	svc addr.HostSVC) (net.PacketConn, uint16, error) {
 
 	return registerMetricsWrapper(ctx, d.Address, ia, public, svc)
@@ -159,7 +159,7 @@ func Dial(ctx context.Context, address string) (*Conn, error) {
 }
 
 func registerMetricsWrapper(ctx context.Context, dispatcher string, ia addr.IA,
-	public *addr.AppAddr, svc addr.HostSVC) (*Conn, uint16, error) {
+	public *net.UDPAddr, svc addr.HostSVC) (*Conn, uint16, error) {
 
 	conn, port, err := register(ctx, dispatcher, ia, public, svc)
 	labels := metrics.RegisterLabels{Result: labelResult(err), SVC: svc.BaseString()}
@@ -167,16 +167,12 @@ func registerMetricsWrapper(ctx context.Context, dispatcher string, ia addr.IA,
 	return conn, port, err
 }
 
-func register(ctx context.Context, dispatcher string, ia addr.IA, public *addr.AppAddr,
+func register(ctx context.Context, dispatcher string, ia addr.IA, public *net.UDPAddr,
 	svc addr.HostSVC) (*Conn, uint16, error) {
 
-	publicUDP, err := createUDPAddrFromAppAddr(public)
-	if err != nil {
-		return nil, 0, err
-	}
 	reg := &Registration{
 		IA:            ia,
-		PublicAddress: publicUDP,
+		PublicAddress: public,
 		SVCAddress:    svc,
 	}
 
@@ -208,9 +204,9 @@ func register(ctx context.Context, dispatcher string, ia addr.IA, public *addr.A
 			conn.Close()
 			return nil, 0, registrationReturn.err
 		}
-		if publicUDP.Port != 0 && publicUDP.Port != int(registrationReturn.port) {
+		if public.Port != 0 && public.Port != int(registrationReturn.port) {
 			conn.Close()
-			return nil, 0, serrors.New("port mismatch", "requested", publicUDP.Port,
+			return nil, 0, serrors.New("port mismatch", "requested", public.Port,
 				"received", registrationReturn.port)
 		}
 		// Disable deadline to not affect future I/O
@@ -361,21 +357,6 @@ func (listener *Listener) String() string {
 	return fmt.Sprintf("&{addr: %v}", listener.UnixListener.Addr())
 }
 
-func createUDPAddrFromAppAddr(address *addr.AppAddr) (*net.UDPAddr, error) {
-	if address == nil || address.L3 == nil {
-		return nil, serrors.New("nil application address")
-	}
-	if address.L3.Type() != addr.HostTypeIPv4 && address.L3.Type() != addr.HostTypeIPv6 {
-		return nil, common.NewBasicError("unsupported application address type", nil,
-			"type", address.L3.Type())
-	}
-	ip := address.L3.IP()
-	if ip == nil {
-		panic("inconsistent app address, ip should never be nil")
-	}
-	return &net.UDPAddr{IP: ip, Port: int(address.L4)}, nil
-}
-
 func labelResult(err error) string {
 	switch {
 	case err == nil:
diff --git a/go/lib/sock/udp.go b/go/lib/sock/udp.go
deleted file mode 100644
index a6e631302..000000000
--- a/go/lib/sock/udp.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2016 ETH Zurich
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package sock
-
-import (
-	"fmt"
-	"net"
-)
-
-func ParseAddr(addr string, port int) (*net.UDPAddr, error) {
-	ip := net.ParseIP(addr)
-	if ip == nil {
-		return nil, fmt.Errorf("Unable to parse address %q", addr)
-	}
-	return &net.UDPAddr{IP: ip, Port: port}, nil
-}
diff --git a/go/lib/svc/resolver.go b/go/lib/svc/resolver.go
index 85237ae26..6da720f6a 100644
--- a/go/lib/svc/resolver.go
+++ b/go/lib/svc/resolver.go
@@ -49,8 +49,8 @@ type Resolver struct {
 	LocalIA addr.IA
 	// ConnFactory is used to open ports for SVC resolution messages.
 	ConnFactory snet.PacketDispatcherService
-	// Machine is used to derive addressing information for local conns.
-	Machine snet.LocalMachine
+	// LocalIP is the default L3 address for connections originating from this process.
+	LocalIP net.IP
 	// RoundTripper performs the request/reply exchange for SVC resolutions. If
 	// nil, the default round tripper is used.
 	RoundTripper RoundTripper
@@ -66,8 +66,11 @@ func (r *Resolver) LookupSVC(ctx context.Context, p snet.Path, svc addr.HostSVC)
 
 	// FIXME(scrye): Assume registration is always instant for now. This,
 	// however, should respect ctx.
-	conn, port, err := r.ConnFactory.RegisterTimeout(r.LocalIA, r.Machine.AppAddress(),
-		nil, addr.SvcNone, 0)
+	u := &net.UDPAddr{
+		IP: r.LocalIP,
+	}
+
+	conn, port, err := r.ConnFactory.RegisterTimeout(r.LocalIA, u, nil, addr.SvcNone, 0)
 	if err != nil {
 		return nil, common.NewBasicError(errRegistration, err)
 	}
@@ -76,7 +79,7 @@ func (r *Resolver) LookupSVC(ctx context.Context, p snet.Path, svc addr.HostSVC)
 		SCIONPacketInfo: snet.SCIONPacketInfo{
 			Source: snet.SCIONAddress{
 				IA:   r.LocalIA,
-				Host: r.Machine.AppAddress().L3,
+				Host: addr.HostFromIP(r.LocalIP),
 			},
 			Destination: snet.SCIONAddress{
 				IA:   p.Destination(),
diff --git a/go/lib/svc/svc.go b/go/lib/svc/svc.go
index 9f5030368..89359195b 100644
--- a/go/lib/svc/svc.go
+++ b/go/lib/svc/svc.go
@@ -72,7 +72,7 @@ type ResolverPacketDispatcher struct {
 	handler     RequestHandler
 }
 
-func (d *ResolverPacketDispatcher) RegisterTimeout(ia addr.IA, public *addr.AppAddr,
+func (d *ResolverPacketDispatcher) RegisterTimeout(ia addr.IA, public *net.UDPAddr,
 	bind *net.UDPAddr, svc addr.HostSVC,
 	timeout time.Duration) (snet.PacketConn, uint16, error) {
 
@@ -84,7 +84,7 @@ func (d *ResolverPacketDispatcher) RegisterTimeout(ia addr.IA, public *addr.AppA
 		PacketConn: c,
 		source: snet.SCIONAddress{
 			IA:   ia,
-			Host: public.L3,
+			Host: addr.HostFromIP(public.IP),
 		},
 		handler: d.handler,
 	}
diff --git a/go/tools/scmp/main.go b/go/tools/scmp/main.go
index 19220fc77..519654c3b 100644
--- a/go/tools/scmp/main.go
+++ b/go/tools/scmp/main.go
@@ -69,7 +69,7 @@ func main() {
 	// Connect to the dispatcher
 	dispatcherService := reliable.NewDispatcher(*dispatcher)
 	cmn.Conn, _, err = dispatcherService.Register(context.Background(), cmn.Local.IA,
-		cmn.Local.Host, addr.SvcNone)
+		cmn.Local.ToNetUDPAddr(), addr.SvcNone)
 	if err != nil {
 		cmn.Fatal("Unable to register with the dispatcher addr=%s\nerr=%v", cmn.Local, err)
 	}


Test patch:
diff --git a/go/godispatcher/main_test.go b/go/godispatcher/main_test.go
index 12d604fd8..644749ca7 100644
--- a/go/godispatcher/main_test.go
+++ b/go/godispatcher/main_test.go
@@ -441,7 +441,10 @@ func RunTestCase(t *testing.T, tc *TestCase, settings *TestSettings) {
 	conn, _, err := dispatcherService.Register(
 		ctx,
 		tc.ClientAddress.IA,
-		&addr.AppAddr{L3: tc.ClientAddress.PublicAddress, L4: tc.ClientAddress.PublicPort},
+		&net.UDPAddr{
+			IP:   tc.ClientAddress.PublicAddress.IP(),
+			Port: int(tc.ClientAddress.PublicPort),
+		},
 		tc.ClientAddress.ServiceAddress,
 	)
 	xtest.FailOnErr(t, err, "unable to open socket")
diff --git a/go/lib/snet/router_test.go b/go/lib/snet/router_test.go
deleted file mode 100644
index cbf60a052..000000000
--- a/go/lib/snet/router_test.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2019 ETH Zurich
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package snet_test
-
-import (
-	"net"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-
-	"github.com/scionproto/scion/go/lib/addr"
-	"github.com/scionproto/scion/go/lib/snet"
-)
-
-func TestLocalMachineBuildAppAddress(t *testing.T) {
-	tests := map[string]struct {
-		Machine         *snet.LocalMachine
-		ExpectedAppAddr *addr.AppAddr
-	}{
-		"nil IP": {
-			Machine: &snet.LocalMachine{},
-			ExpectedAppAddr: &addr.AppAddr{
-				L3: addr.HostFromIP(nil),
-			},
-		},
-		"only default IP": {
-			Machine: &snet.LocalMachine{
-				InterfaceIP: net.IP{192, 0, 2, 1},
-			},
-			ExpectedAppAddr: &addr.AppAddr{
-				L3: addr.HostFromIP(net.IP{192, 0, 2, 1}),
-			},
-		},
-		"if public IP is set, it is used to construct app address": {
-			Machine: &snet.LocalMachine{
-				InterfaceIP: net.IP{192, 168, 0, 1},
-				PublicIP:    net.IP{192, 0, 2, 1},
-			},
-			ExpectedAppAddr: &addr.AppAddr{
-				L3: addr.HostFromIP(net.IP{192, 0, 2, 1}),
-			},
-		},
-	}
-
-	for name, test := range tests {
-		t.Run(name, func(t *testing.T) {
-			assert.Equal(t, test.ExpectedAppAddr, test.Machine.AppAddress())
-		})
-	}
-}
-
-func TestLocalMachineBuildBindAddress(t *testing.T) {
-	tests := map[string]struct {
-		Machine          *snet.LocalMachine
-		ExpectedBindAddr *net.UDPAddr
-	}{
-		"bind IP is computed based on default IP": {
-			Machine: &snet.LocalMachine{
-				InterfaceIP: net.IP{192, 0, 2, 1},
-			},
-			ExpectedBindAddr: &net.UDPAddr{IP: net.IP{192, 0, 2, 1}},
-		},
-	}
-
-	for name, test := range tests {
-		t.Run(name, func(t *testing.T) {
-			assert.Equal(t, test.ExpectedBindAddr, test.Machine.BindAddress())
-		})
-	}
-}
diff --git a/go/lib/sock/reliable/reconnect/network_test.go b/go/lib/sock/reliable/reconnect/network_test.go
index c8db7b327..c770a2d4e 100644
--- a/go/lib/sock/reliable/reconnect/network_test.go
+++ b/go/lib/sock/reliable/reconnect/network_test.go
@@ -40,17 +40,22 @@ func TestReconnect(t *testing.T) {
 			mockConn := mock_net.NewMockPacketConn(ctrl)
 			Convey("Allocated ports are reused on subsequent attempts", func() {
 				mockDispatcher.EXPECT().
-					Register(context.Background(), localAddr.IA, localNoPortAddr.Host, svc).
+					Register(context.Background(), localAddr.IA,
+						localNoPortAddr.ToNetUDPAddr(), svc).
 					Return(mockConn, uint16(80), nil)
-				newExpectedAddr := localNoPortAddr.Host.Copy()
-				newExpectedAddr.L4 = 80
+
+				want := &net.UDPAddr{
+					IP:   localNoPortAddr.Host.Copy().L3.IP(),
+					Port: 80,
+				}
+
 				mockDispatcher.EXPECT().
-					Register(context.Background(), localAddr.IA, newExpectedAddr, svc).
+					Register(context.Background(), localAddr.IA, want, svc).
 					Return(mockConn, uint16(80), nil)
 
 				network := reconnect.NewDispatcherService(mockDispatcher)
 				packetConn, _, _ := network.RegisterTimeout(context.Background(), localAddr.IA,
-					localNoPortAddr.Host, svc)
+					localNoPortAddr.ToNetUDPAddr(), svc)
 				packetConn.(*reconnect.PacketConn).Reconnect()
 			})
 		})
diff --git a/go/lib/svc/resolver_test.go b/go/lib/svc/resolver_test.go
index 469762528..b4ee41273 100644
--- a/go/lib/svc/resolver_test.go
+++ b/go/lib/svc/resolver_test.go
@@ -62,11 +62,10 @@ func TestResolver(t *testing.T) {
 			SoMsg("err", err, ShouldNotBeNil)
 		})
 		Convey("Local machine information is used to build conns", func() {
-			machine := snet.LocalMachine{InterfaceIP: net.IP{192, 0, 2, 1}}
 			mockPacketDispatcherService := mock_snet.NewMockPacketDispatcherService(ctrl)
 			mockConn := mock_snet.NewMockPacketConn(ctrl)
 			mockPacketDispatcherService.EXPECT().RegisterTimeout(srcIA,
-				machine.AppAddress(),
+				&net.UDPAddr{IP: net.IP{192, 0, 2, 1}},
 				nil,
 				addr.SvcNone,
 				time.Duration(0)).Return(mockConn, uint16(42), nil)
@@ -77,7 +76,7 @@ func TestResolver(t *testing.T) {
 			resolver := &svc.Resolver{
 				LocalIA:      srcIA,
 				ConnFactory:  mockPacketDispatcherService,
-				Machine:      machine,
+				LocalIP:      net.IP{192, 0, 2, 1},
 				RoundTripper: mockRoundTripper,
 			}
 			resolver.LookupSVC(context.Background(), mockPath, addr.SvcCS)
diff --git a/go/lib/svc/svc_test.go b/go/lib/svc/svc_test.go
index 0c6b2ba0a..b2087e535 100644
--- a/go/lib/svc/svc_test.go
+++ b/go/lib/svc/svc_test.go
@@ -50,7 +50,7 @@ func TestSVCResolutionServer(t *testing.T) {
 
 			dispatcherService := svc.NewResolverPacketDispatcher(mockPacketDispatcherService,
 				mockReqHandler)
-			conn, port, err := dispatcherService.RegisterTimeout(addr.IA{}, &addr.AppAddr{},
+			conn, port, err := dispatcherService.RegisterTimeout(addr.IA{}, &net.UDPAddr{},
 				&net.UDPAddr{}, addr.SvcPS, 0)
 			SoMsg("conn", conn, ShouldBeNil)
 			SoMsg("port", port, ShouldEqual, 0)
@@ -62,7 +62,7 @@ func TestSVCResolutionServer(t *testing.T) {
 
 			dispatcherService := svc.NewResolverPacketDispatcher(mockPacketDispatcherService,
 				mockReqHandler)
-			conn, port, err := dispatcherService.RegisterTimeout(addr.IA{}, &addr.AppAddr{},
+			conn, port, err := dispatcherService.RegisterTimeout(addr.IA{}, &net.UDPAddr{},
 				&net.UDPAddr{}, addr.SvcPS, 0)
 			SoMsg("conn", conn, ShouldNotBeNil)
 			SoMsg("port", port, ShouldEqual, 1337)