From a3a94e44bb4f653bc9d8e46f0f3eabb4706752a8 Mon Sep 17 00:00:00 2001 From: darkclip Date: Sat, 2 Sep 2023 05:33:10 +0800 Subject: [PATCH] update --- cf-watch.sh | 1 + chgwgpeer | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 chgwgpeer diff --git a/cf-watch.sh b/cf-watch.sh index ce7865a5..0aad352c 100755 --- a/cf-watch.sh +++ b/cf-watch.sh @@ -33,6 +33,7 @@ while [ $loss -gt 50 ]; do cfip=$(cf_v4); echo "changing $dev endpoint to $cfip"; wg set $dev peer "bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=" endpoint "$cfip:4500"; + pfSsh.php playback chgwgpeer 0 $cfip 4500 || true; sleep 5; loss=$(get_ping_loss $watch); done; diff --git a/chgwgpeer b/chgwgpeer new file mode 100644 index 00000000..6986631b --- /dev/null +++ b/chgwgpeer @@ -0,0 +1,18 @@ + +global $config, $argv, $command_split; + +if (is_array($command_split)) { + $args = array_slice($command_split, 2); +} else { + $args = array_slice($argv, 3); +} + +if (!isset($args[0]) || !isset($args[1]) || !isset($args[2])) { + exit(-1); +} + +echo $args[0] . " -> " . $args[1] . ":" . $args[2] . "\n"; + +$config['installedpackages']['wireguard']['peers']['item'][$args[0]]['endpoint'] = $args[1]; +$config['installedpackages']['wireguard']['peers']['item'][$args[0]]['port'] = $args[2]; +write_config();