mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Defer SQS client IP extraction to ClientOffers
Now that both SQS and AMP cache are pulling remote addresses from the SDP, avoid duplicate decodings of the ClientPollRequest by extracting the remote addr in ClientOffers.
This commit is contained in:
parent
0bbcb1eca4
commit
70974640ab
1 changed files with 1 additions and 19 deletions
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/messages"
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/sqsclient"
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/util"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -148,26 +147,9 @@ func (r *sqsHandler) handleMessage(mainCtx context.Context, message *types.Messa
|
|||
|
||||
encPollReq = []byte(*message.Body)
|
||||
|
||||
// Get best guess Client IP for geolocating
|
||||
remoteAddr := ""
|
||||
req, err := messages.DecodeClientPollRequest(encPollReq)
|
||||
if err != nil {
|
||||
log.Printf("SQSHandler: error encounted when decoding client poll request %s: %v\n", *clientID, err)
|
||||
} else {
|
||||
sdp, err := util.DeserializeSessionDescription(req.Offer)
|
||||
if err != nil {
|
||||
log.Printf("SQSHandler: error encounted when deserializing session desc %s: %v\n", *clientID, err)
|
||||
} else {
|
||||
candidateAddrs := util.GetCandidateAddrs(sdp.SDP)
|
||||
if len(candidateAddrs) > 0 {
|
||||
remoteAddr = candidateAddrs[0].String()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arg := messages.Arg{
|
||||
Body: encPollReq,
|
||||
RemoteAddr: remoteAddr,
|
||||
RemoteAddr: "",
|
||||
RendezvousMethod: messages.RendezvousSqs,
|
||||
Context: ctx,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue