Skip to content

Commit

Permalink
sync (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan168 authored Jan 24, 2024
2 parents aea489e + 2490378 commit 9b5ee2a
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 31 deletions.
36 changes: 33 additions & 3 deletions luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ function wizard_add()
end
end

-- Enable/disable IPv6
local disableipv6 = luci.http.formvalue("enableipv6") or "1"
ucic:set("openmptcprouter","settings","disable_ipv6",disableipv6)


-- Set interfaces settings
local downloadmax = 0
local uploadmax = 0
Expand Down Expand Up @@ -393,6 +398,10 @@ function wizard_add()
ucic:set("network",intf,"ip6addr",ip6addr:gsub("%s+", ""))
ucic:set("network",intf,"ip6gw",ip6gw:gsub("%s+", ""))
ucic:set("network",intf,"ipv6","1")
elseif proto ~= "static" and proto ~= "dhcp" and disableipv6 ~= "1" then
ucic:set("network",intf,"ip6addr","")
ucic:set("network",intf,"ip6gw","")
ucic:set("network",intf,"ipv6","1")
else
ucic:set("network",intf,"ip6addr","")
ucic:set("network",intf,"ip6gw","")
Expand Down Expand Up @@ -521,9 +530,6 @@ function wizard_add()
ucic:save("network")
ucic:commit("network")

-- Enable/disable IPv6
local disableipv6 = luci.http.formvalue("enableipv6") or "1"
ucic:set("openmptcprouter","settings","disable_ipv6",disableipv6)
--local ut = require "luci.util"
--local result = ut.ubus("openmptcprouter", "set_ipv6_state", { disable_ipv6 = disableipv6 })
local ula = luci.http.formvalue("ula") or ""
Expand Down Expand Up @@ -759,6 +765,7 @@ function wizard_add()
ucic:set("openmptcprouter","settings","proxy",default_proxy)
ucic:save("openmptcprouter")
ucic:save("shadowsocks-libev")
ucic:save("shadowsocks-rust")
ucic:save("v2ray")
ucic:save("xray")

Expand All @@ -770,6 +777,14 @@ function wizard_add()
ucic:delete("openmptcprouter","omr","ss_" .. sectionname)
end
end)
ucic:foreach("shadowsocks-rust","server", function(s)
local sectionname = s[".name"]
if sectionname:match("^sss.*") then
ucic:delete("shadowsocks-rust",sectionname,"ip")
ucic:set("shadowsocks-rust",sectionname,"disabled","1")
ucic:delete("openmptcprouter","omr","ss_" .. sectionname)
end
end)

local ss_servers_nginx = {}
local ss_servers_ha = {}
Expand Down Expand Up @@ -818,15 +833,21 @@ function wizard_add()
if default_proxy == "shadowsocks" and serversnb > disablednb and ssip ~= "" then
ucic:set("shadowsocks-libev","sss" .. nbip,"disabled","0")
end
ucic:set("shadowsocks-rust","sss" .. nbip,"server",ssip)
if default_proxy == "shadowsocks-rust" and serversnb > disablednb and ssip ~= "" then
ucic:set("shadowsocks-rust","sss" .. nbip,"disabled","0")
end
nbip = nbip + 1
if disableipv6 == "1" and nbip > 0 then
ucic:set("shadowsocks-libev","sss" .. nbip,"disabled","1")
ucic:set("shadowsocks-rust","sss" .. nbip,"disabled","1")
break
end
end
if nbip == 1 then
--ucic:set("shadowsocks-libev","sss" .. nbip,"server",server_ip)
ucic:set("shadowsocks-libev","sss" .. nbip,"disabled","1")
ucic:set("shadowsocks-rust","sss" .. nbip,"disabled","1")
end
end
k = k + 1
Expand Down Expand Up @@ -864,6 +885,10 @@ function wizard_add()
if default_proxy == "shadowsocks" and serversnb > disablednb and ssip ~= "" then
ucic:set("shadowsocks-libev","sss" .. nbip,"disabled","0")
end
ucic:set("shadowsocks-rust","sss" .. nbip,"server",ssip)
if default_proxy == "shadowsocks-rust" and serversnb > disablednb and ssip ~= "" then
ucic:set("shadowsocks-rust","sss" .. nbip,"disabled","0")
end
nbip = nbip + 1
if disableipv6 == "1" and nbip > 0 then
break
Expand All @@ -872,6 +897,7 @@ function wizard_add()
if nbip == 1 then
-- ucic:set("shadowsocks-libev","sss" .. nbip,"server",server_ip)
ucic:set("shadowsocks-libev","sss" .. nbip,"disabled","1")
ucic:set("shadowsocks-rust","sss" .. nbip,"disabled","1")
end
end
end
Expand All @@ -894,6 +920,7 @@ function wizard_add()
ucic:save("glorytun-udp")
--ucic:commit("glorytun")
ucic:save("shadowsocks-libev")
ucic:save("shadowsocks-rust")
--ucic:commit("shadowsocks-libev")


Expand Down Expand Up @@ -1059,6 +1086,8 @@ function wizard_add()
ucic:commit("xray")
ucic:save("shadowsocks-libev")
ucic:commit("shadowsocks-libev")
ucic:save("shadowsocks-rust")
ucic:commit("shadowsocks-rust")


-- Set Glorytun settings
Expand Down Expand Up @@ -1218,6 +1247,7 @@ function wizard_add()
-- luci.sys.call("sleep 2")
--end
luci.sys.call("/etc/init.d/shadowsocks-libev restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/shadowsocks-rust restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/glorytun restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/glorytun-udp restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/mlvpn restart >/dev/null 2>/dev/null")
Expand Down
5 changes: 5 additions & 0 deletions luci-app-openmptcprouter/root/bin/anonymous_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ uci show | \
-e "/openvpn\.omr\.remote=/s/......$/xxxxxx'/" \
-e "/shadowsocks-libev\.sss.*\.server=/s/......$/xxxxxx'/" \
-e "/shadowsocks-libev\.sss.*\.key=/s/......$/xxxxxx'/" \
-e "/shadowsocks-rust\.sss.*\.server=/s/......$/xxxxxx'/" \
-e "/shadowsocks-rust\.sss.*\.key=/s/......$/xxxxxx'/" \
-e "/external_ip=/s/......$/xxxxxx'/" \
-e "/obfs_host=/s/..........$/xxxxxx'/" \
-e "/vmess_address=/s/......$/xxxxxx'/" \
-e "/vless_address=/s/......$/xxxxxx'/" \
-e "/trojan_address=/s/......$/xxxxxx'/" \
-e "/socks_address=/s/......$/xxxxxx'/" \
-e "/vless_reality_address=/s/......$/xxxxxx'/" \
-e "/vpn\.key=/s/......$/xxxxxx'/" \
-e "/vps\.key=/s/......$/xxxxxx'/" \
-e "/wgkey=/s/......$/xxxxxx'/" \
Expand Down
4 changes: 2 additions & 2 deletions omr-bypass/files/etc/init.d/omr-bypass-nft
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ _intf_rule() {
uci batch <<-EOF
set firewall.omr_dst_bypass_${intf}_dstip_${ipv46}=rule
set firewall.omr_dst_bypass_${intf}_dstip_${ipv46}.name="omr_dst_bypass_${intf}_rule"
set firewall.omr_dst_bypass_${intf}_dstip_${ipv46}.ipset="omr_dst_bypass_${intf}_4"
set firewall.omr_dst_bypass_${intf}_dstip_${ipv46}.ipset="omr_dst_bypass_${intf}_${ipv46}"
set firewall.omr_dst_bypass_${intf}_dstip_${ipv46}.target='MARK'
set firewall.omr_dst_bypass_${intf}_dstip_${ipv46}.src='lan'
set firewall.omr_dst_bypass_${intf}_dstip_${ipv46}.dest='*'
Expand All @@ -598,7 +598,7 @@ _intf_rule() {
set firewall.omr_dst_bypass_${intf}_dstip_${ipv46}_accept.mark="0x${ipv46}539${count}"
set firewall.omr_dst_bypass_${intf}_srcip_${ipv46}=rule
set firewall.omr_dst_bypass_${intf}_srcip_${ipv46}.name="omr_dst_bypass_${intf}_srcip"
set firewall.omr_dst_bypass_${intf}_srcip_${ipv46}.ipset="omr_dst_bypass_${intf}_4"
set firewall.omr_dst_bypass_${intf}_srcip_${ipv46}.ipset="omr_dst_bypass_${intf}_${ipv46}"
set firewall.omr_dst_bypass_${intf}_srcip_${ipv46}.src='lan'
set firewall.omr_dst_bypass_${intf}_srcip_${ipv46}.dest='*'
set firewall.omr_dst_bypass_${intf}_srcip_${ipv46}.target='MARK'
Expand Down
8 changes: 6 additions & 2 deletions omr-tracker/files/etc/init.d/omr-tracker
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ _initialize_shadowsocks_tracker() {
set shadowsocks-libev.tracker_${server}=ss_local
set shadowsocks-libev.tracker_${server}.server=$server
set shadowsocks-libev.tracker_${server}.local_address="127.0.0.1"
set shadowsocks-libev.tracker_${server}.local_port=1111
set shadowsocks-libev.tracker_${server}.local_port=${count}
set shadowsocks-libev.tracker_${server}.mode=tcp_and_udp
set shadowsocks-libev.tracker_${server}.timeout=600
set shadowsocks-libev.tracker_${server}.fast_open=1
Expand All @@ -233,6 +233,7 @@ _initialize_shadowsocks_tracker() {
# EOF
# /etc/init.d/shadowsocks-libev restart
# }
count=$((count+1))
}

_initialize_shadowsocks_rust_tracker() {
Expand All @@ -252,7 +253,7 @@ _initialize_shadowsocks_rust_tracker() {
set shadowsocks-rust.tracker_${server}=ss_local
set shadowsocks-rust.tracker_${server}.server=$server
set shadowsocks-rust.tracker_${server}.local_address="127.0.0.1"
set shadowsocks-rust.tracker_${server}.local_port=1111
set shadowsocks-rust.tracker_${server}.local_port=${count)
set shadowsocks-rust.tracker_${server}.mode=tcp_and_udp
set shadowsocks-rust.tracker_${server}.timeout=600
set shadowsocks-rust.tracker_${server}.fast_open=0
Expand All @@ -265,6 +266,7 @@ _initialize_shadowsocks_rust_tracker() {
logger -t "omr-tracker" "Restart ShadowSocks"
/etc/init.d/shadowsocks-rust restart
}
count=$((count+1))
}
_launch_shadowsocks_tracker() {
Expand Down Expand Up @@ -406,9 +408,11 @@ start_service() {
local ss_enable=0
local ss_rust_enable=0
logger -t "omr-tracker" "Launching..."
count=1111
config_load shadowsocks-libev
config_foreach _initialize_shadowsocks_tracker server
count=1111
config_load shadowsocks-rust
config_foreach _initialize_shadowsocks_rust_tracker server
Expand Down
62 changes: 38 additions & 24 deletions openmptcprouter-api/files/usr/libexec/rpcd/openmptcprouter
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ function interfaces_status()
local master = uci:get("openmptcprouter",s[".name"],"master") or "1"
local current = uci:get("openmptcprouter",s[".name"],"current") or "0"
for key, value in pairs(serverips) do
serverip = sys.exec('resolveip ' .. value .. ' | head -n 1')
serverip = sys.exec('resolveip ' .. value .. ' | head -n 1 | tr -d "\n"')
if serverip ~= "" and (current == "1" or mArray.openmptcprouter["wan_addr"] == serverip or mArray.openmptcprouter["wan_addr6"] == serverip) and mArray.openmptcprouter["vps_admin"] == false then
mArray.openmptcprouter["vps_omr_version"] = uci:get("openmptcprouter", s[".name"], "omr_version") or ""
mArray.openmptcprouter["vps_kernel"] = uci:get("openmptcprouter",s[".name"],"kernel") or ""
Expand All @@ -904,8 +904,7 @@ function interfaces_status()
local vpsinfo_json = ""
if mArray.openmptcprouter["service_addr_ip"] ~= "" then
vpsinfo_json = sys.exec('curl --max-time ' .. timeout .. ' -s -k -H "Authorization: Bearer ' .. token .. '" https://' .. serverip .. ':' .. adminport .. '/status')
end
if mArray.openmptcprouter["service_addr_ip6"] ~= "" then
elseif mArray.openmptcprouter["service_addr_ip6"] ~= "" then
vpsinfo_json = sys.exec('curl --max-time ' .. timeout .. ' -s -k -H "Authorization: Bearer ' .. token .. '" https://[' .. serverip .. ']:' .. adminport .. '/status')
end
if vpsinfo_json ~= "" and vpsinfo_json ~= nil then
Expand Down Expand Up @@ -991,7 +990,7 @@ function interfaces_status()
mArray.openmptcprouter["vps_admin_error_msg"] = "No result"
uci:set("openmptcprouter",s[".name"],"token_error","1")
mArray.openmptcprouter["vps_admin_error"] = true
uci:delete("openmptcprouter",s[".name"],"token")
--uci:delete("openmptcprouter",s[".name"],"token")
uci:save("openmptcprouter",s[".name"])
uci:commit("openmptcprouter",s[".name"])
end
Expand Down Expand Up @@ -1477,26 +1476,41 @@ function interfaces_status()
local server_ping = ""
local server_http = ""
--if connectivity ~= "ERROR" and ifname ~= "" and gateway ~= "" and gw_ping ~= "DOWN" and ifname ~= nil and mArray.openmptcprouter["service_addr"] ~= "" and ipaddr ~= "" then
if ifname ~= "" and (gateway ~= "" or gateway6 ~= "") and ifname ~= nil and mArray.openmptcprouter["service_addr"] ~= "" and (ipaddr ~= "" or ip6addr ~= "") and connectivity ~= "ERROR" then
local serverip = mArray.openmptcprouter["service_addr"]
if serverip == "127.0.0.1" then
serverip = mArray.openmptcprouter["wan_addr"]
end
if serverip ~= "" and uci:get("openmptcprouter", "settings", "disableserverping") ~= "1" then
local server_ping_test = sys.exec("ping -B -w 1 -c 1 -I " .. ifname .. " " .. serverip)
local server_ping_result = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | grep '100% packet loss'"))
if server_ping_result ~= "" then
server_ping = "DOWN"
if connectivity == "OK" then
connectivity = "WARNING"
end
else
mArray.openmptcprouter["vps_status"] = "UP"
server_ping = "UP"
latency = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | cut -d '/' -s -f5 | cut -d '.' -f1"))
end
end

if ifname ~= "" and (gateway ~= "" or gateway6 ~= "") and ifname ~= nil and (ipaddr ~= "" or ip6addr ~= "") and connectivity ~= "ERROR" then
if uci:get("openmptcprouter", "settings", "disableserverping") ~= "1" then
uci:foreach("openmptcprouter", "server", function(s)
local serverips = uci:get("openmptcprouter",s[".name"],"ip") or { "" }
local master = uci:get("openmptcprouter",s[".name"],"master") or "1"
local current = uci:get("openmptcprouter",s[".name"],"current") or "0"
if current == "1" then
for key, value in pairs(serverips) do
local serverip = mArray.openmptcprouter["service_addr"]
if serverip == "127.0.0.1" then
serverip = mArray.openmptcprouter["wan_addr"]
end
if gateway ~= "" then
serverip = sys.exec('resolveip -4 ' .. value .. ' | head -n 1')
elseif gateway6 ~= "" then
serverip = sys.exec('resolveip -6 ' .. value .. ' | head -n 1')
end
if serverip ~= "" then
local server_ping_test = sys.exec("ping -B -w 1 -c 1 -I " .. ifname .. " " .. serverip)
local server_ping_result = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | grep '100% packet loss'"))
if server_ping_result ~= "" then
server_ping = "DOWN"
if connectivity == "OK" then
connectivity = "WARNING"
end
else
mArray.openmptcprouter["vps_status"] = "UP"
server_ping = "UP"
latency = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | cut -d '/' -s -f5 | cut -d '.' -f1"))
end
end
end
end
end)
end
if adminport == "" then
adminport = "65500"
end
Expand Down
22 changes: 22 additions & 0 deletions shadowsocks-rust/files/shadowsocks-rust.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ config ss_redir hi1
option ipv6_first 1
option no_delay 0

config ss_redir hi2
option server 'sss1'
option local_address '::'
option local_port '1100'
option mode 'tcp_and_udp'
option timeout '1000'
option fast_open 0
option verbose 0
option syslog 1
option reuse_port 0
option mptcp 1
option ipv6_first 1
option no_delay 0

config ss_rules 'ss_rules'
option disabled 0
option redir_tcp 'hi1'
Expand All @@ -28,6 +42,14 @@ config server 'sss0'
option method '2022-blake3-aes-256-gcm'
option obfs 0

config server 'sss1'
option disabled 1
option server '192.168.1.3'
option server_port '65280'
option password ''
option method '2022-blake3-aes-256-gcm'
option obfs 0

config ss_tunnel 'dns'
option disabled 1
option mode 'tcp_and_udp'
Expand Down

0 comments on commit 9b5ee2a

Please sign in to comment.