mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 20:59:19 +02:00
fix #2970 parsing IPv6 address in wireguard peers configure
This commit is contained in:
parent
7c9e3f97f1
commit
b091076bae
|
@ -254,7 +254,6 @@ func (h *Handler) makeVirtualTun(bind *netBindClient) (Tunnel, error) {
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// serialize the config into an IPC request
|
// serialize the config into an IPC request
|
||||||
func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) string {
|
func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) string {
|
||||||
var request strings.Builder
|
var request strings.Builder
|
||||||
|
@ -275,8 +274,11 @@ func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) stri
|
||||||
request.WriteString(fmt.Sprintf("preshared_key=%s\n", peer.PreSharedKey))
|
request.WriteString(fmt.Sprintf("preshared_key=%s\n", peer.PreSharedKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
split := strings.Split(peer.Endpoint, ":")
|
address, port, err := net.SplitHostPort(peer.Endpoint)
|
||||||
addr := net.ParseAddress(split[0])
|
if err != nil {
|
||||||
|
newError("failed to split endpoint ", peer.Endpoint, " into address and port").AtError().WriteToLog()
|
||||||
|
}
|
||||||
|
addr := net.ParseAddress(address)
|
||||||
if addr.Family().IsDomain() {
|
if addr.Family().IsDomain() {
|
||||||
dialerIp := bind.dialer.DestIpAddress()
|
dialerIp := bind.dialer.DestIpAddress()
|
||||||
if dialerIp != nil {
|
if dialerIp != nil {
|
||||||
|
@ -306,7 +308,7 @@ func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) stri
|
||||||
}
|
}
|
||||||
|
|
||||||
if peer.Endpoint != "" {
|
if peer.Endpoint != "" {
|
||||||
request.WriteString(fmt.Sprintf("endpoint=%s:%s\n", addr, split[1]))
|
request.WriteString(fmt.Sprintf("endpoint=%s:%s\n", addr, port))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ip := range peer.AllowedIps {
|
for _, ip := range peer.AllowedIps {
|
||||||
|
|
Loading…
Reference in New Issue