Documentation
¶
Index ¶
- Constants
- Variables
- func CalcAppDataDir() string
- func ChownFileIfNeeded(path string)
- func ImportConfig(data []byte, directory string) error
- func IsDevVersion() bool
- func SystemInfoFromUserAgent(userAgent string) (goos string, goarch string)
- func VersionFromUserAgent(userAgent string) string
- type AppType
- type BlockedPeer
- type Config
- func (c *Config) CheckIPUnique(checkIP string, exceptPeerID string) error
- func (c *Config) DNSNamesMapping() map[string]string
- func (c *Config) DataDir() string
- func (c *Config) DevMode() bool
- func (c *Config) Export() []byte
- func (c *Config) GenUniqPeerAlias(name, alias string) string
- func (c *Config) GenUniqPeerAliasUnlocked(name, alias string) string
- func (c *Config) GenerateNextIpAddr() string
- func (c *Config) GenerateNextIpAddrExcept(except []string) string
- func (c *Config) GetBlockedPeer(peerID string) (BlockedPeer, bool)
- func (c *Config) GetBootstrapPeers() []peer.AddrInfo
- func (c *Config) GetListenAddresses() []multiaddr.Multiaddr
- func (c *Config) GetPeer(peerID string) (KnownPeer, bool)
- func (c *Config) GetPeerUnlocked(peerID string) (KnownPeer, bool)
- func (c *Config) IsUniqPeerAlias(excludePeerID, alias string) bool
- func (c *Config) IsUniqPeerAliasUnlocked(excludePeerID, alias string) bool
- func (c *Config) KnownPeersIds() []peer.ID
- func (c *Config) LogLevel() zapcore.Level
- func (c *Config) NodeName() string
- func (c *Config) PeerstoreDir() string
- func (c *Config) PrivKey() []byte
- func (c *Config) RemoveBlockedPeer(peerID string)
- func (c *Config) RemovePeer(peerID string) (KnownPeer, bool)
- func (c *Config) Save()
- func (c *Config) SaveLocked()
- func (c *Config) SetIdentity(key crypto.PrivKey, id peer.ID)
- func (c *Config) SetListenAddresses(multiaddrs []multiaddr.Multiaddr)
- func (c *Config) UpdatePeerFields(peerID string, mutate func(*KnownPeer)) bool
- func (c *Config) UpdatePeerLastSeen(peerID string)
- func (c *Config) UpsertBlockedPeer(peerID, displayName string)
- func (c *Config) UpsertPeer(peer KnownPeer)
- func (c *Config) UpsertPeerUnlocked(peer KnownPeer)
- func (c *Config) VPNLocalIPMask() (net.IP, net.IPMask)
- func (c *Config) VPNLocalIPMaskUnlocked() (net.IP, net.IPMask)
- type DNSConfig
- type HttpBasicAuthConfig
- type KnownPeer
- type P2pNodeConfig
- type SOCKS5Config
- type UpdateConfig
- type VPNConfig
- type VPNGatewayConfig
Constants ¶
const ( AppConfigFilename = "config_awl.json" AppDataDirectory = "anywherelan" DhtPeerstoreDataDirectory = "peerstore" AppDataDirEnvKey = "AWL_DATA_DIR" // TODO 8989 maybe? DefaultHTTPPort = 8639 AdminHttpServerDomainName = "admin" AdminHttpServerIP = "127.0.0.66" AdminHttpServerListenAddress = "127.0.0.66:80" DefaultPeerAlias = "peer" )
const ( DefaultVPNInterfaceName = "awl0" // TODO: generate subnets if this has already taken DefaultVPNNetworkSubnet = "10.66.0.1/16" )
const DevVersion = "dev"
Variables ¶
var ( // set via ldflags Version = DevVersion UserAgent = UserAgentPrefix + SystemInfo + "/" + Version UserAgentPrefix = "awl/" SystemInfo = runtime.GOOS + "-" + runtime.GOARCH // set via ldflags IsWindows7 = "" )
var DefaultBootstrapPeers []multiaddr.Multiaddr
var LinuxFilesOwnerUID = os.Geteuid()
LinuxFilesOwnerUID is used to set correct files owner uid. This is needed because by default all files belong to root when we run as root, but they are stored in user's directory.
Functions ¶
func CalcAppDataDir ¶
func CalcAppDataDir() string
func ChownFileIfNeeded ¶ added in v0.9.0
func ChownFileIfNeeded(path string)
func ImportConfig ¶
func IsDevVersion ¶ added in v0.5.1
func IsDevVersion() bool
IsDevVersion Possible duplicate of *Config.DevMode() Based on build version (unchangeable after build, could be used only by developers)
func SystemInfoFromUserAgent ¶ added in v0.7.0
func VersionFromUserAgent ¶
Types ¶
type BlockedPeer ¶
type Config ¶
type Config struct {
sync.RWMutex `swaggerignore:"true"`
Version string `json:"version"`
LoggerLevel string `json:"loggerLevel"`
HttpListenAddress string `json:"httpListenAddress"`
HttpListenOnAdminHost bool `json:"httpListenOnAdminHost"`
HttpBasicAuth HttpBasicAuthConfig `json:"httpBasicAuth"`
P2pNode P2pNodeConfig `json:"p2pNode"`
VPNConfig VPNConfig `json:"vpn"`
VPNGateway VPNGatewayConfig `json:"vpnGateway"`
SOCKS5 SOCKS5Config `json:"socks5"`
DNS DNSConfig `json:"dns"`
KnownPeers map[string]KnownPeer `json:"knownPeers"`
BlockedPeers map[string]BlockedPeer `json:"blockedPeers"`
Update UpdateConfig `json:"update"`
// contains filtered or unexported fields
}
func (*Config) CheckIPUnique ¶ added in v0.15.0
CheckIPUnique is not thread safe. Checks IP for: valid ip, unique across peers, in vpn net mask
func (*Config) DNSNamesMapping ¶
func (*Config) DevMode ¶
DevMode Possible duplicate of IsDevVersion() Based on Config.LoggerLevel (could be used by any user)
func (*Config) GenUniqPeerAlias ¶ added in v0.5.1
func (*Config) GenUniqPeerAliasUnlocked ¶ added in v0.18.0
GenUniqPeerAliasUnlocked is GenUniqPeerAlias without locking; the caller must hold the lock.
func (*Config) GenerateNextIpAddr ¶
GenerateNextIpAddr is not thread safe.
func (*Config) GenerateNextIpAddrExcept ¶ added in v0.15.0
GenerateNextIpAddrExcept is not thread safe.
func (*Config) GetBlockedPeer ¶
func (c *Config) GetBlockedPeer(peerID string) (BlockedPeer, bool)
func (*Config) GetBootstrapPeers ¶
func (*Config) GetListenAddresses ¶
func (*Config) GetPeerUnlocked ¶ added in v0.18.0
GetPeerUnlocked is GetPeer without locking; the caller must hold the lock.
func (*Config) IsUniqPeerAlias ¶ added in v0.5.1
func (*Config) IsUniqPeerAliasUnlocked ¶ added in v0.18.0
IsUniqPeerAliasUnlocked is IsUniqPeerAlias without locking; the caller must hold the lock.
func (*Config) KnownPeersIds ¶
func (*Config) NodeName ¶ added in v0.18.0
NodeName returns this node's name under the read lock. P2pNode.Name is mutated at runtime (UpdateMySettings), so it must not be read directly without the lock.
func (*Config) PeerstoreDir ¶
func (*Config) RemoveBlockedPeer ¶
func (*Config) SaveLocked ¶ added in v0.18.0
func (c *Config) SaveLocked()
SaveLocked persists the config without taking the lock. The caller must already hold c.Lock(). Use this when atomically batching mutations and persistence under a single critical section.
func (*Config) SetListenAddresses ¶
func (*Config) UpdatePeerFields ¶ added in v0.18.0
UpdatePeerFields atomically applies mutate to the stored KnownPeer under the write lock and persists the change. It returns false if the peer is unknown.
mutate must only change the fields it owns and must NOT replace the struct wholesale, so that fields updated concurrently by other callers are not clobbered. mutate runs while the lock is held, so it must not call other Config methods that take the lock (use the *Unlocked variants instead).
func (*Config) UpdatePeerLastSeen ¶
func (*Config) UpsertBlockedPeer ¶
func (*Config) UpsertPeer ¶
func (*Config) UpsertPeerUnlocked ¶ added in v0.15.0
type DNSConfig ¶ added in v0.16.0
type DNSConfig struct {
DisableDNS bool `json:"disableDNS"`
ListenAddress string `json:"listenAddress"`
// UpstreamDNSAddress is the public resolver (host:port) that the awl
// DNS resolver forwards non-.awl queries to. Used as a fallback when
// the OS exposes no base nameserver, and forced as the sole upstream in
// VPN gateway client mode so DNS traverses the tunnel and does not leak.
// On Android the host reads this value to configure VpnService DNS.
UpstreamDNSAddress string `json:"upstreamDNSAddress"`
}
type HttpBasicAuthConfig ¶ added in v0.17.0
type KnownPeer ¶
type KnownPeer struct {
// Hex-encoded multihash representing a peer ID
PeerID string `json:"peerId"`
// Peer provided name
Name string `json:"name"`
// User provided name
Alias string `json:"alias"`
// IPAddr used for forwarding
IPAddr string `json:"ipAddr"`
// DomainName without zone suffix (.awl)
DomainName string `json:"domainName"`
// Time of adding to config (accept/invite)
CreatedAt time.Time `json:"createdAt"`
// Time of last connection
LastSeen time.Time `json:"lastSeen"`
// Has remote peer confirmed our invitation
Confirmed bool `json:"confirmed"`
// Has remote peer declined our invitation
Declined bool `json:"declined"`
WeAllowUsingAsExitNode bool `json:"weAllowUsingAsExitNode"`
AllowedUsingAsExitNode bool `json:"allowedUsingAsExitNode"`
// RemoteVPNGatewayServerEnabled is the remote peer's VPNGatewayConfig.ServerEnabled
// as advertised via the status protocol. Combined with AllowedUsingAsExitNode
// (also from status) it determines whether this peer is currently a valid
// VPN gateway target for us — see KnownPeer.CanUseAsVPNGateway.
RemoteVPNGatewayServerEnabled bool `json:"remoteVPNGatewayServerEnabled"`
}
func (KnownPeer) CanUseAsVPNGateway ¶ added in v0.18.0
CanUseAsVPNGateway reports whether this peer can currently be used as a VPN gateway. It requires both that the peer permits being used as an exit node (shared with SOCKS5 via AllowedUsingAsExitNode) and that the peer has VPN gateway server enabled on its side (RemoteVPNGatewayServerEnabled). Both flags are populated from the status protocol exchange in service/auth_status.go.
func (KnownPeer) DisplayName ¶
type P2pNodeConfig ¶
type P2pNodeConfig struct {
// Hex-encoded multihash representing a peer ID, calculated from Identity
PeerID string `json:"peerId"`
Name string `json:"name"`
Identity string `json:"identity"`
BootstrapPeers []string `json:"bootstrapPeers"`
// With this option only BootstrapPeers from config will be used
IgnoreDefaultBootstrapPeers *bool `json:"ignoreDefaultBootstrapPeers,omitempty"`
ListenAddresses []string `json:"listenAddresses"`
ReconnectionIntervalSec time.Duration `json:"reconnectionIntervalSec" swaggertype:"primitive,integer"` //nolint:staticcheck
AutoAcceptAuthRequests bool `json:"autoAcceptAuthRequests"`
UseDedicatedConnForEachStream bool `json:"useDedicatedConnForEachStream"`
ParallelSendingStreamsCount int `json:"parallelSendingStreamsCount"`
}
type SOCKS5Config ¶ added in v0.12.0
type SOCKS5Config struct {
ListenerEnabled bool `json:"listenerEnabled"`
// allow using my host as proxy
ProxyingEnabled bool `json:"proxyingEnabled"`
ListenAddress string `json:"listenAddress"`
// peer that is set as proxy
UsingPeerID string `json:"usingPeerID"`
// Optional local auth credentials. If both are set, SOCKS5 clients must authenticate.
Username string `json:"username"`
Password string `json:"password"`
}
type UpdateConfig ¶
type VPNGatewayConfig ¶ added in v0.18.0
type VPNGatewayConfig struct {
// ClientEnabled — route all traffic through GatewayPeerID (client side).
ClientEnabled bool `json:"clientEnabled"`
// GatewayPeerID — selected gateway peer ID.
GatewayPeerID string `json:"gatewayPeerID"`
// ServerEnabled — this node serves as a VPN gateway for others.
// Propagated via the status protocol so peers know whether to offer
// this node as an option in their UI.
ServerEnabled bool `json:"serverEnabled"`
}
VPNGatewayConfig configures full-tunnel VPN gateway mode.
VPN gateway is a separate feature from SOCKS5 exit-node: a peer can allow being used as a SOCKS5 exit (KnownPeer.AllowedUsingAsExitNode, propagated via the status protocol) without serving as a VPN gateway, and vice versa. KnownPeer.CanUseAsVPNGateway() combines both.