mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-12 18:41:51 +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
|
@ -675,7 +675,7 @@ function wizard_add()
|
|||
ucic:set("shadowsocks-libev",sectionname,"disabled","0")
|
||||
end
|
||||
end)
|
||||
elseif (default_proxy == "v2ray" or default_proxy == "v2ray-vmess" or default_proxy == "v2ray-trojan") and serversnb > 0 and serversnb > disablednb then
|
||||
elseif (default_proxy == "v2ray" or default_proxy == "v2ray-vmess" or default_proxy == "v2ray-trojan" or default_proxy == "v2ray-socks") and serversnb > 0 and serversnb > disablednb then
|
||||
--ucic:set("shadowsocks-libev","sss0","disabled","1")
|
||||
ucic:set("v2ray","main","enabled","1")
|
||||
if default_proxy == "v2ray" then
|
||||
|
@ -684,6 +684,8 @@ function wizard_add()
|
|||
ucic:set("v2ray","omrout","protocol","vmess")
|
||||
elseif default_proxy == "v2ray-trojan" then
|
||||
ucic:set("v2ray","omrout","protocol","trojan")
|
||||
elseif default_proxy == "v2ray-socks" then
|
||||
ucic:set("v2ray","omrout","protocol","socks")
|
||||
end
|
||||
ucic:foreach("shadowsocks-libev", "server", function(s)
|
||||
local sectionname = s[".name"]
|
||||
|
@ -741,6 +743,7 @@ function wizard_add()
|
|||
ucic:set("v2ray","omrout","s_vmess_address",server_ip)
|
||||
ucic:set("v2ray","omrout","s_vless_address",server_ip)
|
||||
ucic:set("v2ray","omrout","s_trojan_address",server_ip)
|
||||
ucic:set("v2ray","omrout","s_socks_address",server_ip)
|
||||
luci.sys.call("uci -q del openvpn.omr.remote")
|
||||
luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip)
|
||||
ucic:set("qos","serverin","srchost",server_ip)
|
||||
|
@ -780,6 +783,7 @@ function wizard_add()
|
|||
ucic:set("v2ray","omrout","s_vmess_address",server_ip)
|
||||
ucic:set("v2ray","omrout","s_vless_address",server_ip)
|
||||
ucic:set("v2ray","omrout","s_trojan_address",server_ip)
|
||||
ucic:set("v2ray","omrout","s_socks_address",server_ip)
|
||||
luci.sys.call("uci -q del openvpn.omr.remote")
|
||||
luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip)
|
||||
ucic:set("qos","serverin","srchost",server_ip)
|
||||
|
@ -832,6 +836,7 @@ function wizard_add()
|
|||
ucic:set("v2ray","omrout","s_vmess_user_security","none")
|
||||
ucic:set("v2ray","omrout","s_vless_user_security","none")
|
||||
ucic:set("v2ray","omrout","s_trojan_user_security","none")
|
||||
ucic:set("v2ray","omrout","s_socks_user_security","none")
|
||||
elseif encryption == "aes-256-gcm" then
|
||||
ucic:set("openmptcprouter","settings","encryption","aes-256-gcm")
|
||||
ucic:set("shadowsocks-libev","sss0","method","aes-256-gcm")
|
||||
|
@ -843,6 +848,7 @@ function wizard_add()
|
|||
ucic:set("v2ray","omrout","s_vmess_user_security","aes-128-gcm")
|
||||
ucic:set("v2ray","omrout","s_vless_user_security","aes-128-gcm")
|
||||
ucic:set("v2ray","omrout","s_trojan_user_security","aes-128-gcm")
|
||||
ucic:set("v2ray","omrout","s_socks_user_security","aes-128-gcm")
|
||||
elseif encryption == "aes-256-cfb" then
|
||||
ucic:set("openmptcprouter","settings","encryption","aes-256-cfb")
|
||||
ucic:set("shadowsocks-libev","sss0","method","aes-256-cfb")
|
||||
|
@ -854,6 +860,7 @@ function wizard_add()
|
|||
ucic:set("v2ray","omrout","s_vmess_user_security","aes-128-gcm")
|
||||
ucic:set("v2ray","omrout","s_vless_user_security","aes-128-gcm")
|
||||
ucic:set("v2ray","omrout","s_trojan_user_security","aes-128-gcm")
|
||||
ucic:set("v2ray","omrout","s_socks_user_security","aes-128-gcm")
|
||||
elseif encryption == "chacha20-ietf-poly1305" then
|
||||
ucic:set("openmptcprouter","settings","encryption","chacha20")
|
||||
ucic:set("shadowsocks-libev","sss0","method","chacha20-ietf-poly1305")
|
||||
|
@ -865,6 +872,7 @@ function wizard_add()
|
|||
ucic:set("v2ray","omrout","s_vmess_user_security","chacha20-poly1305")
|
||||
ucic:set("v2ray","omrout","s_vless_user_security","chacha20-poly1305")
|
||||
ucic:set("v2ray","omrout","s_trojan_user_security","chacha20-poly1305")
|
||||
ucic:set("v2ray","omrout","s_socks_user_security","chacha20-poly1305")
|
||||
else
|
||||
ucic:set("openmptcprouter","settings","encryption","other")
|
||||
end
|
||||
|
@ -906,6 +914,7 @@ function wizard_add()
|
|||
ucic:set("v2ray","omrout","s_vmess_user_id",v2ray_user)
|
||||
ucic:set("v2ray","omrout","s_vless_user_id",v2ray_user)
|
||||
ucic:set("v2ray","omrout","s_trojan_user_id",v2ray_user)
|
||||
ucic:set("v2ray","omrout","s_socks_user_id",v2ray_user)
|
||||
ucic:save("v2ray")
|
||||
ucic:commit("v2ray")
|
||||
|
||||
|
|
|
@ -236,6 +236,7 @@
|
|||
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray" then %>selected="selected"<% end %>>V2Ray VLESS</option><% end %>
|
||||
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-vmess" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-vmess" then %>selected="selected"<% end %>>V2Ray VMESS</option><% end %>
|
||||
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-trojan" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-trojan" then %>selected="selected"<% end %>>V2Ray TROJAN</option><% end %>
|
||||
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-socks" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-socks" then %>selected="selected"<% end %>>V2Ray SOCKS</option><% end %>
|
||||
<option value="none" <% if uci:get("openmptcprouter","settings","proxy") == "none" then %>selected="selected"<% end %>>None</option>
|
||||
</select>
|
||||
<br />
|
||||
|
@ -245,7 +246,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if nixio.fs.access("/etc/init.d/shadowsocks-libev") then %>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:ShadowSocks key%></label>
|
||||
<div class="cbi-value-field">
|
||||
|
@ -256,6 +257,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if nixio.fs.access("/etc/init.d/v2ray") then %>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:V2Ray user id%></label>
|
||||
<div class="cbi-value-field">
|
||||
|
@ -266,6 +269,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Encryption%></label>
|
||||
<div class="cbi-value-field">
|
||||
|
|
|
@ -1425,6 +1425,8 @@ _set_config_from_vps() {
|
|||
v2ray_port="65228"
|
||||
if ([ -n "$v2ray_key" ] && [ "$v2ray_key" != "$(uci -q get v2ray.omrout.s_vmess_user_id)" ]) || ([ -n "$v2ray_port" ] && [ "$v2ray_port" != "$(uci -q get v2ray.omrout.s_vmess.port)" ]); then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set v2ray.omrout.s_socks_user_id="$v2ray_key"
|
||||
set v2ray.omrout.s_socks_port="$((v2ray_port+1))"
|
||||
set v2ray.omrout.s_trojan_user_id="$v2ray_key"
|
||||
set v2ray.omrout.s_trojan_port="$((v2ray_port+1))"
|
||||
set v2ray.omrout.s_vmess_user_id="$v2ray_key"
|
||||
|
@ -1436,6 +1438,7 @@ _set_config_from_vps() {
|
|||
uci -q set v2ray.omrout.s_vmess_address="$vpsip"
|
||||
uci -q set v2ray.omrout.s_vless_address="$vpsip"
|
||||
uci -q set v2ray.omrout.s_trojan_address="$vpsip"
|
||||
uci -q set v2ray.omrout.s_socks_address="$vpsip"
|
||||
fi
|
||||
uci -q commit v2ray
|
||||
logger -t "OMR-VPS" "V2ray restart..."
|
||||
|
|
|
@ -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…
Reference in a new issue