Move browser dialer start stop to instance lifecycle

Agent-Logs-Url: https://github.com/XTLS/Xray-core/sessions/b8c640ab-f93c-4609-8e34-a8e14e2be9e7

Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-27 13:32:47 +00:00
committed by GitHub
parent 3a826b7ece
commit 8043924af5
3 changed files with 31 additions and 3 deletions
@@ -123,6 +123,20 @@ func StartCollectedDialerProxyURLs() error {
return nil
}
func StopCollectedDialerProxyURLs() error {
var stopErr error
for listenAddr, server := range serversByListenAddr {
if err := server.stop(); err != nil && stopErr == nil {
stopErr = errors.New("failed to stop browser dialer listener on ", listenAddr).Base(err)
}
}
dialersByAddress = map[string]*dialerInstance{}
serversByListenAddr = map[string]*dialerServer{}
pendingURLs = nil
initialized = false
return stopErr
}
type dialerInstance struct {
conns chan *websocket.Conn
page []byte
@@ -227,6 +241,14 @@ func (d *dialerServer) start() error {
return nil
}
func (d *dialerServer) stop() error {
if !d.started {
return nil
}
d.started = false
return d.server.Close()
}
func closeConnection(w http.ResponseWriter) {
hijacker, ok := w.(http.Hijacker)
if !ok {