Documentation
¶
Overview ¶
Package wg implements wormhole integration with WireGuard
Index ¶
- func ConvertFromString(private, public string) ([32]byte, [32]byte, error)
- func Decrypt(ciphertext []byte, private, public string) ([]byte, error)
- func DeriveKeys(sharedSecret [32]byte) ([32]byte, [32]byte, error)
- func Encrypt(payload []byte, private, public string) ([]byte, error)
- func GetOrGenerateKeyPair(storage KeyStorage) (string, string, error)
- func PerformKeyExchange(privateKey, peerPublicKey [32]byte) ([32]byte, error)
- func RenderTemplate(settings Config) (string, error)
- type Config
- type KeyStorage
- type Peer
- type Watcher
- type WireguardConfigReloader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertFromString ¶
ConvertFromString decodes base64 encoded private and public keys.
func DeriveKeys ¶
DeriveKeys derives encryption and authentication keys using HKDF.
func GetOrGenerateKeyPair ¶
func GetOrGenerateKeyPair(storage KeyStorage) (string, string, error)
GetOrGenerateKeyPair returns the stored key pair or generates a new one
func PerformKeyExchange ¶
PerformKeyExchange computes a shared secret using peer's public key and our private key.
func RenderTemplate ¶
RenderTemplate renders the WireGuard configuration template with the given settings
Types ¶
type Config ¶
type Config struct { Address string Subnet string ListenPort int PrivateKey string EnableKeepAlive bool Peers []Peer }
Config represents the WireGuard configuration
func (*Config) DeleteByPublicKey ¶
DeleteByPublicKey removes a peer from the configuration by its public key
type KeyStorage ¶
type KeyStorage interface { Store(private, public string) error Load() (private, public string, err error) }
KeyStorage is responsible for storing and loading WireGuard key pair
func NewBoltKeyStorage ¶
func NewBoltKeyStorage(path string) KeyStorage
NewBoltKeyStorage creates a new KeyStorage that stores keys in a BoltDB database
func NewInMemoryKeyStorage ¶
func NewInMemoryKeyStorage() KeyStorage
NewInMemoryKeyStorage creates a new KeyStorage that stores keys in memory
func NewNoStorage ¶
func NewNoStorage() KeyStorage
NewNoStorage creates a new KeyStorage that does not store keys
type Peer ¶
type Peer struct { Name string PublicKey string AllowedIPs string Endpoint string PersistentKeepalive int }
Peer represents a single WireGuard peer in the configuration
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches for changes in the WireGuard configuration and updates it
func NewWatcher ¶
NewWatcher creates a new Watcher instance
type WireguardConfigReloader ¶
WireguardConfigReloader is an interface for updating Wireguard configuration