mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Forward bridge fingerprint
gitlab 28651
This commit is contained in:
parent
281d917beb
commit
b563141c6a
7 changed files with 41 additions and 11 deletions
|
@ -29,10 +29,13 @@ each encoded in JSON format
|
|||
{
|
||||
offer: <sdp offer>
|
||||
[nat: (unknown|restricted|unrestricted)]
|
||||
[fingerprint: <fingerprint string>]
|
||||
}
|
||||
|
||||
The NAT field is optional, and if it is missing a
|
||||
value of "unknown" will be assumed.
|
||||
value of "unknown" will be assumed. The fingerprint
|
||||
is also optional and, if absent, will be assigned the
|
||||
fingerprint of the default bridge.
|
||||
|
||||
== ClientPollResponse ==
|
||||
<poll response> :=
|
||||
|
@ -49,13 +52,25 @@ for the error.
|
|||
|
||||
*/
|
||||
|
||||
// The bridge fingerprint to assume, for client poll requests that do not
|
||||
// specify a fingerprint. Before #28651, there was only one bridge with one
|
||||
// fingerprint, which all clients expected to be connected to implicitly.
|
||||
// If a client is old enough that it does not specify a fingerprint, this is
|
||||
// the fingerprint it expects. Clients that do set a fingerprint in the
|
||||
// SOCKS params will also be assumed to want to connect to the default bridge.
|
||||
const defaultBridgeFingerprint = "2B280B23E1107BB62ABFC40DDCC8824814F80A72"
|
||||
|
||||
type ClientPollRequest struct {
|
||||
Offer string `json:"offer"`
|
||||
NAT string `json:"nat"`
|
||||
Offer string `json:"offer"`
|
||||
NAT string `json:"nat"`
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
}
|
||||
|
||||
// Encodes a poll message from a snowflake client
|
||||
func (req *ClientPollRequest) EncodeClientPollRequest() ([]byte, error) {
|
||||
if req.Fingerprint == "" {
|
||||
req.Fingerprint = defaultBridgeFingerprint
|
||||
}
|
||||
body, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -87,6 +102,10 @@ func DecodeClientPollRequest(data []byte) (*ClientPollRequest, error) {
|
|||
return nil, fmt.Errorf("no supplied offer")
|
||||
}
|
||||
|
||||
if message.Fingerprint == "" {
|
||||
message.Fingerprint = defaultBridgeFingerprint
|
||||
}
|
||||
|
||||
switch message.NAT {
|
||||
case "":
|
||||
message.NAT = nat.NATUnknown
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue