mirror of https://github.com/v2ray/v2ray-core
converting from host to address directly
parent
34a0cb0b70
commit
6543facd51
|
@ -3,6 +3,8 @@ package json
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Host struct {
|
type Host struct {
|
||||||
|
@ -51,3 +53,11 @@ func (this *Host) IP() net.IP {
|
||||||
func (this *Host) Domain() string {
|
func (this *Host) Domain() string {
|
||||||
return this.domain
|
return this.domain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Host) Address() v2net.Address {
|
||||||
|
if this.IsIP() {
|
||||||
|
return v2net.IPAddress(this.IP())
|
||||||
|
} else {
|
||||||
|
return v2net.DomainAddress(this.Domain())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -14,11 +14,7 @@ type DokodemoConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *DokodemoConfig) Address() v2net.Address {
|
func (this *DokodemoConfig) Address() v2net.Address {
|
||||||
if this.Host.IsIP() {
|
return this.Host.Address()
|
||||||
return v2net.IPAddress(this.Host.IP())
|
|
||||||
} else {
|
|
||||||
return v2net.DomainAddress(this.Host.Domain())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *DokodemoConfig) Port() v2net.Port {
|
func (this *DokodemoConfig) Port() v2net.Port {
|
||||||
|
|
|
@ -37,11 +37,7 @@ func (t *ConfigTarget) UnmarshalJSON(data []byte) error {
|
||||||
log.Error("Address is not set in VMess outbound config.")
|
log.Error("Address is not set in VMess outbound config.")
|
||||||
return proxyconfig.BadConfiguration
|
return proxyconfig.BadConfiguration
|
||||||
}
|
}
|
||||||
if rawConfig.Address.IsIP() {
|
t.Destination = v2net.TCPDestination(rawConfig.Address.Address(), rawConfig.Port)
|
||||||
t.Destination = v2net.TCPDestination(v2net.IPAddress(rawConfig.Address.IP()), rawConfig.Port)
|
|
||||||
} else {
|
|
||||||
t.Destination = v2net.TCPDestination(v2net.DomainAddress(rawConfig.Address.Domain()), rawConfig.Port)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue