Documentation ¶
Overview ¶
Package networker abstracts network configuration from the rest of the system.
Index ¶
- Variables
- type Combined
- func (netw *Combined) AllowFileshare(uniqueAddress meshnet.UniqueAddress) error
- func (netw *Combined) AllowIncoming(uniqueAddress meshnet.UniqueAddress, lanAllowed bool) error
- func (netw *Combined) BlockFileshare(uniqueAddress meshnet.UniqueAddress) error
- func (netw *Combined) BlockIncoming(uniqueAddress meshnet.UniqueAddress) error
- func (netw *Combined) ConnectionStatus() (ConnectionStatus, error)
- func (netw *Combined) DenyIPv6() error
- func (netw *Combined) DisableFirewall() error
- func (netw *Combined) DisableRouting()
- func (netw *Combined) EnableFirewall() error
- func (netw *Combined) EnableRouting()
- func (netw *Combined) GetConnectionParameters() (vpn.ServerData, bool)
- func (netw *Combined) IsMeshnetActive() bool
- func (netw *Combined) IsNetworkSet() bool
- func (netw *Combined) IsVPNActive() bool
- func (netw *Combined) LastServerName() string
- func (netw *Combined) PermitIPv6() error
- func (c *Combined) Reconnect(stateIsUp bool)
- func (netw *Combined) Refresh(c mesh.MachineMap) error
- func (netw *Combined) ResetRouting(peer mesh.MachinePeer, peers mesh.MachinePeers) error
- func (netw *Combined) SetAllowlist(allowlist config.Allowlist) error
- func (netw *Combined) SetDNS(nameservers []string) error
- func (netw *Combined) SetKillSwitch(allowlist config.Allowlist) error
- func (netw *Combined) SetLanDiscovery(enabled bool)
- func (netw *Combined) SetMesh(cfg mesh.MachineMap, self netip.Addr, privateKey string) (err error)
- func (netw *Combined) SetVPN(v vpn.VPN)
- func (netw *Combined) Start(ctx context.Context, creds vpn.Credentials, serverData vpn.ServerData, ...) (err error)
- func (netw *Combined) StatusMap() (map[string]string, error)
- func (netw *Combined) Stop() error
- func (netw *Combined) UnSetMesh() error
- func (netw *Combined) UnsetDNS() error
- func (netw *Combined) UnsetFirewall() error
- func (netw *Combined) UnsetKillSwitch() error
- type ConnectionStatus
- type Networker
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMeshNotActive to report to outside ErrMeshNotActive = errors.New("mesh is not active") // ErrMeshPeerIsNotRoutable to report to outside ErrMeshPeerIsNotRoutable = errors.New("mesh peer is not routable") // ErrMeshPeerNotFound to report to outside ErrMeshPeerNotFound = errors.New("mesh peer not found") // ErrNothingToCancel is returned when `Cancel()` is called but there is no in progress // connection to be canceled ErrNothingToCancel = errors.New("nothing to cancel") )
Functions ¶
This section is empty.
Types ¶
type Combined ¶
type Combined struct {
// contains filtered or unexported fields
}
Combined configures networking for VPN connections.
It is implemented in such a way, that all public methods use sync.Mutex and all private ones don't.
func NewCombined ¶
func NewCombined( vpnet vpn.VPN, mesh meshnet.Mesh, gateway routes.GatewayRetriever, publisher events.Publisher[string], allowlistRouter routes.Service, dnsSetter dns.Setter, ipv6 ipv6.Blocker, fw firewall.Service, allowlist allowlist.Routing, devices device.ListFunc, policyRouter routes.PolicyService, dnsHostSetter dns.HostnameSetter, router routes.Service, peerRouter routes.Service, exitNode exitnode.Node, fwmark uint32, lanDiscovery bool, ) *Combined
NewCombined returns a ready made version of Combined.
func (*Combined) AllowFileshare ¶
func (netw *Combined) AllowFileshare(uniqueAddress meshnet.UniqueAddress) error
func (*Combined) AllowIncoming ¶
func (netw *Combined) AllowIncoming(uniqueAddress meshnet.UniqueAddress, lanAllowed bool) error
AllowIncoming traffic from the uniqueAddress.
func (*Combined) BlockFileshare ¶
func (netw *Combined) BlockFileshare(uniqueAddress meshnet.UniqueAddress) error
func (*Combined) BlockIncoming ¶
func (netw *Combined) BlockIncoming(uniqueAddress meshnet.UniqueAddress) error
Unblock address.
func (*Combined) ConnectionStatus ¶
func (netw *Combined) ConnectionStatus() (ConnectionStatus, error)
ConnectionStatus get connection information
func (*Combined) DisableFirewall ¶
DisableFirewall turns all firewall operations to noop.
func (*Combined) DisableRouting ¶
func (netw *Combined) DisableRouting()
func (*Combined) EnableFirewall ¶
EnableFirewall activates the firewall and applies the rules according to the user's settings. (killswitch, allowlist)
func (*Combined) EnableRouting ¶
func (netw *Combined) EnableRouting()
func (*Combined) GetConnectionParameters ¶
func (netw *Combined) GetConnectionParameters() (vpn.ServerData, bool)
func (*Combined) IsMeshnetActive ¶
IsMeshnetActive returns true when meshnet was activated. Otherwise false is returned.
Thread safe.
func (*Combined) IsNetworkSet ¶
func (*Combined) IsVPNActive ¶
IsVPNActive returns true when connection to VPN server is established. Otherwise false is returned.
Thread safe.
func (*Combined) LastServerName ¶
LastServerName returns last used server hostname
func (*Combined) PermitIPv6 ¶
func (*Combined) Refresh ¶
func (netw *Combined) Refresh(c mesh.MachineMap) error
Refresh peer list.
func (*Combined) ResetRouting ¶
func (netw *Combined) ResetRouting(peer mesh.MachinePeer, peers mesh.MachinePeers) error
func (*Combined) SetAllowlist ¶
func (*Combined) SetKillSwitch ¶
func (*Combined) SetLanDiscovery ¶
func (*Combined) Start ¶
func (netw *Combined) Start( ctx context.Context, creds vpn.Credentials, serverData vpn.ServerData, allowlist config.Allowlist, nameservers config.DNS, enableLocalTraffic bool, ) (err error)
Start VPN connection after preparing the network.
func (*Combined) UnsetFirewall ¶
func (*Combined) UnsetKillSwitch ¶
type ConnectionStatus ¶
type ConnectionStatus struct { // State of the vpn. OpenVPN specific. State vpn.State // Technology, which may or may not match what's in the config Technology config.Technology // Protocol, which may or may not match what's in the config Protocol config.Protocol // IP of the other end of the connection IP netip.Addr // Name in a human readable form of the other end of the connection Name string // Hostname of the other end of the connection Hostname string // Country of the other end of the connection Country string // City of the other end of the connection City string // Download is the amount of data received through the connection Download uint64 // Upload is the amount of data sent through the connection Upload uint64 // Uptime since the connection start Uptime *time.Duration // Is virtual server VirtualLocation bool }
ConnectionStatus of a currently active connection
type Networker ¶
type Networker interface { Start( context.Context, vpn.Credentials, vpn.ServerData, config.Allowlist, config.DNS, bool, ) error // Cancel is created instead of using context.Context because `Start` is shared between VPN // and meshnet networkers Stop() error // stop vpn UnSetMesh() error // stop meshnet SetDNS(nameservers []string) error UnsetDNS() error IsVPNActive() bool IsMeshnetActive() bool ConnectionStatus() (ConnectionStatus, error) EnableFirewall() error DisableFirewall() error EnableRouting() DisableRouting() SetAllowlist(allowlist config.Allowlist) error IsNetworkSet() bool SetKillSwitch(config.Allowlist) error UnsetKillSwitch() error PermitIPv6() error DenyIPv6() error SetVPN(vpn.VPN) LastServerName() string SetLanDiscovery(bool) UnsetFirewall() error GetConnectionParameters() (vpn.ServerData, bool) }
Networker configures networking for connections.
At the moment interface is designed to support only VPN connections.