mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
refactor(proxy): better RelayURL
description
It's the case that it's simply "default" after https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/87 Now the broker specifies the relay URL (see `ProxyPollResponse`).
This commit is contained in:
parent
ec9476e5ab
commit
2bbd4d0643
2 changed files with 10 additions and 7 deletions
|
@ -56,9 +56,10 @@ const (
|
||||||
DefaultPollInterval = 5 * time.Second
|
DefaultPollInterval = 5 * time.Second
|
||||||
DefaultBrokerURL = "https://snowflake-broker.torproject.net/"
|
DefaultBrokerURL = "https://snowflake-broker.torproject.net/"
|
||||||
DefaultNATProbeURL = "https://snowflake-broker.torproject.net:8443/probe"
|
DefaultNATProbeURL = "https://snowflake-broker.torproject.net:8443/probe"
|
||||||
DefaultRelayURL = "wss://snowflake.torproject.net/"
|
// This is rather a "DefaultDefaultRelayURL"
|
||||||
DefaultSTUNURL = "stun:stun.l.google.com:19302"
|
DefaultRelayURL = "wss://snowflake.torproject.net/"
|
||||||
DefaultProxyType = "standalone"
|
DefaultSTUNURL = "stun:stun.l.google.com:19302"
|
||||||
|
DefaultProxyType = "standalone"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -125,7 +126,9 @@ type SnowflakeProxy struct {
|
||||||
BrokerURL string
|
BrokerURL string
|
||||||
// KeepLocalAddresses indicates whether local SDP candidates will be sent to the broker
|
// KeepLocalAddresses indicates whether local SDP candidates will be sent to the broker
|
||||||
KeepLocalAddresses bool
|
KeepLocalAddresses bool
|
||||||
// RelayURL is the URL of the Snowflake server that all traffic will be relayed to
|
// RelayURL is the default `URL` of the server (relay)
|
||||||
|
// that this proxy will forward client connections to,
|
||||||
|
// in case the broker itself did not specify the said URL
|
||||||
RelayURL string
|
RelayURL string
|
||||||
// OutboundAddress specify an IP address to use as SDP host candidate
|
// OutboundAddress specify an IP address to use as SDP host candidate
|
||||||
OutboundAddress string
|
OutboundAddress string
|
||||||
|
@ -728,7 +731,7 @@ func (sf *SnowflakeProxy) Start() error {
|
||||||
}
|
}
|
||||||
_, err = url.Parse(sf.RelayURL)
|
_, err = url.Parse(sf.RelayURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid relay url: %s", err)
|
return fmt.Errorf("invalid default relay url: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !namematcher.IsValidRule(sf.RelayDomainNamePattern) {
|
if !namematcher.IsValidRule(sf.RelayDomainNamePattern) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ func main() {
|
||||||
rawBrokerURL := flag.String("broker", sf.DefaultBrokerURL, "broker URL")
|
rawBrokerURL := flag.String("broker", sf.DefaultBrokerURL, "broker URL")
|
||||||
unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed")
|
unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed")
|
||||||
keepLocalAddresses := flag.Bool("keep-local-addresses", false, "keep local LAN address ICE candidates")
|
keepLocalAddresses := flag.Bool("keep-local-addresses", false, "keep local LAN address ICE candidates")
|
||||||
relayURL := flag.String("relay", sf.DefaultRelayURL, "websocket relay URL")
|
defaultRelayURL := flag.String("relay", sf.DefaultRelayURL, "websocket relay URL")
|
||||||
probeURL := flag.String("nat-probe-server", sf.DefaultNATProbeURL, "NAT check probe server URL")
|
probeURL := flag.String("nat-probe-server", sf.DefaultNATProbeURL, "NAT check probe server URL")
|
||||||
outboundAddress := flag.String("outbound-address", "", "prefer the given address as outbound address")
|
outboundAddress := flag.String("outbound-address", "", "prefer the given address as outbound address")
|
||||||
allowedRelayHostNamePattern := flag.String("allowed-relay-hostname-pattern", "snowflake.torproject.net$", "a pattern to specify allowed hostname pattern for relay URL.")
|
allowedRelayHostNamePattern := flag.String("allowed-relay-hostname-pattern", "snowflake.torproject.net$", "a pattern to specify allowed hostname pattern for relay URL.")
|
||||||
|
@ -97,7 +97,7 @@ func main() {
|
||||||
STUNURL: *stunURL,
|
STUNURL: *stunURL,
|
||||||
BrokerURL: *rawBrokerURL,
|
BrokerURL: *rawBrokerURL,
|
||||||
KeepLocalAddresses: *keepLocalAddresses,
|
KeepLocalAddresses: *keepLocalAddresses,
|
||||||
RelayURL: *relayURL,
|
RelayURL: *defaultRelayURL,
|
||||||
NATProbeURL: *probeURL,
|
NATProbeURL: *probeURL,
|
||||||
OutboundAddress: *outboundAddress,
|
OutboundAddress: *outboundAddress,
|
||||||
EphemeralMinPort: ephemeralPortsRange[0],
|
EphemeralMinPort: ephemeralPortsRange[0],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue