diff --git a/derp/derp_client.go b/derp/derp_client.go index 7291efbec..aca67fef6 100644 --- a/derp/derp_client.go +++ b/derp/derp_client.go @@ -129,13 +129,13 @@ func (c *Client) parseServerInfo(b []byte) (*serverInfo, error) { } type clientInfo struct { - Version int // `json:"version,omitempty"` + Version int `json:"version,omitempty"` // MeshKey optionally specifies a pre-shared key used by // trusted clients. It's required to subscribe to the // connection list & forward packets. It's empty for regular // users. - MeshKey string // `json:"meshKey,omitempty"` + MeshKey string `json:"meshKey,omitempty"` } func (c *Client) sendClientKey() error { diff --git a/derp/derp_server.go b/derp/derp_server.go index fbc9fa8df..7c6394e50 100644 --- a/derp/derp_server.go +++ b/derp/derp_server.go @@ -712,7 +712,7 @@ func (s *Server) sendServerKey(bw *bufio.Writer) error { } type serverInfo struct { - Version int // `json:"version,omitempty"` + Version int `json:"version,omitempty"` } func (s *Server) sendServerInfo(bw *bufio.Writer, clientKey key.Public) error { diff --git a/derp/derp_test.go b/derp/derp_test.go index 1ca32128d..d9e6580ff 100644 --- a/derp/derp_test.go +++ b/derp/derp_test.go @@ -8,6 +8,7 @@ import ( "bufio" "context" crand "crypto/rand" + "encoding/json" "errors" "expvar" "fmt" @@ -32,6 +33,22 @@ func newPrivateKey(tb testing.TB) (k key.Private) { return } +func TestClientInfoUnmarshal(t *testing.T) { + for i, in := range []string{ + `{"Version":5,"MeshKey":"abc"}`, + `{"version":5,"meshKey":"abc"}`, + } { + var got clientInfo + if err := json.Unmarshal([]byte(in), &got); err != nil { + t.Fatalf("[%d]: %v", i, err) + } + want := clientInfo{Version: 5, MeshKey: "abc"} + if got != want { + t.Errorf("[%d]: got %+v; want %+v", i, got, want) + } + } +} + func TestSendRecv(t *testing.T) { serverPrivateKey := newPrivateKey(t) s := NewServer(serverPrivateKey, t.Logf)