package lienol: update
This commit is contained in:
parent
b655948196
commit
a34a169518
14
package/lienol/luci-app-fileassistant/Makefile
Normal file
14
package/lienol/luci-app-fileassistant/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
# From https://github.com/DarkDean89/luci-app-filebrowser
|
||||
# From https://github.com/stuarthua/oh-my-openwrt/tree/master/stuart/luci-app-fileassistant
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for Fileassistant
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@ -0,0 +1,68 @@
|
||||
.fb-container {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.fb-container .cbi-button {
|
||||
height: 1.8rem;
|
||||
}
|
||||
.fb-container .cbi-input-text {
|
||||
margin-bottom: 1rem;
|
||||
width: 100%;
|
||||
}
|
||||
.fb-container .panel-title {
|
||||
padding-bottom: 0;
|
||||
width: 50%;
|
||||
border-bottom: none;
|
||||
}
|
||||
.fb-container .panel-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 1rem;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.fb-container .upload-container {
|
||||
display: none;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
.fb-container .upload-file {
|
||||
margin-right: 2rem;
|
||||
}
|
||||
.fb-container .cbi-value-field {
|
||||
text-align: left;
|
||||
}
|
||||
.fb-container .parent-icon strong {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
.fb-container td[class$="-icon"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
.fb-container .file-icon, .fb-container .folder-icon, .fb-container .link-icon {
|
||||
position: relative;
|
||||
}
|
||||
.fb-container .file-icon:before, .fb-container .folder-icon:before, .fb-container .link-icon:before {
|
||||
display: inline-block;
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
content: '';
|
||||
background-size: contain;
|
||||
margin: 0 0.5rem 0 1rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.fb-container .file-icon:before {
|
||||
background-image: url(file-icon.png);
|
||||
}
|
||||
.fb-container .folder-icon:before {
|
||||
background-image: url(folder-icon.png);
|
||||
}
|
||||
.fb-container .link-icon:before {
|
||||
background-image: url(link-icon.png);
|
||||
}
|
||||
@media screen and (max-width: 480px) {
|
||||
.fb-container .upload-file {
|
||||
width: 14.6rem;
|
||||
}
|
||||
.fb-container .cbi-value-owner,
|
||||
.fb-container .cbi-value-perm {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,288 @@
|
||||
String.prototype.replaceAll = function(search, replacement) {
|
||||
var target = this;
|
||||
return target.replace(new RegExp(search, 'g'), replacement);
|
||||
};
|
||||
(function () {
|
||||
var iwxhr = new XHR();
|
||||
var listElem = document.getElementById("list-content");
|
||||
listElem.onclick = handleClick;
|
||||
var currentPath;
|
||||
var pathElem = document.getElementById("current-path");
|
||||
pathElem.onblur = function () {
|
||||
update_list(this.value.trim());
|
||||
};
|
||||
pathElem.onkeyup = function (evt) {
|
||||
if (evt.keyCode == 13) {
|
||||
this.blur();
|
||||
}
|
||||
};
|
||||
function removePath(filename, isdir) {
|
||||
var c = confirm('你确定要删除 ' + filename + ' 吗?');
|
||||
if (c) {
|
||||
iwxhr.get('/cgi-bin/luci/admin/nas/fileassistant/delete',
|
||||
{
|
||||
path: concatPath(currentPath, filename),
|
||||
isdir: isdir
|
||||
},
|
||||
function (x, res) {
|
||||
if (res.ec === 0) {
|
||||
refresh_list(res.data, currentPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function installPath(filename, isdir) {
|
||||
if (isdir === "1") {
|
||||
alert('这是一个目录,请选择 ipk 文件进行安装!');
|
||||
return;
|
||||
}
|
||||
var isipk = isIPK(filename);
|
||||
if (isipk === 0) {
|
||||
alert('只允许安装 ipk 格式的文件!');
|
||||
return;
|
||||
}
|
||||
var c = confirm('你确定要安装 ' + filename + ' 吗?');
|
||||
if (c) {
|
||||
iwxhr.get('/cgi-bin/luci/admin/nas/fileassistant/install',
|
||||
{
|
||||
filepath: concatPath(currentPath, filename),
|
||||
isdir: isdir
|
||||
},
|
||||
function (x, res) {
|
||||
if (res.ec === 0) {
|
||||
location.reload();
|
||||
alert('安装成功!');
|
||||
} else {
|
||||
alert('安装失败,请检查文件格式!');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function isIPK(filename) {
|
||||
var index= filename.lastIndexOf(".");
|
||||
var ext = filename.substr(index+1);
|
||||
if (ext === 'ipk') {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function renamePath(filename) {
|
||||
var newname = prompt('请输入新的文件名:', filename);
|
||||
if (newname) {
|
||||
newname = newname.trim();
|
||||
if (newname != filename) {
|
||||
var newpath = concatPath(currentPath, newname);
|
||||
iwxhr.get('/cgi-bin/luci/admin/nas/fileassistant/rename',
|
||||
{
|
||||
filepath: concatPath(currentPath, filename),
|
||||
newpath: newpath
|
||||
},
|
||||
function (x, res) {
|
||||
if (res.ec === 0) {
|
||||
refresh_list(res.data, currentPath);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openpath(filename, dirname) {
|
||||
dirname = dirname || currentPath;
|
||||
window.open('/cgi-bin/luci/admin/nas/fileassistant/open?path='
|
||||
+ encodeURIComponent(dirname) + '&filename='
|
||||
+ encodeURIComponent(filename));
|
||||
}
|
||||
|
||||
function getFileElem(elem) {
|
||||
if (elem.className.indexOf('-icon') > -1) {
|
||||
return elem;
|
||||
}
|
||||
else if (elem.parentNode.className.indexOf('-icon') > -1) {
|
||||
return elem.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
function concatPath(path, filename) {
|
||||
if (path === '/') {
|
||||
return path + filename;
|
||||
}
|
||||
else {
|
||||
return path.replace(/\/$/, '') + '/' + filename;
|
||||
}
|
||||
}
|
||||
|
||||
function handleClick(evt) {
|
||||
var targetElem = evt.target;
|
||||
var infoElem;
|
||||
if (targetElem.className.indexOf('cbi-button-remove') > -1) {
|
||||
infoElem = targetElem.parentNode.parentNode;
|
||||
removePath(infoElem.dataset['filename'] , infoElem.dataset['isdir'])
|
||||
}
|
||||
else if (targetElem.className.indexOf('cbi-button-install') > -1) {
|
||||
infoElem = targetElem.parentNode.parentNode;
|
||||
installPath(infoElem.dataset['filename'] , infoElem.dataset['isdir'])
|
||||
}
|
||||
else if (targetElem.className.indexOf('cbi-button-edit') > -1) {
|
||||
renamePath(targetElem.parentNode.parentNode.dataset['filename']);
|
||||
}
|
||||
else if (targetElem = getFileElem(targetElem)) {
|
||||
if (targetElem.className.indexOf('parent-icon') > -1) {
|
||||
update_list(currentPath.replace(/\/[^/]+($|\/$)/, ''));
|
||||
}
|
||||
else if (targetElem.className.indexOf('file-icon') > -1) {
|
||||
openpath(targetElem.parentNode.dataset['filename']);
|
||||
}
|
||||
else if (targetElem.className.indexOf('link-icon') > -1) {
|
||||
infoElem = targetElem.parentNode;
|
||||
var filepath = infoElem.dataset['linktarget'];
|
||||
if (filepath) {
|
||||
if (infoElem.dataset['isdir'] === "1") {
|
||||
update_list(filepath);
|
||||
}
|
||||
else {
|
||||
var lastSlash = filepath.lastIndexOf('/');
|
||||
openpath(filepath.substring(lastSlash + 1), filepath.substring(0, lastSlash));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (targetElem.className.indexOf('folder-icon') > -1) {
|
||||
update_list(concatPath(currentPath, targetElem.parentNode.dataset['filename']))
|
||||
}
|
||||
}
|
||||
}
|
||||
function refresh_list(filenames, path) {
|
||||
var listHtml = '<table class="cbi-section-table"><tbody>';
|
||||
if (path !== '/') {
|
||||
listHtml += '<tr class="cbi-section-table-row cbi-rowstyle-2"><td class="parent-icon" colspan="6"><strong>..</strong></td></tr>';
|
||||
}
|
||||
if (filenames) {
|
||||
for (var i = 0; i < filenames.length; i++) {
|
||||
var line = filenames[i];
|
||||
if (line) {
|
||||
var f = line.match(/(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+([\S\s]+)/);
|
||||
var isLink = f[1][0] === 'z' || f[1][0] === 'l' || f[1][0] === 'x';
|
||||
var o = {
|
||||
displayname: f[9],
|
||||
filename: isLink ? f[9].split(' -> ')[0] : f[9],
|
||||
perms: f[1],
|
||||
date: f[7] + ' ' + f[6] + ' ' + f[8],
|
||||
size: f[5],
|
||||
owner: f[3],
|
||||
icon: (f[1][0] === 'd') ? "folder-icon" : (isLink ? "link-icon" : "file-icon")
|
||||
};
|
||||
|
||||
var install_btn = '<button class="cbi-button cbi-button-install" style="visibility: hidden;">安装</button>';
|
||||
var index= o.filename.lastIndexOf(".");
|
||||
var ext = o.filename.substr(index+1);
|
||||
if (ext === 'ipk') {
|
||||
install_btn = '<button class="cbi-button cbi-button-install">安装</button>';
|
||||
}
|
||||
|
||||
listHtml += '<tr class="cbi-section-table-row cbi-rowstyle-' + (1 + i%2)
|
||||
+ '" data-filename="' + o.filename + '" data-isdir="' + Number(f[1][0] === 'd' || f[1][0] === 'z') + '"'
|
||||
+ ((f[1][0] === 'z' || f[1][0] === 'l') ? (' data-linktarget="' + f[9].split(' -> ')[1]) : '')
|
||||
+ '">'
|
||||
+ '<td class="cbi-value-field ' + o.icon + '">'
|
||||
+ '<strong>' + o.displayname + '</strong>'
|
||||
+ '</td>'
|
||||
+ '<td class="cbi-value-field cbi-value-owner">'+o.owner+'</td>'
|
||||
+ '<td class="cbi-value-field cbi-value-date">'+o.date+'</td>'
|
||||
+ '<td class="cbi-value-field cbi-value-size">'+o.size+'</td>'
|
||||
+ '<td class="cbi-value-field cbi-value-perm">'+o.perms+'</td>'
|
||||
+ '<td class="cbi-section-table-cell">\
|
||||
<button class="cbi-button cbi-button-edit">重命名</button>\
|
||||
<button class="cbi-button cbi-button-remove">删除</button>'
|
||||
+ install_btn
|
||||
+ '</td>'
|
||||
+ '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
listHtml += "</table>";
|
||||
listElem.innerHTML = listHtml;
|
||||
}
|
||||
function update_list(path, opt) {
|
||||
opt = opt || {};
|
||||
path = concatPath(path, '');
|
||||
if (currentPath != path) {
|
||||
iwxhr.get('/cgi-bin/luci/admin/nas/fileassistant/list',
|
||||
{path: path},
|
||||
function (x, res) {
|
||||
if (res.ec === 0) {
|
||||
refresh_list(res.data, path);
|
||||
}
|
||||
else {
|
||||
refresh_list([], path);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (!opt.popState) {
|
||||
history.pushState({path: path}, null, '?path=' + path);
|
||||
}
|
||||
currentPath = path;
|
||||
pathElem.value = currentPath;
|
||||
}
|
||||
};
|
||||
|
||||
var uploadToggle = document.getElementById('upload-toggle');
|
||||
var uploadContainer = document.getElementById('upload-container');
|
||||
var isUploadHide = true;
|
||||
uploadToggle.onclick = function() {
|
||||
if (isUploadHide) {
|
||||
uploadContainer.style.display = 'inline-flex';
|
||||
}
|
||||
else {
|
||||
uploadContainer.style.display = 'none';
|
||||
}
|
||||
isUploadHide = !isUploadHide;
|
||||
};
|
||||
var uploadBtn = uploadContainer.getElementsByClassName('cbi-input-apply')[0];
|
||||
uploadBtn.onclick = function (evt) {
|
||||
var uploadinput = document.getElementById('upload-file');
|
||||
var fullPath = uploadinput.value;
|
||||
if (!fullPath) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
else {
|
||||
var formData = new FormData();
|
||||
var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/'));
|
||||
formData.append('upload-filename', fullPath.substring(startIndex + 1));
|
||||
formData.append('upload-dir', concatPath(currentPath, ''));
|
||||
formData.append('upload-file', uploadinput.files[0]);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/cgi-bin/luci/admin/nas/fileassistant/upload", true);
|
||||
xhr.onload = function() {
|
||||
if (xhr.status == 200) {
|
||||
var res = JSON.parse(xhr.responseText);
|
||||
refresh_list(res.data, currentPath);
|
||||
uploadinput.value = '';
|
||||
}
|
||||
else {
|
||||
alert('上传失败,请稍后再试...');
|
||||
}
|
||||
};
|
||||
xhr.send(formData);
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function(evt) {
|
||||
var initPath = '/';
|
||||
if (/path=([/\w]+)/.test(location.search)) {
|
||||
initPath = RegExp.$1;
|
||||
}
|
||||
update_list(initPath, {popState: true});
|
||||
});
|
||||
window.addEventListener('popstate', function (evt) {
|
||||
var path = '/';
|
||||
if (evt.state && evt.state.path) {
|
||||
path = evt.state.path;
|
||||
}
|
||||
update_list(path, {popState: true});
|
||||
});
|
||||
|
||||
})();
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@ -0,0 +1,230 @@
|
||||
module("luci.controller.fileassistant", package.seeall)
|
||||
|
||||
function index()
|
||||
|
||||
entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false
|
||||
|
||||
local page
|
||||
page = entry({"admin", "nas", "fileassistant"}, template("fileassistant"), _("文件助手"), 1)
|
||||
page.i18n = "base"
|
||||
page.dependent = true
|
||||
|
||||
page = entry({"admin", "nas", "fileassistant", "list"}, call("fileassistant_list"), nil)
|
||||
page.leaf = true
|
||||
|
||||
page = entry({"admin", "nas", "fileassistant", "open"}, call("fileassistant_open"), nil)
|
||||
page.leaf = true
|
||||
|
||||
page = entry({"admin", "nas", "fileassistant", "delete"}, call("fileassistant_delete"), nil)
|
||||
page.leaf = true
|
||||
|
||||
page = entry({"admin", "nas", "fileassistant", "rename"}, call("fileassistant_rename"), nil)
|
||||
page.leaf = true
|
||||
|
||||
page = entry({"admin", "nas", "fileassistant", "upload"}, call("fileassistant_upload"), nil)
|
||||
page.leaf = true
|
||||
|
||||
page = entry({"admin", "nas", "fileassistant", "install"}, call("fileassistant_install"), nil)
|
||||
page.leaf = true
|
||||
|
||||
end
|
||||
|
||||
function list_response(path, success)
|
||||
luci.http.prepare_content("application/json")
|
||||
local result
|
||||
if success then
|
||||
local rv = scandir(path)
|
||||
result = {
|
||||
ec = 0,
|
||||
data = rv
|
||||
}
|
||||
else
|
||||
result = {
|
||||
ec = 1
|
||||
}
|
||||
end
|
||||
luci.http.write_json(result)
|
||||
end
|
||||
|
||||
function fileassistant_list()
|
||||
local path = luci.http.formvalue("path")
|
||||
list_response(path, true)
|
||||
end
|
||||
|
||||
function fileassistant_open()
|
||||
local path = luci.http.formvalue("path")
|
||||
local filename = luci.http.formvalue("filename")
|
||||
local io = require "io"
|
||||
local mime = to_mime(filename)
|
||||
|
||||
file = path..filename
|
||||
|
||||
local download_fpi = io.open(file, "r")
|
||||
luci.http.header('Content-Disposition', 'inline; filename="'..filename..'"' )
|
||||
luci.http.prepare_content(mime)
|
||||
luci.ltn12.pump.all(luci.ltn12.source.file(download_fpi), luci.http.write)
|
||||
end
|
||||
|
||||
function fileassistant_delete()
|
||||
local path = luci.http.formvalue("path")
|
||||
local isdir = luci.http.formvalue("isdir")
|
||||
path = path:gsub("<>", "/")
|
||||
path = path:gsub(" ", "\ ")
|
||||
local success
|
||||
if isdir then
|
||||
success = os.execute('rm -r "'..path..'"')
|
||||
else
|
||||
success = os.remove(path)
|
||||
end
|
||||
list_response(nixio.fs.dirname(path), success)
|
||||
end
|
||||
|
||||
function fileassistant_rename()
|
||||
local filepath = luci.http.formvalue("filepath")
|
||||
local newpath = luci.http.formvalue("newpath")
|
||||
local success = os.execute('mv "'..filepath..'" "'..newpath..'"')
|
||||
list_response(nixio.fs.dirname(filepath), success)
|
||||
end
|
||||
|
||||
function fileassistant_install()
|
||||
local filepath = luci.http.formvalue("filepath")
|
||||
local isdir = luci.http.formvalue("isdir")
|
||||
local ext = filepath:match(".+%.(%w+)$")
|
||||
filepath = filepath:gsub("<>", "/")
|
||||
filepath = filepath:gsub(" ", "\ ")
|
||||
local success
|
||||
if isdir == "1" then
|
||||
success = false
|
||||
elseif ext == "ipk" then
|
||||
success = installIPK(filepath)
|
||||
else
|
||||
success = false
|
||||
end
|
||||
list_response(nixio.fs.dirname(filepath), success)
|
||||
end
|
||||
|
||||
function installIPK(filepath)
|
||||
luci.sys.exec('opkg --force-depends install "'..filepath..'"')
|
||||
luci.sys.exec('rm -rf /tmp/luci-*')
|
||||
return true;
|
||||
end
|
||||
|
||||
function fileassistant_upload()
|
||||
local filecontent = luci.http.formvalue("upload-file")
|
||||
local filename = luci.http.formvalue("upload-filename")
|
||||
local uploaddir = luci.http.formvalue("upload-dir")
|
||||
local filepath = uploaddir..filename
|
||||
|
||||
local fp
|
||||
luci.http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not fp and meta and meta.name == "upload-file" then
|
||||
fp = io.open(filepath, "w")
|
||||
end
|
||||
if fp and chunk then
|
||||
fp:write(chunk)
|
||||
end
|
||||
if fp and eof then
|
||||
fp:close()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
list_response(uploaddir, true)
|
||||
end
|
||||
|
||||
function scandir(directory)
|
||||
local i, t, popen = 0, {}, io.popen
|
||||
|
||||
local pfile = popen("ls -lh \""..directory.."\" | egrep '^d' ; ls -lh \""..directory.."\" | egrep -v '^d|^l'")
|
||||
for fileinfo in pfile:lines() do
|
||||
i = i + 1
|
||||
t[i] = fileinfo
|
||||
end
|
||||
pfile:close()
|
||||
pfile = popen("ls -lh \""..directory.."\" | egrep '^l' ;")
|
||||
for fileinfo in pfile:lines() do
|
||||
i = i + 1
|
||||
linkindex, _, linkpath = string.find(fileinfo, "->%s+(.+)$")
|
||||
local finalpath;
|
||||
if string.sub(linkpath, 1, 1) == "/" then
|
||||
finalpath = linkpath
|
||||
else
|
||||
finalpath = nixio.fs.realpath(directory..linkpath)
|
||||
end
|
||||
local linktype;
|
||||
if not finalpath then
|
||||
finalpath = linkpath;
|
||||
linktype = 'x'
|
||||
elseif nixio.fs.stat(finalpath, "type") == "dir" then
|
||||
linktype = 'z'
|
||||
else
|
||||
linktype = 'l'
|
||||
end
|
||||
fileinfo = string.sub(fileinfo, 2, linkindex - 1)
|
||||
fileinfo = linktype..fileinfo.."-> "..finalpath
|
||||
t[i] = fileinfo
|
||||
end
|
||||
pfile:close()
|
||||
return t
|
||||
end
|
||||
|
||||
MIME_TYPES = {
|
||||
["txt"] = "text/plain";
|
||||
["conf"] = "text/plain";
|
||||
["ovpn"] = "text/plain";
|
||||
["log"] = "text/plain";
|
||||
["js"] = "text/javascript";
|
||||
["json"] = "application/json";
|
||||
["css"] = "text/css";
|
||||
["htm"] = "text/html";
|
||||
["html"] = "text/html";
|
||||
["patch"] = "text/x-patch";
|
||||
["c"] = "text/x-csrc";
|
||||
["h"] = "text/x-chdr";
|
||||
["o"] = "text/x-object";
|
||||
["ko"] = "text/x-object";
|
||||
|
||||
["bmp"] = "image/bmp";
|
||||
["gif"] = "image/gif";
|
||||
["png"] = "image/png";
|
||||
["jpg"] = "image/jpeg";
|
||||
["jpeg"] = "image/jpeg";
|
||||
["svg"] = "image/svg+xml";
|
||||
|
||||
["zip"] = "application/zip";
|
||||
["pdf"] = "application/pdf";
|
||||
["xml"] = "application/xml";
|
||||
["xsl"] = "application/xml";
|
||||
["doc"] = "application/msword";
|
||||
["ppt"] = "application/vnd.ms-powerpoint";
|
||||
["xls"] = "application/vnd.ms-excel";
|
||||
["odt"] = "application/vnd.oasis.opendocument.text";
|
||||
["odp"] = "application/vnd.oasis.opendocument.presentation";
|
||||
["pl"] = "application/x-perl";
|
||||
["sh"] = "application/x-shellscript";
|
||||
["php"] = "application/x-php";
|
||||
["deb"] = "application/x-deb";
|
||||
["iso"] = "application/x-cd-image";
|
||||
["tgz"] = "application/x-compressed-tar";
|
||||
|
||||
["mp3"] = "audio/mpeg";
|
||||
["ogg"] = "audio/x-vorbis+ogg";
|
||||
["wav"] = "audio/x-wav";
|
||||
|
||||
["mpg"] = "video/mpeg";
|
||||
["mpeg"] = "video/mpeg";
|
||||
["avi"] = "video/x-msvideo";
|
||||
}
|
||||
|
||||
function to_mime(filename)
|
||||
if type(filename) == "string" then
|
||||
local ext = filename:match("[^%.]+$")
|
||||
|
||||
if ext and MIME_TYPES[ext:lower()] then
|
||||
return MIME_TYPES[ext:lower()]
|
||||
end
|
||||
end
|
||||
|
||||
return "application/octet-stream"
|
||||
end
|
||||
@ -0,0 +1,20 @@
|
||||
<%+header%>
|
||||
|
||||
<link rel="stylesheet" href="/luci-static/resources/fileassistant/fb.css?v=@ver">
|
||||
<h2 name="content">文件助手</h2>
|
||||
<fieldset class="cbi-section fb-container">
|
||||
<input id="current-path" type="text" class="current-path cbi-input-text" value="/"/>
|
||||
<div class="panel-container">
|
||||
<div class="panel-title">文件列表</div>
|
||||
<button id="upload-toggle" class="upload-toggle cbi-button cbi-button-edit">上传</button>
|
||||
</div>
|
||||
<div class="upload-container" id="upload-container">
|
||||
<input id="upload-file" name="upload-file" class="upload-file" type="file">
|
||||
<button type="button" class="cbi-button cbi-input-apply">点我上传</button>
|
||||
</div>
|
||||
<div id="list-content"></div>
|
||||
</fieldset>
|
||||
|
||||
<script src="/luci-static/resources/fileassistant/fb.js?v=@ver"></script>
|
||||
|
||||
<%+footer%>
|
||||
17
package/lienol/luci-app-mia/Makefile
Normal file
17
package/lienol/luci-app-mia/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for Mia
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=3-20190309
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
|
||||
17
package/lienol/luci-app-mia/luasrc/controller/mia.lua
Normal file
17
package/lienol/luci-app-mia/luasrc/controller/mia.lua
Normal file
@ -0,0 +1,17 @@
|
||||
module("luci.controller.mia", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/mia") then return end
|
||||
|
||||
entry({"admin", "network"}, firstchild(), "Control", 44).dependent = false
|
||||
entry({"admin", "network", "mia"}, cbi("mia"), _("时间控制"), 10).dependent =
|
||||
true
|
||||
entry({"admin", "network", "mia", "status"}, call("status")).leaf = true
|
||||
end
|
||||
|
||||
function status()
|
||||
local e = {}
|
||||
e.status = luci.sys.call("iptables -L FORWARD |grep MIA >/dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
44
package/lienol/luci-app-mia/luasrc/model/cbi/mia.lua
Normal file
44
package/lienol/luci-app-mia/luasrc/model/cbi/mia.lua
Normal file
@ -0,0 +1,44 @@
|
||||
local o = require "luci.sys"
|
||||
local a, t, e
|
||||
a = Map("mia", translate("上网时间管理"),
|
||||
translate("上网时间段控制系统。"))
|
||||
a.template = "mia/index"
|
||||
t = a:section(TypedSection, "basic", translate("Running Status"))
|
||||
t.anonymous = true
|
||||
e = t:option(DummyValue, "mia_status", translate("当前状态"))
|
||||
e.template = "mia/mia"
|
||||
e.value = translate("Collecting data...")
|
||||
t = a:section(TypedSection, "basic", translate("基本设置"))
|
||||
t.anonymous = true
|
||||
e = t:option(Flag, "enable", translate("开启"))
|
||||
e.rmempty = false
|
||||
t = a:section(TypedSection, "macbind", translate("客户端设置"))
|
||||
t.template = "cbi/tblsection"
|
||||
t.anonymous = true
|
||||
t.addremove = true
|
||||
e = t:option(Flag, "enable", translate("开启控制"))
|
||||
e.rmempty = false
|
||||
e = t:option(Value, "macaddr", translate("黑名单MAC"))
|
||||
e.rmempty = true
|
||||
o.net.mac_hints(function(t, a) e:value(t, "%s (%s)" % {t, a}) end)
|
||||
e = t:option(Value, "timeon", translate("禁止上网开始时间"))
|
||||
e.default = "00:00"
|
||||
e.optional = false
|
||||
e = t:option(Value, "timeoff", translate("取消禁止上网时间"))
|
||||
e.default = "23:59"
|
||||
e.optional = false
|
||||
e = t:option(Flag, "z1", translate("周一"))
|
||||
e.rmempty = true
|
||||
e = t:option(Flag, "z2", translate("周二"))
|
||||
e.rmempty = true
|
||||
e = t:option(Flag, "z3", translate("周三"))
|
||||
e.rmempty = true
|
||||
e = t:option(Flag, "z4", translate("周四"))
|
||||
e.rmempty = true
|
||||
e = t:option(Flag, "z5", translate("周五"))
|
||||
e.rmempty = true
|
||||
e = t:option(Flag, "z6", translate("周六"))
|
||||
e.rmempty = true
|
||||
e = t:option(Flag, "z7", translate("周日"))
|
||||
e.rmempty = true
|
||||
return a
|
||||
17
package/lienol/luci-app-mia/luasrc/view/mia/index.htm
Normal file
17
package/lienol/luci-app-mia/luasrc/view/mia/index.htm
Normal file
@ -0,0 +1,17 @@
|
||||
<%#
|
||||
Copyright 2016 Chen RuiWei <crwbak@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<% include("cbi/map") %>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "mia", "status")%>', null,
|
||||
function (x, result) {
|
||||
var status = document.getElementsByClassName('mia_status')[0];
|
||||
status.setAttribute("style", "font-weight:bold;");
|
||||
status.setAttribute("color", result.status ? "green" : "red");
|
||||
status.innerHTML = result.status ? '<%=translate("RUNNING")%>' : '<%=translate("NOT RUNNING")%>';
|
||||
}
|
||||
)
|
||||
//]]>
|
||||
</script>
|
||||
3
package/lienol/luci-app-mia/luasrc/view/mia/mia.htm
Normal file
3
package/lienol/luci-app-mia/luasrc/view/mia/mia.htm
Normal file
@ -0,0 +1,3 @@
|
||||
<%+cbi/valueheader%>
|
||||
<font class="mia_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
|
||||
<%+cbi/valuefooter%>
|
||||
2
package/lienol/luci-app-mia/po/zh-cn/mia.po
Normal file
2
package/lienol/luci-app-mia/po/zh-cn/mia.po
Normal file
@ -0,0 +1,2 @@
|
||||
msgid "Control"
|
||||
msgstr "管控"
|
||||
3
package/lienol/luci-app-mia/root/etc/config/mia
Normal file
3
package/lienol/luci-app-mia/root/etc/config/mia
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
config basic
|
||||
option enable '0'
|
||||
111
package/lienol/luci-app-mia/root/etc/init.d/mia
Executable file
111
package/lienol/luci-app-mia/root/etc/init.d/mia
Executable file
@ -0,0 +1,111 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt-dist
|
||||
# Copyright (C) 2016 fw867 <ffkykzs@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
START=99
|
||||
|
||||
CONFIG=mia
|
||||
|
||||
uci_get_by_type() {
|
||||
local index=0
|
||||
if [ -n $4 ]; then
|
||||
index=$4
|
||||
fi
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
is_true() {
|
||||
case $1 in
|
||||
1|on|true|yes|enabled) echo 0;;
|
||||
*) echo 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
load_config() {
|
||||
ENABLED=$(uci_get_by_type basic enable)
|
||||
return $(is_true $ENABLED)
|
||||
}
|
||||
|
||||
add_rule(){
|
||||
local kp_enabled=0
|
||||
local ss_enabled=0
|
||||
[ `iptables -t nat -L SS 2>/dev/null |wc -l` -gt 0 ] && ss_enabled=1
|
||||
[ `iptables -t nat -L KOOLPROXY 2>/dev/null |wc -l` -gt 0 ] && kp_enabled=1
|
||||
for i in $(seq 0 100)
|
||||
do
|
||||
local enable=$(uci_get_by_type macbind enable '' $i)
|
||||
local macaddr=$(uci_get_by_type macbind macaddr '' $i)
|
||||
local timeon=$(uci_get_by_type macbind timeon '' $i)
|
||||
local timeoff=$(uci_get_by_type macbind timeoff '' $i)
|
||||
local z1=$(uci_get_by_type macbind z1 '' $i)
|
||||
local z2=$(uci_get_by_type macbind z2 '' $i)
|
||||
local z3=$(uci_get_by_type macbind z3 '' $i)
|
||||
local z4=$(uci_get_by_type macbind z4 '' $i)
|
||||
local z5=$(uci_get_by_type macbind z5 '' $i)
|
||||
local z6=$(uci_get_by_type macbind z6 '' $i)
|
||||
local z7=$(uci_get_by_type macbind z7 '' $i)
|
||||
[ "$z1" == "1" ] && Z1="Mon,"
|
||||
[ "$z2" == "1" ] && Z2="Tue,"
|
||||
[ "$z3" == "1" ] && Z3="Wed,"
|
||||
[ "$z4" == "1" ] && Z4="Thu,"
|
||||
[ "$z5" == "1" ] && Z5="Fri,"
|
||||
[ "$z6" == "1" ] && Z6="Sat,"
|
||||
[ "$z7" == "1" ] && Z7="Sun"
|
||||
if [ -z $enable ] || [ -z $macaddr ] || [ -z $timeoff ] || [ -z $timeon ]; then
|
||||
break
|
||||
fi
|
||||
if [ "$enable" == "1" ]; then
|
||||
iptables -t filter -I MIA -m mac --mac-source $macaddr -m time --kerneltz --timestart $timeon --timestop $timeoff --weekdays $Z1$Z2$Z3$Z4$Z5$Z6$Z7 -j DROP
|
||||
[ "$ss_enabled" -eq 1 ] && iptables -t nat -I SS $((i+1)) -m mac --mac-source $macaddr -m time --kerneltz --timestart $timeon --timestop $timeoff --weekdays $Z1$Z2$Z3$Z4$Z5$Z6$Z7 -j RETURN
|
||||
[ "$kp_enabled" -eq 1 ] && [ -z `iptables -t nat -L KOOLPROXY | grep -w RETURN | grep -w "$macaddr"` ] && iptables -t nat -I KOOLPROXY $((i+1)) -m mac --mac-source $macaddr -m time --kerneltz --timestart $timeon --timestop $timeoff --weekdays $Z1$Z2$Z3$Z4$Z5$Z6$Z7 -j RETURN
|
||||
fi
|
||||
for n in $(seq 1 7)
|
||||
do
|
||||
unset "Z$n"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
get_kp_disrule(){
|
||||
macaddr=$1
|
||||
local is_kp_disrule=0
|
||||
index=`uci show koolproxy |grep -w "$macaddr" |awk -F'.' '{print $2}'`
|
||||
[ -n "$indexs" ] && [ `uci -q get koolproxy.$index.filter_mode` == "disable" ] && is_kp_disrule=1
|
||||
}
|
||||
|
||||
del_rule(){
|
||||
type=$1
|
||||
blackMacAdd=$(iptables -t nat -L $type | grep -w RETURN | grep -w "MAC" | awk '{print $7}')
|
||||
[ -n "$blackMacAdd" ] && {
|
||||
for macaddrb in $blackMacAdd
|
||||
do
|
||||
[ "$type" == "KOOLPROXY" ] && {
|
||||
get_kp_disrule $macaddrb
|
||||
[ "$is_kp_disrule" -eq 1 ] && continue
|
||||
}
|
||||
iptables -t nat -D $type -m mac --mac-source $macaddrb -j RETURN
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
start(){
|
||||
! load_config && exit 0
|
||||
iptables -L FORWARD|grep -c MIA 2>/dev/null && [ $? -eq 0 ] && exit 0;
|
||||
iptables -t filter -N MIA
|
||||
iptables -t filter -I FORWARD -m comment --comment "Rule For Control" -j MIA
|
||||
add_rule
|
||||
}
|
||||
stop(){
|
||||
iptables -t filter -D FORWARD -m comment --comment "Rule For Control" -j MIA
|
||||
iptables -t filter -F MIA
|
||||
iptables -t filter -X MIA
|
||||
[ `iptables -t nat -L SS 2>/dev/null |wc -l` -gt 0 ] && del_rule SS
|
||||
[ `iptables -t nat -L KOOLPROXY 2>/dev/null |wc -l` -gt 0 ] && del_rule KOOLPROXY
|
||||
}
|
||||
|
||||
11
package/lienol/luci-app-mia/root/etc/uci-defaults/luci-app-control-mia
Executable file
11
package/lienol/luci-app-mia/root/etc/uci-defaults/luci-app-control-mia
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@mia[-1]
|
||||
add ucitrack mia
|
||||
set ucitrack.@mia[-1].init=mia
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=2.0
|
||||
PKG_RELEASE:=86-20191024
|
||||
PKG_RELEASE:=89-20191101
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PO2LMO:=./po2lmo
|
||||
@ -15,6 +15,7 @@ PO2LMO:=./po2lmo
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
menu "Configuration"
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks
|
||||
bool "Include Shadowsocks Redir (ss-redir)"
|
||||
@ -64,10 +65,10 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_dns-forwarder
|
||||
bool "Include dns-forwarder"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=LuCI support for PassWall(fanqiang) By Lienol
|
||||
|
||||
@ -91,23 +91,16 @@ function hide_menu()
|
||||
end
|
||||
|
||||
function link_add_server()
|
||||
local type = luci.http.formvalue("type")
|
||||
local link = luci.http.formvalue("link")
|
||||
if type == "SSR" then
|
||||
luci.sys.call('rm -f /tmp/ssr_links.conf && echo "' .. link ..
|
||||
'" >> /tmp/ssr_links.conf')
|
||||
luci.sys.call("/usr/share/passwall/subscription_ssr.sh add >/dev/null")
|
||||
elseif type == "V2ray" then
|
||||
luci.sys.call('rm -f /tmp/v2ray_links.conf && echo "' .. link ..
|
||||
'" >> /tmp/v2ray_links.conf')
|
||||
luci.sys
|
||||
.call("/usr/share/passwall/subscription_v2ray.sh add >/dev/null")
|
||||
end
|
||||
luci.sys.call('rm -f /tmp/links.conf && echo "' .. link ..
|
||||
'" >> /tmp/links.conf')
|
||||
luci.sys.call("/usr/share/passwall/subscription.sh add >/dev/null")
|
||||
end
|
||||
|
||||
function get_log()
|
||||
-- luci.sys.exec("[ -f /var/log/passwall.log ] && sed '1!G;h;$!d' /var/log/passwall.log > /var/log/passwall_show.log")
|
||||
luci.http.write(luci.sys.exec("[ -f '/var/log/passwall.log' ] && cat /var/log/passwall.log"))
|
||||
luci.http.write(luci.sys.exec(
|
||||
"[ -f '/var/log/passwall.log' ] && cat /var/log/passwall.log"))
|
||||
end
|
||||
|
||||
function clear_log() luci.sys.call("echo '' > /var/log/passwall.log") end
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
local ucursor = require"luci.model.uci".cursor()
|
||||
local json = require "luci.jsonc"
|
||||
local server_section = arg[1]
|
||||
local proto = arg[2]
|
||||
local redir_port = arg[3]
|
||||
local socks5_proxy_port = arg[4]
|
||||
local server = ucursor:get_all("passwall", server_section)
|
||||
|
||||
local trojan = {
|
||||
run_type = "client",
|
||||
local_addr = "0.0.0.0",
|
||||
local_port = socks5_proxy_port,
|
||||
remote_addr = server.server,
|
||||
remote_port = tonumber(server.server_port),
|
||||
password = {server.password},
|
||||
log_level = 1,
|
||||
ssl = {
|
||||
verify = true,
|
||||
verify_hostname = true,
|
||||
cert = "",
|
||||
cipher = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RSA-AES128-GCM-SHA256:RSA-AES256-GCM-SHA384:RSA-AES128-SHA:RSA-AES256-SHA:RSA-3DES-EDE-SHA",
|
||||
sni = "",
|
||||
alpn = {"h2", "http/1.1"},
|
||||
reuse_session = true,
|
||||
session_ticket = false,
|
||||
curves = ""
|
||||
},
|
||||
tcp = {
|
||||
no_delay = true,
|
||||
keep_alive = true,
|
||||
fast_open = false,
|
||||
fast_open_qlen = 20
|
||||
}
|
||||
}
|
||||
print(json.stringify(trojan, 1))
|
||||
@ -68,10 +68,7 @@ s = m:section(TypedSection, "global_subscribe", translate("Server Subscribe"))
|
||||
s.anonymous = true
|
||||
|
||||
---- Subscribe URL
|
||||
o = s:option(DynamicList, "baseurl_ssr", translate("SSR Subscribe URL"),
|
||||
translate(
|
||||
"Servers unsubscribed will be deleted in next update; Please summit the Subscribe URL first before manually update."))
|
||||
o = s:option(DynamicList, "baseurl_v2ray", translate("V2ray Subscribe URL"),
|
||||
o = s:option(DynamicList, "subscribe_url", translate("Subscribe URL"),
|
||||
translate(
|
||||
"Servers unsubscribed will be deleted in next update; Please summit the Subscribe URL first before manually update."))
|
||||
|
||||
|
||||
@ -70,6 +70,9 @@ end
|
||||
if is_installed("brook") or is_finded("brook") then
|
||||
serverType:value("Brook", translate("Brook Server"))
|
||||
end
|
||||
if is_installed("trojan") or is_finded("trojan") then
|
||||
serverType:value("Trojan", translate("Trojan Server"))
|
||||
end
|
||||
|
||||
o = s:option(ListValue, "v2ray_protocol", translate("V2ray Protocol"))
|
||||
o:value("vmess", translate("Vmess"))
|
||||
@ -92,6 +95,7 @@ o.rmempty = false
|
||||
o:depends("server_type", "SS")
|
||||
o:depends("server_type", "SSR")
|
||||
o:depends("server_type", "Brook")
|
||||
o:depends("server_type", "Trojan")
|
||||
|
||||
o = s:option(ListValue, "ss_encrypt_method", translate("Encrypt Method"))
|
||||
for a, t in ipairs(ss_encrypt_method) do o:value(t) end
|
||||
|
||||
@ -23,10 +23,9 @@ local dsp = require "luci.dispatcher"
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function ajax_add_server(type,link) {
|
||||
if(type && link) {
|
||||
function ajax_add_server(link) {
|
||||
if (link) {
|
||||
XHR.get('<%=dsp.build_url("admin/vpn/passwall/link_add_server")%>', {
|
||||
'type': type,
|
||||
'link': link
|
||||
},
|
||||
function(x, data) {
|
||||
@ -50,13 +49,9 @@ local dsp = require "luci.dispatcher"
|
||||
}
|
||||
|
||||
function add_server() {
|
||||
var servers_type_dom = document.getElementById("servers_type");
|
||||
var servers_type_dom_index = servers_type_dom.selectedIndex;
|
||||
|
||||
var servers_type = servers_type_dom.options[servers_type_dom_index].value;
|
||||
var servers_link = document.getElementById("servers_link").value;
|
||||
if (servers_link.trim() != "") {
|
||||
ajax_add_server(servers_type,servers_link);
|
||||
ajax_add_server(servers_link);
|
||||
}
|
||||
else {
|
||||
alert("<%:Please Enter The Link%>");
|
||||
@ -74,17 +69,8 @@ local dsp = require "luci.dispatcher"
|
||||
</div>
|
||||
|
||||
<div id="div1">
|
||||
<div class="cbi-value" data-index="1" data-depends="[]">
|
||||
<label class="cbi-value-title"><%:Server Type%></label>
|
||||
<div class="cbi-value-field">
|
||||
<select id="servers_type" class="cbi-input-select" size="1">
|
||||
<option value="SSR" selected="selected">SSR</option>
|
||||
<option value="V2ray">V2ray</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Please Enter The Link%></label>
|
||||
<label class="cbi-value-title"><%:Please Enter The SS/SSR/V2ray Link%></label>
|
||||
<div class="cbi-value-field">
|
||||
<textarea id="servers_link" rows="5" cols="50"></textarea>
|
||||
</div>
|
||||
|
||||
@ -13,6 +13,9 @@ msgstr "V2ray 服务器"
|
||||
msgid "Brook Server"
|
||||
msgstr "Brook 服务器"
|
||||
|
||||
msgid "Trojan Server"
|
||||
msgstr "Trojan 服务器"
|
||||
|
||||
msgid "Auto"
|
||||
msgstr "自动"
|
||||
|
||||
@ -193,8 +196,8 @@ msgstr "本机"
|
||||
msgid "Danger"
|
||||
msgstr "危险"
|
||||
|
||||
msgid "Please Enter The Link"
|
||||
msgstr "请输入链接"
|
||||
msgid "Please Enter The SS/SSR/V2ray Link"
|
||||
msgstr "请输入SS/SSR/V2ray链接"
|
||||
|
||||
msgid "Add Server"
|
||||
msgstr "添加服务器"
|
||||
@ -505,11 +508,8 @@ msgstr "如果你希望从内存中运行,请更改路径,例如/tmp/brook
|
||||
msgid "Server Subscribe"
|
||||
msgstr "服务器订阅"
|
||||
|
||||
msgid "SSR Subscribe URL"
|
||||
msgstr "SSR订阅网址"
|
||||
|
||||
msgid "V2ray Subscribe URL"
|
||||
msgstr "V2ray订阅网址"
|
||||
msgid "Subscribe URL"
|
||||
msgstr "订阅网址"
|
||||
|
||||
msgid "Servers unsubscribed will be deleted in next update; Please summit the Subscribe URL first before manually update."
|
||||
msgstr "取消订阅的服务器将在下次更新时删除,请先输入订阅网址保存提交之后再更新。"
|
||||
|
||||
@ -14,7 +14,7 @@ config global_haproxy
|
||||
|
||||
config global_delay
|
||||
option auto_on '0'
|
||||
option start_daemon '1'
|
||||
option start_daemon '0'
|
||||
option start_delay '20'
|
||||
|
||||
config global_dns
|
||||
@ -48,8 +48,8 @@ config global_rules
|
||||
option Pcap_Routing_update '0'
|
||||
option Pcap_WhiteList_update '0'
|
||||
option auto_update '0'
|
||||
option gfwlist_version '2019-10-18'
|
||||
option chnroute_version '2019-10-18'
|
||||
option gfwlist_version '2019-10-28'
|
||||
|
||||
config global_app
|
||||
option v2ray_client_file '/usr/bin/v2ray/'
|
||||
|
||||
@ -272,12 +272,12 @@ gen_config_file() {
|
||||
SOCKS5_PROXY_SERVER_PORT=$server_port
|
||||
if [ "$server_type" == "ss" -o "$server_type" == "ssr" ]; then
|
||||
gen_ss_ssr_config_file $server_type $local_port 0 $server $config_file_path
|
||||
fi
|
||||
if [ "$server_type" == "v2ray" ]; then
|
||||
elif [ "$server_type" == "v2ray" ]; then
|
||||
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua $server nil nil $local_port >$config_file_path
|
||||
fi
|
||||
if [ "$server_type" == "brook" ]; then
|
||||
elif [ "$server_type" == "brook" ]; then
|
||||
BROOK_SOCKS5_CMD="client -l 0.0.0.0:$local_port -i 0.0.0.0 -s $server_ip:$server_port -p $(config_get $server password)"
|
||||
elif [ "$server_type" == "trojan" ]; then
|
||||
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_trojan_client_config_file.lua $server nil nil $local_port >$config_file_path
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -290,11 +290,9 @@ gen_config_file() {
|
||||
UDP_REDIR_SERVER_PORT=$server_port
|
||||
if [ "$server_type" == "ss" -o "$server_type" == "ssr" ]; then
|
||||
gen_ss_ssr_config_file $server_type $local_port 0 $server $config_file_path
|
||||
fi
|
||||
if [ "$server_type" == "v2ray" ]; then
|
||||
elif [ "$server_type" == "v2ray" ]; then
|
||||
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua $server udp $local_port nil >$config_file_path
|
||||
fi
|
||||
if [ "$server_type" == "brook" ]; then
|
||||
elif [ "$server_type" == "brook" ]; then
|
||||
BROOK_UDP_CMD="tproxy -l 0.0.0.0:$local_port -s $server_ip:$server_port -p $(config_get $server password)"
|
||||
fi
|
||||
fi
|
||||
@ -358,8 +356,7 @@ gen_config_file() {
|
||||
else
|
||||
if [ "$server_type" == "ss" -o "$server_type" == "ssr" ]; then
|
||||
gen_ss_ssr_config_file $server_type $local_port 0 $server $config_file_path
|
||||
fi
|
||||
if [ "$server_type" == "brook" ]; then
|
||||
elif [ "$server_type" == "brook" ]; then
|
||||
BROOK_TCP_CMD="tproxy -l 0.0.0.0:$local_port -s $server_ip:$server_port -p $(config_get $server password)"
|
||||
fi
|
||||
fi
|
||||
@ -399,6 +396,10 @@ start_tcp_redir_other() {
|
||||
elif [ "$TYPE" == "brook" ]; then
|
||||
brook_bin=$(find_bin Brook)
|
||||
[ -n "$brook_bin" ] && $brook_bin $BROOK_TCP_CMD &>/dev/null &
|
||||
elif [ "$TYPE" == "trojan" ]; then
|
||||
#trojan_bin=$(find_bin trojan)
|
||||
#[ -n "$trojan_bin" ] && $trojan_bin -c $config_file >/dev/null &
|
||||
echolog "目前暂不支持Trojan透明代理,请使用Socks5代理"
|
||||
else
|
||||
ss_bin=$(find_bin "$TYPE"-redir)
|
||||
[ -n "$ss_bin" ] && {
|
||||
@ -434,6 +435,10 @@ start_udp_redir_other() {
|
||||
elif [ "$TYPE" == "brook" ]; then
|
||||
brook_bin=$(find_bin brook)
|
||||
[ -n "$brook_bin" ] && $brook_bin $BROOK_UDP_CMD &>/dev/null &
|
||||
elif [ "$TYPE" == "trojan" ]; then
|
||||
#trojan_bin=$(find_bin trojan)
|
||||
#[ -n "$trojan_bin" ] && $trojan_bin -c $config_file >/dev/null &
|
||||
echolog "目前暂不支持Trojan透明代理,请使用Socks5代理"
|
||||
else
|
||||
ss_bin=$(find_bin "$TYPE"-redir)
|
||||
[ -n "$ss_bin" ] && {
|
||||
@ -458,6 +463,10 @@ start_tcp_redir() {
|
||||
elif [ "$TCP_REDIR_SERVER_TYPE" == "brook" ]; then
|
||||
brook_bin=$(find_bin Brook)
|
||||
[ -n "$brook_bin" ] && $brook_bin $BROOK_TCP_CMD &>/dev/null &
|
||||
elif [ "$TCP_REDIR_SERVER_TYPE" == "trojan" ]; then
|
||||
#trojan_bin=$(find_bin trojan)
|
||||
#[ -n "$trojan_bin" ] && $trojan_bin -c $CONFIG_TCP_FILE >/dev/null &
|
||||
echolog "目前暂不支持Trojan透明代理,请使用Socks5代理"
|
||||
else
|
||||
ss_bin=$(find_bin "$TCP_REDIR_SERVER_TYPE"-redir)
|
||||
[ -n "$ss_bin" ] && {
|
||||
@ -482,6 +491,10 @@ start_udp_redir() {
|
||||
elif [ "$UDP_REDIR_SERVER_TYPE" == "brook" ]; then
|
||||
brook_bin=$(find_bin brook)
|
||||
[ -n "$brook_bin" ] && $brook_bin $BROOK_UDP_CMD &>/dev/null &
|
||||
elif [ "$UDP_REDIR_SERVER_TYPE" == "trojan" ]; then
|
||||
#trojan_bin=$(find_bin trojan)
|
||||
#[ -n "$trojan_bin" ] && $trojan_bin -c $CONFIG_UDP_FILE >/dev/null &
|
||||
echolog "目前暂不支持Trojan透明代理,请使用Socks5代理"
|
||||
else
|
||||
ss_bin=$(find_bin "$UDP_REDIR_SERVER_TYPE"-redir)
|
||||
[ -n "$ss_bin" ] && {
|
||||
@ -504,6 +517,9 @@ start_socks5_proxy() {
|
||||
elif [ "$SOCKS5_PROXY_SERVER_TYPE" == "brook" ]; then
|
||||
brook_bin=$(find_bin brook)
|
||||
[ -n "$brook_bin" ] && $brook_bin $BROOK_SOCKS5_CMD &>/dev/null &
|
||||
elif [ "$SOCKS5_PROXY_SERVER_TYPE" == "trojan" ]; then
|
||||
trojan_bin=$(find_bin trojan)
|
||||
[ -n "$trojan_bin" ] && $trojan_bin -c $CONFIG_SOCKS5_FILE >/dev/null &
|
||||
else
|
||||
ss_bin=$(find_bin "$SOCKS5_PROXY_SERVER_TYPE"-local)
|
||||
[ -n "$ss_bin" ] && $ss_bin -c $CONFIG_SOCKS5_FILE -b 0.0.0.0 >/dev/null 2>&1 &
|
||||
@ -782,9 +798,9 @@ EOF
|
||||
subscribe_by_ss=$(config_t_get global_subscribe subscribe_by_ss)
|
||||
[ -z "$subscribe_by_ss" ] && subscribe_by_ss=0
|
||||
[ "$subscribe_by_ss" -eq 1 ] && {
|
||||
baseurl=$(config_t_get global_subscribe baseurl)
|
||||
[ -n "$baseurl" ] && {
|
||||
for url in $baseurl; do
|
||||
subscribe_url=$(config_t_get global_subscribe subscribe_url)
|
||||
[ -n "$subscribe_url" ] && {
|
||||
for url in $subscribe_url; do
|
||||
if [ -n "$(echo -n "$url" | grep "//")" ]; then
|
||||
echo -n "$url" | awk -F'/' '{print $3}' | sed "s/^/server=&\/./g" | sed "s/$/\/127.0.0.1#7913/g" >>$TMP_DNSMASQ_PATH/subscribe.conf
|
||||
echo -n "$url" | awk -F'/' '{print $3}' | sed "s/^/ipset=&\/./g" | sed "s/$/\/router/g" >>$TMP_DNSMASQ_PATH/subscribe.conf
|
||||
|
||||
@ -86,6 +86,8 @@ server=/.2017.hk/127.0.0.1#7913
|
||||
ipset=/.2017.hk/gfwlist
|
||||
server=/.21andy.com/127.0.0.1#7913
|
||||
ipset=/.21andy.com/gfwlist
|
||||
server=/.21join.com/127.0.0.1#7913
|
||||
ipset=/.21join.com/gfwlist
|
||||
server=/.21pron.com/127.0.0.1#7913
|
||||
ipset=/.21pron.com/gfwlist
|
||||
server=/.21sextury.com/127.0.0.1#7913
|
||||
@ -2336,6 +2338,8 @@ server=/.demo.opera-mini.net/127.0.0.1#7913
|
||||
ipset=/.demo.opera-mini.net/gfwlist
|
||||
server=/.democrats.org/127.0.0.1#7913
|
||||
ipset=/.democrats.org/gfwlist
|
||||
server=/.demosisto.hk/127.0.0.1#7913
|
||||
ipset=/.demosisto.hk/gfwlist
|
||||
server=/.depositphotos.com/127.0.0.1#7913
|
||||
ipset=/.depositphotos.com/gfwlist
|
||||
server=/.derekhsu.homeip.net/127.0.0.1#7913
|
||||
@ -3064,6 +3068,8 @@ server=/.fanhaodang.com/127.0.0.1#7913
|
||||
ipset=/.fanhaodang.com/gfwlist
|
||||
server=/.fanqiang.tk/127.0.0.1#7913
|
||||
ipset=/.fanqiang.tk/gfwlist
|
||||
server=/.fanqiangdang.com/127.0.0.1#7913
|
||||
ipset=/.fanqiangdang.com/gfwlist
|
||||
server=/.fanqianghou.com/127.0.0.1#7913
|
||||
ipset=/.fanqianghou.com/gfwlist
|
||||
server=/.fanqiangyakexi.net/127.0.0.1#7913
|
||||
@ -3372,6 +3378,8 @@ server=/.freefuckvids.com/127.0.0.1#7913
|
||||
ipset=/.freefuckvids.com/gfwlist
|
||||
server=/.freegao.com/127.0.0.1#7913
|
||||
ipset=/.freegao.com/gfwlist
|
||||
server=/.freehongkong.org/127.0.0.1#7913
|
||||
ipset=/.freehongkong.org/gfwlist
|
||||
server=/.freeilhamtohti.org/127.0.0.1#7913
|
||||
ipset=/.freeilhamtohti.org/gfwlist
|
||||
server=/.freekwonpyong.org/127.0.0.1#7913
|
||||
@ -6788,6 +6796,8 @@ server=/.ny.visiontimes.com/127.0.0.1#7913
|
||||
ipset=/.ny.visiontimes.com/gfwlist
|
||||
server=/.nyaa.eu/127.0.0.1#7913
|
||||
ipset=/.nyaa.eu/gfwlist
|
||||
server=/.nyaa.si/127.0.0.1#7913
|
||||
ipset=/.nyaa.si/gfwlist
|
||||
server=/.nydus.ca/127.0.0.1#7913
|
||||
ipset=/.nydus.ca/gfwlist
|
||||
server=/.nylon-angel.com/127.0.0.1#7913
|
||||
@ -7616,6 +7626,8 @@ server=/.rapidmoviez.com/127.0.0.1#7913
|
||||
ipset=/.rapidmoviez.com/gfwlist
|
||||
server=/.rapidvpn.com/127.0.0.1#7913
|
||||
ipset=/.rapidvpn.com/gfwlist
|
||||
server=/.rarbgprx.org/127.0.0.1#7913
|
||||
ipset=/.rarbgprx.org/gfwlist
|
||||
server=/.raremovie.cc/127.0.0.1#7913
|
||||
ipset=/.raremovie.cc/gfwlist
|
||||
server=/.raremovie.net/127.0.0.1#7913
|
||||
@ -9672,6 +9684,8 @@ server=/.tycool.com/127.0.0.1#7913
|
||||
ipset=/.tycool.com/gfwlist
|
||||
server=/.typepad.com/127.0.0.1#7913
|
||||
ipset=/.typepad.com/gfwlist
|
||||
server=/.u15.info/127.0.0.1#7913
|
||||
ipset=/.u15.info/gfwlist
|
||||
server=/.u9un.com/127.0.0.1#7913
|
||||
ipset=/.u9un.com/gfwlist
|
||||
server=/.ub0.cc/127.0.0.1#7913
|
||||
@ -10856,6 +10870,8 @@ server=/.yibaochina.com/127.0.0.1#7913
|
||||
ipset=/.yibaochina.com/gfwlist
|
||||
server=/.yidio.com/127.0.0.1#7913
|
||||
ipset=/.yidio.com/gfwlist
|
||||
server=/.yigeni.com/127.0.0.1#7913
|
||||
ipset=/.yigeni.com/gfwlist
|
||||
server=/.yilubbs.com/127.0.0.1#7913
|
||||
ipset=/.yilubbs.com/gfwlist
|
||||
server=/.yingsuoss.com/127.0.0.1#7913
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
CONFIG=passwall
|
||||
LOCK_FILE=/var/lock/${CONFIG}_subscription.lock
|
||||
Date=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
@ -13,23 +15,311 @@ config_t_get() {
|
||||
echo $ret
|
||||
}
|
||||
|
||||
decode_url_link() {
|
||||
link=$1
|
||||
num=$2
|
||||
len=$((${#link}-$num))
|
||||
mod4=$(($len%4))
|
||||
if [ "$mod4" -gt 0 ]; then
|
||||
var="===="
|
||||
newlink=${link}${var:$mod4}
|
||||
echo -n "$newlink" | sed 's/-/+/g; s/_/\//g' | /usr/bin/base64 -d -i 2> /dev/null
|
||||
else
|
||||
echo -n "$link" | sed 's/-/+/g; s/_/\//g' | /usr/bin/base64 -d -i 2> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
get_server_index(){
|
||||
[ -f "/etc/config/$CONFIG" ] && {
|
||||
servers_index=$(uci show $CONFIG | grep -c "=servers")
|
||||
}
|
||||
}
|
||||
|
||||
get_local_servers(){
|
||||
[ -f "/etc/config/$CONFIG" ] && [ "`uci show $CONFIG | grep -c 'sub_server'`" -gt 0 ] && {
|
||||
get_server_index
|
||||
for i in `seq $servers_index -1 1`
|
||||
do
|
||||
[ "$(uci show $CONFIG.@servers[$(($i-1))]|grep -c "sub_server")" -eq 1 ] && {
|
||||
if [ ! -f "/usr/share/${CONFIG}/sub/all_localservers" ]; then
|
||||
echo $(config_t_get servers server $(($i-1))) > /usr/share/${CONFIG}/sub/all_localservers
|
||||
else
|
||||
echo $(config_t_get servers server $(($i-1))) >> /usr/share/${CONFIG}/sub/all_localservers
|
||||
fi
|
||||
}
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
get_remote_config(){
|
||||
remarks="(订阅)"
|
||||
[ -n "$3" ] && remarks="(导入)"
|
||||
group="sub_server"
|
||||
if [ "$1" == "ss" ]; then
|
||||
decode_link="$2"
|
||||
server=$(echo "$decode_link" | awk -F ':' '{print $2}' | awk -F '@' '{print $2}')
|
||||
server_port=$(echo "$decode_link" | awk -F ':' '{print $3}')
|
||||
ssr_encrypt_method=$(echo "$decode_link" | awk -F ':' '{print $1}')
|
||||
password=$(echo "$decode_link" | awk -F ':' '{print $2}' | awk -F '@' '{print $1}')
|
||||
server_host=$server
|
||||
elif [ "$1" == "ssr" ]; then
|
||||
decode_link="$2"
|
||||
server=$(echo "$decode_link" | awk -F ':' '{print $1}')
|
||||
server_port=$(echo "$decode_link" | awk -F ':' '{print $2}')
|
||||
protocol=$(echo "$decode_link" | awk -F ':' '{print $3}')
|
||||
ssr_encrypt_method=$(echo "$decode_link" | awk -F ':' '{print $4}')
|
||||
obfs=$(echo "$decode_link" | awk -F ':' '{print $5}')
|
||||
password=$(decode_url_link $(echo "$decode_link" | awk -F ':' '{print $6}' | awk -F '/' '{print $1}') 0)
|
||||
|
||||
obfsparm_temp=$(echo "$decode_link" |grep -Eo "obfsparam.+" |sed 's/obfsparam=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$obfsparm_temp" ] && obfsparam=$(decode_url_link $obfsparm_temp 0) || obfsparam=''
|
||||
protoparam_temp=$(echo "$decode_link" |grep -Eo "protoparam.+" |sed 's/protoparam=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$protoparam_temp" ] && protoparam=$(decode_url_link $protoparam_temp 0) || protoparam=''
|
||||
remarks_temp=$(echo "$decode_link" |grep -Eo "remarks.+" |sed 's/remarks=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$remarks_temp" ] && remarks="${remarks}$(decode_url_link $remarks_temp 0)"
|
||||
group_temp=$(echo "$decode_link" |grep -Eo "group.+" |sed 's/group=//g'|awk -F'&' '{print $1}')
|
||||
server_host=$server
|
||||
elif [ "$1" == "v2ray" ]; then
|
||||
json_load "$2"
|
||||
json_get_var json_v v
|
||||
json_get_var json_ps ps
|
||||
json_get_var json_server add
|
||||
json_get_var json_server_port port
|
||||
json_get_var json_id id
|
||||
json_get_var json_aid aid
|
||||
json_get_var json_security security
|
||||
json_get_var json_net net
|
||||
json_get_var json_type type
|
||||
json_get_var json_transport net
|
||||
json_get_var json_tls tls
|
||||
json_get_var json_host host
|
||||
json_get_var json_path path
|
||||
|
||||
if [ "$json_tls" == "1" ]; then
|
||||
json_tls="tls"
|
||||
else
|
||||
json_tls="none"
|
||||
fi
|
||||
|
||||
remarks="${remarks}${json_ps}"
|
||||
server_host=$json_server
|
||||
fi
|
||||
|
||||
# 把全部服务器节点写入文件 /usr/share/${CONFIG}/sub/all_onlineservers
|
||||
if [ ! -f "/usr/share/${CONFIG}/sub/all_onlineservers" ]; then
|
||||
echo $server_host > /usr/share/${CONFIG}/sub/all_onlineservers
|
||||
else
|
||||
echo $server_host >> /usr/share/${CONFIG}/sub/all_onlineservers
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
add_servers(){
|
||||
get_server_index
|
||||
uci_set="uci set $CONFIG.@servers[$servers_index]."
|
||||
uci add $CONFIG servers > /dev/null
|
||||
[ -z "$2" ] && ${uci_set}group="$group"
|
||||
if [ "$1" == "ss" ]; then
|
||||
${uci_set}remarks="$remarks"
|
||||
${uci_set}server_type="SSR"
|
||||
${uci_set}server="$server_host"
|
||||
${uci_set}use_ipv6=0
|
||||
${uci_set}server_port="$server_port"
|
||||
${uci_set}password="$password"
|
||||
${uci_set}ssr_encrypt_method="$ssr_encrypt_method"
|
||||
${uci_set}timeout=300
|
||||
${uci_set}fast_open=false
|
||||
let addnum_ss+=1
|
||||
elif [ "$1" == "ssr" ]; then
|
||||
${uci_set}remarks="$remarks"
|
||||
${uci_set}server_type="SSR"
|
||||
${uci_set}server="$server_host"
|
||||
${uci_set}use_ipv6=0
|
||||
${uci_set}server_port="$server_port"
|
||||
${uci_set}password="$password"
|
||||
${uci_set}ssr_encrypt_method="$ssr_encrypt_method"
|
||||
${uci_set}protocol="$protocol"
|
||||
${uci_set}protocol_param="$protoparam"
|
||||
${uci_set}obfs="$obfs"
|
||||
${uci_set}obfs_param="$obfsparam"
|
||||
${uci_set}timeout=300
|
||||
${uci_set}fast_open=false
|
||||
let addnum_ssr+=1
|
||||
elif [ "$1" == "v2ray" ]; then
|
||||
${uci_set}remarks="$remarks"
|
||||
${uci_set}server_type="V2ray"
|
||||
${uci_set}v2ray_protocol="vmess"
|
||||
${uci_set}server="$json_server"
|
||||
${uci_set}use_ipv6=0
|
||||
${uci_set}server_port="$json_server_port"
|
||||
${uci_set}v2ray_security="auto"
|
||||
${uci_set}v2ray_VMess_id="$json_id"
|
||||
${uci_set}v2ray_VMess_alterId="$json_aid"
|
||||
${uci_set}v2ray_VMess_level="$json_v"
|
||||
${uci_set}v2ray_transport="$json_net"
|
||||
${uci_set}v2ray_stream_security="$json_tls"
|
||||
${uci_set}v2ray_tcp_guise="$json_type"
|
||||
${uci_set}v2ray_ws_host="$json_host"
|
||||
${uci_set}v2ray_ws_path="$json_path"
|
||||
${uci_set}v2ray_h2_host="$json_host"
|
||||
${uci_set}v2ray_h2_path="$json_path"
|
||||
let addnum_v2ray+=1
|
||||
fi
|
||||
uci commit $CONFIG
|
||||
}
|
||||
|
||||
update_config(){
|
||||
isadded_server=$(uci show $CONFIG | grep -c "server='$server_host'")
|
||||
if [ "$isadded_server" -eq 0 ]; then
|
||||
add_servers $link_type
|
||||
else
|
||||
index=$(uci show $CONFIG | grep -w "server='$server_host'" | cut -d '[' -f2|cut -d ']' -f1)
|
||||
local_server_port=$(config_t_get servers server_port $index)
|
||||
local_vmess_id=$(config_t_get servers v2ray_VMess_id $index)
|
||||
# To Do
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
del_config(){
|
||||
# 删除订阅服务器已经不存在的节点
|
||||
for localserver in $(cat /usr/share/${CONFIG}/sub/all_localservers)
|
||||
do
|
||||
[ "`cat /usr/share/${CONFIG}/sub/all_onlineservers |grep -c "$localserver"`" -eq 0 ] && {
|
||||
for localindex in $(uci show $CONFIG|grep -w "$localserver" |grep -w "server=" |cut -d '[' -f2|cut -d ']' -f1)
|
||||
do
|
||||
del_server_type=$(uci get $CONFIG.@servers[$localindex].server_type)
|
||||
uci delete $CONFIG.@servers[$localindex]
|
||||
uci commit $CONFIG
|
||||
if [ "$del_server_type" == "SS" ]; then
|
||||
let delnum_ss+=1 #删除该节点
|
||||
elif [ "$del_server_type" == "SSR" ]; then
|
||||
let delnum_ssr+=1 #删除该节点
|
||||
elif [ "$del_server_type" == "V2ray" ]; then
|
||||
let delnum_v2ray+=1 #删除该节点
|
||||
fi
|
||||
|
||||
done
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
del_all_config(){
|
||||
get_server_index
|
||||
[ "`uci show $CONFIG | grep -c 'sub_server'`" -eq 0 ] && exit 0
|
||||
current_tcp_redir_server=$(config_t_get global tcp_redir_server)
|
||||
is_sub_server=`uci -q get $CONFIG.$current_tcp_redir_server.group`
|
||||
for i in `seq $servers_index -1 1`
|
||||
do
|
||||
[ "$(uci show $CONFIG.@servers[$(($i-1))] | grep -c 'sub_server')" -eq 1 ] && uci delete $CONFIG.@servers[$(($i-1))] && uci commit $CONFIG
|
||||
done
|
||||
[ -n "$is_sub_server" ] && {
|
||||
uci set $CONFIG.global[0].tcp_redir_server="nil"
|
||||
uci commit $CONFIG && /etc/init.d/$CONFIG stop
|
||||
}
|
||||
}
|
||||
|
||||
add() {
|
||||
LINKS=$(cat /tmp/links.conf 2>/dev/null)
|
||||
[ -n "$LINKS" ] && {
|
||||
[ -f "$LOCK_FILE" ] && return 3
|
||||
touch "$LOCK_FILE"
|
||||
mkdir -p /usr/share/${CONFIG}/sub && rm -f /usr/share/${CONFIG}/sub/*
|
||||
for link in $LINKS
|
||||
do
|
||||
if [ -n "`echo -n "$link" | grep 'ss://'`" ]; then
|
||||
link_type="ss"
|
||||
new_link=`echo -n "$link" | sed 's/ss:\/\///g'`
|
||||
elif [ -n "`echo -n "$link" | grep 'ssr://'`" ]; then
|
||||
link_type="ssr"
|
||||
new_link=`echo -n "$link" | sed 's/ssr:\/\///g'`
|
||||
elif [ -n "`echo -n "$link" | grep 'vmess://'`" ]; then
|
||||
link_type="v2ray"
|
||||
new_link=`echo -n "$link" | sed 's/vmess:\/\///g'`
|
||||
fi
|
||||
[ -z "$link_type" ] && continue
|
||||
decode_link=$(decode_url_link $new_link 1)
|
||||
get_remote_config "$link_type" "$decode_link" 1
|
||||
is_added=$(uci show $CONFIG | grep -v "sub_server" | grep -c "server='$server_host'")
|
||||
[ "$is_added" -gt 0 ] && continue
|
||||
add_servers "$link_type" 1
|
||||
done
|
||||
[ -f "/usr/share/${CONFIG}/sub/all_onlineservers" ] && rm -f /usr/share/${CONFIG}/sub/all_onlineservers
|
||||
}
|
||||
rm -f /tmp/links.conf
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
start() {
|
||||
#防止并发开启服务
|
||||
# 防止并发开启服务
|
||||
[ -f "$LOCK_FILE" ] && return 3
|
||||
touch "$LOCK_FILE"
|
||||
echo "$Date: 开始执行在线订阅脚本..." >>$LOG_FILE
|
||||
/usr/share/$CONFIG/subscription_ssr.sh start 2>/dev/null
|
||||
/usr/share/$CONFIG/subscription_v2ray.sh start 2>/dev/null
|
||||
echo "$Date: 在线订阅脚本执行完毕..." >>$LOG_FILE
|
||||
addnum_ss=0
|
||||
updatenum_ss=0
|
||||
delnum_ss=0
|
||||
addnum_ssr=0
|
||||
updatenum_ssr=0
|
||||
delnum_ssr=0
|
||||
addnum_v2ray=0
|
||||
updatenum_v2ray=0
|
||||
delnum_v2ray=0
|
||||
subscribe_url=$(uci get $CONFIG.@global_subscribe[0].subscribe_url) # 订阅地址
|
||||
[ -z "$subscribe_url" ] && echo "$Date: 订阅地址为空,订阅失败!" >> $LOG_FILE && rm -f "$LOCK_FILE" && exit 0
|
||||
|
||||
echo "$Date: 开始订阅..." >> $LOG_FILE
|
||||
mkdir -p /var/${CONFIG}_sub && rm -f /var/${CONFIG}_sub/*
|
||||
/usr/bin/wget --no-check-certificate --timeout=8 -t 2 $subscribe_url -P /var/${CONFIG}_sub
|
||||
[ ! -d "/var/${CONFIG}_sub" ] || [ "$(ls /var/${CONFIG}_sub | wc -l)" -eq 0 ] && echo "$Date: 订阅链接下载失败,请重试!" >> $LOG_FILE && rm -f "$LOCK_FILE" && exit 0
|
||||
|
||||
mkdir -p /usr/share/${CONFIG}/sub && rm -f /usr/share/${CONFIG}/sub/*
|
||||
get_local_servers
|
||||
for file in /var/${CONFIG}_sub/*
|
||||
do
|
||||
[ -z "$(du -sh $file 2> /dev/null)" ] && echo "$Date: 订阅链接下载 $file 失败,请重试!" >> $LOG_FILE && continue
|
||||
decode_link=$(cat "$file" | /usr/bin/base64 -d 2> /dev/null)
|
||||
maxnum=$(echo -n "$decode_link" | grep "MAX=" | awk -F"=" '{print $2}')
|
||||
if [ -n "$maxnum" ]; then
|
||||
decode_link=$(echo -n "$decode_link" | sed '/MAX=/d' | shuf -n${maxnum})
|
||||
else
|
||||
decode_link=$(echo -n "$decode_link")
|
||||
fi
|
||||
|
||||
[ -z "$decode_link" ] && continue
|
||||
for link in $decode_link
|
||||
do
|
||||
if expr "$link" : "ss://";then
|
||||
link_type="ss"
|
||||
link=$(echo -n "$link" | sed 's/ssr:\/\///g')
|
||||
elif expr "$link" : "ssr://";then
|
||||
link_type="ssr"
|
||||
link=$(echo -n "$link" | sed 's/ssr:\/\///g')
|
||||
elif expr "$link" : "vmess://";then
|
||||
link_type="v2ray"
|
||||
link=$(echo -n "$link" | sed 's/vmess:\/\///g')
|
||||
fi
|
||||
[ -z "$link_type" ] && continue
|
||||
decode_link2=$(decode_url_link $link 1)
|
||||
get_remote_config "$link_type" "$decode_link2"
|
||||
update_config
|
||||
done
|
||||
done
|
||||
[ -f "/usr/share/${CONFIG}/sub/all_localservers" ] && del_config
|
||||
echo "$Date: 本次更新,SS新增服务器节点 $addnum_ss 个,修改 $updatenum_ss 个,删除 $delnum_ss 个。" >> $LOG_FILE
|
||||
echo "$Date: 本次更新,SSR新增服务器节点 $addnum_ssr 个,修改 $updatenum_ssr 个,删除 $delnum_ssr 个。" >> $LOG_FILE
|
||||
echo "$Date: 本次更新,V2ray新增服务器节点 $addnum_v2ray 个,修改 $updatenum_v2ray 个,删除 $delnum_v2ray 个。" >> $LOG_FILE
|
||||
echo "$Date: 订阅完毕..." >> $LOG_FILE
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "$Date: 开始执行删除所有订阅脚本..." >>$LOG_FILE
|
||||
/usr/share/$CONFIG/subscription_ssr.sh stop 2>/dev/null
|
||||
/usr/share/$CONFIG/subscription_v2ray.sh stop 2>/dev/null
|
||||
echo "$Date: 删除所有订阅脚本执行完毕..." >>$LOG_FILE
|
||||
[ "`uci show $CONFIG | grep -c 'sub_server'`" -gt 0 ] && {
|
||||
echo "$Date: 在线订阅节点已全部删除" >> $LOG_FILE
|
||||
del_all_config
|
||||
}
|
||||
rm -rf /var/${CONFIG}_sub
|
||||
rm -rf /usr/share/${CONFIG}/sub
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
@ -38,6 +328,9 @@ case $1 in
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
add)
|
||||
add
|
||||
;;
|
||||
*)
|
||||
start
|
||||
;;
|
||||
|
||||
@ -1,290 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONFIG=passwall
|
||||
LOCK_FILE=/var/lock/${CONFIG}_subscription_ssr.lock
|
||||
Date=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOG_FILE=/var/log/$CONFIG.log
|
||||
|
||||
config_t_get() {
|
||||
local index=0
|
||||
[ -n "$3" ] && index=$3
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
#echo ${ret:=$3}
|
||||
echo $ret
|
||||
}
|
||||
|
||||
config_t_set() {
|
||||
index=$3
|
||||
uci set $CONFIG.@$1[$index].$2=$4
|
||||
}
|
||||
|
||||
decode_url_link(){
|
||||
link=$1
|
||||
num=$2
|
||||
len=$((${#link}-$num))
|
||||
mod4=$(($len%4))
|
||||
if [ "$mod4" -gt 0 ]; then
|
||||
var="===="
|
||||
newlink=${link}${var:$mod4}
|
||||
echo -n "$newlink" | sed 's/-/+/g; s/_/\//g' | /usr/bin/base64 -d -i 2> /dev/null
|
||||
else
|
||||
echo -n "$link" | sed 's/-/+/g; s/_/\//g' | /usr/bin/base64 -d -i 2> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
get_server_index(){
|
||||
[ -f "/etc/config/$CONFIG" ] && {
|
||||
ssindex=$(uci show $CONFIG | grep -c "=servers")
|
||||
}
|
||||
}
|
||||
|
||||
get_local_servers(){
|
||||
[ -f "/etc/config/$CONFIG" ] && [ "`uci show $CONFIG|grep -c 'AutoSuB_SSR'`" -gt 0 ] && {
|
||||
get_server_index
|
||||
for i in `seq $ssindex -1 1`
|
||||
do
|
||||
[ "$(uci show $CONFIG.@servers[$(($i-1))] | grep -c 'AutoSuB_SSR')" -eq 1 ] && {
|
||||
if [ ! -f "/usr/share/$CONFIG/serverconfig_ssr/all_localservers" ]; then
|
||||
echo $(config_t_get servers server $(($i-1))) > /usr/share/$CONFIG/serverconfig_ssr/all_localservers
|
||||
else
|
||||
echo $(config_t_get servers server $(($i-1))) >> /usr/share/$CONFIG/serverconfig_ssr/all_localservers
|
||||
fi
|
||||
}
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
get_remote_config(){
|
||||
decode_link=$1
|
||||
server=$(echo "$decode_link" |awk -F':' '{print $1}')
|
||||
server_port=$(echo "$decode_link" |awk -F':' '{print $2}')
|
||||
protocol=$(echo "$decode_link" |awk -F':' '{print $3}')
|
||||
ssr_encrypt_method=$(echo "$decode_link" |awk -F':' '{print $4}')
|
||||
obfs=$(echo "$decode_link" |awk -F':' '{print $5}')
|
||||
password=$(decode_url_link $(echo "$decode_link" |awk -F':' '{print $6}'|awk -F'/' '{print $1}') 0)
|
||||
|
||||
obfsparm_temp=$(echo "$decode_link" |grep -Eo "obfsparam.+" |sed 's/obfsparam=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$obfsparm_temp" ] && obfsparam=$(decode_url_link $obfsparm_temp 0) || obfsparam=''
|
||||
protoparam_temp=$(echo "$decode_link" |grep -Eo "protoparam.+" |sed 's/protoparam=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$protoparam_temp" ] && protoparam=$(decode_url_link $protoparam_temp 0) || protoparam=''
|
||||
remarks_temp=$(echo "$decode_link" |grep -Eo "remarks.+" |sed 's/remarks=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$remarks_temp" ] && remarks="订阅_$(decode_url_link $remarks_temp 0)" || remarks='订阅'
|
||||
group_temp=$(echo "$decode_link" |grep -Eo "group.+" |sed 's/group=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$group_temp" ] && group="AutoSuB_SSR_$(decode_url_link $group_temp 0)" || group='AutoSuB_SSR'
|
||||
|
||||
##把全部服务器节点写入文件 /usr/share/$CONFIG/serverconfig_ssr/all_onlineservers
|
||||
if [ ! -f "/usr/share/$CONFIG/serverconfig_ssr/all_onlineservers" ]; then
|
||||
echo $server > /usr/share/$CONFIG/serverconfig_ssr/all_onlineservers
|
||||
else
|
||||
echo $server >> /usr/share/$CONFIG/serverconfig_ssr/all_onlineservers
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
add_servers(){
|
||||
get_server_index
|
||||
uci add $CONFIG servers >/dev/null
|
||||
if [ -z "$1" ];then
|
||||
config_t_set servers remarks $ssindex $remarks
|
||||
config_t_set servers group $ssindex $group
|
||||
else
|
||||
config_t_set servers remarks $ssindex $remarks
|
||||
fi
|
||||
config_t_set servers server_type $ssindex "SSR"
|
||||
config_t_set servers server $ssindex $server
|
||||
config_t_set servers use_ipv6 $ssindex 0
|
||||
config_t_set servers server_port $ssindex $server_port
|
||||
config_t_set servers password $ssindex $password
|
||||
config_t_set servers ssr_encrypt_method $ssindex $ssr_encrypt_method
|
||||
config_t_set servers protocol $ssindex $protocol
|
||||
config_t_set servers protocol_param $ssindex $protoparam
|
||||
config_t_set servers obfs $ssindex $obfs
|
||||
config_t_set servers obfs_param $ssindex $obfsparam
|
||||
config_t_set servers timeout $ssindex 300
|
||||
config_t_set servers fast_open $ssindex false
|
||||
uci commit $CONFIG
|
||||
}
|
||||
|
||||
update_config(){
|
||||
|
||||
isadded_server=$(uci show $CONFIG | grep -c "server='$server'")
|
||||
if [ "$isadded_server" -eq 0 ]; then
|
||||
add_servers
|
||||
let addnum+=1
|
||||
|
||||
else
|
||||
index=$(uci show $CONFIG | grep -w "server='$server'" | cut -d '[' -f2|cut -d ']' -f1)
|
||||
local_server_port=$(config_t_get servers server_port $index)
|
||||
local_protocol=$(config_t_get servers protocol $index)
|
||||
local_protocol_param=$(config_t_get servers protocol_param $index)
|
||||
local_ssr_encrypt_method=$(config_t_get servers ssr_encrypt_method $index)
|
||||
local_obfs=$(config_t_get servers obfs $index)
|
||||
local_password=$(config_t_get servers password $index)
|
||||
local_group=$(config_t_get servers group $index)
|
||||
local_remarks=$(config_t_get servers remarks $index)
|
||||
local i=0
|
||||
[ "$(uci show $CONFIG.@servers[$index] | grep -c "obfs_param")" -eq 0 ] && \
|
||||
config_t_set servers obfs_param $index $obfsparam
|
||||
|
||||
if [ -n "$local_protocol_param" ]; then
|
||||
if [ -n "$protoparam" ]; then
|
||||
[ "$local_protocol_param" != "$protoparam" ] && config_t_set servers protocol_param $index $protoparam && let i+=1
|
||||
else
|
||||
config_t_set servers protocol_param $index $protoparam && let i+=1
|
||||
fi
|
||||
else
|
||||
config_t_set servers protocol_param $index $protoparam && [ -n "$protoparam" ] && let i+=1
|
||||
fi
|
||||
[ "$local_server_port" != "$server_port" ] && config_t_set servers server_port $index $server_port && let i+=1
|
||||
[ "$local_protocol" != "$protocol" ] && config_t_set servers protocol $index $protocol && let i+=1
|
||||
[ "$local_ssr_encrypt_method" != "$ssr_encrypt_method" ] && config_t_set servers ssr_encrypt_method $index $ssr_encrypt_method && let i+=1
|
||||
[ "$local_obfs" != "$obfs" ] && config_t_set servers obfs $index $obfs && let i+=1
|
||||
[ "$local_password" != "$password" ] && config_t_set servers password $index $password && let i+=1
|
||||
[ "$local_group" != "$group" ] && config_t_set servers group $index $group
|
||||
[ "$local_remarks" != "$remarks" ] && config_t_set servers remarks $index $remarks
|
||||
[ "$i" -gt 0 ] && uci commit $CONFIG && let updatenum+=1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
del_config(){
|
||||
##删除订阅服务器已经不存在的节点
|
||||
for localserver in $(cat /usr/share/$CONFIG/serverconfig_ssr/all_localservers)
|
||||
do
|
||||
[ "`cat /usr/share/$CONFIG/serverconfig_ssr/all_onlineservers |grep -c "$localserver"`" -eq 0 ] && {
|
||||
for localindex in $(uci show $CONFIG|grep -w "$localserver" |grep -w "server=" |cut -d '[' -f2|cut -d ']' -f1)
|
||||
do
|
||||
uci delete $CONFIG.@servers[$localindex]
|
||||
uci commit $CONFIG
|
||||
let delnum+=1 #删除该节点
|
||||
done
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
del_all_config(){
|
||||
get_server_index
|
||||
[ "`uci show $CONFIG | grep -c 'AutoSuB_SSR'`" -eq 0 ] && exit 0
|
||||
current_tcp_redir_server=$(config_t_get global tcp_redir_server)
|
||||
is_sub_server=`uci -q get $CONFIG.$current_tcp_redir_server.group`
|
||||
for i in `seq $ssindex -1 1`
|
||||
do
|
||||
[ "$(uci show $CONFIG.@servers[$(($i-1))] | grep -c 'AutoSuB_SSR')" -eq 1 ] && uci delete $CONFIG.@servers[$(($i-1))] && uci commit $CONFIG
|
||||
done
|
||||
[ -n "$is_sub_server" ] && {
|
||||
config_t_set global tcp_redir_server 0 'nil'
|
||||
uci commit $CONFIG && /etc/init.d/$CONFIG stop
|
||||
}
|
||||
}
|
||||
|
||||
get_ss_config(){
|
||||
decode_link=$1
|
||||
server=$(echo "$decode_link" |awk -F':' '{print $2}'|awk -F'@' '{print $2}')
|
||||
server_port=$(echo "$decode_link" |awk -F':' '{print $3}')
|
||||
ssr_encrypt_method=$(echo "$decode_link" |awk -F':' '{print $1}')
|
||||
password=$(echo "$decode_link" |awk -F':' '{print $2}'|awk -F'@' '{print $1}')
|
||||
}
|
||||
|
||||
add() {
|
||||
SSR_LINKS=$(cat /tmp/ssr_links.conf 2>/dev/null)
|
||||
[ -n "$SSR_LINKS" ] && {
|
||||
[ -f "$LOCK_FILE" ] && return 3
|
||||
touch "$LOCK_FILE"
|
||||
mkdir -p /usr/share/$CONFIG/serverconfig_ssr
|
||||
rm -f /usr/share/$CONFIG/serverconfig_ssr/*
|
||||
for ssrlink in $SSR_LINKS
|
||||
do
|
||||
if [ -n "`echo -n "$ssrlink" | grep 'ssr://'`" ]; then
|
||||
new_ssrlink=`echo -n "$ssrlink" | sed 's/ssr:\/\///g'`
|
||||
decode_ssrlink=$(decode_url_link $new_ssrlink 1)
|
||||
get_remote_config "$decode_ssrlink"
|
||||
is_added=$(uci show $CONFIG | grep -v 'AutoSuB_SSR' | grep -c "server='$server'")
|
||||
[ "$is_added" -gt 0 ] && continue
|
||||
add_servers 1
|
||||
else
|
||||
|
||||
if [ -n "`echo -n "$ssrlink" | grep '#'`" ]; then
|
||||
new_sslink=`echo -n "$ssrlink" | awk -F'#' '{print $1}' | sed 's/ss:\/\///g'`
|
||||
remarks=`echo -n "$ssrlink" | awk -F'#' '{print $2}'`
|
||||
|
||||
else
|
||||
new_sslink=`echo -n "$ssrlink" | sed 's/ss:\/\///g'`
|
||||
remarks='AddedByLink'
|
||||
fi
|
||||
decode_sslink=$(decode_url_link $new_sslink 1)
|
||||
get_ss_config $decode_sslink
|
||||
is_added=$(uci show $CONFIG | grep -v 'AutoSuB_SSR' | grep -c "server='$server'")
|
||||
[ "$is_added" -gt 0 ] && continue
|
||||
fi
|
||||
done
|
||||
[ -f "/usr/share/$CONFIG/serverconfig_ssr/all_onlineservers" ] && rm -f /usr/share/$CONFIG/serverconfig_ssr/all_onlineservers
|
||||
}
|
||||
rm -f /tmp/ssr_links.conf
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
start() {
|
||||
#防止并发开启服务
|
||||
[ -f "$LOCK_FILE" ] && return 3
|
||||
touch "$LOCK_FILE"
|
||||
addnum=0
|
||||
updatenum=0
|
||||
delnum=0
|
||||
baseurl_ssr=$(uci get $CONFIG.@global_subscribe[0].baseurl_ssr) ##SSR订阅地址
|
||||
[ -z "$baseurl_ssr" ] && echo "$Date: SSR订阅地址为空,跳过!" >> $LOG_FILE && rm -f "$LOCK_FILE" && exit 0
|
||||
|
||||
echo "$Date: 开始订阅SSR..." >> $LOG_FILE
|
||||
[ ! -d "/usr/share/$CONFIG/onlineurl_ssr" ] && mkdir -p /usr/share/$CONFIG/onlineurl_ssr
|
||||
[ ! -d "/usr/share/$CONFIG/serverconfig_ssr" ] && mkdir -p /usr/share/$CONFIG/serverconfig_ssr
|
||||
rm -f /usr/share/$CONFIG/onlineurl_ssr/*
|
||||
|
||||
/usr/bin/wget --no-check-certificate --timeout=8 -t 2 $baseurl_ssr -P /usr/share/$CONFIG/onlineurl_ssr
|
||||
[ ! -d "/usr/share/$CONFIG/onlineurl_ssr" ] || [ "$(ls /usr/share/$CONFIG/onlineurl_ssr |wc -l)" -eq 0 ] && echo "$Date: 订阅链接下载失败,请重试!" >> $LOG_FILE && rm -f "$LOCK_FILE" && exit 0
|
||||
rm -f /usr/share/$CONFIG/serverconfig_ssr/*
|
||||
get_local_servers
|
||||
for file in /usr/share/$CONFIG/onlineurl_ssr/*
|
||||
do
|
||||
[ -z "$(du -sh $file 2> /dev/null)" ] && echo "$Date: 订阅链接下载 $file 失败,请重试!" >> $LOG_FILE && continue
|
||||
maxnum=$(cat "$file" | /usr/bin/base64 -d 2> /dev/null| grep "MAX=" |awk -F"=" '{print $2}')
|
||||
if [ -n "$maxnum" ]; then
|
||||
urllinks=$(cat "$file" | /usr/bin/base64 -d 2> /dev/null| sed '/MAX=/d' | shuf -n${maxnum} | sed 's/ssr:\/\///g')
|
||||
else
|
||||
urllinks=$(cat "$file" | /usr/bin/base64 -d 2> /dev/null| sed 's/ssr:\/\///g')
|
||||
fi
|
||||
[ -z "$urllinks" ] && continue
|
||||
for link in $urllinks
|
||||
do
|
||||
decode_link=$(decode_url_link $link 1)
|
||||
get_remote_config "$decode_link"
|
||||
update_config
|
||||
done
|
||||
done
|
||||
[ -f "/usr/share/$CONFIG/serverconfig_ssr/all_localservers" ] && del_config
|
||||
echo "$Date: 本次更新,SSR新增服务器节点 $addnum 个,修改 $updatenum 个,删除 $delnum 个。" >> $LOG_FILE
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ "`uci show $CONFIG | grep -c 'AutoSuB_SSR'`" -gt 0 ] && {
|
||||
echo "$Date: 在线订阅SSR节点已全部删除" >> $LOG_FILE
|
||||
del_all_config
|
||||
}
|
||||
rm -rf /usr/share/$CONFIG/onlineurl_ssr
|
||||
rm -rf /usr/share/$CONFIG/serverconfig_ssr
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
case $1 in
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
add)
|
||||
add
|
||||
;;
|
||||
*)
|
||||
start
|
||||
;;
|
||||
esac
|
||||
@ -1,249 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
CONFIG=passwall
|
||||
LOCK_FILE=/var/lock/${CONFIG}_subscription_v2ray.lock
|
||||
Date=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOG_FILE=/var/log/$CONFIG.log
|
||||
|
||||
config_t_get() {
|
||||
local index=0
|
||||
[ -n "$3" ] && index=$3
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
#echo ${ret:=$3}
|
||||
echo $ret
|
||||
}
|
||||
|
||||
config_t_set() {
|
||||
index=$3
|
||||
uci set $CONFIG.@$1[$index].$2=$4
|
||||
}
|
||||
|
||||
decode_url_link(){
|
||||
link=$1
|
||||
num=$2
|
||||
len=$((${#link}-$num))
|
||||
mod4=$(($len%4))
|
||||
if [ "$mod4" -gt 0 ]; then
|
||||
var="===="
|
||||
newlink=${link}${var:$mod4}
|
||||
echo -n "$newlink" | sed 's/-/+/g; s/_/\//g' | /usr/bin/base64 -d -i 2> /dev/null
|
||||
else
|
||||
echo -n "$link" | sed 's/-/+/g; s/_/\//g' | /usr/bin/base64 -d -i 2> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
get_remote_config(){
|
||||
json_load "$1"
|
||||
json_get_var v v
|
||||
json_get_var ps ps
|
||||
json_get_var server add
|
||||
json_get_var server_port port
|
||||
json_get_var id id
|
||||
json_get_var aid aid
|
||||
json_get_var net net
|
||||
json_get_var type type
|
||||
json_get_var transport net
|
||||
json_get_var tls tls
|
||||
json_get_var ws_host host
|
||||
json_get_var ws_path path
|
||||
|
||||
if [ "$tls" == "1" ]; then
|
||||
tls="tls"
|
||||
else
|
||||
tls="none"
|
||||
fi
|
||||
|
||||
remarks="订阅_$ps"
|
||||
group='AutoSuB_V2ray'
|
||||
|
||||
##把全部服务器节点写入文件 /usr/share/$CONFIG/serverconfig_v2ray/all_onlineservers
|
||||
if [ ! -f "/usr/share/$CONFIG/serverconfig_v2ray/all_onlineservers" ]; then
|
||||
echo $server > /usr/share/$CONFIG/serverconfig_v2ray/all_onlineservers
|
||||
else
|
||||
echo $server >> /usr/share/$CONFIG/serverconfig_v2ray/all_onlineservers
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
get_server_index(){
|
||||
[ -f "/etc/config/$CONFIG" ] && {
|
||||
v2ray_index=$(uci show $CONFIG | grep -c "=servers")
|
||||
}
|
||||
}
|
||||
|
||||
get_local_servers(){
|
||||
[ -f "/etc/config/$CONFIG" ] && [ "`uci show $CONFIG | grep -c 'AutoSuB_V2ray'`" -gt 0 ] && {
|
||||
get_server_index
|
||||
for i in `seq $v2ray_index -1 1`
|
||||
do
|
||||
[ "$(uci show $CONFIG.@servers[$(($i-1))]|grep -c "AutoSuB_V2ray")" -eq 1 ] && {
|
||||
if [ ! -f "/usr/share/$CONFIG/serverconfig_v2ray/all_localservers" ]; then
|
||||
echo $(config_t_get servers server $(($i-1))) > /usr/share/$CONFIG/serverconfig_v2ray/all_localservers
|
||||
else
|
||||
echo $(config_t_get servers server $(($i-1))) >> /usr/share/$CONFIG/serverconfig_v2ray/all_localservers
|
||||
fi
|
||||
}
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
add_servers(){
|
||||
get_server_index
|
||||
uci add $CONFIG servers >/dev/null
|
||||
if [ -z "$1" ];then
|
||||
config_t_set servers remarks $v2ray_index $remarks
|
||||
config_t_set servers group $v2ray_index $group
|
||||
else
|
||||
config_t_set servers remarks $v2ray_index $remarks
|
||||
fi
|
||||
config_t_set servers server_type $v2ray_index 'V2ray'
|
||||
config_t_set servers v2ray_protocol $v2ray_index 'vmess'
|
||||
config_t_set servers server $v2ray_index $server
|
||||
config_t_set servers use_ipv6 $v2ray_index 0
|
||||
config_t_set servers server_port $v2ray_index $server_port
|
||||
config_t_set servers v2ray_security $v2ray_index 'auto'
|
||||
config_t_set servers v2ray_VMess_id $v2ray_index $id
|
||||
config_t_set servers v2ray_VMess_alterId $v2ray_index $aid
|
||||
config_t_set servers v2ray_VMess_level $v2ray_index $v
|
||||
config_t_set servers v2ray_transport $v2ray_index $net
|
||||
config_t_set servers v2ray_stream_security $v2ray_index $tls
|
||||
config_t_set servers v2ray_tcp_guise $v2ray_index $type
|
||||
config_t_set servers v2ray_ws_host $v2ray_index $ws_host
|
||||
config_t_set servers v2ray_ws_path $v2ray_index $ws_path
|
||||
uci commit $CONFIG
|
||||
}
|
||||
|
||||
update_config(){
|
||||
isadded_server=$(uci show $CONFIG | grep -c "server='$server'")
|
||||
if [ "$isadded_server" -eq 0 ]; then
|
||||
add_servers
|
||||
let addnum+=1
|
||||
else
|
||||
index=$(uci show $CONFIG | grep -w "server='$server'" | cut -d '[' -f2|cut -d ']' -f1)
|
||||
local_server_port=$(config_t_get servers server_port $index)
|
||||
local_vmess_id=$(config_t_get servers v2ray_VMess_id $index)
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
del_config(){
|
||||
# 删除订阅服务器已经不存在的节点
|
||||
for localserver in $(cat /usr/share/$CONFIG/serverconfig_v2ray/all_localservers)
|
||||
do
|
||||
[ "`cat /usr/share/$CONFIG/serverconfig_v2ray/all_onlineservers |grep -c "$localserver"`" -eq 0 ] && {
|
||||
for localindex in $(uci show $CONFIG|grep -w "$localserver" |grep -w "server=" |cut -d '[' -f2|cut -d ']' -f1)
|
||||
do
|
||||
uci delete $CONFIG.@servers[$localindex]
|
||||
uci commit $CONFIG
|
||||
let delnum+=1 #删除该节点
|
||||
done
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
del_all_config(){
|
||||
get_server_index
|
||||
[ "`uci show $CONFIG | grep -c 'AutoSuB_V2ray'`" -eq 0 ] && exit 0
|
||||
current_tcp_redir_server=$(config_t_get global tcp_redir_server)
|
||||
is_sub_server=`uci -q get $CONFIG.$current_tcp_redir_server.group`
|
||||
for i in `seq $v2ray_index -1 1`
|
||||
do
|
||||
[ "$(uci show $CONFIG.@servers[$(($i-1))] | grep -c 'AutoSuB_V2ray')" -eq 1 ] && uci delete $CONFIG.@servers[$(($i-1))] && uci commit $CONFIG
|
||||
done
|
||||
[ -n "$is_sub_server" ] && {
|
||||
config_t_set global tcp_redir_server 0 'nil'
|
||||
uci commit $CONFIG && /etc/init.d/$CONFIG stop
|
||||
}
|
||||
}
|
||||
|
||||
add() {
|
||||
V2RAY_LINKS=$(cat /tmp/v2ray_links.conf 2>/dev/null)
|
||||
[ -n "$V2RAY_LINKS" ] && {
|
||||
[ -f "$LOCK_FILE" ] && return 3
|
||||
touch "$LOCK_FILE"
|
||||
mkdir -p /usr/share/$CONFIG/serverconfig_v2ray
|
||||
rm -f /usr/share/$CONFIG/serverconfig_v2ray/*
|
||||
for v2ray_link in $V2RAY_LINKS
|
||||
do
|
||||
if [ -n "`echo -n "$v2ray_link" | grep 'vmess://'`" ]; then
|
||||
new_v2ray_link=`echo -n "$v2ray_link" | sed 's/vmess:\/\///g'`
|
||||
decode_v2ray_link=$(decode_url_link $new_v2ray_link 1)
|
||||
get_remote_config "$decode_v2ray_link"
|
||||
is_added=$(uci show $CONFIG | grep -v "AutoSuB_V2ray" | grep -c "server='$server'")
|
||||
[ "$is_added" -gt 0 ] && continue
|
||||
add_servers 1
|
||||
fi
|
||||
done
|
||||
[ -f "/usr/share/$CONFIG/serverconfig_v2ray/all_onlineservers" ] && rm -f /usr/share/$CONFIG/serverconfig_v2ray/all_onlineservers
|
||||
}
|
||||
rm -f /tmp/v2ray_links.conf
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
start() {
|
||||
#防止并发开启服务
|
||||
[ -f "$LOCK_FILE" ] && return 3
|
||||
touch "$LOCK_FILE"
|
||||
addnum=0
|
||||
updatenum=0
|
||||
delnum=0
|
||||
baseurl_v2ray=$(uci get $CONFIG.@global_subscribe[0].baseurl_v2ray) ##V2ray订阅地址
|
||||
[ -z "$baseurl_v2ray" ] && echo "$Date: V2ray订阅地址为空,跳过!" >> $LOG_FILE && rm -f "$LOCK_FILE" && exit 0
|
||||
|
||||
echo "$Date: 开始订阅V2ray..." >> $LOG_FILE
|
||||
[ ! -d "/usr/share/$CONFIG/onlineurl_v2ray" ] && mkdir -p /usr/share/$CONFIG/onlineurl_v2ray
|
||||
[ ! -d "/usr/share/$CONFIG/serverconfig_v2ray" ] && mkdir -p /usr/share/$CONFIG/serverconfig_v2ray
|
||||
rm -f /usr/share/$CONFIG/onlineurl_v2ray/*
|
||||
|
||||
/usr/bin/wget --no-check-certificate --timeout=8 -t 2 $baseurl_v2ray -P /usr/share/$CONFIG/onlineurl_v2ray
|
||||
[ ! -d "/usr/share/$CONFIG/onlineurl_v2ray" ] || [ "$(ls /usr/share/$CONFIG/onlineurl_v2ray |wc -l)" -eq 0 ] && echo "$Date: 订阅链接下载失败,请重试!" >> $LOG_FILE && rm -f "$LOCK_FILE" && exit 0
|
||||
rm -f /usr/share/$CONFIG/serverconfig_v2ray/*
|
||||
get_local_servers
|
||||
for file in /usr/share/$CONFIG/onlineurl_v2ray/*
|
||||
do
|
||||
[ -z "$(du -sh $file 2> /dev/null)" ] && echo "$Date: 订阅链接下载 $file 失败,请重试!" >> $LOG_FILE && continue
|
||||
maxnum=$(cat "$file" | /usr/bin/base64 -d 2> /dev/null| grep "MAX=" |awk -F"=" '{print $2}')
|
||||
if [ -n "$maxnum" ]; then
|
||||
urllinks=$(cat "$file" | /usr/bin/base64 -d 2> /dev/null| sed '/MAX=/d' | shuf -n${maxnum} | sed 's/vmess:\/\///g')
|
||||
else
|
||||
urllinks=$(cat "$file" | /usr/bin/base64 -d 2> /dev/null| sed 's/vmess:\/\///g')
|
||||
fi
|
||||
[ -z "$urllinks" ] && continue
|
||||
for link in $urllinks
|
||||
do
|
||||
decode_link=$(decode_url_link $link 1)
|
||||
get_remote_config "$decode_link"
|
||||
update_config
|
||||
done
|
||||
done
|
||||
[ -f "/usr/share/$CONFIG/serverconfig_v2ray/all_localservers" ] && del_config
|
||||
echo "$Date: 本次更新,V2ray新增服务器节点 $addnum 个,修改 $updatenum 个,删除 $delnum 个。" >> $LOG_FILE
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ "`uci show $CONFIG | grep -c 'AutoSuB_V2ray'`" -gt 0 ] && {
|
||||
echo "$Date: 在线订阅V2ray节点已全部删除" >> $LOG_FILE
|
||||
del_all_config
|
||||
}
|
||||
rm -rf /usr/share/$CONFIG/onlineurl_v2ray
|
||||
rm -rf /usr/share/$CONFIG/serverconfig_v2ray
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
case $1 in
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
add)
|
||||
add
|
||||
;;
|
||||
*)
|
||||
start
|
||||
;;
|
||||
esac
|
||||
17
package/lienol/luci-app-timewol/Makefile
Normal file
17
package/lienol/luci-app-timewol/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for Timewol
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=3-20190309
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
module("luci.controller.timewol", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/timewol") then return end
|
||||
|
||||
entry({"admin", "network"}, firstchild(), "Control", 44).dependent = false
|
||||
entry({"admin", "network", "timewol"}, cbi("timewol"), _("定时唤醒"), 95).dependent =
|
||||
true
|
||||
entry({"admin", "network", "timewol", "status"}, call("status")).leaf = true
|
||||
end
|
||||
|
||||
function status()
|
||||
local e = {}
|
||||
e.status = luci.sys
|
||||
.call("cat /etc/crontabs/root |grep etherwake >/dev/null") ==
|
||||
0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
37
package/lienol/luci-app-timewol/luasrc/model/cbi/timewol.lua
Normal file
37
package/lienol/luci-app-timewol/luasrc/model/cbi/timewol.lua
Normal file
@ -0,0 +1,37 @@
|
||||
local i = require "luci.sys"
|
||||
local t, e, o
|
||||
t = Map("timewol", translate("定时网络唤醒"),
|
||||
translate("定时唤醒你的局域网设备"))
|
||||
t.template = "timewol/index"
|
||||
e = t:section(TypedSection, "basic", translate("Running Status"))
|
||||
e.anonymous = true
|
||||
o = e:option(DummyValue, "timewol_status", translate("当前状态"))
|
||||
o.template = "timewol/timewol"
|
||||
o.value = translate("Collecting data...")
|
||||
e = t:section(TypedSection, "basic", translate("基本设置"))
|
||||
e.anonymous = true
|
||||
o = e:option(Flag, "enable", translate("开启"))
|
||||
o.rmempty = false
|
||||
e = t:section(TypedSection, "macclient", translate("客户端设置"))
|
||||
e.template = "cbi/tblsection"
|
||||
e.anonymous = true
|
||||
e.addremove = true
|
||||
nolimit_mac = e:option(Value, "macaddr", translate("客户端MAC"))
|
||||
nolimit_mac.rmempty = false
|
||||
i.net.mac_hints(function(e, t) nolimit_mac:value(e, "%s (%s)" % {e, t}) end)
|
||||
nolimit_eth = e:option(Value, "maceth", translate("网络接口"))
|
||||
nolimit_eth.rmempty = false
|
||||
for t, e in ipairs(i.net.devices()) do if e ~= "lo" then nolimit_eth:value(e) end end
|
||||
a = e:option(Value, "minute", translate("分钟"))
|
||||
a.optional = false
|
||||
a = e:option(Value, "hour", translate("小时"))
|
||||
a.optional = false
|
||||
a = e:option(Value, "day", translate("日"))
|
||||
a.optional = false
|
||||
a = e:option(Value, "month", translate("月"))
|
||||
a.optional = false
|
||||
a = e:option(Value, "weeks", translate("星期"))
|
||||
a.optional = false
|
||||
local e = luci.http.formvalue("cbi.apply")
|
||||
if e then io.popen("/etc/init.d/timewol restart") end
|
||||
return t
|
||||
@ -0,0 +1,18 @@
|
||||
<%#
|
||||
Copyright 2016 Chen RuiWei <crwbak@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<% include("cbi/map") %>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "timewol", "status")%>', null,
|
||||
function(x, result)
|
||||
{
|
||||
var status = document.getElementsByClassName('timewol_status')[0];
|
||||
status.setAttribute("style","font-weight:bold;");
|
||||
status.setAttribute("color",result.status ? "green":"red");
|
||||
status.innerHTML = result.status?'<%=translate("RUNNING")%>':'<%=translate("NOT RUNNING")%>';
|
||||
}
|
||||
)
|
||||
//]]>
|
||||
</script>
|
||||
@ -0,0 +1,3 @@
|
||||
<%+cbi/valueheader%>
|
||||
<font class="timewol_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
|
||||
<%+cbi/valuefooter%>
|
||||
2
package/lienol/luci-app-timewol/po/zh-cn/timewol.po
Normal file
2
package/lienol/luci-app-timewol/po/zh-cn/timewol.po
Normal file
@ -0,0 +1,2 @@
|
||||
msgid "Control"
|
||||
msgstr "管控"
|
||||
3
package/lienol/luci-app-timewol/root/etc/config/timewol
Normal file
3
package/lienol/luci-app-timewol/root/etc/config/timewol
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
config basic
|
||||
option enable '0'
|
||||
74
package/lienol/luci-app-timewol/root/etc/init.d/timewol
Executable file
74
package/lienol/luci-app-timewol/root/etc/init.d/timewol
Executable file
@ -0,0 +1,74 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt-dist
|
||||
# Copyright (C) 2016 fw867 <ffkykzs@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
START=99
|
||||
|
||||
CONFIG=timewol
|
||||
|
||||
uci_get_by_type() {
|
||||
local index=0
|
||||
if [ -n $4 ]; then
|
||||
index=$4
|
||||
fi
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
is_true() {
|
||||
case $1 in
|
||||
1|on|true|yes|enabled) echo 0;;
|
||||
*) echo 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
load_config() {
|
||||
ENABLED=$(uci_get_by_type basic enable)
|
||||
return $(is_true $ENABLED)
|
||||
}
|
||||
|
||||
add_rule(){
|
||||
sed -i '/etherwake/d' /etc/crontabs/root >/dev/null 2>&1
|
||||
for i in $(seq 0 100)
|
||||
do
|
||||
local macaddr=$(uci_get_by_type macclient macaddr '' $i)
|
||||
local maceth=$(uci_get_by_type macclient maceth '' $i)
|
||||
local minute=$(uci_get_by_type macclient minute '' $i)
|
||||
local hour=$(uci_get_by_type macclient hour '' $i)
|
||||
local day=$(uci_get_by_type macclient day '' $i)
|
||||
local month=$(uci_get_by_type macclient month '' $i)
|
||||
local weeks=$(uci_get_by_type macclient weeks '' $i)
|
||||
if [ -z $macaddr ] || [ -z $maceth ]; then
|
||||
break
|
||||
fi
|
||||
if [ -z $minute ] ; then
|
||||
minute="0"
|
||||
fi
|
||||
if [ -z $hour ] ; then
|
||||
hour="*"
|
||||
fi
|
||||
if [ -z $day ] ; then
|
||||
day="*"
|
||||
fi
|
||||
if [ -z $month ] ; then
|
||||
month="*"
|
||||
fi
|
||||
if [ -z $weeks ] ; then
|
||||
weeks="*"
|
||||
fi
|
||||
echo "$minute $hour $day $month $weeks /usr/bin/etherwake -D -i $maceth $macaddr" >> /etc/crontabs/root
|
||||
done
|
||||
}
|
||||
|
||||
start() {
|
||||
! load_config && exit 0
|
||||
add_rule
|
||||
}
|
||||
stop() {
|
||||
sed -i '/etherwake/d' /etc/crontabs/root >/dev/null 2>&1
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@timewol[-1]
|
||||
add ucitrack timewol
|
||||
set ucitrack.@timewol[-1].init=timewol
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
17
package/lienol/luci-app-webrestriction/Makefile
Normal file
17
package/lienol/luci-app-webrestriction/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for Webrestriction
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=3-20190309
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
module("luci.controller.webrestriction", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/webrestriction") then return end
|
||||
|
||||
entry({"admin", "network"}, firstchild(), "Control", 44).dependent = false
|
||||
entry({"admin", "network", "webrestriction"}, cbi("webrestriction"),
|
||||
_("访问限制"), 11).dependent = true
|
||||
entry({"admin", "network", "webrestriction", "status"}, call("status")).leaf =
|
||||
true
|
||||
end
|
||||
|
||||
function status()
|
||||
local e = {}
|
||||
e.status = luci.sys.call(
|
||||
"iptables -L FORWARD |grep WEB_RESTRICTION >/dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
@ -0,0 +1,30 @@
|
||||
local o = require "luci.sys"
|
||||
local a, e, t
|
||||
a = Map("webrestriction", translate("访问限制"), translate(
|
||||
"使用黑名单或者白名单模式控制列表中的客户端是否能够连接到互联网。"))
|
||||
a.template = "webrestriction/index"
|
||||
e = a:section(TypedSection, "basic", translate("Running Status"))
|
||||
e.anonymous = true
|
||||
t = e:option(DummyValue, "webrestriction_status", translate("当前状态"))
|
||||
t.template = "webrestriction/webrestriction"
|
||||
t.value = translate("Collecting data...")
|
||||
e = a:section(TypedSection, "basic", translate("全局设置"))
|
||||
e.anonymous = true
|
||||
t = e:option(Flag, "enable", translate("开启"))
|
||||
t.rmempty = false
|
||||
t = e:option(ListValue, "limit_type", translate("限制模式"))
|
||||
t.default = "blacklist"
|
||||
t:value("whitelist", translate("白名单"))
|
||||
t:value("blacklist", translate("Blacklist"))
|
||||
t.rmempty = false
|
||||
e = a:section(TypedSection, "macbind", translate("名单设置"), translate(
|
||||
"如果是黑名单模式,列表中的客户端将被禁止连接到互联网;白名单模式表示仅有列表中的客户端可以连接到互联网。"))
|
||||
e.template = "cbi/tblsection"
|
||||
e.anonymous = true
|
||||
e.addremove = true
|
||||
t = e:option(Flag, "enable", translate("开启控制"))
|
||||
t.rmempty = false
|
||||
t = e:option(Value, "macaddr", translate("MAC地址"))
|
||||
t.rmempty = true
|
||||
o.net.mac_hints(function(e, a) t:value(e, "%s (%s)" % {e, a}) end)
|
||||
return a
|
||||
@ -0,0 +1,18 @@
|
||||
<%#
|
||||
Copyright 2016 Chen RuiWei <crwbak@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<% include("cbi/map") %>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "webrestriction", "status")%>', null,
|
||||
function(x, result)
|
||||
{
|
||||
var status = document.getElementsByClassName('webrestriction_status')[0];
|
||||
status.setAttribute("style","font-weight:bold;");
|
||||
status.setAttribute("color",result.status ? "green":"red");
|
||||
status.innerHTML = result.status?'<%=translate("RUNNING")%>':'<%=translate("NOT RUNNING")%>';
|
||||
}
|
||||
)
|
||||
//]]>
|
||||
</script>
|
||||
@ -0,0 +1,3 @@
|
||||
<%+cbi/valueheader%>
|
||||
<font class="webrestriction_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
|
||||
<%+cbi/valuefooter%>
|
||||
@ -0,0 +1,2 @@
|
||||
msgid "Control"
|
||||
msgstr "管控"
|
||||
@ -0,0 +1,5 @@
|
||||
|
||||
config basic
|
||||
option enable '0'
|
||||
option limit_type 'blacklist'
|
||||
|
||||
86
package/lienol/luci-app-webrestriction/root/etc/init.d/webrestriction
Executable file
86
package/lienol/luci-app-webrestriction/root/etc/init.d/webrestriction
Executable file
@ -0,0 +1,86 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt-dist
|
||||
# Copyright (C) 2016 fw867 <ffkykzs@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
START=99
|
||||
|
||||
CONFIG=webrestriction
|
||||
limit_type=$(uci -q get webrestriction.@basic[0].limit_type)
|
||||
|
||||
uci_get_by_type() {
|
||||
local index=0
|
||||
if [ -n $4 ]; then
|
||||
index=$4
|
||||
fi
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
is_true() {
|
||||
case $1 in
|
||||
1|on|true|yes|enabled) echo 0;;
|
||||
*) echo 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
load_config() {
|
||||
ENABLED=$(uci_get_by_type basic enable)
|
||||
return $(is_true $ENABLED)
|
||||
}
|
||||
|
||||
|
||||
add_rule(){
|
||||
action=$1
|
||||
for i in $(seq 0 100)
|
||||
do
|
||||
enable=$(uci_get_by_type macbind enable '' $i)
|
||||
macaddr=$(uci_get_by_type macbind macaddr '' $i)
|
||||
if [ -z $enable ] || [ -z $macaddr ]; then
|
||||
break
|
||||
fi
|
||||
if [ "$enable" == "1" ]; then
|
||||
iptables -t filter -A WEB_RESTRICTION -m mac --mac-source $macaddr -j $action
|
||||
[ "$limit_type" == "blacklist" ] && iptables -t nat -A WEB_RESTRICTION -m mac --mac-source $macaddr -j RETURN
|
||||
#unset "$macaddr"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
start(){
|
||||
|
||||
! load_config && exit 0
|
||||
[ "`iptables -L FORWARD|grep -c WEB_RESTRICTION`" -gt 0 ] && exit 0;
|
||||
iptables -P FORWARD DROP
|
||||
iptables -t filter -N WEB_RESTRICTION
|
||||
if [ "$limit_type" == "blacklist" ]; then
|
||||
iptables -t nat -N WEB_RESTRICTION
|
||||
add_rule DROP
|
||||
else
|
||||
add_rule ACCEPT
|
||||
iptables -t filter -A WEB_RESTRICTION -j DROP
|
||||
fi
|
||||
|
||||
#获取FORWARD ACCEPT规则行号
|
||||
FA_INDEX=`iptables -t filter -L FORWARD|tail -n +3|sed -n -e '/^ACCEPT/='`
|
||||
if [ -n "$FA_INDEX" ]; then
|
||||
let FA_INDEX+=1
|
||||
fi
|
||||
#确保添加到FORWARD ACCEPT规则之后
|
||||
iptables -t filter -I FORWARD $FA_INDEX -m comment --comment "Rule For Control" -j WEB_RESTRICTION
|
||||
[ "$limit_type" == "blacklist" ] && iptables -t nat -I PREROUTING 1 -m comment --comment "Rule For Control" -j WEB_RESTRICTION
|
||||
}
|
||||
stop(){
|
||||
[ "`iptables -t filter -L | grep -c WEB_RESTRICTION`" -gt 0 ] && {
|
||||
iptables -t filter -D FORWARD -m comment --comment "Rule For Control" -j WEB_RESTRICTION
|
||||
iptables -t nat -D PREROUTING -m comment --comment "Rule For Control" -j WEB_RESTRICTION
|
||||
iptables -t filter -F WEB_RESTRICTION
|
||||
iptables -t filter -X WEB_RESTRICTION
|
||||
iptables -t nat -F WEB_RESTRICTION
|
||||
iptables -t nat -X WEB_RESTRICTION
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@webrestriction[-1]
|
||||
add ucitrack webrestriction
|
||||
set ucitrack.@webrestriction[-1].init=webrestriction
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
18
package/lienol/luci-app-weburl/Makefile
Normal file
18
package/lienol/luci-app-weburl/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for Weburl
|
||||
LUCI_DEPENDS:=+iptables-mod-filter +kmod-ipt-filter
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=3-20190309
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
|
||||
17
package/lienol/luci-app-weburl/luasrc/controller/weburl.lua
Normal file
17
package/lienol/luci-app-weburl/luasrc/controller/weburl.lua
Normal file
@ -0,0 +1,17 @@
|
||||
module("luci.controller.weburl", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/weburl") then return end
|
||||
|
||||
entry({"admin", "network"}, firstchild(), "Control", 44).dependent = false
|
||||
entry({"admin", "network", "weburl"}, cbi("weburl"), _("网址过滤"), 12).dependent =
|
||||
true
|
||||
entry({"admin", "network", "weburl", "status"}, call("status")).leaf = true
|
||||
end
|
||||
|
||||
function status()
|
||||
local e = {}
|
||||
e.status = luci.sys.call("iptables -L FORWARD |grep WEBURL >/dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
36
package/lienol/luci-app-weburl/luasrc/model/cbi/weburl.lua
Normal file
36
package/lienol/luci-app-weburl/luasrc/model/cbi/weburl.lua
Normal file
@ -0,0 +1,36 @@
|
||||
local o = require "luci.sys"
|
||||
local a, t, e
|
||||
a = Map("weburl", translate("网址过滤"), translate(
|
||||
"在这里设置关键词过滤,可以是URL里任意字符,可以过滤如视频网站、QQ、迅雷、淘宝。。。"))
|
||||
a.template = "weburl/index"
|
||||
t = a:section(TypedSection, "basic", translate("Running Status"))
|
||||
t.anonymous = true
|
||||
e = t:option(DummyValue, "weburl_status", translate("当前状态"))
|
||||
e.template = "weburl/weburl"
|
||||
e.value = translate("Collecting data...")
|
||||
t = a:section(TypedSection, "basic", translate("基本设置"), translate(
|
||||
"一般来说普通过滤效果就很好了,强制过滤会使用更复杂的算法导致更高的CPU占用。"))
|
||||
t.anonymous = true
|
||||
e = t:option(Flag, "enable", translate("开启"))
|
||||
e.rmempty = false
|
||||
e = t:option(Flag, "algos", translate("强效过滤"))
|
||||
e.rmempty = false
|
||||
t = a:section(TypedSection, "macbind", translate("关键词设置"), translate(
|
||||
"黑名单MAC不设置为全客户端过滤,如设置只过滤指定的客户端。过滤时间可不设置。"))
|
||||
t.template = "cbi/tblsection"
|
||||
t.anonymous = true
|
||||
t.addremove = true
|
||||
e = t:option(Flag, "enable", translate("开启控制"))
|
||||
e.rmempty = false
|
||||
e = t:option(Value, "macaddr", translate("黑名单MAC"))
|
||||
e.rmempty = true
|
||||
o.net.mac_hints(function(t, a) e:value(t, "%s (%s)" % {t, a}) end)
|
||||
e = t:option(Value, "timeon", translate("开始过滤时间"))
|
||||
e.placeholder = "00:00"
|
||||
e.rmempty = true
|
||||
e = t:option(Value, "timeoff", translate("取消过滤时间"))
|
||||
e.placeholder = "23:59"
|
||||
e.rmempty = true
|
||||
e = t:option(Value, "keyword", translate("网址关键词"))
|
||||
e.rmempty = false
|
||||
return a
|
||||
18
package/lienol/luci-app-weburl/luasrc/view/weburl/index.htm
Normal file
18
package/lienol/luci-app-weburl/luasrc/view/weburl/index.htm
Normal file
@ -0,0 +1,18 @@
|
||||
<%#
|
||||
Copyright 2016 Chen RuiWei <crwbak@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<% include("cbi/map") %>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "weburl", "status")%>', null,
|
||||
function(x, result)
|
||||
{
|
||||
var status = document.getElementsByClassName('weburl_status')[0];
|
||||
status.setAttribute("style","font-weight:bold;");
|
||||
status.setAttribute("color",result.status ? "green":"red");
|
||||
status.innerHTML = result.status?'<%=translate("RUNNING")%>':'<%=translate("NOT RUNNING")%>';
|
||||
}
|
||||
)
|
||||
//]]>
|
||||
</script>
|
||||
@ -0,0 +1,3 @@
|
||||
<%+cbi/valueheader%>
|
||||
<font class="weburl_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
|
||||
<%+cbi/valuefooter%>
|
||||
2
package/lienol/luci-app-weburl/po/zh-cn/weburl.po
Normal file
2
package/lienol/luci-app-weburl/po/zh-cn/weburl.po
Normal file
@ -0,0 +1,2 @@
|
||||
msgid "Control"
|
||||
msgstr "管控"
|
||||
22
package/lienol/luci-app-weburl/root/etc/config/weburl
Normal file
22
package/lienol/luci-app-weburl/root/etc/config/weburl
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
config basic
|
||||
option enable '0'
|
||||
option algos '0'
|
||||
|
||||
config macbind
|
||||
option keyword 'qq.com'
|
||||
option enable '0'
|
||||
option macaddr '00:0C:29:C8:99:9E'
|
||||
|
||||
config macbind
|
||||
option keyword 'taobao.com'
|
||||
option enable '0'
|
||||
|
||||
config macbind
|
||||
option enable '0'
|
||||
option keyword 'youku.com'
|
||||
|
||||
config macbind
|
||||
option enable '0'
|
||||
option keyword 'www'
|
||||
|
||||
88
package/lienol/luci-app-weburl/root/etc/init.d/weburl
Executable file
88
package/lienol/luci-app-weburl/root/etc/init.d/weburl
Executable file
@ -0,0 +1,88 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt-dist
|
||||
# Copyright (C) 2016 fw867 <ffkykzs@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
START=99
|
||||
|
||||
CONFIG=weburl
|
||||
|
||||
uci_get_by_type() {
|
||||
local index=0
|
||||
if [ -n $4 ]; then
|
||||
index=$4
|
||||
fi
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
is_true() {
|
||||
case $1 in
|
||||
1|on|true|yes|enabled) echo 0;;
|
||||
*) echo 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
load_config() {
|
||||
ENABLED=$(uci_get_by_type basic enable)
|
||||
return $(is_true $ENABLED)
|
||||
}
|
||||
|
||||
get_algo_mode(){
|
||||
case "$1" in
|
||||
0)
|
||||
echo "bm"
|
||||
;;
|
||||
1)
|
||||
echo "kmp"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
add_rule(){
|
||||
algos=$(uci_get_by_type basic algos)
|
||||
for i in $(seq 0 100)
|
||||
do
|
||||
enable=$(uci_get_by_type macbind enable '' $i)
|
||||
macaddr=$(uci_get_by_type macbind macaddr '' $i)
|
||||
timeon=$(uci_get_by_type macbind timeon '' $i)
|
||||
timeoff=$(uci_get_by_type macbind timeoff '' $i)
|
||||
keyword=$(uci_get_by_type macbind keyword '' $i)
|
||||
if [ -z $enable ] || [ -z $keyword ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
if [ -z $timeon ] || [ -z $timeoff ]; then
|
||||
settime=""
|
||||
else
|
||||
settime="-m time --kerneltz --timestart $timeon --timestop $timeoff"
|
||||
fi
|
||||
|
||||
if [ "$enable" == "1" ]; then
|
||||
if [ -z $macaddr ]; then
|
||||
iptables -t filter -I WEBURL $settime -m string --string "$keyword" --algo $(get_algo_mode $algos) -j DROP
|
||||
else
|
||||
iptables -t filter -I WEBURL $settime -m mac --mac-source $macaddr -m string --string "$keyword" --algo $(get_algo_mode $algos) -j DROP
|
||||
unset "$macaddr"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
start(){
|
||||
! load_config && exit 0
|
||||
iptables -L FORWARD | grep -c WEBURL 2>/dev/null && [ $? -eq 0 ] && exit 0;
|
||||
iptables -t filter -N WEBURL
|
||||
iptables -t filter -I FORWARD -m comment --comment "Rule For Control" -j WEBURL
|
||||
add_rule
|
||||
}
|
||||
stop(){
|
||||
iptables -t filter -D FORWARD -m comment --comment "Rule For Control" -j WEBURL
|
||||
iptables -t filter -F WEBURL
|
||||
iptables -t filter -X WEBURL
|
||||
}
|
||||
|
||||
11
package/lienol/luci-app-weburl/root/etc/uci-defaults/luci-app-control-weburl
Executable file
11
package/lienol/luci-app-weburl/root/etc/uci-defaults/luci-app-control-weburl
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@weburl[-1]
|
||||
add ucitrack weburl
|
||||
set ucitrack.@weburl[-1].init=weburl
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
86
package/lienol/trojan/Makefile
Normal file
86
package/lienol/trojan/Makefile
Normal file
@ -0,0 +1,86 @@
|
||||
#
|
||||
# Copyright (C) 2018-2019 wongsyrone
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=trojan
|
||||
PKG_VERSION:=1.13.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/trojan-gfw/trojan.git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=842ad5bb07eb8bce035fb274571e586629a97c99
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
CMAKE_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=0
|
||||
|
||||
PKG_BUILD_DEPENDS:=openssl1.1
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
|
||||
PKG_MAINTAINER:=GreaterFire
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
TARGET_CXXFLAGS += -Wall -Wextra
|
||||
TARGET_CXXFLAGS += $(FPIC)
|
||||
|
||||
# LTO
|
||||
TARGET_CXXFLAGS += -flto
|
||||
TARGET_LDFLAGS += -flto
|
||||
|
||||
# CXX standard
|
||||
TARGET_CXXFLAGS += -std=c++11
|
||||
|
||||
TARGET_CXXFLAGS := $(filter-out -O%,$(TARGET_CXXFLAGS)) -O3
|
||||
MY_OPENSSL_DIR:=$(BUILD_DIR)/openssl1.1_staging_dir/usr
|
||||
|
||||
TARGET_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||
TARGET_LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
CMAKE_FIND_ROOT_PATH := $(MY_OPENSSL_DIR);$(CMAKE_FIND_ROOT_PATH)
|
||||
TARGET_CXXFLAGS := -I$(MY_OPENSSL_DIR)/include $(TARGET_CXXFLAGS)
|
||||
TARGET_LDFLAGS := -L$(MY_OPENSSL_DIR)/lib $(TARGET_LDFLAGS)
|
||||
|
||||
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DENABLE_MYSQL=OFF \
|
||||
-DENABLE_SSL_KEYLOG=ON \
|
||||
-DENABLE_NAT=ON \
|
||||
-DFORCE_TCP_FASTOPEN=OFF \
|
||||
-DSYSTEMD_SERVICE=OFF \
|
||||
-DOPENSSL_USE_STATIC_LIBS=TRUE \
|
||||
-DBoost_DEBUG=ON \
|
||||
-DBoost_NO_BOOST_CMAKE=ON
|
||||
|
||||
|
||||
|
||||
define Package/trojan
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=An unidentifiable mechanism that helps you bypass GFW
|
||||
URL:=https://github.com/trojan-gfw/trojan
|
||||
DEPENDS:=+libpthread +libstdcpp \
|
||||
+boost +boost-system +boost-program_options +boost-date_time
|
||||
endef
|
||||
|
||||
|
||||
|
||||
define Package/trojan/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/trojan $(1)/usr/sbin/trojan
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/trojan.config $(1)/etc/config/trojan
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/trojan.init $(1)/etc/init.d/trojan
|
||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/trojan/config.json $(1)/etc/trojan.json
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,trojan))
|
||||
4
package/lienol/trojan/files/trojan.config
Normal file
4
package/lienol/trojan/files/trojan.config
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
config trojan
|
||||
option enabled '0'
|
||||
|
||||
37
package/lienol/trojan/files/trojan.init
Executable file
37
package/lienol/trojan/files/trojan.init
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2018 wongsyrone
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
START=95
|
||||
USE_PROCD=1
|
||||
#PROCD_DEBUG=1
|
||||
|
||||
PROG=/usr/sbin/trojan
|
||||
CONF=/etc/trojan.json
|
||||
|
||||
config_load "trojan"
|
||||
|
||||
parse_trojan() {
|
||||
config_get ENABLED "$section" "enabled"
|
||||
}
|
||||
|
||||
config_foreach parse_trojan 'trojan'
|
||||
|
||||
|
||||
start_service() {
|
||||
if [ "1" = "$ENABLED" ] || [ "on" = "$ENABLED" ] || [ "true" = "$ENABLED" ]; then
|
||||
procd_open_instance
|
||||
procd_set_param command $PROG --config $CONF
|
||||
procd_set_param user root # run service as user root
|
||||
procd_set_param stdout 1 # forward stdout of the command to logd
|
||||
procd_set_param stderr 1 # same for stderr
|
||||
procd_set_param limits nofile="1048576 1048576" # max allowed value can be fetched via /proc/sys/fs/nr_open
|
||||
[ -e /proc/sys/kernel/core_pattern ] && {
|
||||
procd_append_param limits core="unlimited"
|
||||
}
|
||||
procd_close_instance
|
||||
else
|
||||
echo "trojan is disabled"
|
||||
fi
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -43,7 +43,7 @@ if(MSVC)
|
||||
add_definitions(-DBOOST_DATE_TIME_NO_LIB)
|
||||
endif()
|
||||
|
||||
-find_package(OpenSSL 1.0.2 REQUIRED)
|
||||
+find_package(OpenSSL 1.1.1 REQUIRED)
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
target_link_libraries(trojan ${OPENSSL_LIBRARIES})
|
||||
if(OPENSSL_VERSION VERSION_GREATER_EQUAL 1.1.1)
|
||||
Loading…
Reference in New Issue
Block a user