mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add V2Ray Trojan and VMess protocol support
This commit is contained in:
parent
051577195e
commit
a8387400ba
6 changed files with 139 additions and 14 deletions
|
@ -675,9 +675,16 @@ function wizard_add()
|
|||
ucic:set("shadowsocks-libev",sectionname,"disabled","0")
|
||||
end
|
||||
end)
|
||||
elseif default_proxy == "v2ray" and serversnb > 0 and serversnb > disablednb then
|
||||
elseif (default_proxy == "v2ray" or default_proxy == "v2ray-vmess" or default_proxy == "v2ray-trojan") 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
|
||||
ucic:set("v2ray","omrout","protocol","vless")
|
||||
elseif default_proxy == "v2ray-vmess" then
|
||||
ucic:set("v2ray","omrout","protocol","vmess")
|
||||
elseif default_proxy == "v2ray-trojan" then
|
||||
ucic:set("v2ray","omrout","protocol","trojan")
|
||||
end
|
||||
ucic:foreach("shadowsocks-libev", "server", function(s)
|
||||
local sectionname = s[".name"]
|
||||
ucic:set("shadowsocks-libev",sectionname,"disabled","1")
|
||||
|
@ -733,6 +740,7 @@ function wizard_add()
|
|||
ucic:set("ubond","general","host",server_ip)
|
||||
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)
|
||||
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)
|
||||
|
@ -771,6 +779,7 @@ function wizard_add()
|
|||
ucic:set("ubond","general","host",server_ip)
|
||||
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)
|
||||
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)
|
||||
|
@ -822,6 +831,7 @@ function wizard_add()
|
|||
ucic:set("mlvpn","general","cleartext_data","1")
|
||||
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")
|
||||
elseif encryption == "aes-256-gcm" then
|
||||
ucic:set("openmptcprouter","settings","encryption","aes-256-gcm")
|
||||
ucic:set("shadowsocks-libev","sss0","method","aes-256-gcm")
|
||||
|
@ -832,6 +842,7 @@ function wizard_add()
|
|||
ucic:set("mlvpn","general","cleartext_data","0")
|
||||
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")
|
||||
elseif encryption == "aes-256-cfb" then
|
||||
ucic:set("openmptcprouter","settings","encryption","aes-256-cfb")
|
||||
ucic:set("shadowsocks-libev","sss0","method","aes-256-cfb")
|
||||
|
@ -842,6 +853,7 @@ function wizard_add()
|
|||
ucic:set("mlvpn","general","cleartext_data","0")
|
||||
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")
|
||||
elseif encryption == "chacha20-ietf-poly1305" then
|
||||
ucic:set("openmptcprouter","settings","encryption","chacha20")
|
||||
ucic:set("shadowsocks-libev","sss0","method","chacha20-ietf-poly1305")
|
||||
|
@ -852,6 +864,7 @@ function wizard_add()
|
|||
ucic:set("mlvpn","general","cleartext_data","0")
|
||||
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")
|
||||
else
|
||||
ucic:set("openmptcprouter","settings","encryption","other")
|
||||
end
|
||||
|
@ -892,6 +905,7 @@ function wizard_add()
|
|||
local v2ray_user = luci.http.formvalue("v2ray_user")
|
||||
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:save("v2ray")
|
||||
ucic:commit("v2ray")
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:When proxy V2Ray is used, use it for UDP%></label>
|
||||
<label class="cbi-value-title"><%:When proxy V2Ray VLESS or VMESS is used, use it for UDP%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="checkbox" name="v2rayudp" class="cbi-input-checkbox" value="1" <% if luci.model.uci.cursor():get("v2ray","main_transparent_proxy","redirect_udp") == "1" then %>checked<% end %>>
|
||||
</div>
|
||||
|
|
|
@ -233,12 +233,14 @@
|
|||
<div class="cbi-value-field">
|
||||
<select class="cbi-input-select" name="default_proxy" size="1">
|
||||
<% if nixio.fs.access("/etc/init.d/shadowsocks-libev") then %><option value="shadowsocks" <% if uci:get("openmptcprouter","settings","shadowsocks") == "0" or uci:get("openmptcprouter","settings","proxy") == nil then %>selected="selected"<% end %>>Shadowsocks</option><% end %>
|
||||
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray" then %>selected="selected"<% end %>>V2Ray</option><% end %>
|
||||
<% 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 %>
|
||||
<option value="none" <% if uci:get("openmptcprouter","settings","proxy") == "none" then %>selected="selected"<% end %>>None</option>
|
||||
</select>
|
||||
<br />
|
||||
<div class="cbi-value-description">
|
||||
<%:Set the default Proxy used for TCP when ShadowSocks is enabled, for TCP and UDP when V2Ray is enabled.%>
|
||||
<%:Set the default Proxy used for TCP when ShadowSocks is enabled, for TCP and UDP when V2Ray VLESS or VMESS is enabled.%>
|
||||
<%:Only ShadowSocks is supported with server multiple IPs for now.%>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -942,7 +942,7 @@ _vps_firewall_redirect_port() {
|
|||
#uci -q delete firewall.$1
|
||||
#return
|
||||
fi
|
||||
[ "$(uci -q get v2ray.main.enabled)" = "0" ] && v2ray="0"
|
||||
[ "$(uci -q get v2ray.main.enabled)" = "0" ] && [ "$(uci -q get openmptcprouter.omr.v2ray)" != "down" ] && v2ray="0"
|
||||
[ "$proto" = "all" ] && proto="tcp udp"
|
||||
[ "$proto" = "" ] && proto="tcp udp"
|
||||
[ "$src" = "vpn" ] && [ -n "$proto" ] && [ -n "$src_dport" ] && [ "$enabled" != "0" ] && [ "$name" != "Allow-DHCP-Request-VPN" ] && {
|
||||
|
@ -1425,14 +1425,17 @@ _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_trojan_user_id="$v2ray_key"
|
||||
set v2ray.omrout.s_trojan_port="$((v2ray_port+1))"
|
||||
set v2ray.omrout.s_vmess_user_id="$v2ray_key"
|
||||
set v2ray.omrout.s_vmess_port="$v2ray_port"
|
||||
set v2ray.omrout.s_vmess_port="$((v2ray_port+2))"
|
||||
set v2ray.omrout.s_vless_user_id="$v2ray_key"
|
||||
set v2ray.omrout.s_vless_port="$v2ray_port"
|
||||
EOF
|
||||
if [ "$(uci -q get v2ray.omrout.s_vmess_address)" != "127.0.0.1" ]; then
|
||||
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"
|
||||
fi
|
||||
uci -q commit v2ray
|
||||
logger -t "OMR-VPS" "V2ray restart..."
|
||||
|
|
|
@ -282,6 +282,14 @@ inbound_section_validate() {
|
|||
's_vless_default_user_level:uinteger' \
|
||||
's_vless_detour_to:string' \
|
||||
's_vless_disable_insecure_encryption:bool:0' \
|
||||
's_trojan_client_id:string' \
|
||||
's_trojan_client_alter_id:and(uinteger, max(65535))' \
|
||||
's_trojan_client_email:string' \
|
||||
's_trojan_client_user_level:uinteger' \
|
||||
's_trojan_default_alter_id:and(uinteger, max(65535))' \
|
||||
's_trojan_default_user_level:uinteger' \
|
||||
's_trojan_detour_to:string' \
|
||||
's_trojan_disable_insecure_encryption:bool:0' \
|
||||
'ss_network:or("tcp", "kcp", "ws", "http", "domainsocket", "quic")' \
|
||||
'ss_security:or("none", "tls")' \
|
||||
'ss_tls_server_name:host' \
|
||||
|
@ -368,6 +376,13 @@ outbound_section_validate() {
|
|||
's_vless_user_security:or("auto", "aes-128-gcm", "chacha20-poly1305", "none")' \
|
||||
's_vless_user_encryption:or("auto", "none")' \
|
||||
's_vless_user_level:uinteger' \
|
||||
's_trojan_address:host' \
|
||||
's_trojan_port:port' \
|
||||
's_trojan_user_id:string' \
|
||||
's_trojan_user_alter_id:and(uinteger, max(65535))' \
|
||||
's_trojan_user_security:or("auto", "aes-128-gcm", "chacha20-poly1305", "none")' \
|
||||
's_trojan_user_encryption:or("auto", "none")' \
|
||||
's_trojan_user_level:uinteger' \
|
||||
'ss_network:or("tcp", "kcp", "ws", "http", "domainsocket", "quic")' \
|
||||
'ss_security:or("none", "tls")' \
|
||||
'ss_tls_server_name:host' \
|
||||
|
@ -427,12 +442,12 @@ add_v2ray_redirect_rules() {
|
|||
v2ray-rules -f
|
||||
logger -t "v2ray" "v2ray-rules -l ${port} -L ${port} -s $OUTBOUND_SERVERS_V4 --rule-name def --src-default forward --dst-default forward --local-default forward"
|
||||
commandline="-l ${port} -s $OUTBOUND_SERVERS_V4 --rule-name def --src-default forward --dst-default forward --local-default forward"
|
||||
[ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && commandline="$commandline -L ${port}"
|
||||
[ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && ([ "$(uci -q get v2ray.omrout.protocol)" = "vless" ] || [ "$(uci -q get v2ray.omrout.protocol)" = "vmess" ]) && commandline="$commandline -L ${port}"
|
||||
v2ray-rules $commandline
|
||||
[ "$(uci -q get v2ray.main.inbounds | grep omr6)" != "" ] && {
|
||||
v2ray-rules6 -f
|
||||
commandline="-l $((port+1)) -L $((port+1)) -s $OUTBOUND_SERVERS_V6 --rule-name def --src-default forward --dst-default forward --local-default forward"
|
||||
[ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && commandline="$commandline -L ${port+1}"
|
||||
[ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && ([ "$(uci -q get v2ray.omrout.protocol)" = "vless" ] || [ "$(uci -q get v2ray.omrout.protocol)" = "vmess" ]) && commandline="$commandline -L ${port+1}"
|
||||
v2ray-rules6 $commandline
|
||||
}
|
||||
[ -f /etc/init.d/omr-bypass ] && [ -z "$(pgrep -f omr-bypass)" ] && {
|
||||
|
@ -1066,7 +1081,7 @@ add_inbound_setting() {
|
|||
|
||||
json_close_object # default
|
||||
|
||||
if [ -n "$s_vmess_detour_to" ] ; then
|
||||
if [ -n "$s_vless_detour_to" ] ; then
|
||||
json_add_object "detour"
|
||||
json_add_string "to" "$s_vless_detour_to"
|
||||
json_close_object # detour
|
||||
|
@ -1074,6 +1089,45 @@ add_inbound_setting() {
|
|||
|
||||
json_add_boolean "disableInsecureEncryption" "$s_vless_disable_insecure_encryption"
|
||||
|
||||
json_close_object # settings
|
||||
;;
|
||||
"trojan")
|
||||
json_add_object "settings"
|
||||
|
||||
if [ -n "$s_trojan_client_id" ] ; then
|
||||
json_add_array "clients"
|
||||
json_add_object ""
|
||||
|
||||
json_add_string "password" "$s_trojan_client_id"
|
||||
|
||||
test -n "$s_trojan_client_alter_id" && \
|
||||
json_add_int "alterId" "$s_trojan_client_alter_id"
|
||||
test -n "$s_trojan_client_email" && \
|
||||
json_add_string "email" "$s_trojan_client_email"
|
||||
test -n "$s_trojan_client_user_level" && \
|
||||
json_add_int "level" "$s_trojan_client_user_level"
|
||||
|
||||
json_close_object
|
||||
json_close_array # clients
|
||||
fi
|
||||
|
||||
json_add_object "default"
|
||||
|
||||
test -n "$s_trojan_default_alter_id" && \
|
||||
json_add_int "alterId" "$s_trojan_default_alter_id"
|
||||
test -n "$s_trojan_default_user_level" && \
|
||||
json_add_int "level" "$s_trojan_default_user_level"
|
||||
|
||||
json_close_object # default
|
||||
|
||||
if [ -n "$s_trojan_detour_to" ] ; then
|
||||
json_add_object "detour"
|
||||
json_add_string "to" "$s_trojan_detour_to"
|
||||
json_close_object # detour
|
||||
fi
|
||||
|
||||
json_add_boolean "disableInsecureEncryption" "$s_trojan_disable_insecure_encryption"
|
||||
|
||||
json_close_object # settings
|
||||
;;
|
||||
esac
|
||||
|
@ -1535,7 +1589,25 @@ add_outbound_setting() {
|
|||
|
||||
json_close_object
|
||||
|
||||
json_close_array # vlext
|
||||
json_close_array # vnext
|
||||
json_close_object # settings
|
||||
;;
|
||||
"trojan")
|
||||
json_add_object "settings"
|
||||
|
||||
json_add_array "servers"
|
||||
json_add_object ""
|
||||
|
||||
json_add_string "address" "$s_trojan_address"
|
||||
append_server_address "$s_trojan_address"
|
||||
|
||||
json_add_int "port" "$s_trojan_port"
|
||||
|
||||
json_add_string "password" "$s_trojan_user_id"
|
||||
|
||||
json_close_object
|
||||
|
||||
json_close_array # trojan
|
||||
json_close_object # settings
|
||||
;;
|
||||
esac
|
||||
|
@ -1806,7 +1878,7 @@ init_transparent_proxy() {
|
|||
TRANSPARENT_PROXY_PORT="$redirect_port"
|
||||
TRANSPARENT_PROXY_USE_TPROXY="$use_tproxy"
|
||||
|
||||
if [ "x$redirect_udp" = "x1" ] ; then
|
||||
if [ "x$redirect_udp" = "x1" ] && [ "$(uci -q get v2ray.omrout.protocol)" = "vless" ]; then
|
||||
TRANSPARENT_PROXY_ADDITION="udp"
|
||||
elif [ "x$redirect_dns" = "x1" ] ; then
|
||||
TRANSPARENT_PROXY_ADDITION="dns"
|
||||
|
@ -2115,8 +2187,16 @@ rules_up() {
|
|||
config_load v2ray
|
||||
config_get enabled main enabled "0"
|
||||
[ "$enabled" = "0" ] && return
|
||||
OUTBOUND_SERVERS_V4="$(uci -q get v2ray.omrout.s_vless_address)"
|
||||
OUTBOUND_SERVERS_V6="$(uci -q get v2ray.omrout.s_vless_address)"
|
||||
if [ "$(uci -q get v2ray.omrout.protocol)" = "vless" ]; then
|
||||
OUTBOUND_SERVERS_V4="$(uci -q get v2ray.omrout.s_vless_address)"
|
||||
OUTBOUND_SERVERS_V6="$(uci -q get v2ray.omrout.s_vless_address)"
|
||||
elif [ "$(uci -q get v2ray.omrout.protocol)" = "vmess" ]; then
|
||||
OUTBOUND_SERVERS_V4="$(uci -q get v2ray.omrout.s_vmess_address)"
|
||||
OUTBOUND_SERVERS_V6="$(uci -q get v2ray.omrout.s_vmess_address)"
|
||||
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)"
|
||||
fi
|
||||
TRANSPARENT_PROXY_PORT="$(uci -q get v2ray.omr.port)"
|
||||
[ -n "$OUTBOUND_SERVERS_V4" ] || [ -n "$OUTBOUND_SERVERS_V6" ] && {
|
||||
logger -t "v2ray" "Rules UP"
|
||||
|
|
|
@ -36,7 +36,7 @@ if [ -z "$(uci -q get v2ray.main)" ]; then
|
|||
set v2ray.omrout.tag='omrout_tunnel'
|
||||
set v2ray.omrout.protocol='vless'
|
||||
set v2ray.omrout.s_vmess_address=''
|
||||
set v2ray.omrout.s_vmess_port='65228'
|
||||
set v2ray.omrout.s_vmess_port='65230'
|
||||
set v2ray.omrout.s_vmess_user_id=''
|
||||
set v2ray.omrout.s_vmess_user_security='none'
|
||||
set v2ray.omrout.s_vmess_user_alter_id='0'
|
||||
|
@ -46,6 +46,12 @@ if [ -z "$(uci -q get v2ray.main)" ]; then
|
|||
set v2ray.omrout.s_vless_user_security='none'
|
||||
set v2ray.omrout.s_vless_user_encryption='none'
|
||||
set v2ray.omrout.s_vless_user_alter_id='0'
|
||||
set v2ray.omrout.s_trojan_address=''
|
||||
set v2ray.omrout.s_trojan_port='65229'
|
||||
set v2ray.omrout.s_trojan_user_id=''
|
||||
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.ss_network='tcp'
|
||||
set v2ray.omrout.ss_security='tls'
|
||||
set v2ray.omrout.ss_tls_allow_insecure='1'
|
||||
|
@ -155,4 +161,24 @@ if [ "$(uci -q get v2ray.policy_level_0.conn_idle)" = "2400" ]; then
|
|||
EOF
|
||||
fi
|
||||
|
||||
if [ "$(uci -q get v2ray.omrout.s_vmess_port)" = "65228" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set v2ray.omrout.s_vmess_port='65230'
|
||||
commit v2ray
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "$(uci -q get v2ray.omrout.s_trojan_port)" = "" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set v2ray.omrout.s_trojan_address=''
|
||||
set v2ray.omrout.s_trojan_port='65229'
|
||||
set v2ray.omrout.s_trojan_user_id=''
|
||||
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'
|
||||
commit v2ray
|
||||
EOF
|
||||
fi
|
||||
|
||||
fi
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue