Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Anti-censorship
Pluggable Transports
Snowflake
Commits
5d7a3766
Verified
Commit
5d7a3766
authored
Apr 11, 2022
by
shelikhoo
Browse files
Add Relay Info Forwarding for Snowflake
parent
d5a87c3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
broker/broker.go
View file @
5d7a3766
...
...
@@ -36,6 +36,13 @@ type BrokerContext struct {
snowflakeLock
sync
.
Mutex
proxyPolls
chan
*
ProxyPoll
metrics
*
Metrics
bridgeList
BridgeListHolderFileBased
allowedRelayPattern
string
}
func
(
ctx
*
BrokerContext
)
GetBridgeInfo
(
fingerprint
[
20
]
byte
)
(
BridgeInfo
,
error
)
{
return
ctx
.
bridgeList
.
GetBridgeInfo
(
fingerprint
)
}
func
NewBrokerContext
(
metricsLogger
*
log
.
Logger
)
*
BrokerContext
{
...
...
@@ -139,6 +146,14 @@ func (ctx *BrokerContext) AddSnowflake(id string, proxyType string, natType stri
return
snowflake
}
func
(
ctx
*
BrokerContext
)
InstallBridgeListProfile
(
reader
io
.
Reader
,
relayPattern
string
)
error
{
if
err
:=
ctx
.
bridgeList
.
LoadBridgeInfo
(
reader
);
err
!=
nil
{
return
err
}
ctx
.
allowedRelayPattern
=
relayPattern
return
nil
}
// Client offer contains an SDP, bridge fingerprint and the NAT type of the client
type
ClientOffer
struct
{
natType
string
...
...
broker/ipc.go
View file @
5d7a3766
...
...
@@ -102,7 +102,13 @@ func (i *IPC) ProxyPolls(arg messages.Arg, response *[]byte) error {
}
i
.
ctx
.
metrics
.
promMetrics
.
ProxyPollTotal
.
With
(
prometheus
.
Labels
{
"nat"
:
natType
,
"status"
:
"matched"
})
.
Inc
()
b
,
err
=
messages
.
EncodePollResponse
(
string
(
offer
.
sdp
),
true
,
offer
.
natType
)
var
relayURL
string
if
info
,
err
:=
i
.
ctx
.
bridgeList
.
GetBridgeInfo
(
offer
.
fingerprint
);
err
!=
nil
{
return
err
}
else
{
relayURL
=
info
.
WebSocketAddress
}
b
,
err
=
messages
.
EncodePollResponseWithRelayURL
(
string
(
offer
.
sdp
),
true
,
offer
.
natType
,
relayURL
)
if
err
!=
nil
{
return
messages
.
ErrInternal
}
...
...
@@ -141,6 +147,10 @@ func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte) error {
}
copy
(
offer
.
fingerprint
[
:
],
fingerprint
)
if
_
,
err
:=
i
.
ctx
.
GetBridgeInfo
(
offer
.
fingerprint
);
err
!=
nil
{
return
err
}
// Only hand out known restricted snowflakes to unrestricted clients
var
snowflakeHeap
*
SnowflakeHeap
if
offer
.
natType
==
NATUnrestricted
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment