mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add V2Ray Socks Protocol support
This commit is contained in:
parent
a8387400ba
commit
1e70503fe0
5 changed files with 76 additions and 33 deletions
|
@ -290,6 +290,8 @@ inbound_section_validate() {
|
|||
's_trojan_default_user_level:uinteger' \
|
||||
's_trojan_detour_to:string' \
|
||||
's_trojan_disable_insecure_encryption:bool:0' \
|
||||
's_socks_client_id:string' \
|
||||
's_socks_client_email:string:"openmptcprouter"' \
|
||||
'ss_network:or("tcp", "kcp", "ws", "http", "domainsocket", "quic")' \
|
||||
'ss_security:or("none", "tls")' \
|
||||
'ss_tls_server_name:host' \
|
||||
|
@ -383,6 +385,10 @@ outbound_section_validate() {
|
|||
's_trojan_user_security:or("auto", "aes-128-gcm", "chacha20-poly1305", "none")' \
|
||||
's_trojan_user_encryption:or("auto", "none")' \
|
||||
's_trojan_user_level:uinteger' \
|
||||
's_socks_address:host' \
|
||||
's_socks_port:port' \
|
||||
's_socks_user_id:string' \
|
||||
's_socks_email:string:openmptcprouter' \
|
||||
'ss_network:or("tcp", "kcp", "ws", "http", "domainsocket", "quic")' \
|
||||
'ss_security:or("none", "tls")' \
|
||||
'ss_tls_server_name:host' \
|
||||
|
@ -1003,6 +1009,14 @@ add_inbound_setting() {
|
|||
json_close_object
|
||||
json_close_array # accounts
|
||||
fi
|
||||
if [ -n "$s_socks_client_id" ] ; then
|
||||
json_add_array "accounts"
|
||||
json_add_object ""
|
||||
json_add_string "user" "$s_socks_email"
|
||||
json_add_string "pass" "$s_socks_client_id"
|
||||
json_close_object
|
||||
json_close_array # accounts
|
||||
fi
|
||||
|
||||
json_add_boolean "udp" "$s_socks_udp"
|
||||
|
||||
|
@ -1503,36 +1517,6 @@ add_outbound_setting() {
|
|||
json_add_boolean "ota" "$s_shadowsocks_ota"
|
||||
json_close_object
|
||||
|
||||
json_close_array # servers
|
||||
json_close_object # settings
|
||||
;;
|
||||
"socks")
|
||||
json_add_object "settings"
|
||||
json_add_array "servers"
|
||||
|
||||
json_add_object ""
|
||||
|
||||
json_add_string "address" "$s_socks_server_address"
|
||||
append_server_address "$s_socks_server_address"
|
||||
|
||||
json_add_int "port" "$s_socks_server_port"
|
||||
|
||||
if [ -n "$s_socks_account_user" ] ; then
|
||||
json_add_array "users"
|
||||
json_add_object ""
|
||||
|
||||
json_add_string "user" "$s_socks_account_user"
|
||||
json_add_string "pass" "$s_socks_account_pass"
|
||||
|
||||
test -n "$s_socks_user_level" && \
|
||||
json_add_int "level" "$s_socks_user_level"
|
||||
|
||||
json_close_object
|
||||
json_close_array # users
|
||||
fi
|
||||
|
||||
json_close_object
|
||||
|
||||
json_close_array # servers
|
||||
json_close_object # settings
|
||||
;;
|
||||
|
@ -1610,6 +1594,29 @@ add_outbound_setting() {
|
|||
json_close_array # trojan
|
||||
json_close_object # settings
|
||||
;;
|
||||
"socks")
|
||||
json_add_object "settings"
|
||||
|
||||
json_add_array "servers"
|
||||
json_add_object ""
|
||||
|
||||
json_add_string "address" "$s_socks_address"
|
||||
append_server_address "$s_socks_address"
|
||||
|
||||
json_add_int "port" "$s_socks_port"
|
||||
|
||||
json_add_array "users"
|
||||
json_add_object ""
|
||||
json_add_string "pass" "$s_socks_user_id"
|
||||
json_add_string "user" "$s_socks_email"
|
||||
json_close_object
|
||||
json_close_array # users
|
||||
|
||||
json_close_object
|
||||
|
||||
json_close_array # socks
|
||||
json_close_object # settings
|
||||
;;
|
||||
esac
|
||||
|
||||
json_add_object "streamSettings"
|
||||
|
@ -1878,7 +1885,7 @@ init_transparent_proxy() {
|
|||
TRANSPARENT_PROXY_PORT="$redirect_port"
|
||||
TRANSPARENT_PROXY_USE_TPROXY="$use_tproxy"
|
||||
|
||||
if [ "x$redirect_udp" = "x1" ] && [ "$(uci -q get v2ray.omrout.protocol)" = "vless" ]; then
|
||||
if [ "x$redirect_udp" = "x1" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "trojan" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "socks" ]; then
|
||||
TRANSPARENT_PROXY_ADDITION="udp"
|
||||
elif [ "x$redirect_dns" = "x1" ] ; then
|
||||
TRANSPARENT_PROXY_ADDITION="dns"
|
||||
|
@ -2196,6 +2203,9 @@ rules_up() {
|
|||
elif [ "$(uci -q get v2ray.omrout.protocol)" = "trojan" ]; then
|
||||
OUTBOUND_SERVERS_V4="$(uci -q get v2ray.omrout.s_trojan_address)"
|
||||
OUTBOUND_SERVERS_V6="$(uci -q get v2ray.omrout.s_trojan_address)"
|
||||
elif [ "$(uci -q get v2ray.omrout.protocol)" = "socks" ]; then
|
||||
OUTBOUND_SERVERS_V4="$(uci -q get v2ray.omrout.s_socks_address)"
|
||||
OUTBOUND_SERVERS_V6="$(uci -q get v2ray.omrout.s_socks_address)"
|
||||
fi
|
||||
TRANSPARENT_PROXY_PORT="$(uci -q get v2ray.omr.port)"
|
||||
[ -n "$OUTBOUND_SERVERS_V4" ] || [ -n "$OUTBOUND_SERVERS_V6" ] && {
|
||||
|
|
|
@ -52,6 +52,12 @@ if [ -z "$(uci -q get v2ray.main)" ]; then
|
|||
set v2ray.omrout.s_trojan_user_security='none'
|
||||
set v2ray.omrout.s_trojan_user_encryption='none'
|
||||
set v2ray.omrout.s_trojan_user_alter_id='0'
|
||||
set v2ray.omrout.s_socks_address=''
|
||||
set v2ray.omrout.s_socks_port='65229'
|
||||
set v2ray.omrout.s_socks_user_id=''
|
||||
set v2ray.omrout.s_socks_user_security='none'
|
||||
set v2ray.omrout.s_socks_user_encryption='none'
|
||||
set v2ray.omrout.s_socks_user_alter_id='0'
|
||||
set v2ray.omrout.ss_network='tcp'
|
||||
set v2ray.omrout.ss_security='tls'
|
||||
set v2ray.omrout.ss_tls_allow_insecure='1'
|
||||
|
@ -179,6 +185,17 @@ if [ "$(uci -q get v2ray.omrout.s_trojan_port)" = "" ]; then
|
|||
commit v2ray
|
||||
EOF
|
||||
fi
|
||||
if [ "$(uci -q get v2ray.omrout.s_socks_port)" = "" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set v2ray.omrout.s_socks_address=''
|
||||
set v2ray.omrout.s_socks_port='65229'
|
||||
set v2ray.omrout.s_socks_user_id=''
|
||||
set v2ray.omrout.s_socks_user_security='none'
|
||||
set v2ray.omrout.s_socks_user_encryption='none'
|
||||
set v2ray.omrout.s_socks_user_alter_id='0'
|
||||
commit v2ray
|
||||
EOF
|
||||
fi
|
||||
|
||||
fi
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue