mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Represent Bridge Fingerprint As String
This commit is contained in:
parent
dd61e2be0f
commit
f789dce6d2
7 changed files with 69 additions and 21 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"container/heap"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/bridgefingerprint"
|
||||
"log"
|
||||
"net"
|
||||
"time"
|
||||
|
@ -130,7 +131,11 @@ func (i *IPC) ProxyPolls(arg messages.Arg, response *[]byte) error {
|
|||
|
||||
i.ctx.metrics.promMetrics.ProxyPollTotal.With(prometheus.Labels{"nat": natType, "status": "matched"}).Inc()
|
||||
var relayURL string
|
||||
if info, err := i.ctx.bridgeList.GetBridgeInfo(offer.fingerprint); err != nil {
|
||||
bridgeFingerprint, err := bridgefingerprint.FingerprintFromBytes(offer.fingerprint)
|
||||
if err != nil {
|
||||
return messages.ErrBadRequest
|
||||
}
|
||||
if info, err := i.ctx.bridgeList.GetBridgeInfo(bridgeFingerprint); err != nil {
|
||||
return err
|
||||
} else {
|
||||
relayURL = info.WebSocketAddress
|
||||
|
@ -172,12 +177,18 @@ func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte) error {
|
|||
if err != nil {
|
||||
return sendClientResponse(&messages.ClientPollResponse{Error: err.Error()}, response)
|
||||
}
|
||||
copy(offer.fingerprint[:], fingerprint)
|
||||
|
||||
if _, err := i.ctx.GetBridgeInfo(offer.fingerprint); err != nil {
|
||||
BridgeFingerprint, err := bridgefingerprint.FingerprintFromBytes(fingerprint)
|
||||
if err != nil {
|
||||
return sendClientResponse(&messages.ClientPollResponse{Error: err.Error()}, response)
|
||||
}
|
||||
|
||||
if _, err := i.ctx.GetBridgeInfo(BridgeFingerprint); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
offer.fingerprint = BridgeFingerprint.ToBytes()
|
||||
|
||||
// Only hand out known restricted snowflakes to unrestricted clients
|
||||
var snowflakeHeap *SnowflakeHeap
|
||||
if offer.natType == NATUnrestricted {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue