backend

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const PeerNameRegExp = `([A-Za-z][0-9A-Za-z-_]*)`
View Source
const ServerFileName = `0001-server.toml`

Variables

This section is empty.

Functions

func RandomIP4

func RandomIP4(A string) string

func RandomIP6

func RandomIP6() string

Types

type Client

type Client struct {
	PublicKey      string
	PrivateKey     string
	ClientRoute    string
	AddServerRoute string
	MTU            int
	DNS            string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ip int, name string) *Client

func ReadClient

func ReadClient(dir string, fileName string, ipNum int, name string) (*Client, error)

func (*Client) AllowedIps

func (c *Client) AllowedIps(srv *Server) string

func (*Client) GetFileName

func (c *Client) GetFileName() string

func (*Client) GetIP4

func (c *Client) GetIP4(srv *Server) string

func (*Client) GetIP6

func (c *Client) GetIP6(srv *Server) string

func (*Client) GetIPNumber

func (c *Client) GetIPNumber() int

func (*Client) GetIPNumberString

func (c *Client) GetIPNumberString() string

func (*Client) GetName

func (c *Client) GetName() string

func (*Client) GetPlainTextConfig

func (c *Client) GetPlainTextConfig(srv *Server) (string, error)

func (*Client) WriteOnce

func (c *Client) WriteOnce(dir string) error

type Server

type Server struct {
	Interface                 string
	Address4                  string
	Address6                  string
	PresharedKey              string
	PrivateKey                string
	PublicKey                 string
	ListenPort                uint16
	PostUp4                   string
	PostDown4                 string
	PostUp6                   string
	PostDown6                 string
	ClientRoute               string
	ClientDNS                 string
	ClientServerEndpoint      string
	MTU                       int
	ClientPersistentKeepalive int
	// contains filtered or unexported fields
}

func NewServerWithBlueprint

func NewServerWithBlueprint(b ServerBlueprint) *Server

func (*Server) GetInterfaceString

func (s *Server) GetInterfaceString() string

func (*Server) WriteInterfaceBlock

func (s *Server) WriteInterfaceBlock(w io.Writer, writeComment bool) error

func (*Server) WriteOnce

func (s *Server) WriteOnce(dir string) error

type ServerBlueprint

type ServerBlueprint struct {
	InterfaceName string
	Endpoint      string
	Port          uint16
	Nat4          bool
	Nat6          bool
	Net4          string
	Net6          string
	DNS           []string
}

type State

type State struct {
	Server  *Server
	Clients map[int]*Client
	// contains filtered or unexported fields
}

func ReadState

func ReadState(dir string, wlog *log.Logger) (*State, error)

func (*State) AddPeer

func (s *State) AddPeer(peerName string) error

func (*State) CanAddPeer

func (s *State) CanAddPeer(peerName string) (int, error)

func (*State) DeletePeer

func (s *State) DeletePeer(idx int) error

func (*State) GenerateWireguardFile

func (s *State) GenerateWireguardFile(wgConfigPath string, backup bool) error

func (*State) IterateClients

func (s *State) IterateClients(f func(*Client) error) error

func (*State) JoinPath

func (s *State) JoinPath(path string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL