mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-24 12:46:15 +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
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
|
|
@ -17,8 +13,6 @@ type ProxyAction string
|
|||
const (
|
||||
// default proxy port
|
||||
NmProxyPort = 51722
|
||||
// default CIDR for proxy peers
|
||||
DefaultCIDR = "127.0.0.1/8"
|
||||
// PersistentKeepaliveInterval - default keepalive for wg peer
|
||||
DefaultPersistentKeepaliveInterval = time.Duration(time.Second * 20)
|
||||
|
||||
|
|
@ -32,9 +26,6 @@ const (
|
|||
NoProxy ProxyAction = "NO_PROXY"
|
||||
)
|
||||
|
||||
// PeerConnMap - type for peer conn config map
|
||||
type PeerConnMap map[string]*Conn
|
||||
|
||||
// Proxy - struct for proxy config
|
||||
type Proxy struct {
|
||||
PeerPublicKey wgtypes.Key
|
||||
|
|
@ -47,41 +38,6 @@ type Proxy struct {
|
|||
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
|
||||
type RelayedConf struct {
|
||||
RelayedPeerEndpoint *net.UDPAddr `json:"relayed_peer_endpoint"`
|
||||
|
|
@ -100,19 +56,6 @@ type PeerConf struct {
|
|||
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
|
||||
type ProxyManagerPayload struct {
|
||||
Action ProxyAction `json:"action"`
|
||||
|
|
@ -135,11 +78,3 @@ type ProxyMetric struct {
|
|||
TrafficSent int64 `json:"traffic_sent"` // 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