mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
use cbor instead of json to avoid double base64
This commit is contained in:
parent
6e0bc74fb8
commit
33b3891648
3 changed files with 10 additions and 2 deletions
|
@ -9,6 +9,8 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/fxamacker/cbor"
|
||||
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/bridgefingerprint"
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/nat"
|
||||
)
|
||||
|
@ -159,7 +161,7 @@ type ClientConnectionMetadata struct {
|
|||
}
|
||||
|
||||
func (meta *ClientConnectionMetadata) EncodeConnectionMetadata() (string, error) {
|
||||
jsonData, err := json.Marshal(meta)
|
||||
jsonData, err := cbor.Marshal(meta, cbor.CanonicalEncOptions())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -174,7 +176,7 @@ func DecodeConnectionMetadata(data string) (*ClientConnectionMetadata, error) {
|
|||
}
|
||||
|
||||
var meta ClientConnectionMetadata
|
||||
err = json.Unmarshal(decodedData, &meta)
|
||||
err = cbor.Unmarshal(decodedData, &meta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue