diff --git a/cf-watch.sh b/cf-watch.sh index 266c0b99..ac84b478 100755 --- a/cf-watch.sh +++ b/cf-watch.sh @@ -4,7 +4,7 @@ conf=$2; pids=$(pgrep -afl $0); if [ $(echo $pids|grep -o $0|wc -l) -gt 1 ]; then exit; -fi +fi; get_rnd(){ echo $(od -An -N2 -i /dev/random); @@ -43,4 +43,6 @@ while [ $loss -gt 40 ]; do loss=$(get_ping_loss $watch); done; endpoint=$(wg show $dev endpoints | awk '{print $2}'); -pfSsh.php playback chgwgpeer $conf $(echo $endpoint|awk -F: '{print $1}') $(echo $endpoint|awk -F: '{print $2}') || true; +if [ $(pfSsh.php playback chgwgpeer $conf) != $endpoint ]; then + pfSsh.php playback chgwgpeer $conf $(echo $endpoint|awk -F: '{print $1}') $(echo $endpoint|awk -F: '{print $2}') || true; +fi; \ No newline at end of file diff --git a/chgwgpeer b/chgwgpeer index 4efd5177..e3db4fab 100644 --- a/chgwgpeer +++ b/chgwgpeer @@ -8,7 +8,10 @@ if (is_array($command_split)) { } if (!isset($args[0]) || !isset($args[1]) || !isset($args[2])) { - exit(-1); + if (isset($args[0])){ + echo $config['installedpackages']['wireguard']['peers']['item'][$args[0]]['endpoint'] . ":" . $config['installedpackages']['wireguard']['peers']['item'][$args[0]]['port']; + } + exit(0); } echo $args[0] . " -> " . $args[1] . ":" . $args[2] . "\n";