mullvad
import "redn3t.com/odirscan/internal/mullvad"
Index
- func IsConnected() (bool, error)
- func SelectProxies(cfg config.MullvadConfig, limit int, filter RelayFilter) ([]string, error)
- func StartUpdater(cfg config.MullvadConfig)
- type AmIConnected
- type Location
- type MullvadRelays
- type MullvadRelaysLocations
- type Relay
- type RelayFilter
- type WireguardEndpoints
func IsConnected
func IsConnected() (bool, error)
func SelectProxies
func SelectProxies(cfg config.MullvadConfig, limit int, filter RelayFilter) ([]string, error)
SelectProxies returns up to limit proxy strings for relays matching filter, formatted as socks5://hostname:<port> for use with colly's proxy switcher. limit <= 0 means no limit. Reports an error if the relay list is not loaded.
func StartUpdater
func StartUpdater(cfg config.MullvadConfig)
StartUpdater performs an initial relay list update and then checks for updates at the interval specified by cfg.UpdateInterval. It returns immediately after the first update; subsequent checks run in the background.
type AmIConnected
type AmIConnected struct {
// Ip corresponds to the JSON schema field "ip".
Ip *string `json:"ip,omitempty" yaml:"ip,omitempty" mapstructure:"ip,omitempty"`
// MullvadExitIp corresponds to the JSON schema field "mullvad_exit_ip".
MullvadExitIp bool `json:"mullvad_exit_ip" yaml:"mullvad_exit_ip" mapstructure:"mullvad_exit_ip"`
// MullvadExitIpHostname corresponds to the JSON schema field
// "mullvad_exit_ip_hostname".
MullvadExitIpHostname *string `json:"mullvad_exit_ip_hostname,omitempty" yaml:"mullvad_exit_ip_hostname,omitempty" mapstructure:"mullvad_exit_ip_hostname,omitempty"`
AdditionalProperties interface{} `mapstructure:",remain"`
}
func (*AmIConnected) UnmarshalJSON
func (j *AmIConnected) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Location
type Location struct {
// City corresponds to the JSON schema field "city".
City string `json:"city" yaml:"city" mapstructure:"city"`
// Country corresponds to the JSON schema field "country".
Country string `json:"country" yaml:"country" mapstructure:"country"`
// Latitude corresponds to the JSON schema field "latitude".
Latitude float64 `json:"latitude" yaml:"latitude" mapstructure:"latitude"`
// Longitude corresponds to the JSON schema field "longitude".
Longitude float64 `json:"longitude" yaml:"longitude" mapstructure:"longitude"`
}
func (*Location) UnmarshalJSON
func (j *Location) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type MullvadRelays
type MullvadRelays struct {
// Locations corresponds to the JSON schema field "locations".
Locations MullvadRelaysLocations `json:"locations" yaml:"locations" mapstructure:"locations"`
// Wireguard corresponds to the JSON schema field "wireguard".
Wireguard WireguardEndpoints `json:"wireguard" yaml:"wireguard" mapstructure:"wireguard"`
}
Relays holds the most recently loaded Mullvad relay list. It is nil until the first successful parse completes.
var Relays *MullvadRelays
func (*MullvadRelays) UnmarshalJSON
func (j *MullvadRelays) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type MullvadRelaysLocations
type MullvadRelaysLocations map[string]Location
type Relay
type Relay struct {
// Active corresponds to the JSON schema field "active".
Active bool `json:"active" yaml:"active" mapstructure:"active"`
// Hostname corresponds to the JSON schema field "hostname".
Hostname string `json:"hostname" yaml:"hostname" mapstructure:"hostname"`
// IncludeInCountry corresponds to the JSON schema field "include_in_country".
IncludeInCountry bool `json:"include_in_country" yaml:"include_in_country" mapstructure:"include_in_country"`
// Ipv4AddrIn corresponds to the JSON schema field "ipv4_addr_in".
Ipv4AddrIn string `json:"ipv4_addr_in" yaml:"ipv4_addr_in" mapstructure:"ipv4_addr_in"`
// Ipv6AddrIn corresponds to the JSON schema field "ipv6_addr_in".
Ipv6AddrIn string `json:"ipv6_addr_in" yaml:"ipv6_addr_in" mapstructure:"ipv6_addr_in"`
// Location corresponds to the JSON schema field "location".
Location string `json:"location" yaml:"location" mapstructure:"location"`
// PublicKey corresponds to the JSON schema field "public_key".
PublicKey string `json:"public_key" yaml:"public_key" mapstructure:"public_key"`
// Weight corresponds to the JSON schema field "weight".
Weight int `json:"weight" yaml:"weight" mapstructure:"weight"`
AdditionalProperties interface{} `mapstructure:",remain"`
}
func (*Relay) UnmarshalJSON
func (j *Relay) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type RelayFilter
RelayFilter specifies which relays SelectProxies should include. Zero values impose no constraint for that field. Active and IncludeInCountry are always required to be true and are not exposed.
type RelayFilter struct {
Location *regexp.Regexp // match relay.Location against pattern; nil = any
Owned *bool // nil = any, true = owned only, false = non-owned only
Weight func(int) bool // nil = no weight filter
}
type WireguardEndpoints
type WireguardEndpoints struct {
// Ipv4Gateway corresponds to the JSON schema field "ipv4_gateway".
Ipv4Gateway string `json:"ipv4_gateway" yaml:"ipv4_gateway" mapstructure:"ipv4_gateway"`
// Ipv6Gateway corresponds to the JSON schema field "ipv6_gateway".
Ipv6Gateway string `json:"ipv6_gateway" yaml:"ipv6_gateway" mapstructure:"ipv6_gateway"`
// PortRanges corresponds to the JSON schema field "port_ranges".
PortRanges [][]int `json:"port_ranges" yaml:"port_ranges" mapstructure:"port_ranges"`
// Relays corresponds to the JSON schema field "relays".
Relays []Relay `json:"relays" yaml:"relays" mapstructure:"relays"`
}
func (*WireguardEndpoints) UnmarshalJSON
func (j *WireguardEndpoints) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
Generated by gomarkdoc