fix: 修复 TLS ConnectionState、SPA 回退、健康检查与监听小问题
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.asio.asia/nixevol/NixMsg/internal/httpx"
|
||||
"git.asio.asia/nixevol/NixMsg/internal/listener"
|
||||
"github.com/coder/websocket"
|
||||
)
|
||||
@@ -31,11 +32,13 @@ func (b *Broker) WSHandler(proxies *listener.ProxySet) http.Handler {
|
||||
defer cancel()
|
||||
|
||||
nc := websocket.NetConn(ctx, c, websocket.MessageBinary)
|
||||
var nets []*net.IPNet
|
||||
if proxies != nil {
|
||||
ip := proxies.ClientIP(r)
|
||||
if ip != "" {
|
||||
nc = listener.WithRemoteAddr(nc, &net.TCPAddr{IP: net.ParseIP(ip)})
|
||||
}
|
||||
nets = proxies.IPNets()
|
||||
}
|
||||
ip := httpx.ClientIP(r, nets)
|
||||
if parsed := net.ParseIP(ip); parsed != nil {
|
||||
nc = listener.WithRemoteAddr(nc, &net.TCPAddr{IP: parsed})
|
||||
}
|
||||
_ = nc.SetReadDeadline(time.Now().Add(10 * time.Second))
|
||||
_ = b.AttachWS(nc)
|
||||
|
||||
Reference in New Issue
Block a user