mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-06 01:23:38 +08:00
fix: wireguard server resolve when only a server in peers
This commit is contained in:
parent
10f8ba4434
commit
5678131591
@ -304,13 +304,16 @@ func (w *WireGuard) init(ctx context.Context) error {
|
|||||||
ipcConf := "private_key=" + w.option.PrivateKey
|
ipcConf := "private_key=" + w.option.PrivateKey
|
||||||
if len(w.option.Peers) > 0 {
|
if len(w.option.Peers) > 0 {
|
||||||
for i, peer := range w.option.Peers {
|
for i, peer := range w.option.Peers {
|
||||||
|
ipcConf += "\npublic_key=" + peer.PublicKey
|
||||||
destination, err := w.resolve(ctx, peer.Addr())
|
destination, err := w.resolve(ctx, peer.Addr())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// !!! do not set initErr here !!!
|
// !!! do not set initErr here !!!
|
||||||
// let us can retry domain resolve in next time
|
// let us can retry domain resolve in next time
|
||||||
return E.Cause(err, "resolve endpoint domain for peer ", i)
|
return E.Cause(err, "resolve endpoint domain for peer ", i)
|
||||||
}
|
}
|
||||||
ipcConf += "\npublic_key=" + peer.PublicKey
|
if len(w.option.Peers) == 1 { // must call SetConnectAddr if isConnect == true
|
||||||
|
w.bind.SetConnectAddr(destination)
|
||||||
|
}
|
||||||
ipcConf += "\nendpoint=" + destination.String()
|
ipcConf += "\nendpoint=" + destination.String()
|
||||||
if peer.PreSharedKey != "" {
|
if peer.PreSharedKey != "" {
|
||||||
ipcConf += "\npreshared_key=" + peer.PreSharedKey
|
ipcConf += "\npreshared_key=" + peer.PreSharedKey
|
||||||
@ -332,7 +335,7 @@ func (w *WireGuard) init(ctx context.Context) error {
|
|||||||
// let us can retry domain resolve in next time
|
// let us can retry domain resolve in next time
|
||||||
return E.Cause(err, "resolve endpoint domain")
|
return E.Cause(err, "resolve endpoint domain")
|
||||||
}
|
}
|
||||||
w.bind.SetConnectAddr(destination)
|
w.bind.SetConnectAddr(destination) // must call SetConnectAddr if isConnect == true
|
||||||
ipcConf += "\nendpoint=" + destination.String()
|
ipcConf += "\nendpoint=" + destination.String()
|
||||||
if w.option.PreSharedKey != "" {
|
if w.option.PreSharedKey != "" {
|
||||||
ipcConf += "\npreshared_key=" + w.option.PreSharedKey
|
ipcConf += "\npreshared_key=" + w.option.PreSharedKey
|
||||||
|
Loading…
x
Reference in New Issue
Block a user