netmaker/nm-proxy/models/peer.go

51 lines
1,021 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 func()
ResetConn func()
PeerListenPort uint32
RemoteConnAddr *net.UDPAddr
LocalConnAddr *net.UDPAddr
RecieverChan chan []byte
2022-11-27 22:11:07 +08:00
}
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
IfaceKeyHash string
PeerMap map[string]*ConnConfig
2022-11-27 22:11:07 +08:00
}