mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
refactor: use named returns for some funcs
This should make the functions easier to use, harder to confuse the return values with the same type.
This commit is contained in:
parent
e6555e4a1e
commit
5e7b35bf12
1 changed files with 10 additions and 5 deletions
|
@ -198,7 +198,7 @@ func EncodePollResponseWithRelayURL(offer string, success bool, natType, relayUR
|
|||
Status: failReason,
|
||||
})
|
||||
}
|
||||
func DecodePollResponse(data []byte) (string, string, error) {
|
||||
func DecodePollResponse(data []byte) (offer string, natType string, err error) {
|
||||
offer, natType, relayURL, err := DecodePollResponseWithRelayURL(data)
|
||||
if relayURL != "" {
|
||||
return "", "", ErrExtraInfo
|
||||
|
@ -208,7 +208,12 @@ func DecodePollResponse(data []byte) (string, string, error) {
|
|||
|
||||
// Decodes a poll response from the broker and returns an offer and the client's NAT type
|
||||
// If there is a client match, the returned offer string will be non-empty
|
||||
func DecodePollResponseWithRelayURL(data []byte) (string, string, string, error) {
|
||||
func DecodePollResponseWithRelayURL(data []byte) (
|
||||
offer string,
|
||||
natType string,
|
||||
relayURL string,
|
||||
err_ error,
|
||||
) {
|
||||
var message ProxyPollResponse
|
||||
|
||||
err := json.Unmarshal(data, &message)
|
||||
|
@ -231,7 +236,7 @@ func DecodePollResponseWithRelayURL(data []byte) (string, string, string, error)
|
|||
}
|
||||
}
|
||||
|
||||
natType := message.NAT
|
||||
natType = message.NAT
|
||||
if natType == "" {
|
||||
natType = "unknown"
|
||||
}
|
||||
|
@ -254,10 +259,10 @@ func EncodeAnswerRequest(answer string, sid string) ([]byte, error) {
|
|||
}
|
||||
|
||||
// Returns the sdp answer and proxy sid
|
||||
func DecodeAnswerRequest(data []byte) (string, string, error) {
|
||||
func DecodeAnswerRequest(data []byte) (answer string, sid string, err error) {
|
||||
var message ProxyAnswerRequest
|
||||
|
||||
err := json.Unmarshal(data, &message)
|
||||
err = json.Unmarshal(data, &message)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue