config.go 585 B

12345678910111213141516171819202122232425262728293031323334
  1. package websocket
  2. import (
  3. "net/http"
  4. "github.com/xtls/xray-core/common"
  5. "github.com/xtls/xray-core/transport/internet"
  6. )
  7. func (c *Config) GetNormalizedPath() string {
  8. path := c.Path
  9. if path == "" {
  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 k, v := range c.Header {
  20. header.Add(k, v)
  21. }
  22. header.Set("Host", c.Host)
  23. return header
  24. }
  25. func init() {
  26. common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
  27. return new(Config)
  28. }))
  29. }