This commit is contained in:
TenderIronh
2023-08-09 22:52:29 +08:00
parent b2a7619bd6
commit e21adebc26
8 changed files with 355 additions and 15 deletions
+10
View File
@@ -17,6 +17,7 @@ type p2pApp struct {
listener net.Listener
listenerUDP *net.UDPConn
tunnel *P2PTunnel
iptree *IPTree
rtid uint64 // relay tunnelID
relayNode string
relayMode string
@@ -64,6 +65,15 @@ func (app *p2pApp) listenTCP() error {
}
break
}
// check white list
if app.config.Whitelist != "" {
remoteIP := strings.Split(conn.RemoteAddr().String(), ":")[0]
if !app.iptree.Contains(remoteIP) {
conn.Close()
gLog.Printf(LvERROR, "%s not in whitelist, access denied", remoteIP)
continue
}
}
oConn := overlayConn{
tunnel: app.tunnel,
connTCP: conn,