all: add extra information to serialized endpoints
magicsock.Conn.ParseEndpoint requires a peer's public key, disco key, and legacy ip/ports in order to do its job. We currently accomplish that by: * adding the public key in our wireguard-go fork * encoding the disco key as magic hostname * using a bespoke comma-separated encoding It's a bit messy. Instead, switch to something simpler: use a json-encoded struct containing exactly the information we need, in the form we use it. Our wireguard-go fork still adds the public key to the address when it passes it to ParseEndpoint, but now the code compensating for that is just a couple of simple, well-commented lines. Once this commit is in, we can remove that part of the fork and remove the compensating code. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
@ -53,21 +53,3 @@ func TestParseEndpoint(t *testing.T) {
|
||||
t.Error("Error was expected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateEndpoints(t *testing.T) {
|
||||
tests := []struct {
|
||||
in string
|
||||
want error
|
||||
}{
|
||||
{"", nil},
|
||||
{"1.2.3.4:5", nil},
|
||||
{"1.2.3.4:5,6.7.8.9:10", nil},
|
||||
{",", &ParseError{why: "Missing port from endpoint", offender: ""}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got := validateEndpoints(tt.in)
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("%q = %#v (%s); want %#v (%s)", tt.in, got, got, tt.want, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user