Browse Source

fix peer setting

afeiszli 3 years ago
parent
commit
d7abd9c612
1 changed files with 7 additions and 2 deletions
  1. 7 2
      netclient/ncutils/netclientutils.go

+ 7 - 2
netclient/ncutils/netclientutils.go

@@ -155,7 +155,12 @@ func parsePeers(keepalive int32, peers []wgtypes.PeerConfig) (string, error) {
 	if keepalive <= 0 {
 	if keepalive <= 0 {
 		keepalive = 20
 		keepalive = 20
 	}
 	}
+	
 	for _, peer := range peers {
 	for _, peer := range peers {
+		endpointString :=  ""
+		if peer.Endpoint != nil && peer.Endpoint.String() != "" {
+			endpointString += "Endpoint = " + peer.Endpoint.String()
+		}
 		newAllowedIps := []string{}
 		newAllowedIps := []string{}
 		for _, allowedIP := range peer.AllowedIPs {
 		for _, allowedIP := range peer.AllowedIPs {
 			newAllowedIps = append(newAllowedIps, allowedIP.String())
 			newAllowedIps = append(newAllowedIps, allowedIP.String())
@@ -163,14 +168,14 @@ func parsePeers(keepalive int32, peers []wgtypes.PeerConfig) (string, error) {
 		peersString += fmt.Sprintf(`[Peer]
 		peersString += fmt.Sprintf(`[Peer]
 PublicKey = %s
 PublicKey = %s
 AllowedIps = %s
 AllowedIps = %s
-Endpoint = %s
 PersistentKeepAlive = %s
 PersistentKeepAlive = %s
+%s
 
 
 `,
 `,
 			peer.PublicKey.String(),
 			peer.PublicKey.String(),
 			strings.Join(newAllowedIps, ","),
 			strings.Join(newAllowedIps, ","),
-			peer.Endpoint.String(),
 			strconv.Itoa(int(keepalive)),
 			strconv.Itoa(int(keepalive)),
+			endpointString,
 		)
 		)
 	}
 	}
 	return peersString, nil
 	return peersString, nil