v2ray-core/proxy/dokodemo/json/json.go

41 lines
973 B
Go
Raw Normal View History

2015-12-06 17:21:15 +00:00
package json
import (
v2net "github.com/v2ray/v2ray-core/common/net"
v2netjson "github.com/v2ray/v2ray-core/common/net/json"
"github.com/v2ray/v2ray-core/proxy/common/config/json"
)
type DokodemoConfig struct {
Host *v2netjson.Host `json:"address"`
2015-12-16 22:53:38 +00:00
PortValue v2net.Port `json:"port"`
2015-12-06 17:21:15 +00:00
NetworkList *v2netjson.NetworkList `json:"network"`
TimeoutValue int `json:"timeout"`
}
func (this *DokodemoConfig) Address() v2net.Address {
if this.Host.IsIP() {
2015-12-16 22:53:38 +00:00
return v2net.IPAddress(this.Host.IP())
2015-12-06 17:21:15 +00:00
} else {
2015-12-16 22:53:38 +00:00
return v2net.DomainAddress(this.Host.Domain())
2015-12-06 17:21:15 +00:00
}
}
2015-12-16 22:53:38 +00:00
func (this *DokodemoConfig) Port() v2net.Port {
return this.PortValue
}
2015-12-06 17:21:15 +00:00
func (this *DokodemoConfig) Network() v2net.NetworkList {
return this.NetworkList
}
func (this *DokodemoConfig) Timeout() int {
return this.TimeoutValue
}
func init() {
json.RegisterInboundConnectionConfig("dokodemo-door", func() interface{} {
return new(DokodemoConfig)
})
}