Documentation
¶
Overview ¶
Package vpn pkg/vpn/client.go c4-app-vpn
Package vpn pkg/vpn/client_config.go c4-app-vpn
Package vpn pkg/vpn/client_embed.go c2-app-vpn
In-process embedding entry for the VPN client. The standard construction path (NewClient + Serve) is an APP: it reads the appserver environment for direct-route IPs, reports status over the app RPC, and dials the server through the app client. An embedder — the wasm visor's in-tab VPN instance is the driving case — has none of that: it dials the vpn-server route group itself and owns the lifecycle. NewClientEmbedded skips the environment and RPC coupling entirely (nil appCl; the status setters no-op), and ServeConn runs one VPN session over the conn the embedder dialed: handshake, TUN (on js the gVisor netstack, netstack_tun.go), and the packet copy loops.
Package vpn pkg/vpn/client_hello.go c4-app-vpn
Package vpn pkg/vpn/client_unix.go c4-app-vpn
Package vpn pkg/vpn/const.go c4-app-vpn
Package vpn pkg/vpn/env.go c4-app-vpn
Package vpn pkg/vpn/errors.go c4-app-vpn
Package vpn pkg/vpn/firewall_iptables_linux.go c4-app-vpn
The default firewall backend: iptables shell-outs, identical to what the router has always done. Each installed rule's full argv is recorded so teardown can remove it with the matching `-D`. This is the fleet path; the pure-Go nftables backend (firewall_nftfw_linux.go) replaces it only under the `nftfw` build tag.
Package vpn pkg/vpn/firewall_linux.go c4-app-vpn
firewall abstracts the vpn-router's packet-filter / NAT rules behind a small interface with two build-tagged backends, so the SAME router code runs either with iptables (default — the fleet's proven path) or with a pure-Go nftables backend (build tag `nftfw`, for the gokrazy appliance, which ships no iptables binary). Each backend tracks the rules it installs and removes them all in teardown(). See firewall_iptables_linux.go and firewall_nftfw_linux.go.
Package vpn pkg/vpn/handshake_status.go c4-app-vpn
Package vpn pkg/vpn/ip_generator.go c4-app-vpn
Package vpn pkg/vpn/mesh_client_linux.go c4-app-vpn
Package vpn pkg/vpn/mesh_gateway_standalone_linux.go c4-app-vpn
Standalone mesh gateway: the mesh-name resolver + transparent proxy of the full vpn-router (setupMeshGateway), but WITHOUT taking over the LAN. It runs no DHCP, assigns no address, brings up no tunnel — it only serves `.dmsg` / `.skynet` DNS and REDIRECTs synthetic-pool TCP into the mesh.
This is the "board behind your existing router" topology: a small appliance on the LAN gives every other device transparent, zero-per-device access to dmsg/skynet by name, while the household's own OpenWRT / DD-WRT router keeps doing DHCP and the default route. Two router-side settings wire it up:
- DNS forward: `.dmsg` / `.skynet` queries → this board's DNS (below).
- static route: the synthetic pool (default 100.64.0.0/16) → this board.
A LAN client then resolves `reward.dmsg` via the router → this board's DNS → a synthetic IP; its packets to that IP are static-routed here; PREROUTING REDIRECT lands them on the transparent proxy, which reads SO_ORIGINAL_DST and dials the encoded PK over the mesh (bypassing any VPN tunnel). Same mechanism as setupMeshGateway, minus the router role — see meshgw and router_linux.go.
Package vpn pkg/vpn/meshapp.go c4-app-vpn
Shared mesh-gateway wiring for the vpn-router and vpn-client apps: build the MeshDial from an app.Client, parse operator-supplied aliases, and load-or-mint the TLS CA. Kept here so both apps configure the gateway identically.
Package vpn pkg/vpn/net.go c4-app-vpn
Package vpn pkg/vpn/netstack_tun.go c4-app-vpn
A gVisor userspace netstack behind the same TUNDevice seam the platform TUNs implement. On js/wasm it IS the TUN (a browser has no L3 interface to open — newTUNDevice in tun_device_js.go builds one of these), but the type is pure Go and compiles everywhere: the VPN data plane only needs something that emits one IP packet per Read and accepts one IP packet per Write, and the netstack's channel endpoint is exactly that. In-tab (or in-process) dialers open TCP/UDP connections INSIDE this stack via Client.NetstackDial; the stack turns them into IP packets; the unchanged client serve loop copies those to the vpn-server over the route group, which does the real clearnet egress. The server cannot tell such a client from a native one, and no privileges are involved anywhere — no root, no device node.
Package vpn pkg/vpn/os.go c4-app-vpn
Package vpn pkg/vpn/os_client_linux.go c4-app-vpn
Package vpn pkg/vpn/os_linux.go c4-app-vpn
Package vpn pkg/vpn/os_server_linux.go c4-app-vpn
Package vpn pkg/vpn/router.go c4-app-vpn
Package vpn pkg/vpn/router_linux.go c4-app-vpn
Package vpn pkg/vpn/server.go c4-app-vpn
Package vpn pkg/vpn/server_config.go c4-app-vpn
Package vpn pkg/vpn/server_hello.go c4-app-vpn
Package vpn pkg/vpn/share.go c4-app-vpn
Sharing the tunnel with other devices — the phone's VPN hotspot.
On a phone the tunnel is the TUN the system hands out, and the kernel routes into it only what apps ON the phone send. A device on the phone's hotspot never reaches it: tethered traffic is forwarded below VpnService, straight to the uplink, and no unprivileged app can change that. The one process that could proxy for such a device — this one — is excluded from its own tunnel, because its dmsg traffic is what carries the tunnel.
So shared traffic enters the tunnel beside the kernel instead of through it: a userspace netstack (netstack_tun.go) that carries the SAME address the server assigned to this client. Its packets reach the server over the same route-group conn as the kernel's, and the server cannot tell them apart — which is what keeps its per-client rules applying to them (the secure mode's local-network block is keyed on that one address). Replies are told apart by destination port: the netstack takes its ephemeral ports from [shareFirstPort, shareLastPort], above the kernel's own range (32768–60999), so a reply to one of those ports is the netstack's and every other packet is the kernel's.
The proxy in front of it speaks SOCKS5 and HTTP on one connection (pkg/proxyfront), resolves names through the tunnel too, and dials nothing but the netstack: with no tunnel up a shared connection fails, it never leaves by the phone's own uplink.
Package vpn pkg/vpn/share_other.go c4-app-vpn
Package vpn pkg/vpn/share_unix.go c4-app-vpn
Package vpn pkg/vpn/skydns.go c4-app-vpn
Package vpn pkg/vpn/skydns_linux.go c4-app-vpn
Package vpn pkg/vpn/subnet_ip_incrementer.go c4-app-vpn
Package vpn pkg/vpn/tun_device.go c4-app-vpn
Package vpn pkg/vpn/tun_device_unix.go c4-app-vpn
Index ¶
- Constants
- func AllowIPToLocalNetwork(src, _ net.IP) error
- func AppEnvArgs(config DirectRoutesEnvConfig) map[string]string
- func BlockIPToLocalNetwork(src, _ net.IP) error
- func DefaultNetworkGateway() (net.IP, error)
- func DisableIPMasquerading(ifcName string) error
- func EnableIPMasquerading(ifcName string) error
- func EnableIPv4Forwarding() error
- func EnableIPv6Forwarding() error
- func GetIPTablesForwardPolicy() (string, error)
- func GetIPv4ForwardingValue() (string, error)
- func GetIPv6ForwardingValue() (string, error)
- func IPFromEnv(key string) (net.IP, bool, error)
- func LoadOrCreateMeshCA(certPath, keyPath, defaultDir string) (skynetca.LeafMinter, error)
- func MeshDialer(appCl *app.Client) meshgw.MeshDial
- func ParseIP(addr string) (net.IP, bool, error)
- func ParseMeshAliases(in []string) (map[string]cipher.PubKey, error)
- func ReadJSON(conn net.Conn, data interface{}) error
- func ReadJSONWithTimeout(conn net.Conn, data interface{}, timeout time.Duration) error
- func RunMeshGatewayOnly(ctx context.Context, cfg MeshGatewayConfig, log logrus.FieldLogger) error
- func RunSkyDNS(ctx context.Context, cfg SkyDNSConfig) error
- func SetIPTablesForwardAcceptPolicy() error
- func SetIPTablesForwardPolicy(policy string) error
- func SetIPv4ForwardingValue(val string) error
- func SetIPv6ForwardingValue(val string) error
- func WriteJSON(conn net.Conn, data interface{}) error
- func WriteJSONWithTimeout(conn net.Conn, data interface{}, timeout time.Duration) error
- type Client
- func (c *Client) AddDirectRoute(ip net.IP) error
- func (c *Client) AddRoute(ip, gateway string) error
- func (c *Client) ChangeRoute(ip, gateway string) error
- func (c *Client) Close()
- func (c *Client) DeleteRoute(ip, gateway string) error
- func (c *Client) ListenIPC(client *ipc.Client)
- func (c *Client) NetstackDial(ctx context.Context, network, address string) (net.Conn, error)
- func (c *Client) RemoveDirectRoute(ip net.IP) error
- func (c *Client) RevertDNS()
- func (c *Client) Serve() error
- func (c *Client) ServeConn(conn net.Conn) error
- func (c *Client) SetupDNS() error
- func (c *Client) SetupTUN(ifcName, ipCIDR, gateway string, mtu int) error
- func (c *Client) TunReady() bool
- type ClientConfig
- type ClientHello
- type DirectRoutesEnvConfig
- type HandshakeStatus
- type IPGenerator
- type MeshGatewayConfig
- type Router
- type RouterConfig
- type Server
- type ServerConfig
- type ServerHello
- type SkyDNSConfig
- type TUNDevice
- type WiFiConfig
Constants ¶
const ( // TUNNetmaskCIDR is a general netmask used for all TUN interfaces in CIDR format (only suffix). TUNNetmaskCIDR = "/29" // TUNMTU is MTU value used for all TUN interfaces. TUNMTU = 1500 )
const ( // DmsgAddrsCountEnvKey is env arg holding Dmsg servers count. DmsgAddrsCountEnvKey = "DMSG_SRV_COUNT" // DmsgAddrEnvPrefix is prefix for each env arg holding Dmsg server address. DmsgAddrEnvPrefix = "ADDR_DMSG_SRV_" // DmsgDiscAddrEnvKey is env arg holding Dmsg discovery address. DmsgDiscAddrEnvKey = "ADDR_DMSG_DISC" // TPDiscAddrEnvKey is env arg holding TP discovery address. TPDiscAddrEnvKey = "ADDR_TP_DISC" // AddressResolverAddrEnvKey is env arg holding address resolver address. AddressResolverAddrEnvKey = "ADDR_ADDRESS_RESOLVER" // RFAddrEnvKey is env arg holding RF address. RFAddrEnvKey = "ADDR_RF" // STCPTableLenEnvKey is env arg holding Stcp table length. STCPTableLenEnvKey = "STCP_TABLE_LEN" // STCPKeyEnvPrefix is prefix for each env arg holding Skywire-TCP entity key. STCPKeyEnvPrefix = "STCP_TABLE_KEY_" // STCPValueEnvPrefix is prefix for each env arg holding Skywire-TCP entity value. STCPValueEnvPrefix = "STCP_TABLE_" // TPRemoteIPsLenEnvKey is env arg holding TP remote IPs length. TPRemoteIPsLenEnvKey = "TP_REMOTE_IPS_LEN" // TPRemoteIPsEnvPrefix is prefix for each env arg holding TP remote IP. TPRemoteIPsEnvPrefix = "ADDR_TP_REMOTE_" )
Variables ¶
This section is empty.
Functions ¶
func AllowIPToLocalNetwork ¶
AllowIPToLocalNetwork allows all the packets coming from `source` to private IP ranges.
func AppEnvArgs ¶
func AppEnvArgs(config DirectRoutesEnvConfig) map[string]string
AppEnvArgs forms env args to pass to the app process.
func BlockIPToLocalNetwork ¶
BlockIPToLocalNetwork blocks all the packets coming from `source` to private IP ranges.
func DefaultNetworkGateway ¶
DefaultNetworkGateway fetches system's default network gateway.
func DisableIPMasquerading ¶
DisableIPMasquerading disables IP masquerading for the interface with name `ifcName`.
func EnableIPMasquerading ¶
EnableIPMasquerading enables IP masquerading for the interface with name `ifcName`.
func EnableIPv4Forwarding ¶
func EnableIPv4Forwarding() error
EnableIPv4Forwarding enables IPv4 forwarding.
func EnableIPv6Forwarding ¶
func EnableIPv6Forwarding() error
EnableIPv6Forwarding enables IPv6 forwarding.
func GetIPTablesForwardPolicy ¶
GetIPTablesForwardPolicy gets current policy for iptables `forward` chain.
func GetIPv4ForwardingValue ¶
GetIPv4ForwardingValue gets current value of IPv4 forwarding (via /proc — no sysctl binary needed).
func GetIPv6ForwardingValue ¶
GetIPv6ForwardingValue gets current value of IPv6 forwarding (via /proc).
func IPFromEnv ¶
IPFromEnv gets IP address from the env arg `key`. Env value may be one of: - full URL with port; - full URL without port; - domain with port; - domain without port; - IP with port; - IP without port. In case domain is provided instead of an IP address, a DNS lookup is also performed to resolve the actual IP address
func LoadOrCreateMeshCA ¶
func LoadOrCreateMeshCA(certPath, keyPath, defaultDir string) (skynetca.LeafMinter, error)
LoadOrCreateMeshCA loads the mesh-gateway CA from certPath/keyPath, generating and persisting a fresh one (permitting .dmsg/.skynet) if absent. Empty paths default under defaultDir. It prints the cert path + fingerprint so the operator can install it as trusted on the clients that will use the gateway.
func MeshDialer ¶
MeshDialer adapts an app.Client to meshgw.MeshDial: scheme ("dmsg" / "skynet") is the appnet network type; port is the mesh routing port (the client's original destination port).
func ParseIP ¶
ParseIP parses IP string `addr`. `addr` may be on of: - full URL with port; - full URL without port; - domain with port; - domain without port; - IP with port; - IP without port. - dmshhttp url with port; - dmshhttp url without port. In case domain is provided instead of an IP address, a DNS lookup is also performed to resolve the actual IP address
func ParseMeshAliases ¶
ParseMeshAliases turns repeated `name=<pk>` strings into a friendly-name → PK map for the mesh gateway.
func ReadJSONWithTimeout ¶
ReadJSONWithTimeout reads portion of data from the `conn` and unmarshals it into `data` with the specified read `timeout`.
func RunMeshGatewayOnly ¶
func RunMeshGatewayOnly(ctx context.Context, cfg MeshGatewayConfig, log logrus.FieldLogger) error
RunMeshGatewayOnly runs a standalone mesh gateway until ctx is canceled, then tears its state (firewall REDIRECT + IPv4 forwarding) back down. It reuses the same firewall backend (iptables, or nftables under -tags nftfw) and meshgw engine as the full router; it just skips the DHCP/DNS-server-owns-the-LAN, interface, WiFi, and tunnel-NAT roles.
func RunSkyDNS ¶ added in v1.3.100
func RunSkyDNS(ctx context.Context, cfg SkyDNSConfig) error
RunSkyDNS serves SkyDNS on a tunnel of its own until ctx ends. Only skydns.Range is routed into it. The host asks it for .dmsg and .skynet names through systemd-resolved where that runs, and through resolv.conf otherwise.
func SetIPTablesForwardAcceptPolicy ¶
func SetIPTablesForwardAcceptPolicy() error
SetIPTablesForwardAcceptPolicy sets ACCEPT policy for iptables `forward` chain.
func SetIPTablesForwardPolicy ¶
SetIPTablesForwardPolicy sets `policy` for iptables `forward` chain.
func SetIPv4ForwardingValue ¶
SetIPv4ForwardingValue sets `val` value of IPv4 forwarding (via /proc).
func SetIPv6ForwardingValue ¶
SetIPv6ForwardingValue sets `val` value of IPv6 forwarding (via /proc).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a VPN client.
func NewClient ¶
func NewClient(cfg ClientConfig, appCl *app.Client) (*Client, error)
NewClient creates VPN client instance.
func NewClientEmbedded ¶
func NewClientEmbedded(cfg ClientConfig) *Client
NewClientEmbedded constructs a Client for in-process use: no app environment, no app RPC, no direct-route management. The zero directIPs set is correct for the browser (there is no OS routing table to protect), and acceptable for any embedder that manages its own underlay reachability.
func (*Client) AddDirectRoute ¶
AddDirectRoute counts one more user of a direct route to ip — packets to it go directly, ignoring the VPN — installing it on the first.
func (*Client) AddRoute ¶
AddRoute adds route to `ip` with `netmask` through the `gateway` to the OS routing table.
func (*Client) ChangeRoute ¶
ChangeRoute changes current route to `ip` to go through the `gateway` in the OS routing table.
func (*Client) DeleteRoute ¶
DeleteRoute removes route to `ip` with `netmask` through the `gateway` from the OS routing table.
func (*Client) ListenIPC ¶
ListenIPC starts named-pipe based connection server for windows or unix socket in Linux/Mac
func (*Client) NetstackDial ¶
NetstackDial dials network ("tcp"/"udp") address host:port THROUGH the tunnel: the connection originates inside the netstack and its packets ride the VPN to the server's clearnet egress. host must be an IPv4 literal — name resolution belongs to the caller (resolve over NetstackDial UDP :53, or via whatever resolver the app already uses).
func (*Client) RemoveDirectRoute ¶
RemoveDirectRoute counts one user fewer, removing the route when none is left — unless the visor named the IP at start, whose route stays.
func (*Client) RevertDNS ¶
func (c *Client) RevertDNS()
RevertDNS trying to revert DNS values same as before starting vpn-client if it changed
func (*Client) ServeConn ¶
ServeConn runs a single VPN session over an already-dialed connection to the vpn-server. It blocks until the session ends (server close, conn failure, or Close). The TUN persists across calls so an embedder may re-dial and call ServeConn again on reconnect, exactly like the app's own serve loop does.
func (*Client) SetupTUN ¶
SetupTUN sets the allocated TUN interface up, setting its IP, gateway, netmask and MTU.
type ClientConfig ¶
type ClientConfig struct {
Killswitch bool
ServerPK cipher.PubKey
DNSAddr string
// MuxRoutes, when > 1, dials the server over that many parallel
// (multiplexed) routes. MinHops, when >= 2, forces the route through
// at least that many intermediate visors (multihop) instead of a
// direct path. Both default to 0 (the plain single-route dial).
MuxRoutes int
MinHops int
// DmsgFallback, when true, dials the VPN server over a direct dmsg stream if
// the skynet (route) dial fails. Opt-in: dmsg relays through a dmsg server, so
// the fallback trades higher latency and a metadata downgrade (the dmsg server
// sees both endpoint PKs, unlike a source-routed multihop skynet path) for the
// resilience of an always-available baseline. Default off keeps the plain
// skynet-only dial.
DmsgFallback bool
// MeshGateway, when true (Linux only), additionally runs a local MESH
// GATEWAY: the host resolves *.dmsg / *.skynet by name and those connections
// are proxied over the mesh (bypassing the tunnel), the single-machine
// counterpart of the vpn-router's LAN gateway. MeshDial must be set.
MeshGateway bool
// MeshGatewayCIDR is the synthetic-IP pool (empty = 100.64.0.0/16).
MeshGatewayCIDR string
// MeshDial performs the mesh dial for resolved names; the vpn-client app
// wires it to its app.Client. Required when MeshGateway is true.
MeshDial meshgw.MeshDial
// MeshAliases maps friendly names to PKs (reach http://<alias>.dmsg). Optional.
MeshAliases map[string]cipher.PubKey
// MeshTLSMinter, when set, enables TLS-MITM for HTTPS to *.dmsg / *.skynet.
// The host must trust the minter's CA. Optional.
MeshTLSMinter skynetca.LeafMinter
}
ClientConfig is a configuration for VPN client.
type ClientHello ¶
type ClientHello struct {
}
ClientHello is a message sent by client during the Client/Server handshake.
type DirectRoutesEnvConfig ¶
type DirectRoutesEnvConfig struct {
DmsgDiscovery string
DmsgServers []string
TPDiscovery string
RF string
AddressResolver string
TPRemoteIPs []string
STCPTable map[cipher.PubKey]string
}
DirectRoutesEnvConfig contains all the addresses which need to be communicated directly, not through the VPN service.
type HandshakeStatus ¶
type HandshakeStatus int
HandshakeStatus is a status of Client/Server handshake.
const ( // HandshakeStatusOK is returned on successful handshake. HandshakeStatusOK HandshakeStatus = iota // HandshakeStatusBadRequest is returned if Client hello message was malformed. HandshakeStatusBadRequest // HandshakeNoFreeIPs is returned if no free IPs left to assign to TUNs. HandshakeNoFreeIPs // HandshakeStatusInternalError is returned in all other cases when some server error occurred. HandshakeStatusInternalError // HandshakeStatusForbidden is returned if client is not in the server's whitelist. HandshakeStatusForbidden )
func (HandshakeStatus) String ¶
func (hs HandshakeStatus) String() string
type IPGenerator ¶
type IPGenerator struct {
// contains filtered or unexported fields
}
IPGenerator is used to generate IPs for TUN interfaces.
type MeshGatewayConfig ¶
type MeshGatewayConfig struct {
// LANInterface is the interface LAN traffic arrives on — the `iif` the
// PREROUTING REDIRECT matches. Required: the REDIRECT must be pinned to the
// downstream link so it never catches the board's own upstream traffic.
LANInterface string
// BindIP is the address the DNS server and transparent proxy listen on.
// Nil / unspecified = all interfaces (0.0.0.0). Set it to the board's LAN IP
// to avoid exposing DNS on other interfaces.
BindIP net.IP
// DNSPort is the mesh-name DNS port. 0 = defaultMeshGatewayDNSPort (53).
DNSPort int
// CIDR is the synthetic-IP pool leased to `.dmsg` / `.skynet` names. Empty =
// defaultMeshGatewayCIDR (100.64.0.0/16). This is the range the upstream
// router must static-route to this board.
CIDR string
// MeshDial dials the mesh for a resolved (scheme, pk, port). Required — from
// the vpn-router app it is vpn.MeshDialer(appClient).
MeshDial meshgw.MeshDial
// Aliases (optional) maps friendly names → PK for names that aren't a raw PK.
Aliases map[string]cipher.PubKey
// TLSMinter (optional) enables TLS-MITM for HTTPS to `.dmsg` / `.skynet`
// (port 443). LAN clients must trust the minter's CA.
TLSMinter skynetca.LeafMinter
}
MeshGatewayConfig configures a standalone mesh gateway (RunMeshGatewayOnly).
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router orchestrates the downstream interface, the DHCP/DNS + optional WiFi AP daemons, and the forwarding/NAT into the mesh-VPN tunnel. Construct with NewRouter, then Run.
func NewRouter ¶
func NewRouter(cfg RouterConfig, log logrus.FieldLogger) (*Router, error)
NewRouter validates cfg and returns a Router ready to Run. It does not touch any system state.
type RouterConfig ¶
type RouterConfig struct {
// LANInterface is the downstream interface that serves clients — a wired NIC
// (e.g. "eth1") for the ethernet-out variant, or an AP-capable wireless NIC
// (e.g. "wlan0") for the WiFi-out variant.
LANInterface string
// TUNInterface is the upstream mesh-VPN tunnel to masquerade into (e.g.
// "tun0"), owned by the vpn-client app. Empty = auto-detect the first tun*
// interface once vpn-client has brought it up.
TUNInterface string
// Gateway is the router's own address on the downstream subnet (the default
// gateway handed to clients), e.g. 192.168.42.1.
Gateway net.IP
// Subnet is the downstream network in CIDR form, e.g. 192.168.42.0/24.
Subnet *net.IPNet
// DHCPStart and DHCPEnd bound the DHCP address pool. Both must lie inside
// Subnet. Zero values default to .10 … .254 of the subnet.
DHCPStart net.IP
DHCPEnd net.IP
// DNS is the resolver advertised to clients over DHCP (e.g. 1.1.1.1). Zero
// value defaults to the Gateway (dnsmasq then resolves for clients).
DNS net.IP
// LeaseTime is the DHCP lease duration in dnsmasq form (e.g. "12h"). Empty
// defaults to "12h".
LeaseTime string
// WiFi, when non-nil, additionally runs hostapd to create a WiFi AP on
// LANInterface. Nil = ethernet-out (no AP).
WiFi *WiFiConfig
// MeshDial, when non-nil, enables the MESH GATEWAY: the router's DNS answers
// *.dmsg / *.skynet with synthetic IPs, and a transparent proxy dials those
// targets over the mesh via this func — so any downstream client can reach
// dmsg/skynet services by name. The vpn-router app supplies a dialer backed
// by its app.Client. Nil = mesh gateway off. See pkg/vpnrouter/meshgw.
MeshDial meshgw.MeshDial
// MeshGatewayCIDR is the private range the mesh gateway leases synthetic IPs
// from. Empty defaults to defaultMeshGatewayCIDR. Ignored when MeshDial nil.
MeshGatewayCIDR string
// MeshAliases maps friendly names to destination PKs, so a client can reach
// `http://<alias>.dmsg` instead of the raw `<pk-label>.dmsg`. May be nil.
// Ignored when MeshDial nil.
MeshAliases map[string]cipher.PubKey
// MeshTLSMinter, when non-nil (and MeshDial set), enables TLS-MITM for the
// mesh gateway: HTTPS to *.dmsg / *.skynet is terminated with a leaf minted
// here and bridged to the plain-HTTP mesh upstream, so browsers get a secure
// context. LAN clients must trust the minter's CA. Ignored when MeshDial nil.
MeshTLSMinter skynetca.LeafMinter
}
RouterConfig is the platform-neutral configuration for a VPN router.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a VPN server.
func NewServer ¶
func NewServer(cfg ServerConfig, appCl *app.Client) (*Server, error)
NewServer creates VPN server instance.
func (*Server) AddRoute ¶
AddRoute adds route to `ip` with `netmask` through the `gateway` to the OS routing table.
type ServerConfig ¶
ServerConfig is a configuration for VPN server.
type ServerHello ¶
type ServerHello struct {
Status HandshakeStatus `json:"status"`
TUNIP net.IP `json:"tun_ip"`
TUNGateway net.IP `json:"tun_gateway"`
}
ServerHello is a message sent by server during the Client/Server handshake.
type SkyDNSConfig ¶ added in v1.3.100
type SkyDNSConfig struct {
// Dial carries connections to mesh names. See MeshDialer.
Dial meshgw.MeshDial
// Upstream is the resolver for every other name, an IP. Empty means the
// phone's own, as the app reports them.
Upstream string
Log logrus.FieldLogger
}
SkyDNSConfig is SkyDNS on a tunnel of its own, with no VPN server behind it.
type TUNDevice ¶
type TUNDevice interface {
io.ReadWriteCloser
Name() string
}
TUNDevice is a wrapper for TUN interface.
type WiFiConfig ¶
type WiFiConfig struct {
SSID string
// Passphrase is the WPA2 pre-shared key (8–63 chars). Empty = open network
// (allowed but strongly discouraged; validate() warns via error unless
// explicitly opened with AllowOpen).
Passphrase string
// Band is "2.4" or "5". Selects hostapd hw_mode (g / a).
Band string
// Channel is the 802.11 channel. 0 = a sensible default for the band
// (channel 6 on 2.4 GHz, 36 on 5 GHz).
Channel int
// CountryCode is the regulatory domain (e.g. "US"). Empty = "US".
CountryCode string
// AllowOpen permits an empty Passphrase (open network) without erroring.
AllowOpen bool
}
WiFiConfig configures the hostapd access point for the WiFi-out variant.
func (WiFiConfig) HostapdConf ¶
func (w WiFiConfig) HostapdConf(iface string) string
HostapdConf renders the hostapd configuration for the WiFi-out variant. It is pure (no I/O). iface is the wireless interface the AP runs on.
Source Files
¶
- client.go
- client_config.go
- client_embed.go
- client_hello.go
- client_unix.go
- const.go
- env.go
- errors.go
- firewall_iptables_linux.go
- firewall_linux.go
- handshake_status.go
- ip_generator.go
- mesh_client_linux.go
- mesh_gateway_standalone_linux.go
- meshapp.go
- net.go
- netstack_tun.go
- os.go
- os_client_linux.go
- os_linux.go
- os_server_linux.go
- router.go
- router_linux.go
- server.go
- server_config.go
- server_hello.go
- share.go
- share_other.go
- share_unix.go
- skydns.go
- skydns_linux.go
- subnet_ip_incrementer.go
- tun_device.go
- tun_device_unix.go