derp: remove JSON struct tags in comments
They don't work in comments. Added a test too to show that there's no change in behavior. (It does case insensitive matching on parse anyway)reviewable/pr696/r1
parent
1af70e2468
commit
805850add9
|
@ -129,13 +129,13 @@ func (c *Client) parseServerInfo(b []byte) (*serverInfo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientInfo struct {
|
type clientInfo struct {
|
||||||
Version int // `json:"version,omitempty"`
|
Version int `json:"version,omitempty"`
|
||||||
|
|
||||||
// MeshKey optionally specifies a pre-shared key used by
|
// MeshKey optionally specifies a pre-shared key used by
|
||||||
// trusted clients. It's required to subscribe to the
|
// trusted clients. It's required to subscribe to the
|
||||||
// connection list & forward packets. It's empty for regular
|
// connection list & forward packets. It's empty for regular
|
||||||
// users.
|
// users.
|
||||||
MeshKey string // `json:"meshKey,omitempty"`
|
MeshKey string `json:"meshKey,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) sendClientKey() error {
|
func (c *Client) sendClientKey() error {
|
||||||
|
|
|
@ -712,7 +712,7 @@ func (s *Server) sendServerKey(bw *bufio.Writer) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type serverInfo struct {
|
type serverInfo struct {
|
||||||
Version int // `json:"version,omitempty"`
|
Version int `json:"version,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) sendServerInfo(bw *bufio.Writer, clientKey key.Public) error {
|
func (s *Server) sendServerInfo(bw *bufio.Writer, clientKey key.Public) error {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
crand "crypto/rand"
|
crand "crypto/rand"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"expvar"
|
"expvar"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -32,6 +33,22 @@ func newPrivateKey(tb testing.TB) (k key.Private) {
|
||||||
return
|
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) {
|
func TestSendRecv(t *testing.T) {
|
||||||
serverPrivateKey := newPrivateKey(t)
|
serverPrivateKey := newPrivateKey(t)
|
||||||
s := NewServer(serverPrivateKey, t.Logf)
|
s := NewServer(serverPrivateKey, t.Logf)
|
||||||
|
|
Loading…
Reference in New Issue