json.go 973 B

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