diff --git a/client/client_test.go b/client/client_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6f071a6f42d6ead0202911328a8ee71dfd99a371 --- /dev/null +++ b/client/client_test.go @@ -0,0 +1,25 @@ +package client + +import ( + "encoding/json" + "testing" +) + +// This json was generated from the java model classes +var expected = `{"hopping_config":{"enabled":false,"hop_jitter":10,"min_hop_seconds":10,"obfs4_certs":["XXXXYYYYZZZZ"],"port_count":0,"port_seed":0,"proxy_addr":"127.0.0.1:8080","remotes":["37.218.4.12"]},"kcp_config":{"mtu":1400,"disable_flow_control":true,"enabled":true,"interval":10,"no_delay":true,"read_buffer":16777216,"receive_window_size":65535,"resend":2,"send_window_size":65535,"write_buffer":16777216},"obfs4_cert":"XXXYYYYZZZZZ","proxy_addr":"127.0.0.1:8080","remote_ip":"37.218.4.12","remote_port":"4431"}` + +func TestJsonFormattingEnsureFFIInterop(t *testing.T) { + config := Config{} + err := json.Unmarshal([]byte(expected), &config) + if err != nil { + t.Error("unexpected marshalling error: ", err) + } + + if !config.KCPConfig.DisableFlowControl { + t.Error("DisableFlowControl should be false") + } + + if config.KCPConfig.MTU != 1400 { + t.Error("Unexpected MTU") + } +} diff --git a/obfsvpn/kcp.go b/obfsvpn/kcp.go index 4f0d925d1a1b6e87face0f88d6762dcd81d91870..d2e0c710450ef1328b48f07090d1ebf573e74457 100644 --- a/obfsvpn/kcp.go +++ b/obfsvpn/kcp.go @@ -20,16 +20,16 @@ const ( // https://github.com/skywind3000/kcp/blob/master/README.en.md#protocol-configuration type KCPConfig struct { - Enabled bool - SendWindowSize int - ReceiveWindowSize int - ReadBuffer int - WriteBuffer int - NoDelay bool - Interval int - Resend int - DisableFlowControl bool - MTU int + Enabled bool `json:"enabled"` + SendWindowSize int `json:"send_window_size"` + ReceiveWindowSize int `json:"receive_window_size"` + ReadBuffer int `json:"read_buffer"` + WriteBuffer int `json:"write_buffer"` + NoDelay bool `json:"no_delay"` + Interval int `json:"interval"` + Resend int `json:"resend"` + DisableFlowControl bool `json:"disable_flow_control"` + MTU int `json:"mtu"` } func DefaultKCPConfig() *KCPConfig {