mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-29 19:45:13 +08:00
update 2026-08-16 16:21:47
This commit is contained in:
1 parent
d298a9b0c2
commit
9f4ff1bb27
21 files changed
+78
-115
No files matched your search
@@ -965,20 +965,27 @@ start_socks5_udp_with_ipt2socks() {
|
||||
local local_port="$2"
|
||||
local threads="$3"
|
||||
local ipt2socks_bin
|
||||
local auth_opts=""
|
||||
local server_ip
|
||||
local _i
|
||||
|
||||
ipt2socks_bin="$(first_type ipt2socks)"
|
||||
server_ip="$(get_host_ip "$sid")"
|
||||
|
||||
[ -x "$ipt2socks_bin" ] || return 1
|
||||
[ -n "$server_ip" ] || {
|
||||
echolog "UDP TPROXY Relay:Socks5 无法解析服务器地址。"
|
||||
return 1
|
||||
}
|
||||
set --
|
||||
if [ "$(uci_get_by_name "$sid" auth_enable 0)" = "1" ]; then
|
||||
auth_opts="-a $(uci_get_by_name "$sid" username) -k $(uci_get_by_name "$sid" password)"
|
||||
set -- -a "$(uci_get_by_name "$sid" username)" \
|
||||
-k "$(uci_get_by_name "$sid" password)"
|
||||
fi
|
||||
for _i in $(seq 1 "$threads"); do
|
||||
ln_start_bin "$ipt2socks_bin" ipt2socks -U -r -b 0.0.0.0 -4 \
|
||||
-s "$(uci_get_by_name "$sid" server)" \
|
||||
-s "$server_ip" \
|
||||
-p "$(uci_get_by_name "$sid" server_port)" \
|
||||
-l "$local_port" "$auth_opts"
|
||||
-l "$local_port" "$@"
|
||||
done
|
||||
echolog "UDP TPROXY Relay:Socks5 via IPT2Socks $threads Threads Started!"
|
||||
return 0
|
||||
@@ -989,21 +996,28 @@ start_socks5_redir_with_ipt2socks() {
|
||||
local local_port="$2"
|
||||
local threads="$3"
|
||||
local ipt2socks_bin
|
||||
local auth_opts=""
|
||||
local server_ip
|
||||
local _i
|
||||
|
||||
ipt2socks_bin="$(first_type ipt2socks)"
|
||||
server_ip="$(get_host_ip "$sid")"
|
||||
|
||||
[ -x "$ipt2socks_bin" ] || return 1
|
||||
[ -n "$server_ip" ] || {
|
||||
echolog "Main node:Socks5 无法解析服务器地址。"
|
||||
return 1
|
||||
}
|
||||
set --
|
||||
if [ "$(uci_get_by_name "$sid" auth_enable 0)" = "1" ]; then
|
||||
auth_opts="-a $(uci_get_by_name "$sid" username) -k $(uci_get_by_name "$sid" password)"
|
||||
set -- -a "$(uci_get_by_name "$sid" username)" \
|
||||
-k "$(uci_get_by_name "$sid" password)"
|
||||
fi
|
||||
for _i in $(seq 1 "$threads"); do
|
||||
ln_start_bin "$ipt2socks_bin" ipt2socks \
|
||||
-T -R -r -b 0.0.0.0 -4 \
|
||||
-s "$(uci_get_by_name "$sid" server)" \
|
||||
-s "$server_ip" \
|
||||
-p "$(uci_get_by_name "$sid" server_port)" \
|
||||
-l "$local_port" "$auth_opts"
|
||||
-l "$local_port" "$@"
|
||||
done
|
||||
echolog "Main node:Socks5 via IPT2Socks $threads Threads Started!"
|
||||
return 0
|
||||
|
||||
@@ -1262,6 +1262,13 @@ compare_rules() {
|
||||
return 0 # No update needed
|
||||
}
|
||||
|
||||
append_nftables_comment() {
|
||||
local name="$1"
|
||||
local value
|
||||
value=$(printf '%s' "$2" | tr '\r\n' ' ')
|
||||
printf '# %s: %s\n' "$name" "$value" >> "$NFTABLES_RULES_FILE"
|
||||
}
|
||||
|
||||
# Auto-update persistence rules
|
||||
persist_nftables_rules() {
|
||||
if [ "$USE_NFT" != "1" ]; then
|
||||
@@ -1296,12 +1303,12 @@ persist_nftables_rules() {
|
||||
echo "# Auto-updated: $(date)" >> "$NFTABLES_RULES_FILE"
|
||||
echo "# Runmode: ${RUNMODE:-router}" >> "$NFTABLES_RULES_FILE"
|
||||
echo "# Server: $server, Port: $local_port" >> "$NFTABLES_RULES_FILE"
|
||||
echo "# WAN_BP_IP: $WAN_BP_IP" >> "$NFTABLES_RULES_FILE"
|
||||
echo "# LAN_AC_IP: $LAN_AC_IP" >> "$NFTABLES_RULES_FILE"
|
||||
echo "# LAN_BP_IP: $LAN_BP_IP" >> "$NFTABLES_RULES_FILE"
|
||||
echo "# WAN_FW_IP: $WAN_FW_IP" >> "$NFTABLES_RULES_FILE"
|
||||
echo "# LAN_FP_IP: $LAN_FP_IP" >> "$NFTABLES_RULES_FILE"
|
||||
echo "# LAN_GM_IP: $LAN_GM_IP" >> "$NFTABLES_RULES_FILE"
|
||||
append_nftables_comment "WAN_BP_IP" "$WAN_BP_IP"
|
||||
append_nftables_comment "LAN_AC_IP" "$LAN_AC_IP"
|
||||
append_nftables_comment "LAN_BP_IP" "$LAN_BP_IP"
|
||||
append_nftables_comment "WAN_FW_IP" "$WAN_FW_IP"
|
||||
append_nftables_comment "LAN_FP_IP" "$LAN_FP_IP"
|
||||
append_nftables_comment "LAN_GM_IP" "$LAN_GM_IP"
|
||||
echo "" >> "$NFTABLES_RULES_FILE"
|
||||
|
||||
local HAS_RULES=0
|
||||
|
||||
Reference in new issue
Block a user