29 lines
965 B
Go
29 lines
965 B
Go
package peer
|
|
|
|
import (
|
|
"net/netip"
|
|
"vppn/peer/control"
|
|
|
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
|
)
|
|
|
|
// WGDevice is the subset of wginterface.Device used by App.
|
|
type WGDevice interface {
|
|
Name() string
|
|
Peers() ([]wgtypes.Peer, error)
|
|
AddPeer(pubKey wgtypes.Key) error
|
|
AddDirect(pubKey wgtypes.Key, endpoint netip.AddrPort, vpnIP netip.Addr) error
|
|
SetRelay(pubKey wgtypes.Key, endpoint netip.AddrPort, network netip.Prefix) error
|
|
AddProbe(pubKey wgtypes.Key, endpoint netip.AddrPort) error
|
|
Promote(pubKey wgtypes.Key, vpnIP netip.Addr) error
|
|
RemovePeer(pubKey wgtypes.Key) error
|
|
}
|
|
|
|
// ControlConn sends pings to peers over the VPN control port.
|
|
// Reading is handled separately via run, which feeds the App's pingCh.
|
|
// buf is a caller-provided scratch buffer (at least control.Size bytes) used to
|
|
// marshal the ping; the caller reuses one across sends.
|
|
type ControlConn interface {
|
|
SendPing(dst netip.AddrPort, ping control.Ping, buf []byte) error
|
|
}
|