mirror of https://github.com/v2ray/v2ray-core
normalized path in websocket
parent
5e7fb6d0dd
commit
1aeab3dd96
|
@ -12,6 +12,17 @@ func (c *Config) IsConnectionReuse() bool {
|
|||
return c.ConnectionReuse.Enable
|
||||
}
|
||||
|
||||
func (c *Config) GetNormailzedPath() string {
|
||||
path := c.Path
|
||||
if len(path) == 0 {
|
||||
return "/"
|
||||
}
|
||||
if path[0] != '/' {
|
||||
return "/" + path
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func init() {
|
||||
common.Must(internet.RegisterProtocolConfigCreator(internet.TransportProtocol_WebSocket, func() interface{} {
|
||||
return new(Config)
|
||||
|
|
|
@ -74,7 +74,7 @@ func wsDial(ctx context.Context, dest v2net.Destination) (net.Conn, error) {
|
|||
if (protocol == "ws" && dest.Port == 80) || (protocol == "wss" && dest.Port == 443) {
|
||||
host = dest.Address.String()
|
||||
}
|
||||
uri := protocol + "://" + host + "/" + wsSettings.Path
|
||||
uri := protocol + "://" + host + wsSettings.GetNormailzedPath()
|
||||
|
||||
conn, resp, err := dialer.Dial(uri, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -108,7 +108,7 @@ func (ln *Listener) listenws(address v2net.Address, port v2net.Port) error {
|
|||
|
||||
go func() {
|
||||
http.Serve(listener, &requestHandler{
|
||||
path: "/" + ln.config.Path,
|
||||
path: "/" + ln.config.GetNormailzedPath(),
|
||||
conns: ln.awaitingConns,
|
||||
})
|
||||
}()
|
||||
|
|
Loading…
Reference in New Issue