luci-app-vssr: bump to 1.20

This commit is contained in:
CN_SZTL 2020-12-13 00:57:45 +08:00
parent 3cc83b9b46
commit 99b6e832c1
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
25 changed files with 406 additions and 252 deletions

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-vssr PKG_NAME:=luci-app-vssr
PKG_VERSION:=1.19 PKG_VERSION:=1.20
PKG_RELEASE:=20201205 PKG_RELEASE:=20201209
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk

View File

@ -13,10 +13,11 @@ function index()
entry({'admin', 'services', 'vssr', 'servers'}, cbi('vssr/servers'), _('Severs Nodes'), 11).leaf = true -- 服务器节点 entry({'admin', 'services', 'vssr', 'servers'}, cbi('vssr/servers'), _('Severs Nodes'), 11).leaf = true -- 服务器节点
entry({'admin', 'services', 'vssr', 'servers'}, arcombine(cbi('vssr/servers'), cbi('vssr/client-config')), _('Severs Nodes'), 11).leaf = true -- 编辑节点 entry({'admin', 'services', 'vssr', 'servers'}, arcombine(cbi('vssr/servers'), cbi('vssr/client-config')), _('Severs Nodes'), 11).leaf = true -- 编辑节点
entry({'admin', 'services', 'vssr', 'control'}, cbi('vssr/control'), _('Access Control'), 12).leaf = true -- 访问控制 entry({'admin', 'services', 'vssr', 'control'}, cbi('vssr/control'), _('Access Control'), 12).leaf = true -- 访问控制
if nixio.fs.access('/usr/bin/v2ray/v2ray') then entry({'admin', 'services', 'vssr', 'router'}, cbi('vssr/router'), _('Router Config'), 13).leaf = true -- 访问控制
entry({'admin', 'services', 'vssr', 'socks5'}, cbi('vssr/socks5'), _('Socks5'), 13).leaf = true -- Socks5代理 if nixio.fs.access('/usr/bin/v2ray/v2ray') or nixio.fs.access('/usr/bin/v2ray') or nixio.fs.access('/usr/bin/xray') or nixio.fs.access('/usr/bin/xray/xray') then
entry({'admin', 'services', 'vssr', 'socks5'}, cbi('vssr/socks5'), _('Socks5'), 14).leaf = true -- Socks5代理
end end
entry({'admin', 'services', 'vssr', 'advanced'}, cbi('vssr/advanced'), _('Advanced Settings'), 14).leaf = true -- 高级设置 entry({'admin', 'services', 'vssr', 'advanced'}, cbi('vssr/advanced'), _('Advanced Settings'), 15).leaf = true -- 高级设置
elseif nixio.fs.access('/usr/bin/ssr-server') then elseif nixio.fs.access('/usr/bin/ssr-server') then
entry({'admin', 'services', 'vssr'}, alias('admin', 'services', 'vssr', 'server'), _('vssr'), 10).dependent = true entry({'admin', 'services', 'vssr'}, alias('admin', 'services', 'vssr', 'server'), _('vssr'), 10).dependent = true
else else
@ -39,6 +40,7 @@ function index()
entry({'admin', 'services', 'vssr', 'flag'}, call('get_flag')) -- 获取节点国旗 iso code entry({'admin', 'services', 'vssr', 'flag'}, call('get_flag')) -- 获取节点国旗 iso code
entry({'admin', 'services', 'vssr', 'ip'}, call('check_ip')) -- 获取ip情况 entry({'admin', 'services', 'vssr', 'ip'}, call('check_ip')) -- 获取ip情况
entry({'admin', 'services', 'vssr', 'switch'}, call('switch')) -- 设置节点为自动切换 entry({'admin', 'services', 'vssr', 'switch'}, call('switch')) -- 设置节点为自动切换
entry({'admin', 'services', 'vssr', 'delnode'}, call('del_node')) -- 删除某个节点
end end
-- 执行订阅 -- 执行订阅
@ -86,6 +88,23 @@ function get_servers()
luci.http.write_json(server_table) luci.http.write_json(server_table)
end end
-- 删除指定节点
function del_node()
local e = {}
local uci = luci.model.uci.cursor()
local node = luci.http.formvalue('node')
e.status = false
e.node = node
if node ~= '' then
uci:delete('vssr', node)
uci:save('vssr')
uci:commit('vssr')
e.status = true
end
luci.http.prepare_content('application/json')
luci.http.write_json(e)
end
-- 切换节点 -- 切换节点
function change_node() function change_node()
local sockets = require 'socket' local sockets = require 'socket'
@ -246,7 +265,7 @@ function refresh_data()
retstring = '-1' retstring = '-1'
end end
elseif set == 'ip_data' then elseif set == 'ip_data' then
refresh_cmd = "wget -O- 'https://ispip.clang.cn/all_cn.txt' > /tmp/china_ssr.txt" refresh_cmd ="wget -O- 'https://ispip.clang.cn/all_cn.txt' > /tmp/china_ssr.txt 2>/dev/null"
sret = luci.sys.call(refresh_cmd) sret = luci.sys.call(refresh_cmd)
icount = luci.sys.exec('cat /tmp/china_ssr.txt | wc -l') icount = luci.sys.exec('cat /tmp/china_ssr.txt | wc -l')
if sret == 0 and tonumber(icount) > 1000 then if sret == 0 and tonumber(icount) > 1000 then
@ -300,4 +319,4 @@ function refresh_data()
end end
luci.http.prepare_content('application/json') luci.http.prepare_content('application/json')
luci.http.write_json({ret = retstring, retcount = icount}) luci.http.write_json({ret = retstring, retcount = icount})
end end

View File

@ -129,7 +129,7 @@ o:value('ssr', translate('ShadowsocksR'))
if nixio.fs.access('/usr/bin/ss-redir') then if nixio.fs.access('/usr/bin/ss-redir') then
o:value('ss', translate('Shadowsocks New Version')) o:value('ss', translate('Shadowsocks New Version'))
end end
if nixio.fs.access('/usr/bin/v2ray/v2ray') or nixio.fs.access('/usr/bin/v2ray') then if nixio.fs.access('/usr/bin/v2ray/v2ray') or nixio.fs.access('/usr/bin/v2ray') or nixio.fs.access('/usr/bin/xray') or nixio.fs.access('/usr/bin/xray/xray') then
o:value('v2ray', translate('V2Ray')) o:value('v2ray', translate('V2Ray'))
o:value('vless', translate('VLESS')) o:value('vless', translate('VLESS'))
end end

View File

@ -6,7 +6,7 @@ local vssr = 'vssr'
local gfwmode = 0 local gfwmode = 0
if nixio.fs.access('/etc/dnsmasq.ssr/gfw_list.conf') then if nixio.fs.access('/etc/vssr/gfw_list.conf') then
gfwmode = 1 gfwmode = 1
end end
@ -26,9 +26,12 @@ uci:foreach(
'vssr', 'vssr',
'servers', 'servers',
function(s) function(s)
s['name'] = s['.name'] if s.type ~= nil then
s['gname'] = '[%s]:%s' % {string.upper(s.type), s.alias} s['name'] = s['.name']
table.insert(server_table, s) local alias = (s.alias ~= nil) and s.alias or "未命名节点"
s['gname'] = '[%s]:%s' % {string.upper(s.type), alias}
table.insert(server_table, s)
end
end end
) )
function my_sort(a,b) function my_sort(a,b)
@ -52,7 +55,7 @@ local route_label = {
'Youtube Proxy', 'Youtube Proxy',
'TaiWan Video Proxy', 'TaiWan Video Proxy',
'Netflix Proxy', 'Netflix Proxy',
'Diseny+ Proxy', 'Disney+ Proxy',
'Prime Video Proxy', 'Prime Video Proxy',
'TVB Video Proxy', 'TVB Video Proxy',
'Custom Proxy' 'Custom Proxy'
@ -119,7 +122,6 @@ o:value('router', translate('IP Route Mode'))
o:value('all', translate('Global Mode')) o:value('all', translate('Global Mode'))
o:value('oversea', translate('Oversea Mode')) o:value('oversea', translate('Oversea Mode'))
o.default = 'router' o.default = 'router'
o = s:option(ListValue, 'dports', translate('Proxy Ports')) o = s:option(ListValue, 'dports', translate('Proxy Ports'))
o:value('1', translate('All Ports')) o:value('1', translate('All Ports'))
o:value('2', translate('Only Common Ports')) o:value('2', translate('Only Common Ports'))

View File

@ -18,16 +18,21 @@ o.datatype = 'ip4addr'
-- Part of LAN -- Part of LAN
s:tab('lan_ac', translate('LAN IP AC')) s:tab('lan_ac', translate('LAN IP AC'))
o = s:taboption('lan_ac', DynamicList, 'lan_ac_ips', translate('LAN Bypassed Host List')) o = s:taboption("lan_ac", ListValue, "lan_ac_mode", translate("LAN Access Control"))
o.datatype = 'ipaddr' o:value("0", translate("Disable"))
luci.ip.neighbors( o:value("w", translate("Allow listed only"))
{family = 4}, o:value("b", translate("Allow all except listed"))
function(entry) o.rmempty = false
if entry.reachable then
o:value(entry.dest:string()) o = s:taboption("lan_ac", DynamicList, "lan_ac_ips", translate("LAN Host List"))
end o.datatype = "ipaddr"
end luci.ip.neighbors({ family = 4 }, function(entry)
) if entry.reachable then
o:value(entry.dest:string())
end
end)
o:depends("lan_ac_mode", "w")
o:depends("lan_ac_mode", "b")
o = s:taboption('lan_ac', DynamicList, 'lan_fp_ips', translate('LAN Force Proxy Host List')) o = s:taboption('lan_ac', DynamicList, 'lan_fp_ips', translate('LAN Force Proxy Host List'))
o.datatype = 'ipaddr' o.datatype = 'ipaddr'
@ -93,9 +98,4 @@ o.remove = function(self, section, value)
NXFS.writefile(blockconf, '') NXFS.writefile(blockconf, '')
end end
s:tab('proxy', translate('Custom Proxy Domain Name')) return m
o = s:taboption('proxy', DynamicList, 'proxy_domain_name', translate('Proxy Domain Name'))
o.datatype = 'hostname'
return m

View File

@ -0,0 +1,55 @@
local m, s, o
local NXFS = require 'nixio.fs'
local router_table = {
yotube = {
name = 'youtube',
des = 'Youtube Domain'
},
tw_video = {
name = 'tw_video',
des = 'Tw Video Domain'
},
netflix = {
name = 'netflix',
des = 'Netflix Domain'
},
disney = {
name = 'disney',
des = 'Disney+ Domain'
},
prime = {
name = 'prime',
des = 'Prime Video Domain'
},
tvb = {
name = 'tvb',
des = 'TVB Domain'
},
custom = {
name = 'custom',
des = 'Custom Domain'
}
}
m = Map('vssr', translate('Router domain config'))
s = m:section(TypedSection, 'access_control')
s.anonymous = true
for _, v in pairs(router_table) do
s:tab(v.name, translate(v.des))
local conf = '/etc/vssr/'.. v.name ..'_domain.list'
o = s:taboption(v.name, TextValue, v.name ..'conf')
o.rows = 13
o.wrap = 'off'
o.rmempty = true
o.cfgvalue = function(self, section)
return NXFS.readfile(conf) or ' '
end
o.write = function(self, section, value)
NXFS.writefile(conf, value:gsub('\r\n', '\n'))
end
o.remove = function(self, section, value)
NXFS.writefile(conf, '')
end
end
return m

View File

@ -12,6 +12,9 @@ uci:foreach(
function(s) function(s)
server_count = server_count + 1 server_count = server_count + 1
s['name'] = s['.name'] s['name'] = s['.name']
if(s.alias == nil) then
s.alias = "未命名节点"
end
table.insert(server_table, s) table.insert(server_table, s)
end end
) )

View File

@ -7,7 +7,7 @@ local sys = require 'luci.sys'
m = Map(vssr) m = Map(vssr)
-- [[ SOCKS5 Proxy ]]-- -- [[ SOCKS5 Proxy ]]--
if nixio.fs.access('/usr/bin/v2ray/v2ray') then if nixio.fs.access('/usr/bin/v2ray/v2ray') or nixio.fs.access('/usr/bin/v2ray') or nixio.fs.access('/usr/bin/xray') or nixio.fs.access('/usr/bin/xray/xray') then
s = m:section(TypedSection, 'socks5_proxy', translate('V2ray SOCKS5 Proxy')) s = m:section(TypedSection, 'socks5_proxy', translate('V2ray SOCKS5 Proxy'))
s.anonymous = true s.anonymous = true

View File

@ -219,7 +219,7 @@
} }
el('.server').value = part2[0]; el('.server').value = part2[0];
el('.server_port').value = others[0]; el('.server_port').value = others[0];
el('.password').value = part1[1]; el('.password').value = part1[0];
if (queryParam.peer || queryParam.sni) { if (queryParam.peer || queryParam.sni) {
el('.tls').checked = true; el('.tls').checked = true;
el('.peer').value = queryParam.peer || queryParam.sni; el('.peer').value = queryParam.peer || queryParam.sni;

View File

@ -1,7 +1,6 @@
<script type="text/javascript" src="/luci-static/vssr/emoji.js?v=1.16"></script> <script type="text/javascript" src="/luci-static/vssr/emoji.js?v=1.16"></script>
<script type="text/javascript" src="/luci-static/vssr/sweetalert.js?v=1.16"></script> <script type="text/javascript" src="/luci-static/vssr/sweetalert.js?v=1.16"></script>
<script type="text/javascript" src="/luci-static/vssr/polyfill.js?v=1.16"></script> <script type="text/javascript" src="/luci-static/vssr/polyfill.js?v=1.16"></script>
<!-- tblsection --> <!-- tblsection -->
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>"> <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
<button class="cbi-button cbi-button-check "><%:Ping All Servers%></button><span class="panel-title">总计 <button class="cbi-button cbi-button-check "><%:Ping All Servers%></button><span class="panel-title">总计
@ -39,10 +38,9 @@
%> onclick="location.href='<%=self:extedit(section.name)%>'" <%- end %> onclick="location.href='<%=self:extedit(section.name)%>'" <%- end
%> alt="<%:Edit%>" title="<%:Edit%>"><span class="icon-edit"></span> <%:Edit%></a> %> alt="<%:Edit%>" title="<%:Edit%>"><span class="icon-edit"></span> <%:Edit%></a>
<%- end; if self.addremove then %> <%- end; if self.addremove then %>
<button class="cbi-button ssr-button" type="submit" value="" <a class="cbi-button ssr-button" type="button" value="" onclick="delete_node('<%=section.name%>')"
onclick="this.form.cbi_state = 'del-section'; return true" alt="<%:Delete%>" title="<%:Delete%>" /><span
name="cbi.rts.<%=self.config%>.<%=section.name%>" alt="<%:Delete%>" title="<%:Delete%>" /><span class="icon-delete"></span> <%:Delete%></a>
class="icon-delete"></span> <%:Delete%></button>
<%- end -%> <%- end -%>
</div> </div>
<%- end -%> <%- end -%>
@ -93,6 +91,7 @@
const CONFIG = '<%=self.config%>'; const CONFIG = '<%=self.config%>';
const CURRENT = '<%=self.current%>'; const CURRENT = '<%=self.current%>';
const CHANGE_NODE_URL = '<%=luci.dispatcher.build_url("admin", "services", "vssr","change")%>'; const CHANGE_NODE_URL = '<%=luci.dispatcher.build_url("admin", "services", "vssr","change")%>';
const DELETE_NODE_URL = '<%=luci.dispatcher.build_url("admin", "services", "vssr","delnode")%>';
const CHECK_PING_URL = '<%=luci.dispatcher.build_url("admin", "services", "vssr","checkport")%>'; const CHECK_PING_URL = '<%=luci.dispatcher.build_url("admin", "services", "vssr","checkport")%>';
const SWITCH_NODE_URL = '<%=luci.dispatcher.build_url("admin", "services", "vssr","switch")%>'; const SWITCH_NODE_URL = '<%=luci.dispatcher.build_url("admin", "services", "vssr","switch")%>';
@ -166,6 +165,21 @@
} }
}) })
} }
//删除节点
function delete_node(node){
XHR.halt();
$.each(ajaxArray, function (n, value) { value.abort(); }) //中断所有的ajax请求
$.get(DELETE_NODE_URL, { node: node },
function (data, status) {
if (data.status) {
var id = '#cbi-<%=self.config%>-' + node;
$(id).parent().remove();
XHR.run();
check()
}
});
}
//设定自动切换 //设定自动切换
$(".incon").click(function () { $(".incon").click(function () {

View File

@ -630,8 +630,8 @@ msgstr "台湾视频服务代理"
msgid "Netflix Proxy" msgid "Netflix Proxy"
msgstr "Netflix 代理" msgstr "Netflix 代理"
msgid "Diseny+ Proxy" msgid "Disney+ Proxy"
msgstr "Diseny+ 代理" msgstr "Disney+ 代理"
msgid "Prime Video Proxy" msgid "Prime Video Proxy"
msgstr "Prime Video 代理" msgstr "Prime Video 代理"
@ -674,3 +674,30 @@ msgstr "VLESS 加密"
msgid "You can manually add group names in front of the URL, splited by ," msgid "You can manually add group names in front of the URL, splited by ,"
msgstr "你可以在URL前面手动添加组名使用 , 分隔" msgstr "你可以在URL前面手动添加组名使用 , 分隔"
msgid "Router Config"
msgstr "分流设置"
msgid "Router domain config"
msgstr "分流域名设置"
msgid "Youtube Domain"
msgstr "YouTube 域名"
msgid "Tw Video Domain"
msgstr "台湾视频域名"
msgid "Netflix Domain"
msgstr "Netflix 域名"
msgid "Disney+ Domain"
msgstr "Disney+ 域名"
msgid "Prime Video Domain"
msgstr "Prime Video 域名"
msgid "TVB Domain"
msgstr "TVB 域名"
msgid "Custom Domain"
msgstr "自定义域名"

5
package/ctcgfw/luci-app-vssr/root/etc/config/vssr Normal file → Executable file
View File

@ -2,7 +2,7 @@
config global config global
option tunnel_forward '8.8.4.4:53' option tunnel_forward '8.8.4.4:53'
option tunnel_address '0.0.0.0' option tunnel_address '0.0.0.0'
option run_mode 'gfw' option run_mode 'router'
option pdnsd_enable '1' option pdnsd_enable '1'
option monitor_enable '1' option monitor_enable '1'
option global_server 'nil' option global_server 'nil'
@ -11,7 +11,7 @@ config global
option switch_time '667' option switch_time '667'
option switch_try_count '3' option switch_try_count '3'
option adblock '0' option adblock '0'
option dports '2' option dports '1'
config socks5_proxy config socks5_proxy
option enable_server '0' option enable_server '0'
@ -38,6 +38,7 @@ config server_subscribe
option proxy '0' option proxy '0'
option auto_update_time '2' option auto_update_time '2'
option auto_update '1' option auto_update '1'
option filter_words '过期时间/剩余流量'

View File

@ -1,4 +1,4 @@
#!/bin/bash /etc/rc.common #!/bin/sh /etc/rc.common
# #
# Copyright (C) 2017 openwrt-ssr # Copyright (C) 2017 openwrt-ssr
# Copyright (C) 2017 yushi studio <ywb94@qq.com> # Copyright (C) 2017 yushi studio <ywb94@qq.com>
@ -8,7 +8,7 @@
# See /LICENSE for more information. # See /LICENSE for more information.
# #
START=90 START=99
STOP=15 STOP=15
extra_command "rules" extra_command "rules"
@ -35,9 +35,6 @@ switch_server=$1
MAXFD=32768 MAXFD=32768
CRON_FILE=/etc/crontabs/root CRON_FILE=/etc/crontabs/root
threads=1 threads=1
shunt_type=("global" "youtube" "tw_video" "netflix" "disney" "prime" "tvb" "custom")
shunt_port=(2080 2081 2082 2083 2084 2085 2086 2087)
shunt_array=("youtube" "tw_video" "netflix" "disney" "prime" "tvb" "custom")
scount=0 scount=0
uci_get_by_name() { uci_get_by_name() {
local ret=$(uci get $NAME.$1.$2 2>/dev/null) local ret=$(uci get $NAME.$1.$2 2>/dev/null)
@ -63,14 +60,23 @@ del_cron() {
} }
count_shunt() { count_shunt() {
scount=0 scount=0
for ((i = 0; i < ${#shunt_array[@]}; i++)); do eval shunt_array1="youtube"
local server_index=$(uci_get_by_type global ${shunt_array[i]}_server) eval shunt_array2="tw_video"
eval shunt_array3="netflix"
eval shunt_array4="disney"
eval shunt_array5="prime"
eval shunt_array6="tvb"
eval shunt_array7="custom"
for i in 1 2 3 4 5 6 7; do
a=$(eval echo "\$shunt_array$i")
local server_index=$(uci_get_by_type global ${a}_server)
local server_type=$(uci_get_by_name $server_index type) local server_type=$(uci_get_by_name $server_index type)
if [ "$server_type" != "" ]; then if [ "$server_type" != "" ]; then
scount=$(($scount + 1)) scount=$(($scount + 1))
fi fi
done done
} }
count_shunt count_shunt
run_mode=$(uci_get_by_type global run_mode) run_mode=$(uci_get_by_type global run_mode)
is_xray=$(uci_get_by_type global use_xray) is_xray=$(uci_get_by_type global use_xray)
@ -149,7 +155,7 @@ start_rules() {
local local_port=$(uci_get_by_name $GLOBAL_SERVER local_port) local local_port=$(uci_get_by_name $GLOBAL_SERVER local_port)
local lan_ac_ips=$(uci_get_by_type access_control lan_ac_ips) local lan_ac_ips=$(uci_get_by_type access_control lan_ac_ips)
local lan_ac_mode="b" local lan_ac_mode=$(uci_get_by_type access_control lan_ac_mode)
local router_proxy=$(uci_get_by_type access_control router_proxy) local router_proxy=$(uci_get_by_type access_control router_proxy)
if [ "$GLOBAL_SERVER" == "$UDP_RELAY_SERVER" -a $kcp_flag == 0 ]; then if [ "$GLOBAL_SERVER" == "$UDP_RELAY_SERVER" -a $kcp_flag == 0 ]; then
ARG_UDP="-u" ARG_UDP="-u"
@ -228,43 +234,34 @@ start_pdnsd() {
chown -R nobody:nogroup /var/pdnsd chown -R nobody:nogroup /var/pdnsd
fi fi
cat >/var/etc/pdnsd.conf <<EOF cat <<-EOF >/var/etc/pdnsd.conf
global { global{
perm_cache=1024; perm_cache=1024;
cache_dir="/var/pdnsd"; cache_dir="/var/pdnsd";
pid_file = /var/run/pdnsd.pid; pid_file="/var/run/pdnsd.pid";
run_as="nobody"; run_as="nobody";
server_ip = 127.0.0.1; server_ip=127.0.0.1;
server_port = 5335; server_port=5335;
status_ctl = on; status_ctl=on;
query_method = tcp_only; query_method=tcp_only;
min_ttl=1h; min_ttl=1h;
max_ttl=1w; max_ttl=1w;
timeout=10; timeout=10;
neg_domain_pol=on; neg_domain_pol=on;
proc_limit=2; proc_limit=2;
procq_limit=8; procq_limit=8;
} par_queries=1;
server { }
label= "ssr-usrdns"; server{
ip = $usr_dns; label="ssr-usrdns";
port = $usr_port; ip=$usr_dns;
timeout=6; port=$usr_port;
uptest=none; timeout=6;
interval=10m; uptest=none;
purge_cache=off; interval=10m;
} purge_cache=off;
server { }
label= "ssr-pdnsd"; EOF
ip = $tcp_dns_list;
port = 5353;
timeout=6;
uptest=none;
interval=10m;
purge_cache=off;
}
EOF
/usr/sbin/pdnsd -c /var/etc/pdnsd.conf & /usr/sbin/pdnsd -c /var/etc/pdnsd.conf &
} }
@ -275,30 +272,47 @@ find_bin() {
ssr) ret="/usr/bin/ssr-redir" ;; ssr) ret="/usr/bin/ssr-redir" ;;
ssr-local) ret="/usr/bin/ssr-local" ;; ssr-local) ret="/usr/bin/ssr-local" ;;
ssr-server) ret="/usr/bin/ssr-server" ;; ssr-server) ret="/usr/bin/ssr-server" ;;
v2ray | vless) v2ray | vless)
ret="/usr/bin/v2ray/v2ray" && [ ! -f "$ret" ] && ret="/usr/bin/v2ray" ret="/usr/bin/v2ray/v2ray" && [ ! -f "$ret" ] && ret="/usr/bin/v2ray"
if [ $is_xray = "1" ]; then if [ $is_xray = "1" ]; then
ret="/usr/bin/xray" && [ ! -f "$ret" ] && ret="/usr/bin/xray/xray" ret="/usr/bin/xray" && [ ! -f "$ret" ] && ret="/usr/bin/xray/xray"
fi fi
;; ;;
trojan) ret="/usr/sbin/trojan" ;; trojan) ret="/usr/sbin/trojan" ;;
socks5 | tun) ret="/usr/sbin/redsocks2" ;;
esac esac
echo $ret echo $ret
} }
#分流节点 #分流节点
start_shunt() { start_shunt() {
for ((i = 0; i < ${#shunt_type[@]}; i++)); do eval shunt_type1="global"
local server_index=$(uci_get_by_type global ${shunt_type[i]}_server) eval shunt_type2="youtube"
local server_port=${shunt_port[i]} eval shunt_type3="tw_video"
eval shunt_type4="netflix"
eval shunt_type5="disney"
eval shunt_type6="prime"
eval shunt_type7="tvb"
eval shunt_type8="custom"
eval shunt_port1=2080
eval shunt_port2=2081
eval shunt_port3=2082
eval shunt_port4=2083
eval shunt_port5=2084
eval shunt_port6=2085
eval shunt_port7=2086
eval shunt_port8=2087
for i in 1 2 3 4 5 6 7 8; do
shunt_type=$(eval echo "\$shunt_type$i")
shunt_port=$(eval echo "\$shunt_port$i")
local server_index=$(uci_get_by_type global ${shunt_type}_server)
local server_port=${shunt_port}
local server_type=$(uci_get_by_name $server_index type) local server_type=$(uci_get_by_name $server_index type)
local server_ip=$(uci_get_by_name $server_index server) local server_ip=$(uci_get_by_name $server_index server)
if ["$server_type" == "vless"]; then if [ "$server_type" = "vless" ]; then
server_type="v2ray" server_type="v2ray"
fi fi
[ "$server_type" == "trojan" ] && re_type="client" || re_type="tcp" [ "$server_type" = "trojan" ] && re_type="client" || re_type="tcp"
if [ "$server_type" != "v2ray" -a "$server_type" != "" ]; then if [ "$server_type" != "v2ray" -a "$server_type" != "" ]; then
local config_file=/var/etc/${NAME}_${shunt_type[i]}.json local config_file=/var/etc/${NAME}_${shunt_type}.json
local bin=$(find_bin $server_type) local bin=$(find_bin $server_type)
lua /usr/share/vssr/genconfig_${server_type}.lua ${server_index} ${re_type} ${server_port} ${server_ip} >${config_file} lua /usr/share/vssr/genconfig_${server_type}.lua ${server_index} ${re_type} ${server_port} ${server_ip} >${config_file}
sed -i 's/\\//g' $config_file sed -i 's/\\//g' $config_file
@ -306,13 +320,13 @@ start_shunt() {
ss | ssr) ss | ssr)
bin=$(find_bin "ss-local") bin=$(find_bin "ss-local")
[ "$server_type" == "ssr" ] && bin=$(find_bin "ssr-local") [ "$server_type" == "ssr" ] && bin=$(find_bin "ssr-local")
$bin -c $config_file $ARG_OTA -f /var/run/vssr-${shunt_type[i]}.pid1 >/dev/null 2>&1 $bin -c $config_file $ARG_OTA -f /var/run/vssr-${shunt_type}.pid1 >/dev/null 2>&1
;; ;;
trojan) trojan)
$bin --config $config_file >/dev/null 2>&1 & $bin --config $config_file >/dev/null 2>&1 &
;; ;;
esac esac
echo "$(date "+%Y-%m-%d %H:%M:%S") ${shunt_type[i]}: $server_type 分流服务已启动!" >>/tmp/vssr.log echo "$(date "+%Y-%m-%d %H:%M:%S") ${shunt_type}: $server_type 分流服务已启动!" >>/tmp/vssr.log
fi fi
done done
return $? return $?
@ -370,7 +384,6 @@ start_redir() {
;; ;;
v2ray | vless) v2ray | vless)
$sscmd -config $last_config_file >/dev/null 2>&1 & $sscmd -config $last_config_file >/dev/null 2>&1 &
echo $sscmd
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) 已启动!" >>/tmp/vssr.log echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) 已启动!" >>/tmp/vssr.log
;; ;;
trojan) trojan)
@ -479,8 +492,10 @@ start_service() {
[ $(uci_get_by_name $1 enable) = "0" ] && return 1 [ $(uci_get_by_name $1 enable) = "0" ] && return 1
let server_count=server_count+1 let server_count=server_count+1
if [ $server_count = 1 ]; then if [ $server_count = 1 ]; then
iptables -N SSR-SERVER-RULE && if ! (iptables-save -t filter | grep SSR-SERVER-RULE >/dev/null); then
iptables -N SSR-SERVER-RULE && \
iptables -t filter -I INPUT -j SSR-SERVER-RULE iptables -t filter -I INPUT -j SSR-SERVER-RULE
fi
fi fi
gen_service_file $1 /var/etc/${NAME}_${server_count}.json gen_service_file $1 /var/etc/${NAME}_${server_count}.json
@ -527,8 +542,9 @@ start_local() {
lua /usr/share/vssr/genconfig_v2ray_s.lua >$CONFIG_SOCK5_FILE lua /usr/share/vssr/genconfig_v2ray_s.lua >$CONFIG_SOCK5_FILE
sed -i 's/\\//g' $config_file sed -i 's/\\//g' $config_file
socksbin=$(find_bin "v2ray")
/usr/bin/v2ray/v2ray -config $CONFIG_SOCK5_FILE >/dev/null 2>&1 & echo $socksbin
$socksbin -config $CONFIG_SOCK5_FILE >/dev/null 2>&1 &
local_enable=1 local_enable=1
} }
@ -551,34 +567,39 @@ start() {
GLOBAL_SERVER=$switch_server GLOBAL_SERVER=$switch_server
switch_enable=1 switch_enable=1
fi fi
if rules; then if rules; then
start_redir if start_redir; then
if [ -f "/tmp/dnsmasq.ssr" ]; then
mkdir -p /tmp/dnsmasq.d \ rm -rf /tmp/dnsmasq.ssr
&& cp -a /etc/vssr/gfw_list.conf /tmp/dnsmasq.ssr \ fi
&& cp -a /etc/vssr/gfw_base.conf /tmp/dnsmasq.ssr \ if [ -f "/tmp/dnsmasq.oversea" ]; then
&& cp -a /etc/vssr/ad.conf /tmp/dnsmasq.ssr \ rm -rf /tmp/dnsmasq.oversea
&& cp -a /etc/vssr/oversea_list.conf /tmp/dnsmasq.oversea fi
mkdir -p /tmp/dnsmasq.d
if ! [ "$run_mode" = "oversea" ]; then if ! [ "$run_mode" = "oversea" ]; then
cat >/tmp/dnsmasq.d/dnsmasq-ssr.conf <<EOF mkdir -p /tmp/dnsmasq.ssr
cp -rf /etc/vssr/gfw_list.conf /tmp/dnsmasq.ssr/
cp -rf /etc/vssr/gfw_base.conf /tmp/dnsmasq.ssr/
cp -rf /etc/vssr/ad.conf /tmp/dnsmasq.ssr/
cat >/tmp/dnsmasq.d/dnsmasq-ssr.conf <<EOF
conf-dir=/tmp/dnsmasq.ssr conf-dir=/tmp/dnsmasq.ssr
EOF EOF
else else
cat >/tmp/dnsmasq.d/dnsmasq-ssr.conf <<EOF mkdir -p /tmp/dnsmasq.oversea
cp -rf /etc/vssr/oversea_list.conf /tmp/dnsmasq.oversea/
cat >/tmp/dnsmasq.d/dnsmasq-ssr.conf <<EOF
conf-dir=/tmp/dnsmasq.oversea conf-dir=/tmp/dnsmasq.oversea
EOF EOF
fi
if [ $(uci_get_by_type global adblock) = 0 ]; then
rm -f /tmp/dnsmasq.ssr/ad.conf
fi
/usr/share/vssr/gfw2ipset.sh
else
/usr/bin/ssr-rules -f
fi fi
if [ $(uci_get_by_type global adblock) = 0 ]; then
rm -f /tmp/dnsmasq.ssr/ad.conf
fi
/usr/share/vssr/gfw2ipset.sh
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi fi
/etc/init.d/dnsmasq restart >/dev/null 2>&1
start_server start_server
start_local start_local
if [ $scount != "0" ]; then if [ $scount != "0" ]; then
@ -615,10 +636,10 @@ stop() {
if [ $(uci_get_by_type global monitor_enable) = 1 ]; then if [ $(uci_get_by_type global monitor_enable) = 1 ]; then
kill -9 $(busybox ps -w | grep vssr-monitor | grep -v grep | awk '{print $1}') >/dev/null 2>&1 kill -9 $(busybox ps -w | grep vssr-monitor | grep -v grep | awk '{print $1}') >/dev/null 2>&1
fi fi
killall -q -9 ss-redir ss-local obfs-local ssr-redir ssr-local ssr-server v2ray v2ray-plugin trojan microsocks ipt2socks dns2socks redsocks2 pdnsd xray killall -q -9 ss-redir ss-local obfs-local ssr-redir ssr-local ssr-server v2ray v2ray-plugin xray trojan microsocks ipt2socks dns2socks pdnsd
if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then
rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf /tmp/dnsmasq.ssr /tmp/dnsmasq.oversea
/etc/init.d/dnsmasq restart >/dev/null 2>&1 /etc/init.d/dnsmasq restart >/dev/null 2>&1
fi fi
del_cron del_cron

View File

@ -1,25 +1,4 @@
api.ipify.org api.ipify.org
fast.com
netflix.ca
netflix.com
netflix.net
netflixinvestor.com
netflixtechblog.com
nflxext.com
nflximg.com
nflximg.net
nflxsearch.net
nflxso.net
nflxvideo.net
amazonprimevideos.com
amazonvideo.cc
amazonvideo.com
prime-video.com
primevideo.cc
primevideo.com
primevideo.info
primevideo.org
primevideo.tv
v2fly.org v2fly.org
github.com github.com
raw.githubusercontent.com raw.githubusercontent.com

View File

@ -0,0 +1,6 @@
cdn.registerdisney.go.com
disneyplus.com
disney-plus.net
dssott.com
bamgrid.com
execute-api.us-east-1.amazonaws.com

View File

@ -0,0 +1,22 @@
fast.com
netflix.ca
netflix.com
netflix.net
netflixinvestor.com
netflixtechblog.com
nflxext.com
nflximg.com
nflximg.net
nflxsearch.net
nflxso.net
nflxvideo.net
netflixdnstest0.com
netflixdnstest1.com
netflixdnstest2.com
netflixdnstest3.com
netflixdnstest4.com
netflixdnstest5.com
netflixdnstest6.com
netflixdnstest7.com
netflixdnstest8.com
netflixdnstest9.com

View File

@ -0,0 +1,12 @@
aiv-cdn.net
amazonaws.com
amazonvideo.com
llnwd.net
amazonprimevideos.com
amazonvideo.cc
prime-video.com
primevideo.cc
primevideo.com
primevideo.info
primevideo.org
primevideo.tv

View File

@ -0,0 +1,2 @@
tvsuper.com
tvb.com

View File

@ -0,0 +1,12 @@
vidol.tv
hinet.net
books.com
litv.tv
pstatic.net
app-measurement.com
kktv.com.tw
gamer.com.tw
wetv.vip
kktv.me
myvideo.net.tw
kk.stream

View File

@ -0,0 +1,14 @@
youtube
ggpht.com
googlevideo.com
withyoutube.com
youtu.be
youtube-nocookie.com
youtube.com
youtubeeducation.com
youtubegaming.com
youtubei.googleapis.com
youtubekids.com
youtubemobilesupport.com
yt.be
ytimg.com

View File

@ -75,6 +75,8 @@ flush_r() {
ipset_r() { ipset_r() {
ipset -N gmlan hash:net 2>/dev/null ipset -N gmlan hash:net 2>/dev/null
$IPT -N SS_SPEC_WAN_AC
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
for ip in $LAN_GM_IP; do ipset -! add gmlan $ip; done for ip in $LAN_GM_IP; do ipset -! add gmlan $ip; done
case "$RUNMODE" in case "$RUNMODE" in
router) router)
@ -83,31 +85,25 @@ ipset_r() {
$(gen_iplist | sed -e "s/^/add ss_spec_wan_ac /") $(gen_iplist | sed -e "s/^/add ss_spec_wan_ac /")
EOF EOF
ipset -N gfwlist hash:net 2>/dev/null ipset -N gfwlist hash:net 2>/dev/null
$IPT -N SS_SPEC_WAN_AC
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
$IPT -A SS_SPEC_WAN_AC -m set --match-set ss_spec_wan_ac dst -j RETURN $IPT -A SS_SPEC_WAN_AC -m set --match-set ss_spec_wan_ac dst -j RETURN
$IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW $IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set ! --match-set china dst -j SS_SPEC_WAN_FW
$IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j RETURN
$IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW
;; ;;
gfw) gfw)
ipset -N gfwlist hash:net 2>/dev/null ipset -N gfwlist hash:net 2>/dev/null
$IPT -N SS_SPEC_WAN_AC
$IPT -A SS_SPEC_WAN_AC -m set --match-set gfwlist dst -j SS_SPEC_WAN_FW $IPT -A SS_SPEC_WAN_AC -m set --match-set gfwlist dst -j SS_SPEC_WAN_FW
$IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set ! --match-set china dst -j SS_SPEC_WAN_FW $IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set ! --match-set china dst -j SS_SPEC_WAN_FW
$IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j RETURN $IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j RETURN
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
;; ;;
oversea) oversea)
ipset -N oversea hash:net 2>/dev/null ipset -N oversea hash:net 2>/dev/null
$IPT -N SS_SPEC_WAN_AC $IPT -I SS_SPEC_WAN_AC -m set --match-set oversea dst -j SS_SPEC_WAN_FW
ipset -N gmlan hash:net 2>/dev/null $IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -j SS_SPEC_WAN_FW
for ip in $LAN_GM_IP; do ipset -! add gmlan $ip; done
$IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j SS_SPEC_WAN_FW $IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j SS_SPEC_WAN_FW
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
;; ;;
all) all)
$IPT -N SS_SPEC_WAN_AC
$IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW $IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
;; ;;
esac esac

View File

@ -19,7 +19,7 @@ local trojan = {
-- 传出连接 -- 传出连接
ssl = { ssl = {
verify = (server.insecure == '0') and true or false, verify = (server.insecure == '0') and true or false,
verify_hostname = (server.tls == '1') and false or true, verify_hostname = (server.tls == '1') and true or false,
cert = '', cert = '',
cipher = 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA', cipher = 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA',
cipher_tls13 = 'TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384', cipher_tls13 = 'TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384',

View File

@ -7,31 +7,34 @@ local local_port = arg[3]
local outbounds_table = {} local outbounds_table = {}
local rules_table = {} local rules_table = {}
function read_conf(file)
local rfile = io.open(file, "r")
local ltable = {}
for line in rfile:lines() do
local re = string.gsub(line, "\r", "")
table.insert(ltable,re)
end
local rtable = next(ltable) ~= nil and ltable or nil
return rtable
end
local v2ray_flow = ucursor:get_first(name, 'global', 'v2ray_flow', '0') local v2ray_flow = ucursor:get_first(name, 'global', 'v2ray_flow', '0')
local proxy_domain_name = ucursor:get_list(name, '@access_control[0]', 'proxy_domain_name')
local custom_domain = read_conf("/etc/vssr/custom_domain.list")
local youtube_domain = read_conf("/etc/vssr/youtube_domain.list")
local tw_video_domain = read_conf("/etc/vssr/tw_video_domain.list")
local netflix_domain = read_conf("/etc/vssr/netflix_domain.list")
local disney_domain = read_conf("/etc/vssr/disney_domain.list")
local prime_domain = read_conf("/etc/vssr/prime_domain.list")
local tvb_domain = read_conf("/etc/vssr/tvb_domain.list")
local flow_table = { local flow_table = {
yotube = { yotube = {
name = 'youtube', name = 'youtube',
port = 2081, port = 2081,
rules = { rules = {
type = 'field', type = 'field',
domain = { domain = youtube_domain,
'youtube',
'ggpht.com',
'googlevideo.com',
'withyoutube.com',
'youtu.be',
'youtube-nocookie.com',
'youtube.com',
'youtubeeducation.com',
'youtubegaming.com',
'youtubei.googleapis.com',
'youtubekids.com',
'youtubemobilesupport.com',
'yt.be',
'ytimg.com'
},
outboundTag = 'youtube' outboundTag = 'youtube'
} }
}, },
@ -40,19 +43,7 @@ local flow_table = {
port = 2082, port = 2082,
rules = { rules = {
type = 'field', type = 'field',
domain = { domain = tw_video_domain,
'vidol.tv',
'hinet.net',
'books.com',
'litv.tv',
'pstatic.net',
'app-measurement.com',
'kktv.com.tw',
'gamer.com.tw',
'wetv.vip',
'kktv.me',
'myvideo.net.tw'
},
outboundTag = 'tw_video' outboundTag = 'tw_video'
} }
}, },
@ -61,30 +52,7 @@ local flow_table = {
port = 2083, port = 2083,
rules = { rules = {
type = 'field', type = 'field',
domain = { domain = netflix_domain,
'fast.com',
'netflix.ca',
'netflix.com',
'netflix.net',
'netflixinvestor.com',
'netflixtechblog.com',
'nflxext.com',
'nflximg.com',
'nflximg.net',
'nflxsearch.net',
'nflxso.net',
'nflxvideo.net',
'netflixdnstest0.com',
'netflixdnstest1.com',
'netflixdnstest2.com',
'netflixdnstest3.com',
'netflixdnstest4.com',
'netflixdnstest5.com',
'netflixdnstest6.com',
'netflixdnstest7.com',
'netflixdnstest8.com',
'netflixdnstest9.com'
},
outboundTag = 'netflix' outboundTag = 'netflix'
} }
}, },
@ -93,14 +61,7 @@ local flow_table = {
port = 2084, port = 2084,
rules = { rules = {
type = 'field', type = 'field',
domain = { domain = disney_domain,
'cdn.registerdisney.go.com',
'disneyplus.com',
'disney-plus.net',
'dssott.com',
'bamgrid.com',
'execute-api.us-east-1.amazonaws.com'
},
outboundTag = 'disney' outboundTag = 'disney'
} }
}, },
@ -109,20 +70,7 @@ local flow_table = {
port = 2085, port = 2085,
rules = { rules = {
type = 'field', type = 'field',
domain = { domain = prime_domain,
'aiv-cdn.net',
'amazonaws.com',
'amazonvideo.com',
'llnwd.net',
'amazonprimevideos.com',
'amazonvideo.cc',
'prime-video.com',
'primevideo.cc',
'primevideo.com',
'primevideo.info',
'primevideo.org',
'primevideo.tv'
},
outboundTag = 'prime' outboundTag = 'prime'
} }
}, },
@ -131,7 +79,7 @@ local flow_table = {
port = 2086, port = 2086,
rules = { rules = {
type = 'field', type = 'field',
domain = {'tvsuper.com', 'tvb.com'}, domain = tvb_domain,
outboundTag = 'tvb' outboundTag = 'tvb'
} }
}, },
@ -140,7 +88,7 @@ local flow_table = {
port = 2087, port = 2087,
rules = { rules = {
type = 'field', type = 'field',
domain = proxy_domain_name, domain = custom_domain,
outboundTag = 'custom' outboundTag = 'custom'
} }
} }
@ -174,14 +122,6 @@ function gen_outbound(server_node, tags, local_ports)
bound = nil bound = nil
else else
local server = ucursor:get_all(name, server_node) local server = ucursor:get_all(name, server_node)
local outbound_security = "none"
if (server.xtls == '1') then
outbound_security = "xtls"
elseif (server.tls == '1') then
outbound_security = "tls"
elseif (server.tls == "0") then
outbound_security = "none"
end
local node_type = server.type == "vless" and "vless" or "vmess" local node_type = server.type == "vless" and "vless" or "vmess"
if server.type ~= 'v2ray' and server.type ~= 'vless' then if server.type ~= 'v2ray' and server.type ~= 'vless' then
@ -218,9 +158,9 @@ function gen_outbound(server_node, tags, local_ports)
-- 底层传输配置 -- 底层传输配置
streamSettings = { streamSettings = {
network = server.transport, network = server.transport,
security = outbound_security, security = (server.tls == '1') and ((server.xtls == '1') and "xtls" or "tls") or "none",
tlsSettings = (outbound_security == "tls") and {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,} or nil, tlsSettings = (server.tls == '1' and server.xtls ~= '1') and {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,} or nil,
xtlsSettings = (outbound_security == "xtls") and {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,} or nil, xtlsSettings = (server.xtls == '1') and {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,} or nil,
kcpSettings = (server.transport == 'kcp') and kcpSettings = (server.transport == 'kcp') and
{ {
mtu = tonumber(server.mtu), mtu = tonumber(server.mtu),
@ -271,10 +211,12 @@ end
if v2ray_flow == '1' then if v2ray_flow == '1' then
table.insert(outbounds_table, gen_outbound(server_section, 'global', 2080)) table.insert(outbounds_table, gen_outbound(server_section, 'global', 2080))
for i, v in pairs(flow_table) do for _, v in pairs(flow_table) do
local server = ucursor:get_first(name, 'global', v.name .. '_server') if(v.rules.domain ~= nil) then
table.insert(outbounds_table, gen_outbound(server, v.name, v.port)) local server = ucursor:get_first(name, 'global', v.name .. '_server')
table.insert(rules_table, (server ~= nil and server ~= 'nil') and v.rules or nil) table.insert(outbounds_table, gen_outbound(server, v.name, v.port))
table.insert(rules_table, (server ~= nil and server ~= 'nil' ) and v.rules or nil)
end
end end
else else
table.insert(outbounds_table, gen_outbound(server_section, 'main', local_port)) table.insert(outbounds_table, gen_outbound(server_section, 'main', local_port))

View File

@ -1,6 +1,12 @@
#!/bin/sh #!/bin/sh
. /lib/functions.sh . /lib/functions.sh
uci_get_by_type() {
local ret=$(uci get vssr.@$1[0].$2 2>/dev/null)
echo ${ret:=$3}
}
v2ray_flow=$(uci_get_by_type global v2ray_flow)
mkdir -p /tmp/dnsmasq.ssr mkdir -p /tmp/dnsmasq.ssr
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"gfwlist"'\n",$0)}' /etc/vssr/gfw.list >/tmp/dnsmasq.ssr/custom_forward.conf awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"gfwlist"'\n",$0)}' /etc/vssr/gfw.list >/tmp/dnsmasq.ssr/custom_forward.conf
@ -11,6 +17,27 @@ awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/vssr/blac
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"whitelist"'\n",$0)}' /etc/vssr/white.list >/tmp/dnsmasq.ssr/whitelist_forward.conf awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"whitelist"'\n",$0)}' /etc/vssr/white.list >/tmp/dnsmasq.ssr/whitelist_forward.conf
if [ "$v2ray_flow" = "1" ]; then
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/vssr/tw_video_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/vssr/tw_video_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/vssr/netflix_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/vssr/netflix_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/vssr/disney_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/vssr/disney_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/vssr/prime_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/vssr/prime_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/vssr/tvb_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/vssr/tvb_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/vssr/custom_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/vssr/custom_domain.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
fi
function valid_ip() { function valid_ip() {
ip=$1 ip=$1
read_ip=$(echo $ip | awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}') read_ip=$(echo $ip | awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}')