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) DisableFirewall() error
- func (netw *Combined) DisableRouting()
- func (netw *Combined) EnableFirewall() error
- func (netw *Combined) EnableRouting()
- func (netw *Combined) ForbidFileshare() error
- 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) PermitFileshare() 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 ErrNoSuchRule
- 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, fw firewall.Service, allowlist allowlist.Routing, devices device.ListFunc, policyRouter routes.PolicyService, dnsHostSetter dns.HostnameSetter, router routes.Service, peerRouter routes.Service, exitNode forwarder.ForwardChainManager, fwmark uint32, lanDiscovery bool, ipv6Blocker ipv6.Blocker, ) *Combined
NewCombined returns a ready made version of Combined.
func (*Combined) AllowFileshare ¶
func (netw *Combined) AllowFileshare(uniqueAddress meshnet.UniqueAddress) error
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) ForbidFileshare ¶
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) PermitFileshare ¶
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 ErrNoSuchRule ¶
type ErrNoSuchRule struct {
// contains filtered or unexported fields
}
ErrNoSuchRule is returned when networker tried to remove a rule, but such rule does not exist
func (ErrNoSuchRule) Error ¶
func (e ErrNoSuchRule) Error() string
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 EnableFirewall() error DisableFirewall() error EnableRouting() DisableRouting() SetAllowlist(allowlist config.Allowlist) error IsNetworkSet() bool SetKillSwitch(config.Allowlist) error UnsetKillSwitch() 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.