WIP: Add websocket support

This commit is contained in:
Owen Schwartz
2024-11-10 22:04:36 -05:00
parent b348c768c7
commit 2e5531b4a5
6 changed files with 515 additions and 151 deletions

View File

@@ -78,6 +78,25 @@ func (pm *ProxyManager) Start() error {
return nil
}
func (pm *ProxyManager) Stop() error {
pm.Lock()
defer pm.Unlock()
for i := range pm.targets {
target := &pm.targets[i]
close(target.cancel)
target.Lock()
if target.listener != nil {
target.listener.Close()
}
if target.udpConn != nil {
target.udpConn.Close()
}
target.Unlock()
}
return nil
}
func (pm *ProxyManager) serveTCP(target *ProxyTarget) {
listener, err := pm.tnet.ListenTCP(&net.TCPAddr{
IP: net.ParseIP(target.Listen),