config.go 632 B

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