Skip to content

Commit

Permalink
Separate XRay and V2Ray key in wizard, add V2Ray/XRay UDP activation …
Browse files Browse the repository at this point in the history
…in Wizard page
  • Loading branch information
Ysurac committed Nov 15, 2024
1 parent 0b3b88a commit d4e18ee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
20 changes: 15 additions & 5 deletions luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,14 @@ function wizard_add()
luci.sys.call("/etc/init.d/shadowsocks-rust rules_down >/dev/null 2>/dev/null")
end

-- Enable/disable v2ray/xray udp
local v2rayudp = luci.http.formvalue("v2rayudp") or "0"
ucic:set("v2ray","main_transparent_proxy","redirect_udp",v2rayudp)
ucic:save("v2ray")
ucic:commit("v2ray")
ucic:set("xray","main_transparent_proxy","redirect_udp",v2rayudp)
ucic:save("xray")
ucic:commit("xray")

local v2ray_user = luci.http.formvalue("v2ray_user")
ucic:set("v2ray","omrout","s_vmess_user_id",v2ray_user)
Expand All @@ -1084,13 +1092,15 @@ function wizard_add()
ucic:set("v2ray","omrout","s_socks_user_id",v2ray_user)
ucic:save("v2ray")
ucic:commit("v2ray")
ucic:set("xray","omrout","s_vmess_user_id",v2ray_user)
ucic:set("xray","omrout","s_vless_user_id",v2ray_user)
ucic:set("xray","omrout","s_vless_reality_user_id",v2ray_user)
ucic:set("xray","omrout","s_trojan_user_id",v2ray_user)
ucic:set("xray","omrout","s_socks_user_id",v2ray_user)
local xray_user = luci.http.formvalue("xray_user")
ucic:set("xray","omrout","s_vmess_user_id",xray_user)
ucic:set("xray","omrout","s_vless_user_id",xray_user)
ucic:set("xray","omrout","s_vless_reality_user_id",xray_user)
ucic:set("xray","omrout","s_trojan_user_id",xray_user)
ucic:set("xray","omrout","s_socks_user_id",xray_user)
ucic:save("xray")
ucic:commit("xray")

ucic:save("shadowsocks-libev")
ucic:commit("shadowsocks-libev")
ucic:save("shadowsocks-rust")
Expand Down
30 changes: 27 additions & 3 deletions luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,42 @@ <h3><%=servername%></h3>
</div>
</div>
<% end %>
<% if nixio.fs.access("/etc/init.d/v2ray") or nixio.fs.access("/etc/init.d/xray") then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:V2Ray/XRay user id%></label>
<label class="cbi-value-title"><%:V2Ray user id%></label>
<div class="cbi-value-field">
<input type="text" name="v2ray_user" placeholder="<%:V2Ray user%>" class="cbi-input-text" value="<%=uci:get("v2ray","omrout","s_vmess_user_id")%>" />
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:V2Ray is used for TCP and UDP.%>
<%:Key is retrieved from server API by default.%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:XRay user id%></label>
<div class="cbi-value-field">
<input type="text" name="xray_user" placeholder="<%:XRay user%>" class="cbi-input-text" value="<%=uci:get("xray","omrout","s_vmess_user_id")%>" />
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/etc/init.d/xray") or nixio.fs.access("/etc/init.d/v2ray") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:V2Ray/XRay 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" or luci.model.uci.cursor():get("xray","main_transparent_proxy","redirect_udp") == "1" then %>checked<% end %>>
<br />
<div class="cbi-value-description">
<%:When proxy V2Ray/XRay VLESS, VMESS or Trojan is used, use it for UDP%>
</div>
</div>
</div>
<% end %>
<div class="cbi-value">
<label class="cbi-value-title"><%:Encryption%></label>
<div class="cbi-value-field">
Expand Down

0 comments on commit d4e18ee

Please sign in to comment.