Documentation ¶
Index ¶
- Constants
- func GenerateKeyPair() (privateKey, publicKey string, err error)
- func GenerateKeyPairByPath(keyFile string) (privateKey, publicKey string, err error)
- func IsWgInstalled() bool
- func IsWgToolInstalled() bool
- func ParsePrivateKey(privateKey string) (*device.NoisePrivateKey, error)
- func ParsePublicKey(publicKey string) (*device.NoisePublicKey, error)
- func PrivateKeyToHex(privateKey string) (string, error)
- func PublicKeyToHex(publicKey string) (string, error)
- func ReadPrivateKey(keyFile string) (*wgtypes.Key, error)
- type ConnState
- type WgInterface
- func (i *WgInterface) Assign(cfg *WgInterface)
- func (i *WgInterface) AssignForce(cfg *WgInterface)
- func (c *WgInterface) FirstPeer() *WgPeer
- func (i *WgInterface) GetIpCidr() string
- func (i *WgInterface) GetIpWithoutCidr() string
- func (p *WgInterface) GetWgTypesKeyBytes(encodedKey string) (*wgtypes.Key, error)
- func (p *WgInterface) GetWgTypesPrivateKeyBytes() (*wgtypes.Key, error)
- func (i *WgInterface) ParsePrivateKey() (*device.NoisePrivateKey, error)
- func (i *WgInterface) PrivateKeyToHex() (string, error)
- type WgPeer
- func (p *WgPeer) AssignForce(peer *WgPeer)
- func (p *WgPeer) GetWgTypesKeyBytes(encodedKey string) (*wgtypes.Key, error)
- func (p *WgPeer) GetWgTypesPSKeyBytes() (*wgtypes.Key, error)
- func (p *WgPeer) GetWgTypesPublicKeyBytes() (*wgtypes.Key, error)
- func (p *WgPeer) ParsePublicKey() (*device.NoisePublicKey, error)
- func (p *WgPeer) PublicKeyToHex() (string, error)
Constants ¶
View Source
const ( WG_AGENT_TYPE_POP uint8 = 1 WG_AGENT_TYPE_CONNECTOR uint8 = 2 WG_AGENT_TYPE_CLIENT uint8 = 3 )
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPairByPath ¶
func IsWgInstalled ¶ added in v0.0.19
func IsWgInstalled() bool
func IsWgToolInstalled ¶ added in v0.0.19
func IsWgToolInstalled() bool
func ParsePrivateKey ¶
func ParsePrivateKey(privateKey string) (*device.NoisePrivateKey, error)
privateKey is base64 encoded
func ParsePublicKey ¶
func ParsePublicKey(publicKey string) (*device.NoisePublicKey, error)
publicKey is base64 encoded
func PrivateKeyToHex ¶
privateKey is base64 encoded
func PublicKeyToHex ¶
publicKey is base64 encoded
Types ¶
type WgInterface ¶
type WgInterface struct { Interface string `json:"interface"` // WireGuard interface, wg0/wg1/wg2... ListenPort int `json:"listen_port"` // [Interface]if this is server side(pop), then need this, PrivateKey string `json:"private_key"` // [Interface][optional],base64 encoded, if empty then use client's IP string `json:"ip"` // [Interface]self ip, get from controller Network string `json:"network"` // [Interface]pop's network, cidr format DNS string `json:"dns"` // [Interface][optional], PublicKey string `json:"public_key"` // [自己的公钥]base64 encoded, 自己的公钥,和PrivateKey是一对, 不需要写在conf文件里,是给对方用的,对方用在自己的conf的peer里 PSK string `json:"psk"` // [同PublicKey] Endpoint string `json:"endpoint"` // [同PublicKey][used in [Peer] peer is client who connect to here];[for server-side it self,this is useless] AllowIps string `json:"allow_ips"` // [同PublicKey][used in [Peer] peer is client who connect to here];for peer, if use single allow-ip mode, then each ip of each peer is a single ip:1.1.1.1/32 ConfFile string `json:"conf_file"` // if empty, default value is {Interface}.conf EthName string `json:"eth_name"` // default value is eth0, used in pop/connector, in PostUp/PostDown Forward *bool `json:"forward"` // use forward, used in pop/connector AgentType uint8 `json:"agent_type"` // [NOT A CONFIG], Peers []WgPeer `json:"peers"` // ... }
used's in clients(pop/connector/client), wg0's conf,
func (*WgInterface) Assign ¶
func (i *WgInterface) Assign(cfg *WgInterface)
func (*WgInterface) AssignForce ¶
func (i *WgInterface) AssignForce(cfg *WgInterface)
func (*WgInterface) FirstPeer ¶
func (c *WgInterface) FirstPeer() *WgPeer
func (*WgInterface) GetIpCidr ¶
func (i *WgInterface) GetIpCidr() string
func (*WgInterface) GetIpWithoutCidr ¶
func (i *WgInterface) GetIpWithoutCidr() string
func (*WgInterface) GetWgTypesKeyBytes ¶
func (p *WgInterface) GetWgTypesKeyBytes(encodedKey string) (*wgtypes.Key, error)
func (*WgInterface) GetWgTypesPrivateKeyBytes ¶
func (p *WgInterface) GetWgTypesPrivateKeyBytes() (*wgtypes.Key, error)
func (*WgInterface) ParsePrivateKey ¶
func (i *WgInterface) ParsePrivateKey() (*device.NoisePrivateKey, error)
func (*WgInterface) PrivateKeyToHex ¶
func (i *WgInterface) PrivateKeyToHex() (string, error)
type WgPeer ¶
type WgPeer struct { AgentType uint8 `json:"agent_type"` // [NOT A CONFIG], Address string `json:"address"` // [NOT A CONFIG],peer's ip address, if client want to ping connected pop, then need to provide this PublicKey string `json:"public_key"` // [Peer][required],base64 encoded, 对方的公钥 PSK string `json:"psk"` // [Peer][optional],base64 encoded, 对方的 Endpoint string `json:"endpoint"` // [Peer][optional],对方的IP地址和端口号,用于建立连接, for pop, endpoint is other pop, if single pop, then del this;for connector/client,endpoint is pop AllowedIPs string `json:"allowed_ips"` // [Peer][optional],指定允许对方使用的IP范围 // not by response Remove bool `json:"remove"` // [Peer], used by uapi/raw api..., means peer is offline/session timeout/kickoff ReplaceAllowedIPs bool `json:"replace_allowed_ips"` // [Peer], used by uapi }
func (*WgPeer) AssignForce ¶
func (*WgPeer) GetWgTypesKeyBytes ¶
func (*WgPeer) GetWgTypesPublicKeyBytes ¶
func (*WgPeer) ParsePublicKey ¶
func (p *WgPeer) ParsePublicKey() (*device.NoisePublicKey, error)
func (*WgPeer) PublicKeyToHex ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.