mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-26 05:56:36 +08:00
leave netclient specific structs in netclient
This commit is contained in:
parent
aad4abc181
commit
4d4252d271
1 changed files with 0 additions and 65 deletions
|
|
@ -1,11 +1,7 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"crypto/md5"
|
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
|
|
@ -17,8 +13,6 @@ type ProxyAction string
|
||||||
const (
|
const (
|
||||||
// default proxy port
|
// default proxy port
|
||||||
NmProxyPort = 51722
|
NmProxyPort = 51722
|
||||||
// default CIDR for proxy peers
|
|
||||||
DefaultCIDR = "127.0.0.1/8"
|
|
||||||
// PersistentKeepaliveInterval - default keepalive for wg peer
|
// PersistentKeepaliveInterval - default keepalive for wg peer
|
||||||
DefaultPersistentKeepaliveInterval = time.Duration(time.Second * 20)
|
DefaultPersistentKeepaliveInterval = time.Duration(time.Second * 20)
|
||||||
|
|
||||||
|
|
@ -32,9 +26,6 @@ const (
|
||||||
NoProxy ProxyAction = "NO_PROXY"
|
NoProxy ProxyAction = "NO_PROXY"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PeerConnMap - type for peer conn config map
|
|
||||||
type PeerConnMap map[string]*Conn
|
|
||||||
|
|
||||||
// Proxy - struct for proxy config
|
// Proxy - struct for proxy config
|
||||||
type Proxy struct {
|
type Proxy struct {
|
||||||
PeerPublicKey wgtypes.Key
|
PeerPublicKey wgtypes.Key
|
||||||
|
|
@ -47,41 +38,6 @@ type Proxy struct {
|
||||||
ProxyStatus bool
|
ProxyStatus bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conn is a peer Connection configuration
|
|
||||||
type Conn struct {
|
|
||||||
// Key is a public key of a remote peer
|
|
||||||
Key wgtypes.Key
|
|
||||||
IsExtClient bool
|
|
||||||
IsRelayed bool
|
|
||||||
RelayedEndpoint *net.UDPAddr
|
|
||||||
Config Proxy
|
|
||||||
StopConn func()
|
|
||||||
ResetConn func()
|
|
||||||
LocalConn net.Conn
|
|
||||||
Mutex *sync.RWMutex
|
|
||||||
NetworkSettings map[string]Settings
|
|
||||||
ServerMap map[string]struct{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemotePeer - struct remote peer data
|
|
||||||
type RemotePeer struct {
|
|
||||||
PeerKey string
|
|
||||||
Endpoint *net.UDPAddr
|
|
||||||
IsExtClient bool
|
|
||||||
LocalConn net.Conn
|
|
||||||
CancelFunc context.CancelFunc
|
|
||||||
CommChan chan *net.UDPAddr
|
|
||||||
}
|
|
||||||
|
|
||||||
// HostInfo - struct for host information
|
|
||||||
type HostInfo struct {
|
|
||||||
PublicIp net.IP
|
|
||||||
PrivIp net.IP
|
|
||||||
PubPort int
|
|
||||||
PrivPort int
|
|
||||||
ProxyEnabled bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// RelayedConf - struct relayed peers config
|
// RelayedConf - struct relayed peers config
|
||||||
type RelayedConf struct {
|
type RelayedConf struct {
|
||||||
RelayedPeerEndpoint *net.UDPAddr `json:"relayed_peer_endpoint"`
|
RelayedPeerEndpoint *net.UDPAddr `json:"relayed_peer_endpoint"`
|
||||||
|
|
@ -100,19 +56,6 @@ type PeerConf struct {
|
||||||
RelayedTo *net.UDPAddr `json:"relayed_to"`
|
RelayedTo *net.UDPAddr `json:"relayed_to"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvPeerKeyToHash - converts peer key to a md5 hash
|
|
||||||
func ConvPeerKeyToHash(peerKey string) string {
|
|
||||||
return fmt.Sprintf("%x", md5.Sum([]byte(peerKey)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsPublicIP indicates whether IP is public or not.
|
|
||||||
func IsPublicIP(ip net.IP) bool {
|
|
||||||
if ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() || ip.IsPrivate() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProxyManagerPayload - struct for proxy manager payload
|
// ProxyManagerPayload - struct for proxy manager payload
|
||||||
type ProxyManagerPayload struct {
|
type ProxyManagerPayload struct {
|
||||||
Action ProxyAction `json:"action"`
|
Action ProxyAction `json:"action"`
|
||||||
|
|
@ -135,11 +78,3 @@ type ProxyMetric struct {
|
||||||
TrafficSent int64 `json:"traffic_sent"` // stored in MB
|
TrafficSent int64 `json:"traffic_sent"` // stored in MB
|
||||||
TrafficRecieved int64 `json:"traffic_recieved"` // stored in MB
|
TrafficRecieved int64 `json:"traffic_recieved"` // stored in MB
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings - struct for host settings
|
|
||||||
type Settings struct {
|
|
||||||
IsRelay bool
|
|
||||||
IsIngressGateway bool
|
|
||||||
IsRelayed bool
|
|
||||||
RelayedTo *net.UDPAddr
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue