Hiddify-Manager icon indicating copy to clipboard operation
Hiddify-Manager copied to clipboard

عدم نصب WARP در نصب کننده نسخه 11.0.11

Open poava opened this issue 5 months ago • 8 comments

وقتی روی سرور خام از اول میخوای هیدیفای رو نصب کنی، وارپ همراه پکیج نصب نمیشه یا به درستی کار نمیکنه. موقعی که از داخل تنظیمات هیدیفای فعالش میکنی و اعمال تغییرات میزنی، توی لاگ ها کلمه زیر مشاهده میشه و در VPN هم IP سرور بر میگرده.

!!!!!!!!!!!!!!! WARP ERROR

داخل سرور هم وقتی میزنی وضعیت ورپ رو نمایش بده، چیزی برای نمایش وجود نداره.

  • Warp Status:
    • Profile: 2025/08/19 13:22:54 Using config file: wgcf-account.toml 2025/08/19 13:22:55 ======================================= 2025/08/19 13:22:55 Device name : DE-Hetzner 2025/08/19 13:22:55 Device model : hiddify 2025/08/19 13:22:55 Device active : true 2025/08/19 13:22:55 Account type : free 2025/08/19 13:22:55 Role : child 2025/08/19 13:22:55 Premium data : 0.00 B 2025/08/19 13:22:55 Quota : 0.00 B 2025/08/19 13:22:55 =======================================
    • Network: Press q to exit

با Reinstall هم مشکل حل نشد.

  • OS: Ubunutu 24.0.4 & Ubuntu 22.0.4
  • Hiddify Version: 11.0.11

poava avatar Aug 19 '25 09:08 poava

کسی راه حلی پیدا نکرد؟

alin30511 avatar Aug 23 '25 19:08 alin30511

See issue in #5093

JeelsBoobz avatar Aug 24 '25 07:08 JeelsBoobz

If had this error on ipv4 only server, so had to update /opt/hiddify-manager/other/warp/wireguard/run.sh bash script to make it work.

#!/bin/bash
# ln -sf $(pwd)/hiddify-warp.service /etc/systemd/system/hiddify-warp.service
# Purpose: keep original behavior but make IPv6 stripping robust on IPv4-only hosts.
# Notes:
#   - No new env vars are introduced; keeps your WGCF_LICENSE_KEY handling intact.
#   - Strips ANY IPv6 from Address/AllowedIPs/ip6tables when IPv6 is disabled or unreachable.
#   - Ensures "Table = off" is correctly placed under [Interface] (and only once).

set -euo pipefail

source /opt/hiddify-manager/common/utils.sh
systemctl disable hiddify-warp.service >/dev/null 2>&1 || true

ipv6_unavailable() {
  # Returns 0 (true) if IPv6 is disabled at kernel level OR not reachable
  if [[ -f /proc/sys/net/ipv6/conf/all/disable_ipv6 ]] && [[ "$(cat /proc/sys/net/ipv6/conf/all/disable_ipv6)" == "1" ]]; then
    return 0
  fi
  # quick reachability probe
  curl -6 -s --connect-timeout 1 https://ifconfig.co/ip >/dev/null 2>&1 || return 0
  return 1
}

ensure_table_off() {
  # Remove any stray Table lines to avoid duplicates, then insert a clean one under [Interface]
  sed -i -E '/^[[:space:]]*Table[[:space:]]*=/d' wgcf-profile.conf || true
  # Insert once right after [Interface] (idempotent because we removed prior ones)
  sed -i '/^\[Interface\]/a Table = off' wgcf-profile.conf
}

strip_ipv6_from_profile() {
  # Robust IPv6 removal from wgcf-profile.conf (handles dual Address lines and ::/0)
  # 1) Keep only IPv4 CIDRs on Address lines (works for "comma-separated" and multi-Address)
  awk -F'=' '
    BEGIN{OFS="="}
    /^[[:space:]]*Address[[:space:]]*=/{
      key=$1; rhs=$2
      gsub(/^[[:space:]]+|[[:space:]]+$/, "", rhs)
      n=split(rhs, arr, /,[[:space:]]*/)
      v4list=""
      for(i=1;i<=n;i++){
        if(arr[i] ~ /(^|[[:space:]])([0-9]{1,3}\.){3}[0-9]{1,3}\/[0-9]+([[:space:]]|$)/){
          v4list = (v4list==""?arr[i]:v4list", "arr[i])
        }
      }
      if(v4list==""){
        print "#" key, rhs   # comment pure-IPv6 Address lines
      } else {
        print "Address", v4list
      }
      next
    }
    {print}
  ' wgcf-profile.conf > wgcf-profile.conf.tmp && mv -f wgcf-profile.conf.tmp wgcf-profile.conf

  # 2) Remove ::/0 from AllowedIPs (solo and mixed)
  sed -i -E 's/^AllowedIPs[[:space:]]*=[[:space:]]*::\/0$/# &/; s/, *::\/0//;' wgcf-profile.conf

  # 3) Remove ip6tables hooks (if any)
  sed -i -E '/ip6tables/d' wgcf-profile.conf
}

function check_wireguard_connection() {
  echo "Checking WARP ..."
  if ! [ -f "wgcf-account.toml" ]; then
    # first-time register (ignore errors to keep flow)
    ./wgcf register --accept-tos -m hiddify -n "$(hostname)" >/dev/null 2>&1 || true
  fi

  # make update non-fatal so we ALWAYS reach generate_warp_config (prevents warp.conf missing)
  ./wgcf update >/dev/null 2>&1 || true

  generate_warp_config

  # Try to start/restart; if it fails due to IPv6, enforce strip and retry once.
  if ! systemctl restart wg-quick@warp; then
    echo "wg-quick@warp failed; enforcing IPv4-only and retrying..."
    strip_ipv6_from_profile
    systemctl restart wg-quick@warp
  fi

  echo "Starting WARP.... checking real connectivitiy"
  sleep .5
  if ! real_test; then
    sleep .5
    echo "Checking real connectivitiy again!"
    real_test || return $?
  fi
}

function real_test() {
  curl -s --interface warp --connect-timeout .5 http://ip-api.com?fields=message,country,org,query
  error=$?
  if [ $error == 0 ]; then
    success "WARP is WORKING!"
  else
    warning "WARP is not working!"
  fi
  return $error
}

function generate_warp_config() {
  echo "Generating WARP config..."
  ./wgcf generate >/dev/null 2>&1 || true

  # Ensure "Table = off" is inside [Interface] (and only once)
  ensure_table_off

  # If host is IPv4-only or IPv6 is unreachable, remove IPv6 from profile
  if ipv6_unavailable; then
    echo "Removing IPV6 from WARP (host IPv4-only or IPv6 unreachable)..."
    strip_ipv6_from_profile
  fi

  # Don’t force DNS; comment it out if present
  sed -i '/^DNS = 1\.1\.1\.1/s/^/# /' wgcf-profile.conf || true

  mkdir -p /etc/wireguard/
  ln -sf "$(pwd)/wgcf-profile.conf" /etc/wireguard/warp.conf
  systemctl enable wg-quick@warp >/dev/null 2>&1 || true
}

# --- Entry flow (kept exactly like your original, no new env vars added) ---

# api.zeroteam.top/warp?format=./wgcf for change warp
export WGCF_LICENSE_KEY="xxx-xxx-xxx"
if ! check_wireguard_connection; then
  # backup only if the file actually exists (avoid "cannot stat")
  [ -f wgcf-account.toml ] && mv wgcf-account.toml wgcf-account.toml.backup
  if ! check_wireguard_connection; then
    # same here — only move if present
    [ -f wgcf-account.toml ] && mv wgcf-account.toml wgcf-account.toml.backup
    export WGCF_LICENSE_KEY=
    if ! check_wireguard_connection; then
      error "!!!!!!!!!!!!!!! WARP ERROR"
    fi
  fi
fi

davodm avatar Sep 06 '25 23:09 davodm

، کلادفلر محدود کرده فکر کنم

نمیذاره کانفیگ پروفایل وایرگارد ساخته بشه

3 تا روش میذارم

بی دردسرترینش روش 3 هست

اگه جواب نگرفتید برید 2 بعد 1

روش 1 دستورات زیر را برای ساخت کانفیگ بصورت دستی اجرا کنید

chmod +x /opt/hiddify-manager/other/warp/wireguard/wgcf
nano /opt/hiddify-manager/other/warp/wireguard/wgcf-profile.conf

محتوای زیر رو. کپی بزنی

[Interface]
PrivateKey = sLvZaSJRIr1FfdtfNcd2U412q224n4ZN7gm11DwFlWA=
Address = 172.16.0.2/32, 2606:4700:110:8a86:42c3:ef30:c39a:2ff5/128
DNS = 1.1.1.1, 1.0.0.1, 2606:4700:4700::1111, 2606:4700:4700::1001
MTU = 1280
Table = off
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = engage.cloudflareclient.com:2408

ctrl +x

سیو کنید و خروج بزنید.


ln -sf /opt/hiddify-manager/other/warp/wireguard/wgcf-profile.conf /etc/wireguard/warp.conf

systemctl enable wg-quick@warp
systemctl restart wg-quick@warp
systemctl status wg-quick@warp

UltimateABC avatar Sep 08 '25 01:09 UltimateABC

باید فایل

/opt/hiddify-manager/other/warp/wireguard/run.sh.j2

اصلاح بشه


nano /opt/hiddify-manager/other/warp/wireguard/run.sh.j2
#!/bin/bash
#ln -sf $(pwd)/hiddify-warp.service /etc/systemd/system/hiddify-warp.service
source /opt/hiddify-manager/common/utils.sh
systemctl disable hiddify-warp.service >/dev/null 2>&1

function check_wireguard_connection() {
  echo "Checking WARP ..."
  if ! [ -f "wgcf-account.toml" ]; then
    # FIX: The incorrect 'mv' command was removed from here.
    ./wgcf register --accept-tos -m hiddify -n $(hostname) >/dev/null 2>&1
  fi

  ./wgcf update >/dev/null 2>&1 || return $?
  generate_warp_config
  systemctl restart wg-quick@warp
  echo "Starting WARP.... checking real connectivitiy"
  sleep .5
  if ! real_test; then
    sleep .5
    echo "Checking real connectivitiy again!"
    real_test || return $?
  fi
}
function real_test() {
  # IMPROVEMENT: Increased timeout from 0.5s to 3s for more reliability.
  curl -s --interface warp --connect-timeout 3 http://ip-api.com?fields=message,country,org,query
  error=$?
  if [ $error == 0 ];then
    success "WARP is WORKING!"
  else
    warning  "WARP is not working!"
  fi
  return $error
}

function generate_warp_config() {
  echo "Generating WARP config..."
  ./wgcf generate >/dev/null 2>&1
  sed -i 's/\[Peer\]/Table = off\n\[Peer\]/g' wgcf-profile.conf

  # Check for IPv6 connectivity and disable it in the config if not available.
  curl --connect-timeout 1 -s https://v6.ident.me/ 2>&1 >/dev/null
  if [ $? != 0 ] || [ $(cat /proc/sys/net/ipv6/conf/all/disable_ipv6) == 1 ]; then
    echo "Removing IPV6 from WARP..."
    sed -i '/Address = [0-9a-fA-F:]\{4,\}/s/^/# /' wgcf-profile.conf
  fi

  sed -i '/DNS = 1.1.1.1/s/^/# /' wgcf-profile.conf
  mkdir -p /etc/wireguard/
  ln -sf $(pwd)/wgcf-profile.conf /etc/wireguard/warp.conf
  systemctl enable wg-quick@warp
}

function create_default_config() {
  echo "Creating default WARP config due to registration failure..."
  cat <<EOF > wgcf-profile.conf
[Interface]
PrivateKey = sLvZaSJRIr1FfdtfNcd2U412q224n4ZN7gm11DwFlWA=
Address = 172.16.0.2/32, 2606:4700:110:8a86:42c3:ef30:c39a:2ff5/128
DNS = 1.1.1.1, 1.0.0.1, 2606:4700:4700::1111, 2606:4700:4700::1001
MTU = 1280
Table = off
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = engage.cloudflareclient.com:2408
EOF
}

# Set the license key from environment/config variables.
export WGCF_LICENSE_KEY="y19Ns2b4-6pRD40N2-41lw30Hy"

# Main execution with retry logic
# Attempt 1: With existing account and license key
if ! check_wireguard_connection; then
  echo "First attempt failed. Trying again with a new account..."
  # Attempt 2: With a new account and the same license key
  mv wgcf-account.toml wgcf-account.toml.backup 2>/dev/null
  if ! check_wireguard_connection; then
    echo "Second attempt failed. Trying again with a new free account..."
    # Attempt 3: With a new account and NO license key (fallback to free)
    mv wgcf-account.toml wgcf-account.toml.backup 2>/dev/null
    export WGCF_LICENSE_KEY=
    if ! check_wireguard_connection; then
      warning "All automatic attempts failed. Falling back to a default WARP config."
      create_default_config
      generate_warp_config
      systemctl restart wg-quick@warp
      if ! real_test; then
        error "!!!!!!!!!!!!!!! WARP ERROR: All attempts to connect failed. Default config also failed."
      fi
    fi
  fi
fi

UltimateABC avatar Sep 08 '25 02:09 UltimateABC

روش سوم - اپدیت wgcf

mv /opt/hiddify-manager/other/warp/wireguard/wgcf /opt/hiddify-manager/other/warp/wireguard/wgcf_backup

sudo wget https://github.com/ViRb3/wgcf/releases/download/v2.2.29/wgcf_2.2.29_linux_amd64 -O /opt/hiddify-manager/other/warp/wireguard/wgcf

sudo chmod +x /opt/hiddify-manager/other/warp/wireguard/wgcf

UltimateABC avatar Sep 08 '25 02:09 UltimateABC

Simple 👍

rm -rf /opt/hiddify-manager/common/packages.db
wget -O /opt/hiddify-manager/common/packages.lock https://raw.githubusercontent.com/hiddify/Hiddify-Manager/6ec9237b83957b64a8e0c63660d33dd1e9120dfd/common/packages.lock
/opt/hiddify-manager/install.sh

JeelsBoobz avatar Sep 08 '25 11:09 JeelsBoobz

hey I have a question. today I noticed when I connect to Hiddify it takes a while for Ip to show. I'm assuming it has to do with warp? is anyone else experiencing this? the connection seems fine just Ip shows late or sometimes doesn't show. thanks

djamgo avatar Sep 29 '25 13:09 djamgo