json.go 921 B

123456789101112131415161718192021222324252627282930313233343536
  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. Port 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(), this.Port)
  16. } else {
  17. return v2net.DomainAddress(this.Host.Domain(), this.Port)
  18. }
  19. }
  20. func (this *DokodemoConfig) Network() v2net.NetworkList {
  21. return this.NetworkList
  22. }
  23. func (this *DokodemoConfig) Timeout() int {
  24. return this.TimeoutValue
  25. }
  26. func init() {
  27. json.RegisterInboundConnectionConfig("dokodemo-door", func() interface{} {
  28. return new(DokodemoConfig)
  29. })
  30. }