Skip to main content

Relay Selection

The SelectProxies() function picks Mullvad relays to use as SOCKS5 proxies, applying configurable filters to the relay list.

How It Works

SelectProxies iterates over all WireGuard relays in the loaded relay list and applies these mandatory filters:

  • Active must be true
  • IncludeInCountry must be true

Then it applies the optional filters from a RelayFilter:

FilterTypeDescription
Location*regexp.RegexpMatch the relay's location string against a regex pattern. nil matches all.
Owned*boolFilter by ownership. nil = any, true = Mullvad-owned only, false = rented only.
Weightfunc(int) boolCustom predicate on the relay's weight value. nil = no weight filter.

Hostname Transformation

Mullvad relays have WireGuard hostnames like se-mma-wg-001. To get the SOCKS5 proxy hostname, odirscan replaces -wg- with -wg-socks5-:

se-mma-wg-001 -> se-mma-wg-socks5-001

The full proxy URL is then:

socks5://se-mma-wg-socks5-001.relays.mullvad.net:1080

Limit

The limit parameter controls how many proxies to return. Set to 0 or negative for no limit. The default configuration requests up to 50 proxies.

Default Filter

The default scanner configuration uses a weight filter:

filter := mullvad.RelayFilter{
Weight: func(num int) bool {
return num <= cfg.MaxRelayWeight // default: 99
},
}

This excludes only the highest-weight relays, giving a broad selection of proxies for round-robin rotation.