config.go 573 B

123456789101112131415161718192021222324252627282930313233
  1. package websocket
  2. import (
  3. "net/http"
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/transport/internet"
  6. )
  7. func (c *Config) GetNormalizedPath() string {
  8. path := c.Path
  9. if len(path) == 0 {
  10. return "/"
  11. }
  12. if path[0] != '/' {
  13. return "/" + path
  14. }
  15. return path
  16. }
  17. func (c *Config) GetRequestHeader() http.Header {
  18. header := http.Header{}
  19. for _, h := range c.Header {
  20. header.Add(h.Key, h.Value)
  21. }
  22. return header
  23. }
  24. func init() {
  25. common.Must(internet.RegisterProtocolConfigCreator(internet.TransportProtocol_WebSocket, func() interface{} {
  26. return new(Config)
  27. }))
  28. }