diff --git a/warp6.sh b/warp6.sh deleted file mode 100755 index 59bfa1a..0000000 --- a/warp6.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/sh - -TMP_JSON="/tmp/warp.json" -TMP_CONF="/tmp/warp_decoded.conf" - -fail() { - exit 1 -} - -need() { - command -v "$1" >/dev/null 2>&1 || return 1 - return 0 -} - -if ! need curl; then - fail "curl is required. Please install curl (opkg update && opkg install curl)." -fi - -if ! need amneziawg; then - fail "amneziawg is required. Please install amneziawg 1.5+" -fi - -ENC_BASE='aHR0cHM6Ly9nZW5lcmF0b3Itd2FycC1jb25maWcudmVyY2VsLmFwcA==' - -decode_base64() { - echo "$1" | awk ' - BEGIN { - b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - for(i=1;i<=length(b64);i++) map[substr(b64,i,1)]=i-1 - } - { - gsub(/[^A-Za-z0-9+=]/,"",$0) - line=line $0 - } - END { - for(i=1;i<=length(line);i+=4){ - a_c=substr(line,i,1); b_c=substr(line,i+1,1); c_c=substr(line,i+2,1); d_c=substr(line,i+3,1); - if(a_c==""||b_c=="") break - a=(a_c in map)?map[a_c]:0 - b=(b_c in map)?map[b_c]:0 - byte1=int(a*4 + b/16); printf("%c",byte1) - if(c_c!="" && c_c!="="){ c=(c_c in map)?map[c_c]:0; byte2=int((b%16)*16 + c/4); printf("%c",byte2) - if(d_c!="" && d_c!="="){ d=(d_c in map)?map[d_c]:0; byte3=int((c%4)*64 + d); printf("%c",byte3) } - } - } - }' -} - -BASE_URL=$(decode_base64 "$ENC_BASE") || fail "Cannot decode base URL" - -PARAMS='?dns=1.1.1.1%2C1.0.0.1%2C2606:4700:4700::1111%2C2606:4700:4700::1001&allowedIPs=0.0.0.0/0,%20::/0' -ENDPOINT_PATH='/warp4s' - -URL="${BASE_URL}${ENDPOINT_PATH}${PARAMS}" - -curl -fsSL \ - -A 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36' \ - -H "Referer: ${BASE_URL}/" \ - -H "Origin: ${BASE_URL}" \ - "$URL" -o "$TMP_JSON" || fail "Failed to download $URL" - -CONTENT=$(grep -o '"content":"[^"]*"' "$TMP_JSON" | sed -e 's/^"content":"//' -e 's/"$//' | tr -d '\r\n') -[ -z "$CONTENT" ] && fail "Field 'content' not found in JSON" - -decode_base64 "$CONTENT" > "$TMP_CONF" || fail "Failed to decode content" - -getval() { - key="$1" - grep -m1 "^$key" "$TMP_CONF" 2>/dev/null | sed -e "s/^$key[[:space:]]*=[[:space:]]*//" -} - -PRIVATE_KEY=$(getval "PrivateKey" || true) -PUBLIC_KEY=$(getval "PublicKey" || true) -ADDR_LINE=$(getval "Address" || true) -ENDPOINT=$(getval "Endpoint" || true) - -ENDPOINT_DOMAIN="${ENDPOINT%%:*}" -ENDPOINT_PORT="${ENDPOINT##*:}" - -IPV6=$(printf '%s' "$ADDR_LINE" | awk -F',' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//') -[ -n "$IPV6" ] && case "$IPV6" in */*) IPV6_MASK="$IPV6" ;; *) IPV6_MASK="${IPV6}/128" ;; esac - -for var in PRIVATE_KEY IPV6_MASK ENDPOINT_DOMAIN ENDPOINT_PORT PUBLIC_KEY; do - eval val=\$$var - [ -z "$val" ] && fail "Variable $var is empty" -done - -uci -q del network.wan6 -uci -q del network.@amneziawg_wan6[0] -uci -q commit network - -I1="" - -uci -q set network.wan6=interface -uci -q set network.wan6.proto="amneziawg" -uci -q set network.wan6.nohostroute="1" -uci -q set network.wan6.private_key="$PRIVATE_KEY" -uci -q set network.wan6.addresses="$IPV6_MASK" -uci -q set network.wan6.awg_jc="4" -uci -q set network.wan6.awg_jmin="40" -uci -q set network.wan6.awg_jmax="70" -uci -q set network.wan6.awg_s1="0" -uci -q set network.wan6.awg_s2="0" -uci -q set network.wan6.awg_h1="1" -uci -q set network.wan6.awg_h2="2" -uci -q set network.wan6.awg_h3="3" -uci -q set network.wan6.awg_h4="4" -uci -q set network.wan6.awg_i1="$I1" -uci -q set network.@amneziawg_wan6[0]=amneziawg - -uci -q add network amneziawg_wan6 >/dev/null 2>&1 -uci -q set network.@amneziawg_wan6[0]=amneziawg_wan6 -uci -q set network.@amneziawg_wan6[0].description="wan6" -uci -q set network.@amneziawg_wan6[0].endpoint_host="$ENDPOINT_DOMAIN" -uci -q set network.@amneziawg_wan6[0].endpoint_port="$ENDPOINT_PORT" -uci -q set network.@amneziawg_wan6[0].public_key="$PUBLIC_KEY" -uci -q set network.@amneziawg_wan6[0].persistent_keepalive="25" -uci -q set network.@amneziawg_wan6[0].route_allowed_ips="1" -uci -q set network.@amneziawg_wan6[0].allowed_ips="::/0" -uci -q commit network - -ifup wan6 - -uci -q set dhcp.lan.ra_default="1" -uci -q commit dhcp -service odhcpd restart - -uci -q set firewall.@zone[1].masq6="1" -uci -q commit firewall -service firewall restart - -rm -f "$TMP_JSON" "$TMP_CONF"