luci-app-clash: sync with upstream source
This commit is contained in:
parent
92e352062e
commit
28d0f34519
@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-clash
|
||||
PKG_VERSION:=1.4.6
|
||||
PKG_VERSION:=1.4.8
|
||||
PKG_MAINTAINER:=frainzy1477
|
||||
|
||||
|
||||
@ -141,6 +141,7 @@ define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_BIN) ./root/usr/share/clash/yum_change.sh $(1)/usr/share/clash/
|
||||
$(INSTALL_BIN) ./root/usr/share/clash/groups.sh $(1)/usr/share/clash/
|
||||
$(INSTALL_BIN) ./root/usr/share/clash/rule.sh $(1)/usr/share/clash/
|
||||
$(INSTALL_BIN) ./root/usr/share/clash/geoip.sh $(1)/usr/share/clash/
|
||||
$(INSTALL_BIN) ./root/usr/share/clash/list.sh $(1)/usr/share/clash/
|
||||
$(INSTALL_BIN) ./root/usr/share/clash/v2ssr.sh $(1)/usr/share/clash/
|
||||
$(INSTALL_BIN) ./root/usr/share/clash/server.list $(1)/usr/share/clash/
|
||||
|
||||
@ -23,7 +23,8 @@ function index()
|
||||
entry({"admin", "services", "clash", "settings"}, firstchild(),_("Settings"), 50)
|
||||
entry({"admin", "services", "clash", "settings", "port"},cbi("clash/port"),_("Proxy Ports"), 60).leaf = true
|
||||
entry({"admin", "services", "clash", "settings", "dns"},cbi("clash/dns"),_("DNS Settings"), 70).leaf = true
|
||||
entry({"admin", "services", "clash", "settings", "list"},cbi("clash/list"),_("Custom List"), 80).leaf = true
|
||||
entry({"admin", "services", "clash", "settings", "geoip"},cbi("clash/geoip"),_("Update GeoIP"), 80).leaf = true
|
||||
entry({"admin", "services", "clash", "settings", "list"},cbi("clash/list"),_("Custom List"), 90).leaf = true
|
||||
|
||||
entry({"admin", "services", "clash", "config"},firstchild(),_("Config"), 100)
|
||||
entry({"admin", "services", "clash", "config", "actconfig"},cbi("clash/actconfig"),_("Config In Use"), 110).leaf = true
|
||||
@ -43,12 +44,16 @@ function index()
|
||||
entry({"admin", "services", "clash", "doupdate"}, call("do_update")).leaf=true
|
||||
entry({"admin", "services", "clash", "start"}, call("do_start")).leaf=true
|
||||
entry({"admin", "services", "clash", "stop"}, call("do_stop")).leaf=true
|
||||
entry({"admin", "services", "clash", "getlog"}, call("get_log")).leaf=true
|
||||
entry({"admin", "services", "clash", "geo"}, call("geoip_check")).leaf=true
|
||||
entry({"admin", "services", "clash", "geoipupdate"}, call("geoip_update")).leaf=true
|
||||
entry({"admin", "services", "clash", "check_geoip"}, call("check_geoip_log")).leaf=true
|
||||
entry({"admin", "services", "clash", "corelog"},call("down_check")).leaf=true
|
||||
entry({"admin", "services", "clash", "logstatus"},call("logstatus_check")).leaf=true
|
||||
|
||||
end
|
||||
|
||||
local fss = require "luci.clash"
|
||||
|
||||
local function dash_port()
|
||||
return luci.sys.exec("uci get clash.config.dash_port 2>/dev/null")
|
||||
end
|
||||
@ -129,6 +134,9 @@ local function readlog()
|
||||
return luci.sys.exec("sed -n '$p' /usr/share/clash/clash_real.txt 2>/dev/null")
|
||||
end
|
||||
|
||||
local function geo_data()
|
||||
return os.date("%Y-%m-%d %H:%M:%S",fss.mtime("/etc/clash/Country.mmdb"))
|
||||
end
|
||||
|
||||
local function downcheck()
|
||||
if nixio.fs.access("/var/run/core_update_error") then
|
||||
@ -143,17 +151,37 @@ end
|
||||
function action_read()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({
|
||||
readlog = readlog();
|
||||
readlog = readlog();
|
||||
})
|
||||
end
|
||||
|
||||
function down_check()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({
|
||||
downcheck = downcheck();
|
||||
downcheck = downcheck();
|
||||
})
|
||||
end
|
||||
|
||||
local function geoipcheck()
|
||||
if nixio.fs.access("/var/run/geoip_update_error") then
|
||||
return "0"
|
||||
elseif nixio.fs.access("/var/run/geoip_update") then
|
||||
return "1"
|
||||
elseif nixio.fs.access("/var/run/geoip_down_complete") then
|
||||
return "2"
|
||||
end
|
||||
end
|
||||
|
||||
function geoip_check()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({
|
||||
geoipcheck = geoipcheck();
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function check_status()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({
|
||||
@ -197,6 +225,11 @@ function act_ping()
|
||||
end
|
||||
|
||||
|
||||
function geoip_update()
|
||||
fs.writefile("/var/run/geoiplog","0")
|
||||
luci.sys.exec("(rm /var/run/geoip_update_error ; touch /var/run/geoip_update ; sh /usr/share/clash/geoip.sh >/tmp/geoip_update.txt 2>&1 || touch /var/run/geoip_update_error ;rm /var/run/geoip_update) &")
|
||||
end
|
||||
|
||||
|
||||
function do_update()
|
||||
fs.writefile("/var/run/clashlog","0")
|
||||
@ -227,6 +260,22 @@ else
|
||||
end
|
||||
end
|
||||
|
||||
function check_geoip_log()
|
||||
luci.http.prepare_content("text/plain; charset=utf-8")
|
||||
local fdp=tonumber(fs.readfile("/var/run/geoiplog")) or 0
|
||||
local f=io.open("/tmp/geoip_update.txt", "r+")
|
||||
f:seek("set",fdp)
|
||||
local a=f:read(2048000) or ""
|
||||
fdp=f:seek()
|
||||
fs.writefile("/var/run/geoiplog",tostring(fdp))
|
||||
f:close()
|
||||
if fs.access("/var/run/geoip_update") then
|
||||
luci.http.write(a)
|
||||
else
|
||||
luci.http.write(a.."\0")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function logstatus_check()
|
||||
luci.http.prepare_content("text/plain; charset=utf-8")
|
||||
|
||||
@ -29,6 +29,13 @@ sev.write = function(self, section, value)
|
||||
NXFS.writefile(conf, value:gsub("\r\n", "\n"))
|
||||
end
|
||||
|
||||
o=s:option(Button,"apply")
|
||||
o.inputtitle = translate("Save & Apply")
|
||||
o.inputstyle = "reload"
|
||||
o.write = function()
|
||||
m.uci:commit("clash")
|
||||
end
|
||||
|
||||
|
||||
o = s:option(Button,"configrm")
|
||||
o.inputtitle = translate("Delete Config")
|
||||
|
||||
@ -15,54 +15,6 @@ m.pageaction = false
|
||||
s.anonymous = true
|
||||
s.addremove=false
|
||||
|
||||
o = s:option(FileUpload, "",translate("Update GEOIP Database"))
|
||||
o.description = translate("NB: Upload GEOIP Database file Country.mmdb")
|
||||
.."<br />"
|
||||
..translate("https://github.com/Dreamacro/maxmind-geoip/releases")
|
||||
.."<br />"
|
||||
..translate("https://static.clash.to/GeoIP2/GeoIP2-Country.tar.gz")
|
||||
|
||||
o.title = translate("Update GEOIP Database")
|
||||
o.template = "clash/clash_upload"
|
||||
um = s:option(DummyValue, "", nil)
|
||||
um.template = "clash/clash_dvalue"
|
||||
|
||||
local dir, fd
|
||||
dir = "/etc/clash/"
|
||||
http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not fd then
|
||||
if not meta then return end
|
||||
|
||||
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
|
||||
|
||||
if not fd then
|
||||
um.value = translate("upload file error.")
|
||||
return
|
||||
end
|
||||
end
|
||||
if chunk and fd then
|
||||
fd:write(chunk)
|
||||
end
|
||||
if eof and fd then
|
||||
fd:close()
|
||||
fd = nil
|
||||
um.value = translate("File saved to") .. ' "/etc/clash/"'
|
||||
SYS.call("chmod + x /etc/clash/Country.mmdb")
|
||||
if luci.sys.call("pidof clash >/dev/null") == 0 then
|
||||
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
if luci.http.formvalue("upload") then
|
||||
local f = luci.http.formvalue("ulfile")
|
||||
if #f <= 0 then
|
||||
um.value = translate("No specify upload file.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
y = s:option(ListValue, "dnsforwader", translate("DNS Forwarding"))
|
||||
y:value("0", translate("disabled"))
|
||||
|
||||
141
package/jsda/luci-app-clash/luasrc/model/cbi/clash/geoip.lua
Normal file
141
package/jsda/luci-app-clash/luasrc/model/cbi/clash/geoip.lua
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
local NXFS = require "nixio.fs"
|
||||
local SYS = require "luci.sys"
|
||||
local HTTP = require "luci.http"
|
||||
local DISP = require "luci.dispatcher"
|
||||
local UTIL = require "luci.util"
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
local clash = "clash"
|
||||
local http = luci.http
|
||||
|
||||
font_red = [[<font color="red">]]
|
||||
font_off = [[</font>]]
|
||||
bold_on = [[<strong>]]
|
||||
bold_off = [[</strong>]]
|
||||
|
||||
|
||||
k = Map(clash)
|
||||
k.reset = false
|
||||
k.submit = false
|
||||
s=k:section(TypedSection, "clash", translate("Local Update GeoIP"))
|
||||
s.anonymous = true
|
||||
s.addremove=false
|
||||
o = s:option(FileUpload, "")
|
||||
o.description = translate("NB: Upload GEOIP Database file Country.mmdb")
|
||||
.."<br />"
|
||||
..translate("https://github.com/Dreamacro/maxmind-geoip/releases")
|
||||
.."<br />"
|
||||
..translate("https://static.clash.to/GeoIP2/GeoIP2-Country.tar.gz")
|
||||
.."<br />"
|
||||
..translate("https://geolite.clash.dev/Country.mmdb")
|
||||
|
||||
o.title = translate(" ")
|
||||
o.template = "clash/clash_upload"
|
||||
um = s:option(DummyValue, "", nil)
|
||||
um.template = "clash/clash_dvalue"
|
||||
|
||||
local dir, fd
|
||||
dir = "/etc/clash/"
|
||||
http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not fd then
|
||||
if not meta then return end
|
||||
|
||||
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
|
||||
|
||||
if not fd then
|
||||
um.value = translate("upload file error.")
|
||||
return
|
||||
end
|
||||
end
|
||||
if chunk and fd then
|
||||
fd:write(chunk)
|
||||
end
|
||||
if eof and fd then
|
||||
fd:close()
|
||||
fd = nil
|
||||
um.value = translate("File saved to") .. ' "/etc/clash/"'
|
||||
SYS.call("chmod + x /etc/clash/Country.mmdb")
|
||||
if luci.sys.call("pidof clash >/dev/null") == 0 then
|
||||
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
if luci.http.formvalue("upload") then
|
||||
local f = luci.http.formvalue("ulfile")
|
||||
if #f <= 0 then
|
||||
um.value = translate("No specify upload file.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
m = Map("clash")
|
||||
s = m:section(TypedSection, "clash" , translate("Online Update GeoIP"))
|
||||
m.pageaction = false
|
||||
s.anonymous = true
|
||||
s.addremove=false
|
||||
|
||||
o = s:option(Flag, "auto_update_geoip", translate("Auto Update"))
|
||||
o.description = translate("Auto Update GeoIP Database")
|
||||
|
||||
o = s:option(ListValue, "auto_update_geoip_time", translate("Update time (every day)"))
|
||||
for t = 0,23 do
|
||||
o:value(t, t..":00")
|
||||
end
|
||||
o.default=0
|
||||
o.description = translate("GeoIP Update Time")
|
||||
|
||||
|
||||
o = s:option(ListValue, "up_time", translate("Update Every (Week/Month)"))
|
||||
o.rmempty = false
|
||||
o.description = translate("Time For Update (Once a week/Month)")
|
||||
o:value("weekly", translate("Weekly"))
|
||||
o:value("monthly", translate("Monthly"))
|
||||
|
||||
o = s:option(ListValue, "geoip_update_day", translate("Update Day (Day of Week)"))
|
||||
o:value("1", translate("Every Monday"))
|
||||
o:value("2", translate("Every Tuesday"))
|
||||
o:value("3", translate("Every Wednesday"))
|
||||
o:value("4", translate("Every Thursday"))
|
||||
o:value("5", translate("Every Friday"))
|
||||
o:value("6", translate("Every Saturday"))
|
||||
o:value("0", translate("Every Sunday"))
|
||||
update_time = SYS.exec("ls -l --full-time /etc/clash/Country.mmdb|awk '{print $6,$7;}'")
|
||||
o.description = translate("Update Time")..'- ' ..font_red..bold_on..update_time..bold_off..font_off..' '
|
||||
o:depends("up_time", "weekly")
|
||||
|
||||
o = s:option(ListValue, "geo_update_week", translate("Update Day (Day of Month)"))
|
||||
o:value("1", translate("Every 1st Day"))
|
||||
o:value("7", translate("Every 7th Day"))
|
||||
o:value("14", translate("Every 14th Day"))
|
||||
o:value("21", translate("Every 21st Day"))
|
||||
o:value("28", translate("Every 28th Day"))
|
||||
update_time = SYS.exec("ls -l --full-time /etc/clash/Country.mmdb|awk '{print $6,$7;}'")
|
||||
o.description = translate("Update Time")..'- ' ..font_red..bold_on..update_time..bold_off..font_off..' '
|
||||
o:depends("up_time", "monthly")
|
||||
|
||||
|
||||
o = s:option(Value, "license_key")
|
||||
o.title = translate("License Key")
|
||||
o.description = translate("MaxMind License Key")..translate(" https://www.maxmind.com/en/geolite2/signup")
|
||||
o.rmempty = true
|
||||
|
||||
o=s:option(Button,"update_geoip")
|
||||
o.inputtitle = translate("Save & Apply")
|
||||
o.title = translate("Save & Apply")
|
||||
o.inputstyle = "reload"
|
||||
o.write = function()
|
||||
m.uci:commit("clash")
|
||||
end
|
||||
|
||||
o = s:option(Button,"download")
|
||||
o.title = translate("Download")
|
||||
o.template = "clash/geoip"
|
||||
|
||||
|
||||
return m, k
|
||||
|
||||
@ -46,7 +46,7 @@ o:depends("type", "fallback")
|
||||
o:depends("type", "load-balance")
|
||||
|
||||
o = s:option(DynamicList, "other_group", translate("Other Group"))
|
||||
o.rmempty = false
|
||||
o.rmempty = true
|
||||
o.description = translate("Proxy Groups Must Exist In Rule")
|
||||
o:value("ALL", translate("All Servers"))
|
||||
uci:foreach("clash", "servers",
|
||||
|
||||
@ -96,7 +96,7 @@ for t,f in ipairs(fss.glob("/etc/clash/provider/*"))do
|
||||
end
|
||||
end
|
||||
end
|
||||
o.rmempty = true
|
||||
o.rmempty = false
|
||||
o:depends("type", "file")
|
||||
|
||||
|
||||
|
||||
@ -28,6 +28,12 @@ sev.write = function(self, section, value)
|
||||
NXFS.writefile(conf, value:gsub("\r\n", "\n"))
|
||||
end
|
||||
|
||||
o=s:option(Button,"apply")
|
||||
o.inputtitle = translate("Save & Apply")
|
||||
o.inputstyle = "reload"
|
||||
o.write = function()
|
||||
m.uci:commit("clash")
|
||||
end
|
||||
|
||||
|
||||
o = s:option(Button,"configrm")
|
||||
|
||||
@ -34,6 +34,14 @@ o.write = function()
|
||||
SYS.call("rm -rf /usr/share/clash/config/upload/config.yaml >/dev/null 2>&1 &")
|
||||
end
|
||||
|
||||
o=s:option(Button,"apply")
|
||||
o.inputtitle = translate("Save & Apply")
|
||||
o.inputstyle = "reload"
|
||||
o.write = function()
|
||||
m.uci:commit("clash")
|
||||
end
|
||||
|
||||
|
||||
return m
|
||||
|
||||
|
||||
|
||||
@ -4,7 +4,8 @@ local HTTP = require "luci.http"
|
||||
local DISP = require "luci.dispatcher"
|
||||
local UTIL = require "luci.util"
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
local m
|
||||
local m , r, k
|
||||
local http = luci.http
|
||||
|
||||
font_green = [[<font color="green">]]
|
||||
font_off = [[</font>]]
|
||||
@ -16,9 +17,63 @@ m:section(SimpleSection).template = "clash/update"
|
||||
m.pageaction = false
|
||||
|
||||
k = Map("clash")
|
||||
s = k:section(TypedSection, "clash")
|
||||
s.anonymous = true
|
||||
|
||||
s=k:section(TypedSection, "clash", translate("Upload Clash(Tun)"))
|
||||
s.anonymous = true
|
||||
s.addremove=false
|
||||
o = s:option(FileUpload, "")
|
||||
o.description = translate("NB: Upload Clash Supported Tun (clash)")
|
||||
.."<br />"
|
||||
..translate("https://github.com/comzyh/clash/releases")
|
||||
.."<br />"
|
||||
..translate("https://github.com/Dreamacro/clash/releases/tag/TUN")
|
||||
|
||||
|
||||
o.title = translate(" ")
|
||||
o.template = "clash/clash_upload"
|
||||
um = s:option(DummyValue, "", nil)
|
||||
um.template = "clash/clash_dvalue"
|
||||
|
||||
local dir, fd
|
||||
dir = "/etc/clash/clashtun/"
|
||||
http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not fd then
|
||||
if not meta then return end
|
||||
|
||||
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
|
||||
|
||||
if not fd then
|
||||
um.value = translate("upload file error.")
|
||||
return
|
||||
end
|
||||
end
|
||||
if chunk and fd then
|
||||
fd:write(chunk)
|
||||
end
|
||||
if eof and fd then
|
||||
fd:close()
|
||||
fd = nil
|
||||
um.value = translate("File saved to") .. ' "/etc/clash/clashtun/"'
|
||||
SYS.call("chmod 755 /etc/clash/clashtun/clash")
|
||||
if luci.sys.call("pidof clash >/dev/null") == 0 then
|
||||
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
if luci.http.formvalue("upload") then
|
||||
local f = luci.http.formvalue("ulfile")
|
||||
if #f <= 0 then
|
||||
um.value = translate("No specify upload file.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
s = k:section(TypedSection, "clash", translate("Download Clash/Clashr"))
|
||||
s.anonymous = true
|
||||
o = s:option(ListValue, "dcore", translate("Core Type"))
|
||||
o.default = "clashcore"
|
||||
o:value("1", translate("Clash"))
|
||||
@ -56,6 +111,6 @@ o.title = translate("Download")
|
||||
o.template = "clash/core_check"
|
||||
|
||||
|
||||
return m, k
|
||||
return m, k
|
||||
|
||||
|
||||
|
||||
77
package/jsda/luci-app-clash/luasrc/view/clash/geoip.htm
Normal file
77
package/jsda/luci-app-clash/luasrc/view/clash/geoip.htm
Normal file
@ -0,0 +1,77 @@
|
||||
<%+cbi/valueheader%>
|
||||
<%local fs=require"nixio.fs"%>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<input type="button" class="cbi-button cbi-button-apply" id="apply_update_geoip" value="<%:Download%>" onclick=" return apply_update() "/>
|
||||
<br /><br />
|
||||
<textarea id="geoip_download" class="cbi-input-textarea" style="width: 100%;display:none" data-update="change" rows="10" cols="100" readonly="readonly" > </textarea>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
function apply_update(){
|
||||
XHR.get('<%=url([[admin]], [[services]], [[clash]], [[geoipupdate]])%>',null,function(x, data){}
|
||||
);
|
||||
poll_check();
|
||||
return
|
||||
}
|
||||
|
||||
function poll_check(){
|
||||
var lv = document.getElementById('geoip_download');
|
||||
lv.style.display="inline"
|
||||
XHR.poll(2, '<%=url([[admin]], [[services]], [[clash]], [[check_geoip]])%>', null,
|
||||
function(x, data) {
|
||||
scroll();
|
||||
var lv = document.getElementById('geoip_download');
|
||||
if (x.responseText && lv) {
|
||||
lv.innerHTML += x.responseText;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "clash", "geo")%>', null, function(x, status) {
|
||||
if ( x && x.status == 200 ) {
|
||||
if(status.geoipcheck==0||status.geoipcheck==2){
|
||||
hide();
|
||||
}
|
||||
if(status.geoipcheck==1){
|
||||
var btn = document.getElementById('apply_update_geoip');
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Download%>';
|
||||
poll_check();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
//]]>
|
||||
|
||||
function hide(){
|
||||
$('#geoip_download').hide();
|
||||
var btn = document.getElementById('apply_update_geoip');
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Download%>';
|
||||
}
|
||||
|
||||
|
||||
function scroll(){
|
||||
var textarea = document.getElementById('geoip_download');
|
||||
textarea.scrollTop = textarea.scrollHeight;
|
||||
}
|
||||
|
||||
|
||||
<% if fs.access("/var/run/geoip_update") then %>
|
||||
var btn = document.getElementById('apply_update_geoip');
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Downloading...%>';
|
||||
poll_check();
|
||||
<%end%>
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<%+cbi/valuefooter%>
|
||||
@ -672,4 +672,97 @@ msgid "Provider File"
|
||||
msgstr "代理集文件"
|
||||
|
||||
msgid "Modify Tun DNS"
|
||||
msgstr "修改Tun DNS"
|
||||
msgstr "修改Tun DNS"
|
||||
|
||||
msgid "Local Update GeoIP"
|
||||
msgstr "本地更新GeoIP数据库"
|
||||
|
||||
msgid "Online Update GeoIP"
|
||||
msgstr "在线更新GeoIP数据库"
|
||||
|
||||
msgid "MaxMind License Key"
|
||||
msgstr "MaxMind许可证密钥"
|
||||
|
||||
msgid "License Key"
|
||||
msgstr "许可证密钥"
|
||||
|
||||
msgid "Auto Update GeoIP Database"
|
||||
msgstr "自动更新GeoIP数据库"
|
||||
|
||||
msgid "Update Day (Day of Month)"
|
||||
msgstr "更新(每月的日)"
|
||||
|
||||
msgid "GeoIP Update Time"
|
||||
msgstr "GeoIP更新时间"
|
||||
|
||||
msgid "Every 1st Day"
|
||||
msgstr "每月的第一天"
|
||||
|
||||
msgid "Every 7th Day"
|
||||
msgstr "每月的第七天"
|
||||
|
||||
msgid "Every 14th Day"
|
||||
msgstr "每月的第十四天"
|
||||
|
||||
msgid "Every 21st Day"
|
||||
msgstr "每月的第二十一天"
|
||||
|
||||
msgid "Every 28th Day"
|
||||
msgstr "每月的第二十八天"
|
||||
|
||||
msgid "Update GeoIP"
|
||||
msgstr "更新GeoIP数据库"
|
||||
|
||||
msgid "Update Time"
|
||||
msgstr "更新时间"
|
||||
|
||||
msgid "Every Monday"
|
||||
msgstr "每周一"
|
||||
|
||||
msgid "Every Tuesday"
|
||||
msgstr "每周二"
|
||||
|
||||
msgid "Every Wednesday"
|
||||
msgstr "每周三"
|
||||
|
||||
msgid "Every Thursday"
|
||||
msgstr "每周四"
|
||||
|
||||
msgid "Every Friday"
|
||||
msgstr "每周五"
|
||||
|
||||
msgid "Every Saturday"
|
||||
msgstr "每周六"
|
||||
|
||||
msgid "Every Sunday"
|
||||
msgstr "每周日"
|
||||
|
||||
msgid "Update Every (Week/Month)"
|
||||
msgstr "更新(每周/每月)"
|
||||
|
||||
msgid "Update Day (Day of Week)"
|
||||
msgstr "更新的天"
|
||||
|
||||
msgid "Time For Update (Once a week/Month)"
|
||||
msgstr "更新(每周一次/每月一次)"
|
||||
|
||||
msgid "Weekly"
|
||||
msgstr "每周"
|
||||
|
||||
msgid "Monthly"
|
||||
msgstr "每月"
|
||||
|
||||
msgid "Upload Clash(Tun)"
|
||||
msgstr "上传Clash(Tun)"
|
||||
|
||||
msgid "NB: Upload Clash Supported Tun (clash)"
|
||||
msgstr "注意:上传clash支持的Tun"
|
||||
|
||||
msgid "Download Clash/Clashr"
|
||||
msgstr "下载Clash/Clashr"
|
||||
|
||||
msgid "No file chosen"
|
||||
msgstr "未选择文件"
|
||||
|
||||
msgid "Chose File"
|
||||
msgstr "选择文件"
|
||||
|
||||
@ -9,20 +9,20 @@ CLASHT="/etc/clash/clashtun/clash"
|
||||
CLASH_CONFIG="/etc/clash"
|
||||
CRON_FILE="/etc/crontabs/root"
|
||||
CONFIG_YAML="/etc/clash/config.yaml"
|
||||
CONFIG_YAML_OLD="/etc/clash/config.yml"
|
||||
CONFIG_YAML_OLD="/etc/clash/config.yml"
|
||||
|
||||
CONFIG_YAML_SUB="/usr/share/clash/config/sub/config.yaml"
|
||||
CONFIG_YAML_UPL="/usr/share/clash/config/upload/config.yaml"
|
||||
CONFIG_YAML_CUS="/usr/share/clash/config/custom/config.yaml"
|
||||
CUSLIST="/tmp/dnsmasq.d/custom_list.conf"
|
||||
CUSLITT="/tmp/dnsmasq.clash"
|
||||
CUSLISTV="/var/dnsmasq.d/custom_list.conf"
|
||||
CUSLISTV="/var/dnsmasq.d/custom_list.conf"
|
||||
CUSLITTV="/var/dnsmasq.clash"
|
||||
REAL_LOG="/usr/share/clash/clash_real.txt"
|
||||
|
||||
revert_dns() {
|
||||
#===========================================================================================================================
|
||||
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
|
||||
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
|
||||
uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#$dns_port >/dev/null 2>&1
|
||||
uci set dhcp.@dnsmasq[0].noresolv=0
|
||||
uci delete dhcp.@dnsmasq[0].cachesize
|
||||
@ -44,6 +44,23 @@ config_type=$(uci get clash.config.config_type 2>/dev/null)
|
||||
[ -z "$(grep -w "/usr/share/clash/clash.sh" $CRON_FILE)" ] && echo "0 $(uci get clash.config.auto_update_time 2>/dev/null) * * * /usr/share/clash/clash.sh" >> $CRON_FILE
|
||||
[ -z "$(grep -w "/usr/share/clash/v2ssr.sh" $CRON_FILE)" ] && echo "0 $(uci get clash.config.auto_update_time 2>/dev/null) * * * /usr/share/clash/v2ssr.sh" >> $CRON_FILE
|
||||
fi
|
||||
auto_geoip=$(uci get clash.config.auto_update_geoip 2>/dev/null)
|
||||
if [ "${auto_geoip}" -eq 1 ]; then
|
||||
day=$(uci get clash.config.geoip_update_day 2>/dev/null)
|
||||
week=$(uci get clash.config.geo_update_week 2>/dev/null)
|
||||
if [ -z $week ];then
|
||||
update_week="*"
|
||||
else
|
||||
update_week=$week
|
||||
fi
|
||||
if [ -z $day ];then
|
||||
update_day="*"
|
||||
else
|
||||
update_day=$day
|
||||
fi
|
||||
|
||||
[ -z "$(grep -w "/usr/share/clash/geoip.sh" $CRON_FILE)" ] && echo "0 $(uci get clash.config.auto_update_geoip_time 2>/dev/null) $update_week * $update_day /usr/share/clash/geoip.sh" >> $CRON_FILE
|
||||
fi
|
||||
crontab $CRON_FILE
|
||||
#===========================================================================================================================
|
||||
}
|
||||
@ -209,6 +226,8 @@ rules(){
|
||||
elif [ "${tun_mode}" -eq 2 ] || [ "${tun_mode}" -eq 3 ];then
|
||||
PROXY_FWMARK="0x162"
|
||||
PROXY_ROUTE_TABLE="0x162"
|
||||
PROXY_BYPASS_USER="root"
|
||||
|
||||
ipset create localnetwork hash:net
|
||||
ipset add localnetwork 127.0.0.0/8
|
||||
ipset add localnetwork 10.0.0.0/8
|
||||
@ -220,16 +239,29 @@ rules(){
|
||||
|
||||
ip tuntap add user root mode tun clash0
|
||||
ip link set clash0 up
|
||||
ip address replace 198.18.0.0/16 dev clash0
|
||||
ip route replace default dev clash0 table "$PROXY_ROUTE_TABLE"
|
||||
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE"
|
||||
|
||||
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE"
|
||||
|
||||
iptables -t mangle -N clash
|
||||
iptables -t mangle -F clash
|
||||
iptables -t mangle -A clash -m owner --uid-owner "$PROXY_BYPASS_USER" -j RETURN
|
||||
iptables -t mangle -A clash -d 198.18.0.0/16 -j MARK --set-mark "$PROXY_FWMARK"
|
||||
iptables -t mangle -A clash -m set --match-set localnetwork dst -j RETURN
|
||||
iptables -t mangle -A clash -m set --match-set localnetwork dst -j RETURN
|
||||
iptables -t mangle -A clash -j MARK --set-mark "$PROXY_FWMARK"
|
||||
|
||||
|
||||
iptables -t nat -N CLASH_DNS
|
||||
iptables -t nat -F CLASH_DNS
|
||||
iptables -t nat -A CLASH_DNS -m owner --uid-owner "$PROXY_BYPASS_USER" -j RETURN
|
||||
iptables -t nat -A CLASH_DNS -p udp -j DNAT --to "127.0.0.1:$dns_port"
|
||||
|
||||
iptables -t mangle -I OUTPUT -j clash
|
||||
iptables -t mangle -I PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK"
|
||||
iptables -t mangle -I PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK"
|
||||
|
||||
iptables -t nat -I OUTPUT -p udp --dport 53 -j CLASH_DNS
|
||||
iptables -t nat -I PREROUTING -p udp --dport 53 -j DNAT --to "127.0.0.1:$dns_port"
|
||||
|
||||
if [ -f /usr/sbin/ip6tables ] && [ "${ipv6}" -eq 1 ]; then
|
||||
ip6tables -t mangle -I PREROUTING -j MARK --set-mark "$PROXY_FWMARK"
|
||||
fi
|
||||
@ -409,7 +441,28 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
|
||||
fi
|
||||
|
||||
yml_dns_change >/dev/null 2>&1
|
||||
|
||||
|
||||
if [ ! -f /etc/clash/Country.mmdb ];then
|
||||
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
|
||||
echo "Cannot find Country.mmdb" >$REAL_LOG
|
||||
elif [ "${lang}" == "zh_cn" ];then
|
||||
echo "找不到Country.mmdb" >$REAL_LOG
|
||||
fi
|
||||
sleep 5
|
||||
echo "Clash for OpenWRT" >$REAL_LOG
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/clash/config.yaml ];then
|
||||
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
|
||||
echo "Cannot find config.yaml" >$REAL_LOG
|
||||
elif [ "${lang}" == "zh_cn" ];then
|
||||
echo "找不到config.yaml" >$REAL_LOG
|
||||
fi
|
||||
sleep 5
|
||||
echo "Clash for OpenWRT" >$REAL_LOG
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${core}" -eq 1 ];then
|
||||
nohup $CLASH -d "$CLASH_CONFIG" > /tmp/clash.txt 2>&1 &
|
||||
@ -525,6 +578,7 @@ remove_mark(){
|
||||
|
||||
tun_mode=$(uci get clash.config.tun_mode 2>/dev/null)
|
||||
ipv6=$(uci get clash.config.ipv6 2>/dev/null)
|
||||
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
|
||||
|
||||
if [ -f /usr/sbin/ip6tables ] && [ "${ipv6}" -eq 1 ]; then
|
||||
ip6tables -t nat -F clash_ipv6 2>/dev/null1 && ip6tables -t nat -X clash_ipv6 2>/dev/null
|
||||
@ -534,7 +588,6 @@ remove_mark(){
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
if [ "${tun_mode}" -eq 2 ] || [ "${tun_mode}" -eq 3 ];then
|
||||
|
||||
PROXY_FWMARK="0x162" 2>/dev/null
|
||||
@ -542,11 +595,15 @@ remove_mark(){
|
||||
|
||||
ip link set dev clash0 down 2>/dev/null
|
||||
ip tuntap del clash0 mode tun 2>/dev/null
|
||||
|
||||
ip route del default dev clash0 table "$PROXY_ROUTE_TABLE" 2>/dev/null
|
||||
ip rule del fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" 2>/dev/null
|
||||
|
||||
iptables -t mangle -D OUTPUT -j clash 2>/dev/null
|
||||
iptables -t mangle -D PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK" 2>/dev/null
|
||||
|
||||
iptables -t nat -D OUTPUT -p udp --dport 53 -j CLASH_DNS
|
||||
iptables -t nat -D PREROUTING -p udp --dport 53 -j DNAT --to "127.0.0.1:$dns_port"
|
||||
|
||||
if [ -f /usr/sbin/ip6tables ] && [ "${ipv6}" -eq 1 ]; then
|
||||
ip6tables -t mangle -D PREROUTING -j MARK --set-mark "$PROXY_FWMARK" 2>/dev/null
|
||||
@ -554,12 +611,19 @@ remove_mark(){
|
||||
|
||||
iptables -t mangle -F clash 2>/dev/null
|
||||
iptables -t mangle -X clash 2>/dev/null
|
||||
|
||||
iptables -t nat -F CLASH_DNS 2>/dev/null
|
||||
iptables -t nat -X CLASH_DNS 2>/dev/null
|
||||
|
||||
ipset destroy localnetwork 2>/dev/null
|
||||
|
||||
fi
|
||||
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
}
|
||||
|
||||
del_list() {
|
||||
sh /usr/share/clash/del_servers.sh >/dev/null 2>&1
|
||||
}
|
||||
|
||||
stop(){
|
||||
#===========================================================================================================================
|
||||
@ -570,6 +634,7 @@ stop(){
|
||||
ipv6=$(uci get clash.config.ipv6 2>/dev/null)
|
||||
core=$(uci get clash.config.core 2>/dev/null)
|
||||
|
||||
|
||||
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
|
||||
echo "Stopping Client..." >$REAL_LOG
|
||||
elif [ "${lang}" == "zh_cn" ];then
|
||||
@ -638,6 +703,7 @@ stop(){
|
||||
elif [ "${lang}" == "zh_cn" ];then
|
||||
echo "重启 Dnsmasq 程序" >$REAL_LOG
|
||||
fi
|
||||
del_list >/dev/null 2>&1
|
||||
revert_dns >/dev/null 2>&1
|
||||
sleep 1
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ rm -rf /tmp/clash.tar.gz >/dev/null 2>&1
|
||||
fi
|
||||
echo '' >/tmp/clash_update.txt 2>/dev/null
|
||||
|
||||
if [ /usr/share/clash/core_down_complete ];then
|
||||
if [ -f /usr/share/clash/core_down_complete ];then
|
||||
rm -rf /usr/share/clash/core_down_complete 2>/dev/null
|
||||
fi
|
||||
|
||||
|
||||
19
package/jsda/luci-app-clash/root/usr/share/clash/del_servers.sh
Executable file
19
package/jsda/luci-app-clash/root/usr/share/clash/del_servers.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash /etc/rc.common
|
||||
. /lib/functions.sh
|
||||
|
||||
del_address(){
|
||||
countt=$(grep -c '' /usr/share/clashbackup/address.list)
|
||||
count_nums=1
|
||||
while [[ $count_nums -le $countt ]]
|
||||
do
|
||||
line=$(sed -n "$count_nums"p /usr/share/clashbackup/address.list)
|
||||
check_addr=$(grep -F "$line" "/usr/share/clash/server.list")
|
||||
line_no=$(grep -n "$check_addr" /usr/share/clash/server.list |awk -F ':' '{print $1}')
|
||||
if [ ! -z $check_addr ];then
|
||||
sed -i "${line_no}d" /usr/share/clash/server.list
|
||||
fi
|
||||
count_nums=$(( $count_nums + 1))
|
||||
done
|
||||
rm -rf /usr/share/clashbackup/address.list >/dev/null 2>&1
|
||||
}
|
||||
del_address >/dev/null 2>&1
|
||||
26
package/jsda/luci-app-clash/root/usr/share/clash/geoip.sh
Executable file
26
package/jsda/luci-app-clash/root/usr/share/clash/geoip.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
Key=$(uci get clash.config.license_key 2>/dev/null)
|
||||
if [ -f /var/run/geoip_down_complete ];then
|
||||
rm -rf /var/run/geoip_down_complete 2>/dev/null
|
||||
fi
|
||||
echo '' >/tmp/geoip_update.txt 2>/dev/null
|
||||
wget -c4 --no-check-certificate --timeout=300 --user-agent="Mozilla" "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key="$Key"&suffix=tar.gz" -O /tmp/ipdb.tar.gz
|
||||
if [ "$?" -eq "0" ]; then
|
||||
tar zxvf /tmp/ipdb.tar.gz -C /tmp\
|
||||
&& rm -rf /tmp/ipdb.tar.gz >/dev/null 2>&1\
|
||||
&& mv /tmp/GeoLite2-Country_*/GeoLite2-Country.mmdb /etc/clash/Country.mmdb\
|
||||
&& rm -rf /tmp/GeoLite2-Country_* >/dev/null 2>&1
|
||||
|
||||
sleep 2
|
||||
touch /var/run/geoip_down_complete >/dev/null 2>&1
|
||||
sleep 2
|
||||
rm -rf /var/run/geoip_update >/dev/null 2>&1
|
||||
echo "" > /tmp/geoip_update.txt >/dev/null 2>&1
|
||||
|
||||
if pidof clash >/dev/null; then
|
||||
/etc/init.d/clash restart 2>/dev/null
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
@ -1,4 +1,40 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash /etc/rc.common
|
||||
. /lib/functions.sh
|
||||
|
||||
dnsforwader=$(uci get clash.config.dnsforwader 2>/dev/null)
|
||||
|
||||
add_address(){
|
||||
servers_get()
|
||||
{
|
||||
local section="$1"
|
||||
config_get "server" "$section" "server" ""
|
||||
echo "$server" >>/tmp/server.conf
|
||||
}
|
||||
config_load clash
|
||||
config_foreach servers_get "servers"
|
||||
|
||||
count=$(grep -c '' /tmp/server.conf)
|
||||
count_num=1
|
||||
while [[ $count_num -le $count ]]
|
||||
do
|
||||
line=$(sed -n "$count_num"p /tmp/server.conf)
|
||||
check_addr=$(grep -F "$line" "/usr/share/clash/server.list")
|
||||
if [ -z $check_addr ];then
|
||||
echo $line >>/usr/share/clashbackup/address.list
|
||||
fi
|
||||
count_num=$(( $count_num + 1))
|
||||
done
|
||||
cat /usr/share/clashbackup/address.list /usr/share/clash/server.list > /usr/share/clash/me.list
|
||||
rm -rf /usr/share/clash/server.list
|
||||
mv /usr/share/clash/me.list /usr/share/clash/server.list
|
||||
chmod 755 /usr/share/clash/server.list
|
||||
rm -rf /tmp/server.conf >/dev/null 2>&1
|
||||
}
|
||||
if [ "${dnsforwader}" -eq 1 ];then
|
||||
add_address >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
|
||||
enable_list=$(uci get clash.config.cus_list 2>/dev/null)
|
||||
if [ $enable_list -eq 1 ];then
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
1.4.6
|
||||
1.4.8
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
#!/bin/bash /etc/rc.common
|
||||
. /lib/functions.sh
|
||||
|
||||
create_config(){
|
||||
|
||||
REAL_LOG="/usr/share/clash/clash_real.txt"
|
||||
lang=$(uci get luci.main.lang 2>/dev/null)
|
||||
config_type=$(uci get clash.config.config_type 2>/dev/null)
|
||||
create=$(uci get clash.config.create 2>/dev/null)
|
||||
load_from=$(uci get clash.config.loadfrom 2>/dev/null)
|
||||
load_from=$(uci get clash.config.loadfrom 2>/dev/null)
|
||||
|
||||
|
||||
if [ "$load_from" == "sub" ];then
|
||||
@ -14,7 +16,6 @@ elif [ "$load_from" == "upl" ];then
|
||||
load="/usr/share/clash/config/upload/config.yaml"
|
||||
fi
|
||||
|
||||
|
||||
if [ "${create}" -eq 1 ];then
|
||||
|
||||
if [ $lang == "en" ] || [ $lang == "auto" ];then
|
||||
@ -36,23 +37,22 @@ CFG_FILE="/etc/config/clash"
|
||||
DNS_FILE="/usr/share/clash/dns.yaml"
|
||||
PROVIDER_FILE="/tmp/yaml_provider.yaml"
|
||||
|
||||
|
||||
|
||||
servcount=$( grep -c "config servers" $CFG_FILE 2>/dev/null)
|
||||
gcount=$( grep -c "config groups" $CFG_FILE 2>/dev/null)
|
||||
if [ $servcount -eq 0 ] || [ $gcount -eq 0 ];then
|
||||
scount=$( grep -c "config servers" $CFG_FILE 2>/dev/null)
|
||||
pcount=$( grep -c "config provider" $CFG_FILE 2>/dev/null)
|
||||
if [ $gcount -eq 0 ];then
|
||||
if [ $lang == "en" ] || [ $lang == "auto" ];then
|
||||
echo "No servers or group. Aborting Operation .." >$REAL_LOG
|
||||
echo "No policy group found. Aborting Operation .." >$REAL_LOG
|
||||
sleep 2
|
||||
echo "Clash for OpenWRT" >$REAL_LOG
|
||||
elif [ $lang == "zh_cn" ];then
|
||||
echo "找不到代理或策略组。中止操作..." >$REAL_LOG
|
||||
echo "找不到策略组。中止操作..." >$REAL_LOG
|
||||
sleep 2
|
||||
echo "Clash for OpenWRT" >$REAL_LOG
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
sleep 2
|
||||
|
||||
|
||||
|
||||
@ -113,6 +113,19 @@ EOF
|
||||
|
||||
}
|
||||
|
||||
if [ $pcount -gt 0 ];then
|
||||
config_load "clash"
|
||||
config_foreach yml_proxy_provider_set "provider"
|
||||
fi
|
||||
|
||||
if [ -f $PROVIDER_FILE ];then
|
||||
sed -i "1i\ " $PROVIDER_FILE 2>/dev/null
|
||||
sed -i "2i\proxy-provider:" $PROVIDER_FILE 2>/dev/null
|
||||
#echo "proxy-provider:" >$PROVIDER_FILE
|
||||
rm -rf /tmp/Proxy_Provider
|
||||
|
||||
fi
|
||||
|
||||
|
||||
servers_set()
|
||||
{
|
||||
@ -353,32 +366,32 @@ EOF
|
||||
}
|
||||
|
||||
|
||||
|
||||
config_load "clash"
|
||||
config_foreach yml_proxy_provider_set "provider"
|
||||
|
||||
if [ -f $PROVIDER_FILE ];then
|
||||
sed -i "1i\ " $PROVIDER_FILE 2>/dev/null
|
||||
sed -i "2i\proxy-provider:" $PROVIDER_FILE 2>/dev/null
|
||||
#echo "proxy-provider:" >$PROVIDER_FILE
|
||||
rm -rf /tmp/Proxy_Provider
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if [ $scount -gt 0 ];then
|
||||
config_load clash
|
||||
config_foreach servers_set "servers"
|
||||
fi
|
||||
|
||||
if [ -z "${scount}" ] || [ "${scount}" -eq 0 ];then
|
||||
cat >> "$SERVER_FILE" <<-EOF
|
||||
- name: Shadowsocks
|
||||
type: ss
|
||||
server: 127.0.0.1
|
||||
port: 1080
|
||||
cipher: aes-256-gcm
|
||||
password: "12345"
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "$(ls -l $SERVER_FILE|awk '{print $5}')" -ne 0 ]; then
|
||||
|
||||
sed -i "1i\ " $SERVER_FILE 2>/dev/null
|
||||
sed -i "2i\Proxy:" $SERVER_FILE 2>/dev/null
|
||||
|
||||
egrep '^ {0,}-' $SERVER_FILE |grep name: |awk -F 'name: ' '{print $2}' |sed 's/,.*//' >$Proxy_Group 2>&1
|
||||
|
||||
sed -i "s/^ \{0,\}/ - /" $Proxy_Group 2>/dev/null
|
||||
|
||||
|
||||
|
||||
yml_servers_add()
|
||||
{
|
||||
|
||||
@ -482,21 +495,21 @@ yml_groups_set()
|
||||
|
||||
if [ "$( grep -c "config provider" $CFG_FILE )" -ne 0 ];then
|
||||
|
||||
echo " use: $group_name" >>$GROUP_FILE
|
||||
|
||||
config_foreach set_proxy_provider "provider" "$group_name"
|
||||
echo " use: $group_name" >>$GROUP_FILE
|
||||
|
||||
config_foreach set_proxy_provider "provider" "$group_name"
|
||||
|
||||
if [ "$set_group" -eq 1 ]; then
|
||||
sed -i "/^ \{0,\}proxies: ${group_name}/c\ proxies:" $GROUP_FILE
|
||||
else
|
||||
sed -i "/proxies: ${group_name}/d" $GROUP_FILE 2>/dev/null
|
||||
fi
|
||||
if [ "$set_group" -eq 1 ]; then
|
||||
sed -i "/^ \{0,\}proxies: ${group_name}/c\ proxies:" $GROUP_FILE
|
||||
else
|
||||
sed -i "/proxies: ${group_name}/d" $GROUP_FILE 2>/dev/null
|
||||
fi
|
||||
|
||||
if [ "$set_proxy_provider" -eq 1 ]; then
|
||||
sed -i "/^ \{0,\}use: ${group_name}/c\ use:" $GROUP_FILE
|
||||
else
|
||||
sed -i "/use: ${group_name}/d" $GROUP_FILE 2>/dev/null
|
||||
fi
|
||||
if [ "$set_proxy_provider" -eq 1 ]; then
|
||||
sed -i "/^ \{0,\}use: ${group_name}/c\ use:" $GROUP_FILE
|
||||
else
|
||||
sed -i "/use: ${group_name}/d" $GROUP_FILE 2>/dev/null
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
@ -562,7 +575,9 @@ EOF
|
||||
|
||||
cat $DNS_FILE >> $TEMP_FILE 2>/dev/null
|
||||
|
||||
if [ -f $SERVER_FILE ];then
|
||||
cat $SERVER_FILE >> $TEMP_FILE 2>/dev/null
|
||||
fi
|
||||
|
||||
cat $GROUP_FILE >> $TEMP_FILE 2>/dev/null
|
||||
|
||||
@ -599,8 +614,9 @@ if pidof clash >/dev/null; then
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
rm -rf $SERVER_FILE
|
||||
|
||||
fi
|
||||
|
||||
}
|
||||
create_config >/dev/null 2>&1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user