2019-02-01 14:08:21 -05:00
|
|
|
// +build !confonly
|
|
|
|
|
2016-12-22 18:30:46 -05:00
|
|
|
package websocket
|
2016-08-13 09:44:36 -04:00
|
|
|
|
2016-10-02 17:43:58 -04:00
|
|
|
import (
|
2017-10-13 11:54:04 -04:00
|
|
|
"net/http"
|
|
|
|
|
2021-02-16 15:31:50 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v4/common"
|
|
|
|
"github.com/v2fly/v2ray-core/v4/transport/internet"
|
2016-08-13 09:44:36 -04:00
|
|
|
)
|
2016-10-02 17:43:58 -04:00
|
|
|
|
2018-08-06 07:48:35 -04:00
|
|
|
const protocolName = "websocket"
|
|
|
|
|
2018-03-02 03:26:14 -05:00
|
|
|
func (c *Config) GetNormalizedPath() string {
|
2017-02-10 05:47:53 -05:00
|
|
|
path := c.Path
|
2019-06-14 09:47:28 -04:00
|
|
|
if path == "" {
|
2017-02-10 05:47:53 -05:00
|
|
|
return "/"
|
|
|
|
}
|
|
|
|
if path[0] != '/' {
|
|
|
|
return "/" + path
|
|
|
|
}
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
2017-10-13 11:54:04 -04:00
|
|
|
func (c *Config) GetRequestHeader() http.Header {
|
|
|
|
header := http.Header{}
|
|
|
|
for _, h := range c.Header {
|
|
|
|
header.Add(h.Key, h.Value)
|
|
|
|
}
|
|
|
|
return header
|
|
|
|
}
|
|
|
|
|
2016-10-02 17:43:58 -04:00
|
|
|
func init() {
|
2019-01-06 14:33:58 -05:00
|
|
|
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
|
2016-10-02 17:43:58 -04:00
|
|
|
return new(Config)
|
2017-01-12 06:54:34 -05:00
|
|
|
}))
|
2016-10-02 17:43:58 -04:00
|
|
|
}
|