1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-08 10:15:53 -05:00

support domain as host in VMess outbound config.

This commit is contained in:
Darien Raymond
2015-12-09 11:20:59 +00:00
parent bc144248e2
commit ed09b4ea6a
5 changed files with 103 additions and 15 deletions

View File

@@ -42,7 +42,7 @@ func TestDokodemoTCP(t *testing.T) {
InboundConfigValue: &mocks.ConnectionConfig{
ProtocolValue: "dokodemo-door",
SettingsValue: &json.DokodemoConfig{
Host: "127.0.0.1",
Host: v2netjson.NewIPHost(net.ParseIP("127.0.0.1")),
Port: port,
NetworkList: &networkList,
TimeoutValue: 0,
@@ -104,7 +104,7 @@ func TestDokodemoUDP(t *testing.T) {
InboundConfigValue: &mocks.ConnectionConfig{
ProtocolValue: "dokodemo-door",
SettingsValue: &json.DokodemoConfig{
Host: "127.0.0.1",
Host: v2netjson.NewIPHost(net.ParseIP("127.0.0.1")),
Port: port,
NetworkList: &networkList,
TimeoutValue: 0,

View File

@@ -1,26 +1,23 @@
package json
import (
"net"
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 string `json:"address"`
Host *v2netjson.Host `json:"address"`
Port v2net.Port `json:"port"`
NetworkList *v2netjson.NetworkList `json:"network"`
TimeoutValue int `json:"timeout"`
}
func (this *DokodemoConfig) Address() v2net.Address {
ip := net.ParseIP(this.Host)
if ip != nil {
return v2net.IPAddress(ip, this.Port)
if this.Host.IsIP() {
return v2net.IPAddress(this.Host.IP(), this.Port)
} else {
return v2net.DomainAddress(this.Host, this.Port)
return v2net.DomainAddress(this.Host.Domain(), this.Port)
}
}