Documentation
¶
Index ¶
- Variables
- func GenerateKeypair() (privateKey, publicKey string, err error)
- func GeneratePresharedKey() (string, error)
- func GeneratePrivateKey() (string, error)
- func PublicKey(privateKey string) (string, error)
- type Client
- type Config
- type EndpointPreference
- type Peer
- type PeerStatus
- type PeerUpdate
- type Runtime
- func (t *Runtime) ClearPrivateKey() error
- func (t *Runtime) Close() error
- func (t *Runtime) RemovePeer(publicKey string) error
- func (t *Runtime) ReplacePeers(ctx context.Context, peers []Peer) error
- func (t *Runtime) SetFirewallMark(mark uint32) error
- func (t *Runtime) SetListenPort(port int) error
- func (t *Runtime) SetPrivateKey(privateKey string) error
- func (t *Runtime) Status() (Status, error)
- func (t *Runtime) UAPIGet() (string, error)
- func (t *Runtime) UAPISet(configuration string) error
- func (t *Runtime) UpdatePeer(ctx context.Context, update PeerUpdate) error
- type Server
- type ServerConfig
- type ServerPeer
- type Status
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotStarted = errors.New("wireguard: device has not been started")
Functions ¶
func GenerateKeypair ¶
func GeneratePresharedKey ¶
func GeneratePrivateKey ¶
Types ¶
type Config ¶
type Config struct {
PrivateKey string
Address []string
DNS []string
MTU int
ListenPort int
FirewallMark uint32
Peers []Peer
Table string
PreUp []string
PostUp []string
PreDown []string
PostDown []string
SaveConfig bool
Logger *log.Logger
}
func ParseConfig ¶
ParseConfig reads official wg and wg-quick configuration fields. Host route, DNS and lifecycle values are preserved in Config but are not executed.
func ParseConfigFile ¶
type EndpointPreference ¶ added in v0.0.2
type EndpointPreference string
const ( EndpointPreferenceAuto EndpointPreference = "auto" EndpointPreferenceIPv4 EndpointPreference = "ipv4" EndpointPreferenceIPv6 EndpointPreference = "ipv6" )
type Peer ¶
type Peer struct {
PublicKey string `json:"public-key"`
Endpoint string `json:"endpoint,omitempty"`
EndpointPreference EndpointPreference `json:"endpoint-preference,omitempty"`
AllowedIPs []string `json:"allowed-ips,omitempty"`
Keepalive int `json:"persistent-keepalive,omitempty"`
// contains filtered or unexported fields
}
type PeerStatus ¶
type PeerUpdate ¶
type PeerUpdate struct {
PublicKey string
UpdateOnly bool
Remove bool
Endpoint *string
Keepalive *int
ReplaceAllowedIPs bool
AllowedIPs []string
RemoveAllowedIPs []string
}
PeerUpdate describes an incremental update using the official WireGuard cross-platform UAPI semantics. Nil pointer fields are left unchanged. An empty PresharedKey clears the existing key, and a zero Keepalive disables persistent keepalives.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func (*Runtime) ClearPrivateKey ¶
func (*Runtime) RemovePeer ¶
func (*Runtime) ReplacePeers ¶
func (*Runtime) SetFirewallMark ¶
func (*Runtime) SetListenPort ¶
func (*Runtime) SetPrivateKey ¶
func (*Runtime) UpdatePeer ¶
func (t *Runtime) UpdatePeer(ctx context.Context, update PeerUpdate) error
type Server ¶
type Server struct {
Config ServerConfig
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(config ServerConfig) *Server
type ServerConfig ¶
type ServerConfig struct {
PrivateKey string
ListenPort int
// ListenIP is retained for configuration compatibility. wireguard-go binds
// both wildcard families; a specific bind address is not supported.
ListenIP string
Address string
Address6 string
Addresses []string
MTU int
FirewallMark uint32
Peers []ServerPeer
Logger *log.Logger
}
type ServerPeer ¶
type ServerPeer = Peer
Click to show internal directories.
Click to hide internal directories.