net/udprelay{/endpoint}, all: move ServerEndpoint to independent pkg (#15934)

ServerEndpoint will be used within magicsock and potentially elsewhere,
which should be possible without needing to import the server
implementation itself.

Updates tailscale/corp#27502

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited
2025-05-09 11:29:36 -07:00
committed by GitHub
parent 7d6d2b4c50
commit 0841477743
7 changed files with 98 additions and 79 deletions

View File

@@ -19,6 +19,7 @@ import (
"tailscale.com/ipn/ipnext"
"tailscale.com/ipn/ipnlocal"
"tailscale.com/net/udprelay"
"tailscale.com/net/udprelay/endpoint"
"tailscale.com/tailcfg"
"tailscale.com/types/key"
"tailscale.com/types/logger"
@@ -57,7 +58,7 @@ type extension struct {
// relayServer is the interface of [udprelay.Server].
type relayServer interface {
AllocateEndpoint(discoA key.DiscoPublic, discoB key.DiscoPublic) (udprelay.ServerEndpoint, error)
AllocateEndpoint(discoA key.DiscoPublic, discoB key.DiscoPublic) (endpoint.ServerEndpoint, error)
Close() error
}

View File

@@ -8,7 +8,7 @@ import (
"testing"
"tailscale.com/ipn"
"tailscale.com/net/udprelay"
"tailscale.com/net/udprelay/endpoint"
"tailscale.com/types/key"
"tailscale.com/types/ptr"
)
@@ -17,8 +17,8 @@ type fakeRelayServer struct{}
func (f *fakeRelayServer) Close() error { return nil }
func (f *fakeRelayServer) AllocateEndpoint(_, _ key.DiscoPublic) (udprelay.ServerEndpoint, error) {
return udprelay.ServerEndpoint{}, errors.New("fake relay server")
func (f *fakeRelayServer) AllocateEndpoint(_, _ key.DiscoPublic) (endpoint.ServerEndpoint, error) {
return endpoint.ServerEndpoint{}, errors.New("fake relay server")
}
func Test_extension_profileStateChanged(t *testing.T) {