Browse Source

foward to ext client from sniffer

Abhishek Kondur 2 years ago
parent
commit
e836284888
2 changed files with 21 additions and 19 deletions
  1. 7 5
      nm-proxy/proxy/proxy.go
  2. 14 14
      nm-proxy/server/server.go

+ 7 - 5
nm-proxy/proxy/proxy.go

@@ -157,14 +157,16 @@ func StartSniffer(ctx context.Context, ifaceName, extClientAddr string, port int
 					fmt.Println("#########################")
 					fmt.Printf("From %s to %s\n", ip.SrcIP, ip.DstIP)
 					fmt.Println("Protocol: ", ip.Protocol)
+					if ip.DstIP.String() == extClientAddr || ip.SrcIP.String() == extClientAddr {
+						if ifacePeers, ok := common.PeerAddrMap[ifaceName]; ok {
+							if peerConf, ok := ifacePeers[ip.DstIP.String()]; ok {
+								log.Println("-----> Fowarding PKT From ExtClient: ", extClientAddr, " to: ", peerConf.Config.RemoteProxyIP)
+								//server.NmProxyServer.Server.WriteTo(packet.Data(),  )
+							}
 
-					if ifacePeers, ok := common.PeerAddrMap[ifaceName]; ok {
-						if peerConf, ok := ifacePeers[ip.DstIP.String()]; ok {
-							log.Println("-----> Fowarding PKT From ExtClient: ", extClientAddr, " to: ", peerConf.Config.RemoteProxyIP)
-							//server.NmProxyServer.Server.WriteTo(packet.Data(),  )
 						}
-
 					}
+
 					fmt.Println("#########################")
 				}
 			}

+ 14 - 14
nm-proxy/server/server.go

@@ -63,20 +63,20 @@ func (p *ProxyServer) Listen(ctx context.Context) {
 			n, srcPeerKeyHash, dstPeerKeyHash = packet.ExtractInfo(buffer, n)
 			//log.Printf("--------> RECV PKT [DSTPORT: %d], [SRCKEYHASH: %s], SourceIP: [%s] \n", localWgPort, srcPeerKeyHash, source.IP.String())
 			if _, ok := common.WgIfaceKeyMap[dstPeerKeyHash]; !ok {
-				if common.IsIngressGateway {
-					log.Println("----> fowarding PKT to EXT client...")
-					if val, ok := common.PeerKeyHashMap[dstPeerKeyHash]; ok && val.IsAttachedExtClient {
-
-						log.Printf("-------->Forwarding the pkt to extClient  [ SourceIP: %s ], [ SourceKeyHash: %s ], [ DstIP: %s ], [ DstHashKey: %s ] \n",
-							source.String(), srcPeerKeyHash, val.Endpoint.String(), dstPeerKeyHash)
-						_, err = NmProxyServer.Server.WriteToUDP(buffer[:n], val.Endpoint)
-						if err != nil {
-							log.Println("Failed to send to remote: ", err)
-						}
-						continue
-
-					}
-				}
+				// if common.IsIngressGateway {
+				// 	log.Println("----> fowarding PKT to EXT client...")
+				// 	if val, ok := common.PeerKeyHashMap[dstPeerKeyHash]; ok && val.IsAttachedExtClient {
+
+				// 		log.Printf("-------->Forwarding the pkt to extClient  [ SourceIP: %s ], [ SourceKeyHash: %s ], [ DstIP: %s ], [ DstHashKey: %s ] \n",
+				// 			source.String(), srcPeerKeyHash, val.Endpoint.String(), dstPeerKeyHash)
+				// 		_, err = NmProxyServer.Server.WriteToUDP(buffer[:n], val.Endpoint)
+				// 		if err != nil {
+				// 			log.Println("Failed to send to remote: ", err)
+				// 		}
+				// 		continue
+
+				// 	}
+				// }
 
 				if common.IsRelay {