Documentation
¶
Index ¶
- func AddClientHandler(st Store, smdClient smdclient.SMDClientInterface) http.HandlerFunc
- func AddWireGuardPeer(interfaceID, publicKey, vpnIP, clientIP string) error
- func GetUsableIP(network *net.IPNet) (net.IP, error)
- type IPAllocator
- type InterfaceManager
- func (m *InterfaceManager) GetInterfaceName() string
- func (m *InterfaceManager) GetPeers() map[string]PeerConfig
- func (m *InterfaceManager) GetServerConfig() (ServerConfig, error)
- func (m *InterfaceManager) IpForPeer(peerName string, publicKey string) string
- func (m *InterfaceManager) PublicKey() (string, error)
- func (m *InterfaceManager) RemovePeer(peerName string) error
- func (m *InterfaceManager) StartServer() error
- type PeerConfig
- type PublicKeyRequest
- type ServerConfig
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClientHandler ¶
func AddClientHandler(st Store, smdClient smdclient.SMDClientInterface) http.HandlerFunc
addClientHandler handles adding a WireGuard client.
func AddWireGuardPeer ¶
AddWireGuardPeer adds a peer to the WireGuard configuration.
Types ¶
type IPAllocator ¶
type IPAllocator struct {
// contains filtered or unexported fields
}
IPAllocator manages IP address allocation within a network range.
func NewIPAllocator ¶
func NewIPAllocator(cidr string) (*IPAllocator, error)
NewIPAllocator initializes a new IPAllocator for a given network.
func (*IPAllocator) IsAllocated ¶
func (a *IPAllocator) IsAllocated(ipAddr net.IPAddr) bool
IsAllocated checks if an IP address is currently allocated.
func (*IPAllocator) NextAvailable ¶
func (a *IPAllocator) NextAvailable() (net.IPAddr, error)
NextAvailable returns the next available IP address in the range.
type InterfaceManager ¶
type InterfaceManager struct {
// contains filtered or unexported fields
}
func NewInterfaceManager ¶
func (*InterfaceManager) GetInterfaceName ¶
func (m *InterfaceManager) GetInterfaceName() string
func (*InterfaceManager) GetPeers ¶
func (m *InterfaceManager) GetPeers() map[string]PeerConfig
func (*InterfaceManager) GetServerConfig ¶
func (m *InterfaceManager) GetServerConfig() (ServerConfig, error)
func (*InterfaceManager) IpForPeer ¶
func (m *InterfaceManager) IpForPeer(peerName string, publicKey string) string
IpForPeer allocates an IP address for a given peer based on its name and public key. If the peer already exists, it returns the existing IP address. Otherwise, it allocates a new IP address for the peer and stores the peer configuration.
func (*InterfaceManager) PublicKey ¶
func (m *InterfaceManager) PublicKey() (string, error)
func (*InterfaceManager) RemovePeer ¶
func (m *InterfaceManager) RemovePeer(peerName string) error
func (*InterfaceManager) StartServer ¶
func (m *InterfaceManager) StartServer() error
type PeerConfig ¶
type PublicKeyRequest ¶
type PublicKeyRequest struct {
PublicKey string `json:"public_key"`
}
PublicKeyRequest represents the JSON payload for a WireGuard public key.