config.go 589 B

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