From eee640ab99810da03e5cf0332a38c2f33f2ee509 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 8 Feb 2026 17:26:39 +0100 Subject: [PATCH] Optimize handshake by using ping instead of DNS lookup Removed DNS lookup for handshake and replaced with ping. --- qbittorrent/rootfs/usr/local/sbin/vpn | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/qbittorrent/rootfs/usr/local/sbin/vpn b/qbittorrent/rootfs/usr/local/sbin/vpn index 41bfed425..08bd7d338 100755 --- a/qbittorrent/rootfs/usr/local/sbin/vpn +++ b/qbittorrent/rootfs/usr/local/sbin/vpn @@ -197,24 +197,17 @@ _wg_wait_handshake() { local timeout="${1:-20}" local iface="${config["Interface"]}" local peer_pk="${config["PublicKey"]}" - local deadline ts dns_ip + local deadline ts deadline=$(( $(date +%s) + timeout )) while [ "$(date +%s)" -lt "${deadline}" ]; do - # Trigger handshake using DNS servers from /etc/resolv.conf - dns_ip="$(awk '/^nameserver[[:space:]]+/ {print $2; exit}' /etc/resolv.conf 2>/dev/null)" - if [ -n "${dns_ip}" ]; then - timeout 2 nslookup example.com "${dns_ip}" >/dev/null 2>&1 || true - else - getent ahosts example.com >/dev/null 2>&1 || true - fi + ping -I "${iface}" -c1 -W1 1.1.1.1 >/dev/null 2>&1 || true ts="$(wg show "${iface}" latest-handshakes 2>/dev/null | awk -v pk="${peer_pk}" '$1==pk{print $2; exit}')" if [ -n "${ts}" ] && [ "${ts}" -gt 0 ] 2>/dev/null; then return 0 fi - sleep 1 done