json.go 931 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package json
  2. import (
  3. "net"
  4. v2net "github.com/v2ray/v2ray-core/common/net"
  5. v2netjson "github.com/v2ray/v2ray-core/common/net/json"
  6. "github.com/v2ray/v2ray-core/proxy/common/config/json"
  7. )
  8. type DokodemoConfig struct {
  9. Host string `json:"address"`
  10. Port v2net.Port `json:"port"`
  11. NetworkList *v2netjson.NetworkList `json:"network"`
  12. TimeoutValue int `json:"timeout"`
  13. }
  14. func (this *DokodemoConfig) Address() v2net.Address {
  15. ip := net.ParseIP(this.Host)
  16. if ip != nil {
  17. return v2net.IPAddress(ip, this.Port)
  18. } else {
  19. return v2net.DomainAddress(this.Host, this.Port)
  20. }
  21. }
  22. func (this *DokodemoConfig) Network() v2net.NetworkList {
  23. return this.NetworkList
  24. }
  25. func (this *DokodemoConfig) Timeout() int {
  26. return this.TimeoutValue
  27. }
  28. func init() {
  29. json.RegisterInboundConnectionConfig("dokodemo-door", func() interface{} {
  30. return new(DokodemoConfig)
  31. })
  32. }