Documentation ¶
Overview ¶
Package mesh provides data types and interfaces for implementing peer to peer communication.
Index ¶
- Variables
- func JobMonitorFileshareProcess(s *Server) func() error
- func JobRefreshMeshnet(s *Server) func() error
- func MakePeerMaps(peers *pb.PeerList) (map[string]*pb.Peer, map[string]*pb.Peer)
- type Checker
- type Events
- type KeyGenerator
- type Mesh
- type Networker
- type Publisher
- type RegisteringChecker
- type Server
- func (s *Server) AcceptInvite(ctx context.Context, req *pb.InviteRequest) (*pb.RespondToInviteResponse, error)
- func (s *Server) AllowFileshare(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.AllowFileshareResponse, error)
- func (s *Server) AllowIncoming(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.AllowIncomingResponse, error)
- func (s *Server) AllowLocalNetwork(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.AllowLocalNetworkResponse, error)
- func (s *Server) AllowRouting(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.AllowRoutingResponse, error)
- func (s *Server) ChangeMachineNickname(ctx context.Context, req *pb.ChangeMachineNicknameRequest) (*pb.ChangeNicknameResponse, error)
- func (s *Server) ChangePeerNickname(ctx context.Context, req *pb.ChangePeerNicknameRequest) (*pb.ChangeNicknameResponse, error)
- func (s *Server) Connect(_ context.Context, req *pb.UpdatePeerRequest) (*pb.ConnectResponse, error)
- func (s *Server) DenyFileshare(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.DenyFileshareResponse, error)
- func (s *Server) DenyIncoming(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.DenyIncomingResponse, error)
- func (s *Server) DenyInvite(ctx context.Context, req *pb.DenyInviteRequest) (*pb.RespondToInviteResponse, error)
- func (s *Server) DenyLocalNetwork(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.DenyLocalNetworkResponse, error)
- func (s *Server) DenyRouting(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.DenyRoutingResponse, error)
- func (s *Server) DisableAutomaticFileshare(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.DisableAutomaticFileshareResponse, error)
- func (s *Server) DisableMeshnet(context.Context, *pb.Empty) (*pb.MeshnetResponse, error)
- func (s *Server) EnableAutomaticFileshare(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.EnableAutomaticFileshareResponse, error)
- func (s *Server) EnableMeshnet(ctx context.Context, _ *pb.Empty) (*pb.MeshnetResponse, error)
- func (s *Server) GetInvites(context.Context, *pb.Empty) (*pb.GetInvitesResponse, error)
- func (s *Server) GetPeers(context.Context, *pb.Empty) (*pb.GetPeersResponse, error)
- func (s *Server) GetPrivateKey(ctx context.Context, _ *pb.Empty) (*pb.PrivateKeyResponse, error)
- func (s *Server) Invite(ctx context.Context, req *pb.InviteRequest) (*pb.InviteResponse, error)
- func (s *Server) IsEnabled(context.Context, *pb.Empty) (*pb.IsEnabledResponse, error)
- func (s *Server) NotifyNewTransfer(ctx context.Context, req *pb.NewTransferNotification) (*pb.NotifyNewTransferResponse, error)
- func (s *Server) RefreshMeshnet(context.Context, *pb.Empty) (*pb.MeshnetResponse, error)
- func (s *Server) RemovePeer(ctx context.Context, req *pb.UpdatePeerRequest) (*pb.RemovePeerResponse, error)
- func (s *Server) RevokeInvite(ctx context.Context, req *pb.DenyInviteRequest) (*pb.RespondToInviteResponse, error)
- func (s *Server) StartJobs()
- func (s *Server) StartMeshnet() error
- type UniqueAddress
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTunnelClosed while enabling meshnet. ErrTunnelClosed = errors.New("tunnel was closed") // MsgMeshnetInviteSendSameAccountEmail is a string used to identify same account error // returned when invite destination address is the same as sender email address MsgMeshnetInviteSendSameAccountEmail = "Bad Request: Email should belong to a different user" )
Functions ¶
func JobRefreshMeshnet ¶
Types ¶
type Checker ¶
type Checker interface { // IsRegistrationInfoCorrect returns true when device has been registered to meshnet. IsRegistrationInfoCorrect() bool // Register the device Register() error }
Checker provides information about meshnet.
type Events ¶
type Events struct { PeerUpdate events.PublishSubcriber[[]string] SelfRemoved events.PublishSubcriber[any] }
Events allow for publishing and subscribing to meshnet related notifications
func NewEvents ¶
func NewEvents( peerUpdate events.PublishSubcriber[[]string], selfRemoved events.PublishSubcriber[any], ) *Events
func NewEventsEmpty ¶
func NewEventsEmpty() *Events
type KeyGenerator ¶
type KeyGenerator interface { // Private returns base64 encoded private key Private() string // Public expects base64 encoded private key and returns base64 encoded public key Public(string) string }
KeyGenerator for use in meshnet.
type Mesh ¶
type Mesh interface { // Enable creates a tunnel interface with a given IP. Enable(netip.Addr, string) error // Disable removes a tunnel interface Disable() error // IsActive returns false when the tunnel is gone. IsActive() bool // Refresh peer list // Has to be called at least once after Enable Refresh(mesh.MachineMap) error // Tun retrieves a tunnel used for the meshnet Tun() tunnel.T // StatusMap retrieves the current status map for the related // meshnet peers StatusMap() (map[string]string, error) // NetworkChanged is called at network changes NetworkChanged() error }
Mesh defines a set of operations that any type that wants to act as a mesh must implement.
type Networker ¶
type Networker interface { // SetMesh sets the meshnet configuration up SetMesh( mesh.MachineMap, netip.Addr, string, ) error Refresh(mesh.MachineMap) error // Remove // UnSetMesh unsets the meshnet configuration UnSetMesh() error // AllowIncoming creates an allowing fw rule for the given // address AllowIncoming(address UniqueAddress, lanAllowed bool) error // BlockIncoming creates a blocking fw rule for the given // address BlockIncoming(UniqueAddress) error AllowFileshare(UniqueAddress) error BlockFileshare(UniqueAddress) error // ResetRouting is used when there are routing setting changes, // except when routing is denied - then BlockRouting must be used. changedPeer is the peer whose routing settings // changed, peers is the map of all the machine peers(including the changed peer). ResetRouting(changedPeer mesh.MachinePeer, peers mesh.MachinePeers) error StatusMap() (map[string]string, error) LastServerName() string Start( context.Context, vpn.Credentials, vpn.ServerData, config.Allowlist, config.DNS, bool, ) error Stop() error GetConnectionParameters() (vpn.ServerData, bool) }
Networker defines functions responsible for network configuration
type RegisteringChecker ¶
type RegisteringChecker struct {
// contains filtered or unexported fields
}
RegisteringChecker does both registration checks and registration, if it's not done.
func NewRegisteringChecker ¶
func NewRegisteringChecker( cm config.Manager, gen KeyGenerator, reg cmesh.Registry, ) *RegisteringChecker
NewRegisteringChecker is a default constructor for RegisteringChecker.
func (*RegisteringChecker) IsRegistrationInfoCorrect ¶
func (r *RegisteringChecker) IsRegistrationInfoCorrect() bool
IsRegistrationInfoCorrect reports meshnet device registration status.
Thread-safe.
func (*RegisteringChecker) Register ¶
func (r *RegisteringChecker) Register() error
Register registers the device in API, even if it was already registered
type Server ¶
type Server struct { pb.UnimplementedMeshnetServer // contains filtered or unexported fields }
Server is an implementation of pb.MeshnetServer. It represents the part of meshnet in a daemon side
func NewServer ¶
func NewServer( ac auth.Checker, cm config.Manager, mc Checker, invitationAPI mesh.Inviter, netw Networker, reg mesh.Registry, nameservers dns.Getter, pub events.Publisher[error], subjectPeerUpdate events.Publisher[[]string], deemonEvents *daemonevents.Events, norduser service.NorduserFileshareClient, connectContext *sharedctx.Context, ) *Server
NewServer is a default constructor for a meshnet server
func (*Server) AcceptInvite ¶
func (s *Server) AcceptInvite( ctx context.Context, req *pb.InviteRequest, ) (*pb.RespondToInviteResponse, error)
AcceptInvite from another peer
func (*Server) AllowFileshare ¶
func (s *Server) AllowFileshare( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.AllowFileshareResponse, error)
AllowFileshare allows peer to send files to this device
func (*Server) AllowIncoming ¶
func (s *Server) AllowIncoming( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.AllowIncomingResponse, error)
AllowIncoming traffic from peer
func (*Server) AllowLocalNetwork ¶
func (s *Server) AllowLocalNetwork( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.AllowLocalNetworkResponse, error)
AllowLocalNetwork allows peer to access local network on this machine
func (*Server) AllowRouting ¶
func (s *Server) AllowRouting( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.AllowRoutingResponse, error)
AllowRouting allows peer to route traffic through this machine
func (*Server) ChangeMachineNickname ¶
func (s *Server) ChangeMachineNickname( ctx context.Context, req *pb.ChangeMachineNicknameRequest, ) (*pb.ChangeNicknameResponse, error)
func (*Server) ChangePeerNickname ¶
func (s *Server) ChangePeerNickname( ctx context.Context, req *pb.ChangePeerNicknameRequest, ) (*pb.ChangeNicknameResponse, error)
func (*Server) Connect ¶
func (s *Server) Connect( _ context.Context, req *pb.UpdatePeerRequest, ) (*pb.ConnectResponse, error)
Connect to peer as if it was a VPN server.
func (*Server) DenyFileshare ¶
func (s *Server) DenyFileshare( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.DenyFileshareResponse, error)
DenyFileshare forbids peer to send files to this device
func (*Server) DenyIncoming ¶
func (s *Server) DenyIncoming( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.DenyIncomingResponse, error)
DenyIncoming traffic from peer
func (*Server) DenyInvite ¶
func (s *Server) DenyInvite( ctx context.Context, req *pb.DenyInviteRequest, ) (*pb.RespondToInviteResponse, error)
DenyInvite from another peer
func (*Server) DenyLocalNetwork ¶
func (s *Server) DenyLocalNetwork( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.DenyLocalNetworkResponse, error)
DenyLocalNetwork denies peer from accessing local network on this machine
func (*Server) DenyRouting ¶
func (s *Server) DenyRouting( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.DenyRoutingResponse, error)
DenyRouting denies peer from routing traffic through this machine
func (*Server) DisableAutomaticFileshare ¶
func (s *Server) DisableAutomaticFileshare( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.DisableAutomaticFileshareResponse, error)
DisableAutomaticFileshare requests from the peer
func (*Server) DisableMeshnet ¶
DisableMeshnet disconnects device from meshnet.
func (*Server) EnableAutomaticFileshare ¶
func (s *Server) EnableAutomaticFileshare( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.EnableAutomaticFileshareResponse, error)
AllowFileshare requests from the peer
func (*Server) EnableMeshnet ¶
EnableMeshnet connects device to meshnet.
func (*Server) GetInvites ¶
GetInvites from the API
func (*Server) GetPrivateKey ¶
GetPrivateKey returns self private key
func (*Server) Invite ¶
func (s *Server) Invite( ctx context.Context, req *pb.InviteRequest, ) (*pb.InviteResponse, error)
Invite another peer
func (*Server) NotifyNewTransfer ¶
func (s *Server) NotifyNewTransfer( ctx context.Context, req *pb.NewTransferNotification, ) (*pb.NotifyNewTransferResponse, error)
NotifyNewTransfer notifies peer about new fileshare transfer
func (*Server) RefreshMeshnet ¶
RefreshMeshnet updates peer configuration.
func (*Server) RemovePeer ¶
func (s *Server) RemovePeer( ctx context.Context, req *pb.UpdatePeerRequest, ) (*pb.RemovePeerResponse, error)
func (*Server) RevokeInvite ¶
func (s *Server) RevokeInvite( ctx context.Context, req *pb.DenyInviteRequest, ) (*pb.RespondToInviteResponse, error)
RevokeInvite to another peer
func (*Server) StartMeshnet ¶
type UniqueAddress ¶
type UniqueAddress struct { // UID is a base64 encoded unique string UID string Address netip.Addr }
UniqueAddress a member of mesh network.
Directories ¶
Path | Synopsis |
---|---|
Package exitnode provides meshnet-related firewall management functionality.
|
Package exitnode provides meshnet-related firewall management functionality. |
Package registry implements extra error handling over MeshAPI request
|
Package registry implements extra error handling over MeshAPI request |