🎉 Sync 2024-03-23 08:59:31

This commit is contained in:
github-actions[bot] 2024-03-23 08:59:31 +08:00
parent 2a9cdfb878
commit 48afee576c
17 changed files with 332 additions and 138 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=alist
PKG_VERSION:=3.32.0
PKG_WEB_VERSION:=3.32.0
PKG_RELEASE:=82
PKG_RELEASE:=83
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)?
@ -45,7 +45,7 @@ define Package/$(PKG_NAME)
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=A file list program that supports multiple storage
URL:=https://alist-doc.nn.ci/
URL:=https://alist.nn.ci/
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
endef

View File

@ -103,7 +103,7 @@ start_service() {
"force_https": false,
"cert_file": "$ssl_cert",
"key_file": "$ssl_key",
"unix_file": "/var/alist.sock"
"unix_file": "/var/run/alist.sock"
},
"temp_dir": "$temp_dir",
"bleve_dir": "$data_dir/bleve",
@ -121,13 +121,15 @@ start_service() {
}
EOF
procd_open_instance alist
procd_open_instance
procd_set_param command $PROG
procd_append_param command server --data $data_dir
procd_set_param stdout 0
procd_set_param stderr 0
procd_set_param respawn
procd_close_instance alist
procd_set_param limits core="unlimited"
procd_set_param limits nofile="200000 200000"
procd_close_instance
}
service_triggers() {

View File

@ -13,12 +13,12 @@ s.anonymous=true
e=s:option(TextValue, "customscript" ,translate("Edit Custom Script"))
e.description = translate("The execution content of the [Scheduled Customscript] in the task name")
e.rows = 5
e.rmempty = false
e.default=" "
e=s:option(TextValue, "customscript2" ,translate("Edit Custom Script2"))
e.description = translate("The execution content of the [Scheduled Customscript2] in the task name")
e.rows = 5
e.rmempty = false
e.default=" "
s=m:section(TypedSection,"stime","")
s.addremove=true
@ -38,9 +38,9 @@ e:value(9,translate("Scheduled DisReconn"))
e:value(10,translate("Scheduled DisRereboot"))
e:value(11,translate("Scheduled Restartmwan3"))
e:value(12,translate("Scheduled Customscript"))
e:value(13,translate("Scheduled Customscript2"))
e:value(14,translate("Scheduled Wifiup"))
e:value(15,translate("Scheduled Wifidown"))
e:value(13,translate("Scheduled Wifiup"))
e:value(14,translate("Scheduled Wifidown"))
e:value(15,translate("Scheduled Customscript2"))
e.default=2
e=s:option(Flag,"enable",translate("Enable"))

View File

@ -1,6 +1,7 @@
config global
option enabled '0'
option customscript '#!/bin/sh'
option customscript '# Sh script rules'
option customscript2 '# Sh script rules'
config stime
option hour '*/4'

View File

@ -77,17 +77,17 @@ do
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript Startup_task" >>$TT
;;
13)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript2 Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript2 Startup_task" >>$TT
;;
14)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler upwifi Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler upwifi Startup_task" >>$TT
;;
15)
14)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler downwifi Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler downwifi Startup_task" >>$TT
;;
15)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript2 Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript2 Startup_task" >>$TT
;;
esac
fi
done

View File

@ -22,8 +22,7 @@ endef
define Package/$(PKG_NAME)/postinst
endef
define Package/$(PKG_NAME)/prerm
endef
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -1,6 +1,7 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
module("luci.controller.netspeedtest", package.seeall)
local http = require "luci.http"
local fs=require"nixio.fs"
local sys=require "luci.sys"
local uci = luci.model.uci.cursor()
@ -8,22 +9,47 @@ name='netspeedtest'
function index()
if not nixio.fs.access("/etc/config/netspeedtest") then return end
local e = entry({"admin","network","netspeedtest"},alias("admin", "network", "netspeedtest", "speedtestlan"),_("Net Speedtest"), 90)
e.dependent=false
e.acl_depends = { "luci-app-netspeedtest" }
local e = entry({"admin","network","netspeedtest"},alias("admin", "network", "netspeedtest", "speedtestlan"),_("Net Speedtest"),90)
e.dependent = false
e.acl_depends = { "luci-app-netspeedtest" }
entry({"admin", "network", "netspeedtest", "speedtestlan"},cbi("netspeedtest/speedtestlan"),_("Lan Speedtest Web"),20).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestiperf3"},cbi("netspeedtest/speedtestiperf3", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Lan Speedtest Iperf3"),30).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestwan"},cbi("netspeedtest/speedtestwan", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Broadband speed test"), 40).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestport"},cbi("netspeedtest/speedtestport", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Server Port Latency Test"), 50).leaf = true
entry({"admin", "network", "netspeedtest", "log"}, form("netspeedtest/log"), _("Log"), 60).leaf = true
entry({"admin", "network", "netspeedtest", "test_port"}, call("test_port"))
entry({"admin", "network", "iperf3_status"}, call("iperf3_status"))
entry({"admin", "network", "test_iperf0"}, post("test_iperf0"), nil).leaf = true
entry({"admin", "network", "test_iperf1"}, post("test_iperf1"), nil).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestwanrun"}, call("speedtestwanrun"))
entry({"admin", "network", "netspeedtest", "realtime_log"}, call("get_log"))
entry({"admin", "network", "netspeedtest", "netcheck"}, call("netcheck"))
entry({"admin", "network", "netspeedtest", "dellog"},call("dellog"))
entry({"admin", "network", "netspeedtest", "getlog"},call("getlog"))
end
function netcheck()
http.prepare_content("text/plain; charset=utf-8")
local f=io.open("/etc/netspeedtest/netspeedtest.log", "r+")
local fdp=fs.readfile("/etc/netspeedtest/netspeedtestpos") or 0
f:seek("set",fdp)
local a=f:read(2048000) or ""
fdp=f:seek()
fs.writefile("/etc/netspeedtest/netspeedtestpos",tostring(fdp))
f:close()
http.write(a)
end
function speedtestwanrun()
local cli = luci.http.formvalue('cli')
uci:set(name, 'speedtestwan', 'speedtest_cli', cli)
uci:commit(name)
fs.writefile("/etc/netspeedtest/netspeedtestpos","0")
http.prepare_content("application/json")
http.write('')
sys.exec(string.format("/etc/init.d/netspeedtest wantest " ..cli.. " > /etc/netspeedtest/netspeedtest.log 2>&1 &" ))
end
function test_port()
local e = {}
@ -82,24 +108,25 @@ function test_iperf1(addr)
sys.call("/etc/init.d/unblockmusic restart")
end
function get_log()
local e = {}
e.running = sys.call("busybox ps -w | grep netspeedtest | grep -v grep >/dev/null") == 0
e.log = fs.readfile("/var/log/netspeedtest.log") or ""
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function dellog()
fs.writefile("/var/log/netspeedtest.log","")
http.prepare_content("application/json")
http.write('')
end
function speedtestwanrun()
local cli = luci.http.formvalue('cli')
uci:set(name, 'speedtestwan', 'speedtest_cli', cli)
uci:commit(name)
testout("/etc/init.d/netspeedtest wantest "..cli)
function getlog()
logfile="/var/log/netspeedtest.log"
if not fs.access(logfile) then
http.write("")
return
end
local f=io.open(logfile,"r")
local a=f:read("*a") or ""
f:close()
a=string.gsub(a,"\n$","")
http.prepare_content("text/plain; charset=utf-8")
http.write(a)
end

View File

@ -0,0 +1,13 @@
local fs = require "nixio.fs"
local uci = require"luci.model.uci".cursor()
local f, t
f = SimpleForm("logview")
f.reset = false
f.submit = false
t=f:field(TextValue,"conf")
t.rmempty=true
t.rows=20
t.template="netspeedtest/log"
t.readonly="readonly"
return f

View File

@ -21,8 +21,5 @@ e = t:option(DummyValue, '', '')
e.rawhtml = true
e.template ='netspeedtest/speedtestport'
e =t:option(DummyValue, '', '')
e.rawhtml = true
e.template = 'netspeedtest/log'
return o

View File

@ -12,12 +12,8 @@ e:value("0",translate("ookla-speedtest-cli"))
e:value("1",translate("python3-speedtest-cli"))
e.default = "1"
e = t:option(DummyValue, '', '')
e.rawhtml = true
e=t:option(Button, "restart", translate("speedtest.net Broadband speed test"))
e.inputtitle=translate("Click to execute")
e.template ='netspeedtest/speedtestwan'
e =t:option(DummyValue, '', '')
e.rawhtml = true
e.template = 'netspeedtest/log'
return o

View File

@ -1,16 +1,53 @@
<%+cbi/valueheader%>
<textarea id="logview.list" class="cbi-input-textarea" style="width: 100%" rows="20" readonly="readonly"></textarea>
<input type="button" class="btn cbi-button cbi-button-apply" id="apply_update_button" value="<%:Clear Log%>" onclick="apply_del_log()"/>
<input type="checkbox" name="NAME" value="reverse" onclick="reverselog()" style="vertical-align:middle;height:auto;"><%:Reverse%></input>
<textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="32" cols="60" readonly="readonly" > </textarea>
<script type="text/javascript">
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","realtime_log")%>';
<script type="text/javascript">//<![CDATA[
var islogreverse=false;
XHR.poll(1, LOG_URL, null, (x, d) => {
let logview = document.getElementById("logview.list");
if (!d.running) {
XHR.halt();
}
logview.value = d.log;
logview.scrollTop = logview.scrollHeight;
});
function createAndDownloadFile(fileName,content){
var aTag=document.createElement('a');
var blob=new Blob([content]);
aTag.download=fileName;
aTag.href=URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(blob);
}
function apply_del_log(){
XHR.get('<%=url([[admin]],[[network]],[[netspeedtest]],[[dellog]])%>',null,function(x,data){
var lv=document.getElementById('cbid.logview.1.conf');
lv.innerHTML="";
}
);
return
}
function reverselog(){
var lv=document.getElementById('cbid.logview.1.conf');
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
if (islogreverse){
islogreverse=false;
}else{
islogreverse=true;
}
return
}
XHR.poll(3,'<%=url([[admin]],[[network]],[[netspeedtest]],[[getlog]])%>',null,
function(x,data){
var lv=document.getElementById('cbid.logview.1.conf');
lv.innerHTML=""
if (x.responseText && lv){
if (islogreverse){
lv.innerHTML=x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
}else{
lv.innerHTML+=x.responseText;
}
}
}
)
//]]>
</script>
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>

View File

@ -3,24 +3,32 @@
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>
<%+cbi/valueheader%>
<label class="cbi-value-title"><%= translate("speedtest.net Broadband speed test") %></label>
<div class="cbi-value-field">
<input class="cbi-button cbi-button-apply" id="run_service" type="button" onclick="run(this)" value="<%=translate('Click to execute') %>" />
<%local fs=require"nixio.fs"%>
<input type="button" class="btn cbi-button cbi-button-apply" id="apply_run_button" value="<%:Click to execute%>" onclick=" return apply_run(this) "/>
<div id="logview" style="display:none">
<input type="checkbox" id="reversetag" value="reverse" onclick=" return reverselog()" style="vertical-align:middle;height: auto;"><%:reverse%></input>
<textarea id="cbid.logview.test.conf" class="cbi-input-textarea" style="width: 100%;display:block;" data-update="change" rows="20" cols="80" readonly="readonly" > </textarea>
</div>
<fieldset class="cbi-section" style="display:none">
<legend id="wanspeedtest-legend">
<%:Collecting data...%>
</legend>
<span id="wanspeedtest-output"></span>
</fieldset>
<script type="text/javascript">
function run(btn) {
<script type="text/javascript">//<![CDATA[
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestwanrun")%>';
const S_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestwan")%>';
const S_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","netcheck")%>';
var checkbtn = document.getElementById('apply_run_button');
var islogreverse = false;
function reverselog(){
var lv = document.getElementById('cbid.logview.test.conf');
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
if (islogreverse){
islogreverse=false;
}else{
islogreverse=true;
}
return
}
function apply_run(btn) {
var sid='speedtestwan'
var opt={
base:"cbid.netspeedtest."+sid,
@ -47,40 +55,45 @@ function run(btn) {
return ret;
}
}
var legend=document.getElementById('wanspeedtest-legend');
var output=document.getElementById('wanspeedtest-output');
btn.value='<%:Waiting (executing)...%>';
btn.disabled=true;
var cli=opt.get("speedtest_cli").value;
console.log(cli);
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Network speed test, please wait...%>'
;
XHR.get(RUN_URL, { cli: cli },
(x) =>{
if (x.responseText)
{
legend.style.display = 'none';
output.innerHTML = String.format('<img src=%h height="300" style="vertical-align:middle" />', x.responseText);
}
else
{
legend.style.display = 'none';
output.innerHTML ='</p><%:Operation execution complete%></p>';
}
btn.disabled=false;
btn.value='<%:Click to execute%>';
}
(x) =>{}
);
return false;
poll_check();
return;
}
</script>
function poll_check(){
var tag = document.getElementById('logview');
tag.style.display="block"
XHR.poll(3, '<%=url([[admin]], [[network]], [[netspeedtest]], [[netcheck]])%>', null,
function(x, data) {
var lv = document.getElementById('cbid.logview.test.conf');
if (x.responseText && lv) {
if (x.responseText=="\u0000"){
for(j = 0,len=this.XHR._q.length; j < len; j++) {
if (this.XHR._q[j].url == '<%=url([[admin]], [[network]], [[netspeedtest]], [[netcheck]])%>'){
this.XHR._q.splice(j,1);
checkbtn.disabled = false;
checkbtn.value = '<%:Click to execute%>';
break;
}
}
return
}
if (islogreverse){
lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
}else{
lv.innerHTML += x.responseText;
}
}
}
);}
//]]>
</script>
<%+cbi/valuefooter%>

View File

@ -15,7 +15,15 @@ EXTRA_COMMANDS="wantest"
TMP_T=/var/netspeedtest_nstest.tmp
BINSPEEDTEST='/usr/bin/speedtest'
LOCK=/var/lock/netspeedtest_nstest.lock
LOGD=/etc/netspeedtest
LOG=/var/log/netspeedtest.log
LOGE=$LOGD/netspeedtest.log
LOGT=$LOGD/netspeedtestpos
[ -d "$LOGD" ] || mkdir -p $LOGD
[ -f "$LOGE" ] || echo "start" > $LOG
[ -f "$LOGT" ] || echo "start" > $LOGT
[ -f "$LOG" ] || echo "start" > $LOG
MAX_LOG=500
limit_log() {
local logf=$1
@ -29,10 +37,6 @@ limit_log() {
fi
}
init_log() {
local logf=$1
[ ! -f "$logf" ] && echo "" > $logf
}
echone() {
echo -ne $* >> $LOG
@ -42,46 +46,50 @@ echone() {
wantest() {
[ -f $LOCK ] && exit
limit_log $LOG 500
init_log $LOG
touch $LOCK
TESTMODE=$1
BINTEMP=$(git_bin_handle $TESTMODE)
# [ -n "$BINTEMP" ] || return
# echone "\n BINTEMP: $BINTEMP "
case $TESTMODE in
0)
echo -ne "\n —————ookla-speedtest测速$TESTMODE—————" >> $LOG
info=$($BINTEMP > $TMP_T 2>&1 )
RESULT=$(echo "$TMP_T" | grep "URL" | awk '{print $NF}')
echo -ne "\n —————ookla-speedtest测速—————\n" | tee -a $LOG
$BINTEMP | tee $TMP_T
RESULT=$(cat $TMP_T | grep 'URL' | cut -c15-)
if [ -n "$RESULT" ] ;then
echo -ne "\n 测服信息:`cat $TMP_T | grep 'Server'| cut -c10- | awk -F: '{printf $2$3}'` 线路:`cat $TMP_T | grep 'ISP' | awk -F: '{printf $2}' ` 延时:`cat $TMP_T | grep 'Latency' | awk -F: '{printf $2}' | awk -F '(' '{printf $1}'`" >> $LOG
echo -ne "\n 下行速率:`cat $TMP_T | grep 'Download' |awk -F: '{printf $2}' | awk -F '(' '{printf $1}'` --" >> $LOG
echo -ne "-- 上行速率:`cat $TMP_T | grep 'Upload' |awk -F: '{printf $2}' | awk -F '(' '{printf $1}'`" >> $LOG
echo -ne "\n 测速结果图片链接:`cat $TMP_T | grep 'URL' | cut -c15-`" >> $LOG
echo -ne "$RESULT"
else
echo -ne "\n 因客户端在LUCI状态下无法执行,测试失败!" >> $LOG
echo -ne "\n 请SSH登陆后输入 /etc/init.d/netspeedtest wantest 0 然后等完成后,刷新后查看记录!" >> $LOG
echo -ne "\n 因客户端在LUCI下运行错误,测试失败!" | tee -a $LOG
echo -ne "\n 请SSH运行:/etc/init.d/netspeedtest wantest 0 测试,完成后,在日志中有测试结果!" | tee -a $LOG
fi
echo -ne "\n 测试时间: `date +%Y-%m-%d' '%H:%M:%S`" >> $LOG
echo -ne "\n ————————————————————\n" >> $LOG
echo -ne "\n 测试时间: `date +%Y-%m-%d' '%H:%M:%S`" | tee -a $LOG
echo -ne "\n ————————————————————\n" | tee -a $LOG
;;
*)
echo -ne "\n —————python3-speedtest测速$TESTMODE—————" >> $LOG
info=$($BINTEMP > $TMP_T 2>&1 )
*)
echo -ne "\n —————python3-speedtest测速—————\n" | tee -a $LOG
$BINTEMP | tee $TMP_T
echo -ne "\n 测服信息:$(cat $TMP_T | grep 'Hosted by'| cut -c10- | awk -F: '{printf $1}') 延时:$(cat $TMP_T | grep 'Hosted by' | awk -F: '{printf $2}')" >> $LOG
echo -ne "\n 下行速率:$(cat $TMP_T | grep 'Download:' |awk -F: '{printf $2}' )" >> $LOG
echo -ne " ---- 上行速率:$(cat $TMP_T | grep 'Upload:' |awk -F: '{printf $2}' )" >> $LOG
echo -ne "\n 下行速率:$(cat $TMP_T | grep 'Download:' |awk -F: '{printf $2}' ) --" >> $LOG
echo -ne "-- 上行速率:$(cat $TMP_T | grep 'Upload:' |awk -F: '{printf $2}' )" >> $LOG
echo -ne "\n 测试结果图片链接:$(cat $TMP_T | grep 'results:' | cut -c16- )" >> $LOG
echo -ne "\n 测试时间:`date +%Y-%m-%d" "%H:%M:%S`" >> $LOG
echo -ne "\n ————————————————————\n" >> $LOG
echo -ne $(cat $TMP_T | grep 'results:' | awk '{print $NF}')
echo -ne "\n 测试时间:`date +%Y-%m-%d" "%H:%M:%S`" | tee -a $LOG
echo -ne "\n ————————————————————\n" | tee -a $LOG
;;
esac
rm -f $LOCK
}
getcpucore(){
#i386, x86_64, arm32, arm32hf, and arm64.
cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
[ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="armel"
[ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs/clash ] && cpucore="armhf"
[ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="aarch64"
[ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="i386"
[ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="x86_64"
echo $cpucore
}
git_bin_handle()
{
@ -95,7 +103,7 @@ case $1 in
chmod 755 $BINSPEEDTEST >/dev/null 2>&1
echo "$BINSPEEDTEST --accept-gdpr --accept-license --progress=no"
else
ooklaurl=`curl --connect-timeout 5 -m 60 -sSL 'https://www.speedtest.net/apps/cli' | grep 'Download for Linux' | sed 's|<|\n<|g' | sed -n '/Download for Linux/,/<\/div>/p' | sed -En "s|.*<a href=\"([^\"]+)\">x86_64|\1|p" `
ooklaurl=`curl --connect-timeout 5 -m 60 -sSL 'https://www.speedtest.net/apps/cli' | grep 'Download for Linux' | sed 's|<|\n<|g' | sed -n '/Download for Linux/,/<\/div>/p' | sed -En "s|.*<a href=\"([^\"]+)\">$(getcpucore)|\1|p" `
[ -n "$ooklaurl" ] && curl -sSL $ooklaurl | tar -xvz -C /tmp >/dev/null 2>&1 || return
mv /tmp/speedtest $BINSPEEDTEST >/dev/null 2>&1
chmod 755 $BINSPEEDTEST >/dev/null 2>&1

View File

@ -1,9 +1,18 @@
#!/bin/sh
chmod +x /etc/init.d/netspeedtest >/dev/null 2>&1
[ `uci -q get partexp.global` ] && uci set partexp.global=global
[ `uci -q get netspeedtest.netspeedtest` ] || uci set netspeedtest.netspeedtest=netspeedtest
[ `uci -q get netspeedtest.speedtestiperf3` ] || uci set netspeedtest.speedtestiperf3=speedtestiperf3
[ `uci -q get netspeedtest.speedtestport` ] || uci set netspeedtest.speedtestport=speedtestport
[ `uci -q get netspeedtest.speedtestwan` ] || uci set netspeedtest.speedtestport=speedtestwan
LOGD=/etc/netspeedtest
LOG=/var/log/netspeedtest.log
LOGE=$LOGD/netspeedtest.log
LOGT=$LOGD/netspeedtestpos
[ -d "$LOGD" ] || mkdir -p $LOGD
[ -f "$LOGE" ] || echo "start" > $LOG
[ -f "$LOGT" ] || echo "start" > $LOGT
[ -f "$LOG" ] || echo "start" > $LOG
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
exit 0

View File

@ -1,43 +1,47 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=microsocks
PKG_VERSION:=1.0.4
PKG_RELEASE:=81
PKG_RELEASE:=82
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/rofl0r/microsocks/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=skip
PKG_MAINTAINER:=Mateusz Korniak <matkorgithubcom@ant.gliwice.pl>
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=COPYING
PKG_MAINTAINER:=lean
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
PKG_BUILD_FLAGS:=lto
include $(INCLUDE_DIR)/package.mk
define Package/microsocks
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=Tiny, portable SOCKS5 server
URL:=https://github.com/rofl0r/microsocks
DEPENDS:=+libpthread
CATEGORY:=Network
TITLE:=SOCKS5 TCP/IP only proxy
endef
define Package/microsocks/description
A SOCKS5 service that you can run on your remote boxes to tunnel connections
through them, if for some reason SSH doesn't cut it for you.
Low resource SOCKS5 proxy.
Supports only SOCKS5 protocol and forwarding only TCP/IP connections.
endef
define Package/microsocks/conffiles
/etc/config/microsocks
endef
TARGET_LDFLAGS+= -Wl,--gc-sections,--as-needed
define Package/microsocks/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/local/bin/microsocks $(1)/usr/bin/microsocks
$(INSTALL_BIN) $(PKG_BUILD_DIR)/microsocks $(1)/usr/bin
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/microsocks.config $(1)/etc/config/microsocks
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/microsocks.init $(1)/etc/init.d/microsocks
endef
$(eval $(call BuildPackage,microsocks))

View File

@ -0,0 +1,14 @@
config microsocks 'config'
option enabled '0'
option bindaddr ''
option listenip '::'
option port '1080'
option user ''
option password ''
# Boolean, must be used together with user/pass
option auth_once '0'
# Boolean, auto setup firewall rule so you can access it from Internet
option internet_access '0'
option quiet '1'

View File

@ -0,0 +1,74 @@
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
CONF="microsocks"
start_service() {
config_load "$CONF"
local _enabled
config_get_bool _enabled "config" "enabled" "0"
[ "$_enabled" -eq "1" ] || return 1
local _port _listenip _bindaddr
local _user _password
local _auth_once _internet_access
local _quiet
config_get _port "config" "port"
config_get _listenip "config" "listenip"
config_get _bindaddr "config" "bindaddr"
config_get _user "config" "user"
config_get _password "config" "password"
config_get_bool _auth_once "config" "auth_once" 0
config_get_bool _internet_access "config" "internet_access" 0
config_get_bool _quiet "config" "quiet" 0
procd_open_instance "$CONF"
procd_set_param command /usr/bin/microsocks
[ -z "$_port" ] || procd_append_param command -p "${_port}"
[ -z "$_listenip" ] || procd_append_param command -i "${_listenip}"
[ -z "$_bindaddr" ] || procd_append_param command -b "${_bindaddr}"
[ -z "$_user" ] || procd_append_param command -u "${_user}"
[ -z "$_password" ] || procd_append_param command -P "${_password}"
[ "$_auth_once" -eq "0" ] || procd_append_param command -1
[ "$_quiet" -eq "0" ] || procd_append_param command -q
procd_set_param limits core="unlimited"
procd_set_param limits nofile="1000000 1000000"
procd_set_param respawn
procd_set_param stderr 1
# TODO: Make it dependable on some verbose/debug config setting?
# procd_set_param stdout 1
[ "$_internet_access" -eq "0" ] || {
procd_open_data
json_add_array firewall
json_add_object ""
json_add_string type rule
json_add_string name "Allow-access-microsocks-at-$_port"
json_add_string src "*"
json_add_string dest_port "$_port"
json_add_string proto tcp
json_add_string target ACCEPT
json_close_object
json_close_array
procd_close_data
}
procd_close_instance
}
service_started() {
procd_set_config_changed firewall
}
service_stopped() {
procd_set_config_changed firewall
}
service_triggers() {
procd_add_reload_trigger "$CONF"
}