Loading README.md +7 −7 Original line number Diff line number Diff line Loading @@ -62,8 +62,8 @@ A JSON response with one or more bridges has the following format: "address": "ADDRESS", "port": PORT, "protocol": "PROTOCOL", "arguments": { "KEY": "VALUE", "params": { "KEY": ["VALUE"], ... }, }, Loading @@ -89,19 +89,19 @@ A JSON response with one or more bridges has the following format: "udp"). * The strings `KEY` and `VALUE` constitute a dictionary that – for obfuscated bridges – contains a bridge's arguments (e.g., "cert": bridges – contains a bridge's parameters (e.g., "cert": "VBYOXYf+SbRu2dCHJkLuL9y7YX4IWhucHGg3ES+l/KKxe3KL+zhCHr5hRqgSE6w80bZvCA"). Unobfuscated bridges (i.e., bridges whose type is "vanilla") don't have the "arguments" key. "params" key. Here is an example of a JSON response, consisting of two bridges: { "b8ac3f413663f3ed3a404a5db8b1445c8c1b37f85849879feb3b1b03ce8cb6d8": { "address": "2001:4860:4860::8888", "arguments": { "cert": "VBYOXYf+SbRu2dCHJkLuL9y7YX4IWhucHGg3ES+l/KKxe3KL+zhCHr5hRqgSE6w80bZvCA", "iat-mode": "0" "params": { "cert": ["VBYOXYf+SbRu2dCHJkLuL9y7YX4IWhucHGg3ES+l/KKxe3KL+zhCHr5hRqgSE6w80bZvCA"], "iat-mode": ["0"] }, "fingerprint": "1234567890ABCDEF1234567890ABCDEF12345678", "port": 80, Loading extrainfo.go +1 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ func populateTransportInfo(transport string, t *Transport) error { if len(kv) != 2 { return fmt.Errorf("key:value pair in %q not separated by a '='", words[3]) } t.Arguments[kv[0]] = kv[1] t.Parameters[kv[0]] = []string{kv[1]} } } Loading extrainfo_test.go +8 −8 Original line number Diff line number Diff line Loading @@ -31,12 +31,12 @@ func TestPopulateTransportInfo(t *testing.T) { if err = populateTransportInfo("transport bar 1.2.3.4:1234 a=b,foo=bar", transport); err != nil { t.Errorf("Failed to parse transport line.") } value, _ := transport.Arguments["a"] if value != "b" { value, _ := transport.Parameters["a"] if value[0] != "b" { t.Errorf("Failed to parse transport arguments.") } value, _ = transport.Arguments["foo"] if value != "bar" { value, _ = transport.Parameters["foo"] if value[0] != "bar" { t.Errorf("Failed to parse transport arguments.") } } Loading Loading @@ -77,12 +77,12 @@ transport obfs5 1.2.3.4:4321 foo=bar if bridge.Transports[0].Fingerprint != "51502DF3D176CC10C52CC65694205BBA185E0982" { t.Errorf("Couldn't parse obfs4 fingerprint.") } value, _ := bridge.Transports[0].Arguments["key"] if value != "value" { value, _ := bridge.Transports[0].Parameters["key"] if value[0] != "value" { t.Errorf("Couldn't parse first obfs4 key=value pair.") } value, _ = bridge.Transports[0].Arguments["1"] if value != "2" { value, _ = bridge.Transports[0].Parameters["1"] if value[0] != "2" { t.Errorf("Couldn't parse second obfs4 key=value pair.") } } transports.go +11 −11 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ type Transport struct { Address IPAddr `json:"address"` Port uint16 `json:"port"` Fingerprint string `json:"fingerprint"` Arguments map[string]string `json:"arguments,omitempty"` Parameters map[string][]string `json:"params,omitempty"` Bridge *Bridge `json:"-"` BlockedIn []*Location `json:"-"` } Loading @@ -21,7 +21,7 @@ type Transport struct { // NewTransport allocates and returns a new Transport object. func NewTransport() *Transport { t := &Transport{} t.Arguments = make(map[string]string) t.Parameters = make(map[string][]string) return t } Loading @@ -29,8 +29,8 @@ func NewTransport() *Transport { func (t *Transport) String() string { var args []string for key, value := range t.Arguments { args = append(args, fmt.Sprintf("%s=%s", key, value)) for key, values := range t.Parameters { args = append(args, fmt.Sprintf("%s=%s", key, values[0])) } return fmt.Sprintf("%s %s:%d %s %s", Loading Loading
README.md +7 −7 Original line number Diff line number Diff line Loading @@ -62,8 +62,8 @@ A JSON response with one or more bridges has the following format: "address": "ADDRESS", "port": PORT, "protocol": "PROTOCOL", "arguments": { "KEY": "VALUE", "params": { "KEY": ["VALUE"], ... }, }, Loading @@ -89,19 +89,19 @@ A JSON response with one or more bridges has the following format: "udp"). * The strings `KEY` and `VALUE` constitute a dictionary that – for obfuscated bridges – contains a bridge's arguments (e.g., "cert": bridges – contains a bridge's parameters (e.g., "cert": "VBYOXYf+SbRu2dCHJkLuL9y7YX4IWhucHGg3ES+l/KKxe3KL+zhCHr5hRqgSE6w80bZvCA"). Unobfuscated bridges (i.e., bridges whose type is "vanilla") don't have the "arguments" key. "params" key. Here is an example of a JSON response, consisting of two bridges: { "b8ac3f413663f3ed3a404a5db8b1445c8c1b37f85849879feb3b1b03ce8cb6d8": { "address": "2001:4860:4860::8888", "arguments": { "cert": "VBYOXYf+SbRu2dCHJkLuL9y7YX4IWhucHGg3ES+l/KKxe3KL+zhCHr5hRqgSE6w80bZvCA", "iat-mode": "0" "params": { "cert": ["VBYOXYf+SbRu2dCHJkLuL9y7YX4IWhucHGg3ES+l/KKxe3KL+zhCHr5hRqgSE6w80bZvCA"], "iat-mode": ["0"] }, "fingerprint": "1234567890ABCDEF1234567890ABCDEF12345678", "port": 80, Loading
extrainfo.go +1 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ func populateTransportInfo(transport string, t *Transport) error { if len(kv) != 2 { return fmt.Errorf("key:value pair in %q not separated by a '='", words[3]) } t.Arguments[kv[0]] = kv[1] t.Parameters[kv[0]] = []string{kv[1]} } } Loading
extrainfo_test.go +8 −8 Original line number Diff line number Diff line Loading @@ -31,12 +31,12 @@ func TestPopulateTransportInfo(t *testing.T) { if err = populateTransportInfo("transport bar 1.2.3.4:1234 a=b,foo=bar", transport); err != nil { t.Errorf("Failed to parse transport line.") } value, _ := transport.Arguments["a"] if value != "b" { value, _ := transport.Parameters["a"] if value[0] != "b" { t.Errorf("Failed to parse transport arguments.") } value, _ = transport.Arguments["foo"] if value != "bar" { value, _ = transport.Parameters["foo"] if value[0] != "bar" { t.Errorf("Failed to parse transport arguments.") } } Loading Loading @@ -77,12 +77,12 @@ transport obfs5 1.2.3.4:4321 foo=bar if bridge.Transports[0].Fingerprint != "51502DF3D176CC10C52CC65694205BBA185E0982" { t.Errorf("Couldn't parse obfs4 fingerprint.") } value, _ := bridge.Transports[0].Arguments["key"] if value != "value" { value, _ := bridge.Transports[0].Parameters["key"] if value[0] != "value" { t.Errorf("Couldn't parse first obfs4 key=value pair.") } value, _ = bridge.Transports[0].Arguments["1"] if value != "2" { value, _ = bridge.Transports[0].Parameters["1"] if value[0] != "2" { t.Errorf("Couldn't parse second obfs4 key=value pair.") } }
transports.go +11 −11 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ type Transport struct { Address IPAddr `json:"address"` Port uint16 `json:"port"` Fingerprint string `json:"fingerprint"` Arguments map[string]string `json:"arguments,omitempty"` Parameters map[string][]string `json:"params,omitempty"` Bridge *Bridge `json:"-"` BlockedIn []*Location `json:"-"` } Loading @@ -21,7 +21,7 @@ type Transport struct { // NewTransport allocates and returns a new Transport object. func NewTransport() *Transport { t := &Transport{} t.Arguments = make(map[string]string) t.Parameters = make(map[string][]string) return t } Loading @@ -29,8 +29,8 @@ func NewTransport() *Transport { func (t *Transport) String() string { var args []string for key, value := range t.Arguments { args = append(args, fmt.Sprintf("%s=%s", key, value)) for key, values := range t.Parameters { args = append(args, fmt.Sprintf("%s=%s", key, values[0])) } return fmt.Sprintf("%s %s:%d %s %s", Loading