netmaker/nm-proxy/models/peer.go

47 lines
909 B
Go
Raw Normal View History

2022-11-27 22:11:07 +08:00
package models
import (
"context"
"net"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
const (
NmProxyPort = 51722
DefaultCIDR = "127.0.0.1/8"
)
// ConnConfig is a peer Connection configuration
type ConnConfig struct {
// Key is a public key of a remote peer
2022-11-29 02:55:42 +08:00
Key wgtypes.Key
2022-11-27 22:11:07 +08:00
IsExtClient bool
IsRelayed bool
RelayedEndpoint *net.UDPAddr
IsAttachedExtClient bool
PeerConf *wgtypes.PeerConfig
StopConn context.CancelFunc
RemoteConn *net.UDPAddr
LocalConn net.Conn
}
type RemotePeer struct {
PeerKey string
Interface string
Endpoint *net.UDPAddr
IsExtClient bool
IsAttachedExtClient bool
}
type ExtClientPeer struct {
CancelFunc context.CancelFunc
CommChan chan *net.UDPAddr
}
type WgIfaceConf struct {
Iface *wgtypes.Device
PeerMap map[string]*ConnConfig
}