mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
hardening(proxy): only accept ws
& wss
relays
This commit is contained in:
parent
14f4c82ff7
commit
0f2bdffba0
2 changed files with 10 additions and 6 deletions
|
@ -651,6 +651,11 @@ func checkIsRelayURLAcceptable(
|
|||
if err != nil {
|
||||
return fmt.Errorf("bad Relay URL %w", err)
|
||||
}
|
||||
// FYI our websocket library also rejects other protocols
|
||||
// https://github.com/gorilla/websocket/blob/5e002381133d322c5f1305d171f3bdd07decf229/client.go#L174-L181
|
||||
if parsedRelayURL.Scheme != "wss" && parsedRelayURL.Scheme != "ws" {
|
||||
return fmt.Errorf("rejected Relay URL protocol")
|
||||
}
|
||||
matcher := namematcher.NewNameMatcher(allowedHostNamePattern)
|
||||
if !matcher.IsMember(parsedRelayURL.Hostname()) || (!allowNonTLSRelay && parsedRelayURL.Scheme != "wss") {
|
||||
return fmt.Errorf("rejected Relay URL")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue