mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-22 00:06:04 +08:00
skip processing ext clients
This commit is contained in:
parent
df41675f74
commit
0119632d31
|
@ -6,13 +6,13 @@ WORKDIR /app
|
|||
COPY . .
|
||||
ENV GO111MODULE=auto
|
||||
|
||||
RUN apk add git
|
||||
RUN apk add git libpcap-dev
|
||||
RUN GOOS=linux CGO_ENABLED=1 go build ${tags} -ldflags="-s -X 'main.version=${version}'" .
|
||||
# RUN go build -tags=ee . -o netmaker main.go
|
||||
FROM alpine:3.15.2
|
||||
|
||||
# add a c lib
|
||||
RUN apk add gcompat iptables wireguard-tools
|
||||
RUN apk add gcompat iptables wireguard-tools libpcap-dev
|
||||
# set the working directory
|
||||
WORKDIR /root/
|
||||
RUN mkdir -p /etc/netclient/config
|
||||
|
|
|
@ -73,6 +73,11 @@ type RemotePeer struct {
|
|||
IsAttachedExtClient bool
|
||||
}
|
||||
|
||||
type ExtClientPeer struct {
|
||||
Endpoint *net.UDPAddr
|
||||
context.CancelFunc
|
||||
}
|
||||
|
||||
type WgIfaceConf struct {
|
||||
Iface *wgtypes.Device
|
||||
PeerMap map[string]*Conn
|
||||
|
@ -86,7 +91,7 @@ var WgIfaceKeyMap = make(map[string]RemotePeer)
|
|||
|
||||
var RelayPeerMap = make(map[string]map[string]RemotePeer)
|
||||
|
||||
var ExtClientsWaitTh = make(map[string][]context.CancelFunc)
|
||||
var ExtClientsWaitTh = make(map[string]ExtClientPeer)
|
||||
|
||||
// RunCmd - runs a local command
|
||||
func RunCmd(command string, printerr bool) (string, error) {
|
||||
|
|
|
@ -209,6 +209,12 @@ func (m *ManagerAction) processPayload() (*wg.WGIface, error) {
|
|||
// handles ext clients
|
||||
if common.IsIngressGateway && m.Payload.PeerMap[m.Payload.Peers[i].PublicKey.String()].IsAttachedExtClient {
|
||||
// check if sniffer already exists otherwise start one
|
||||
if _, ok := common.ExtClientsWaitTh[m.Payload.Peers[i].PublicKey.String()]; ok {
|
||||
log.Println("Ext client th already exists....,removing")
|
||||
m.Payload.Peers = append(m.Payload.Peers[:i], m.Payload.Peers[i+1:]...)
|
||||
|
||||
}
|
||||
log.Println("----> Skip Processing ExtClient: ", m.Payload.Peers[i].PublicKey.String())
|
||||
continue
|
||||
}
|
||||
// check if proxy is off for the peer
|
||||
|
@ -288,7 +294,7 @@ func (m *ManagerAction) processPayload() (*wg.WGIface, error) {
|
|||
m.Payload.Peers = append(m.Payload.Peers[:i], m.Payload.Peers[i+1:]...)
|
||||
}
|
||||
|
||||
} else if !m.Payload.PeerMap[m.Payload.Peers[i].PublicKey.String()].Proxy {
|
||||
} else if !m.Payload.PeerMap[m.Payload.Peers[i].PublicKey.String()].Proxy && !m.Payload.PeerMap[m.Payload.Peers[i].PublicKey.String()].IsAttachedExtClient {
|
||||
log.Println("-----------> skipping peer, proxy is off: ", m.Payload.Peers[i].PublicKey)
|
||||
if err := wgIface.Update(m.Payload.Peers[i], false); err != nil {
|
||||
log.Println("falied to update peer: ", err)
|
||||
|
@ -379,7 +385,10 @@ func (m *ManagerAction) AddInterfaceToProxy() error {
|
|||
}
|
||||
if peerConf.IsExtClient && peerConf.IsAttachedExtClient && shouldProceed {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
common.ExtClientsWaitTh[wgInterface.Name] = append(common.ExtClientsWaitTh[wgInterface.Name], cancel)
|
||||
common.ExtClientsWaitTh[peerI.PublicKey.String()] = common.ExtClientPeer{
|
||||
Endpoint: peerI.Endpoint,
|
||||
CancelFunc: cancel,
|
||||
}
|
||||
go proxy.StartSniffer(ctx, wgInterface.Name, m.Payload.WgAddr, peerConf.Address, wgInterface.Port)
|
||||
}
|
||||
|
||||
|
@ -414,7 +423,10 @@ func (m *ManagerAction) AddInterfaceToProxy() error {
|
|||
isRelayed bool, relayTo *net.UDPAddr, peerConf PeerConf, ingGwAddr string) {
|
||||
addExtClient := false
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
common.ExtClientsWaitTh[wgInterface.Name] = append(common.ExtClientsWaitTh[wgInterface.Name], cancel)
|
||||
common.ExtClientsWaitTh[peerI.PublicKey.String()] = common.ExtClientPeer{
|
||||
Endpoint: peer.Endpoint,
|
||||
CancelFunc: cancel,
|
||||
}
|
||||
defer func() {
|
||||
if addExtClient {
|
||||
log.Println("GOT ENDPOINT for Extclient adding peer...")
|
||||
|
|
Loading…
Reference in a new issue