diff options
author | Arlo Breault <arlolra@gmail.com> | 2022-03-17 10:46:37 -0400 |
---|---|---|
committer | Arlo Breault <arlolra@gmail.com> | 2022-03-31 11:28:00 -0400 |
commit | 2f89fbc2ed3e25d2b4be76edc600cca37de91864 (patch) | |
tree | 7f6cc66e35d41c756f1727ff6bfaaab657263493 /broker | |
parent | fa2f6824d924f3317c82bc740130f354f6a1780c (diff) | |
download | snowflake-2f89fbc2ed3e25d2b4be76edc600cca37de91864.tar.gz snowflake-2f89fbc2ed3e25d2b4be76edc600cca37de91864.zip |
Represent fingerprint internally as byte array
Diffstat (limited to 'broker')
-rw-r--r-- | broker/broker.go | 2 | ||||
-rw-r--r-- | broker/ipc.go | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/broker/broker.go b/broker/broker.go index 6e85fbd..10129d7 100644 --- a/broker/broker.go +++ b/broker/broker.go @@ -143,7 +143,7 @@ func (ctx *BrokerContext) AddSnowflake(id string, proxyType string, natType stri type ClientOffer struct { natType string sdp []byte - fingerprint string + fingerprint [20]byte } func main() { diff --git a/broker/ipc.go b/broker/ipc.go index 2ef4ccd..e11a33c 100644 --- a/broker/ipc.go +++ b/broker/ipc.go @@ -2,6 +2,7 @@ package main import ( "container/heap" + "encoding/hex" "fmt" "log" "net" @@ -130,11 +131,16 @@ func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte) error { } offer := &ClientOffer{ - natType: req.NAT, - sdp: []byte(req.Offer), - fingerprint: req.Fingerprint, + natType: req.NAT, + sdp: []byte(req.Offer), } + fingerprint, err := hex.DecodeString(req.Fingerprint) + if err != nil { + return sendClientResponse(&messages.ClientPollResponse{Error: err.Error()}, response) + } + copy(offer.fingerprint[:], fingerprint) + // Only hand out known restricted snowflakes to unrestricted clients var snowflakeHeap *SnowflakeHeap if offer.natType == NATUnrestricted { |