|
@@ -234,6 +234,7 @@ func (m *ManagerAction) processPayload() (*wg.WGIface, error) {
|
|
|
|
|
|
if currentPeer, ok := wgProxyConf.PeerMap[m.Payload.Peers[i].PublicKey.String()]; ok {
|
|
if currentPeer, ok := wgProxyConf.PeerMap[m.Payload.Peers[i].PublicKey.String()]; ok {
|
|
if currentPeer.IsAttachedExtClient {
|
|
if currentPeer.IsAttachedExtClient {
|
|
|
|
+ m.Payload.Peers = append(m.Payload.Peers[:i], m.Payload.Peers[i+1:]...)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// check if proxy is off for the peer
|
|
// check if proxy is off for the peer
|
|
@@ -351,43 +352,10 @@ func (m *ManagerAction) AddInterfaceToProxy() error {
|
|
log.Println("Endpoint nil for peer: ", peerI.PublicKey.String())
|
|
log.Println("Endpoint nil for peer: ", peerI.PublicKey.String())
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- if peerConf.IsExtClient && !common.IsIngressGateway {
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- shouldProceed := false
|
|
|
|
- if peerConf.IsExtClient && peerConf.IsAttachedExtClient {
|
|
|
|
- // check if ext client got endpoint,otherwise continue
|
|
|
|
- for _, devpeerI := range wgInterface.Device.Peers {
|
|
|
|
- if devpeerI.PublicKey.String() == peerI.PublicKey.String() && devpeerI.Endpoint != nil {
|
|
|
|
- peerI.Endpoint = devpeerI.Endpoint
|
|
|
|
- shouldProceed = true
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- shouldProceed = true
|
|
|
|
- }
|
|
|
|
- if peerConf.IsExtClient && peerConf.IsAttachedExtClient && shouldProceed {
|
|
|
|
- // ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
- // common.ExtClientsWaitTh[peerI.PublicKey.String()] = common.ExtClientPeer{
|
|
|
|
- // CancelFunc: cancel,
|
|
|
|
- // }
|
|
|
|
- //go proxy.StartSniffer(ctx, wgInterface.Name, m.Payload.WgAddr, peerConf.Address, wgInterface.Port)
|
|
|
|
- }
|
|
|
|
|
|
|
|
if peerConf.IsExtClient && !peerConf.IsAttachedExtClient {
|
|
if peerConf.IsExtClient && !peerConf.IsAttachedExtClient {
|
|
peerI.Endpoint = peerConf.IngressGatewayEndPoint
|
|
peerI.Endpoint = peerConf.IngressGatewayEndPoint
|
|
}
|
|
}
|
|
- if shouldProceed {
|
|
|
|
- common.PeerKeyHashMap[fmt.Sprintf("%x", md5.Sum([]byte(peerI.PublicKey.String())))] = models.RemotePeer{
|
|
|
|
- Interface: m.Payload.InterfaceName,
|
|
|
|
- PeerKey: peerI.PublicKey.String(),
|
|
|
|
- IsExtClient: peerConf.IsExtClient,
|
|
|
|
- Endpoint: peerI.Endpoint,
|
|
|
|
- IsAttachedExtClient: peerConf.IsAttachedExtClient,
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
var isRelayed bool
|
|
var isRelayed bool
|
|
var relayedTo *net.UDPAddr
|
|
var relayedTo *net.UDPAddr
|
|
@@ -400,8 +368,8 @@ func (m *ManagerAction) AddInterfaceToProxy() error {
|
|
relayedTo = peerConf.RelayedTo
|
|
relayedTo = peerConf.RelayedTo
|
|
|
|
|
|
}
|
|
}
|
|
- if !shouldProceed && peerConf.IsAttachedExtClient {
|
|
|
|
- log.Println("Extclient endpoint not updated yet....skipping")
|
|
|
|
|
|
+ if peerConf.IsAttachedExtClient {
|
|
|
|
+ log.Println("Extclient Thread...")
|
|
go func(wgInterface *wg.WGIface, peer *wgtypes.PeerConfig,
|
|
go func(wgInterface *wg.WGIface, peer *wgtypes.PeerConfig,
|
|
isRelayed bool, relayTo *net.UDPAddr, peerConf PeerConf, ingGwAddr string) {
|
|
isRelayed bool, relayTo *net.UDPAddr, peerConf PeerConf, ingGwAddr string) {
|
|
addExtClient := false
|
|
addExtClient := false
|
|
@@ -454,6 +422,13 @@ func (m *ManagerAction) AddInterfaceToProxy() error {
|
|
}(wgInterface, &peerI, isRelayed, relayedTo, peerConf, m.Payload.WgAddr)
|
|
}(wgInterface, &peerI, isRelayed, relayedTo, peerConf, m.Payload.WgAddr)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ common.PeerKeyHashMap[fmt.Sprintf("%x", md5.Sum([]byte(peerI.PublicKey.String())))] = models.RemotePeer{
|
|
|
|
+ Interface: m.Payload.InterfaceName,
|
|
|
|
+ PeerKey: peerI.PublicKey.String(),
|
|
|
|
+ IsExtClient: peerConf.IsExtClient,
|
|
|
|
+ Endpoint: peerI.Endpoint,
|
|
|
|
+ IsAttachedExtClient: peerConf.IsAttachedExtClient,
|
|
|
|
+ }
|
|
|
|
|
|
peerpkg.AddNewPeer(wgInterface, &peerI, peerConf.Address, isRelayed,
|
|
peerpkg.AddNewPeer(wgInterface, &peerI, peerConf.Address, isRelayed,
|
|
peerConf.IsExtClient, peerConf.IsAttachedExtClient, relayedTo)
|
|
peerConf.IsExtClient, peerConf.IsAttachedExtClient, relayedTo)
|