2023-11-29 01:23:31 Auto Sync

This commit is contained in:
WindyMadman 2023-11-29 01:23:31 +08:00
parent e0f7d4fcd1
commit 67ffea2dd6
23 changed files with 1135 additions and 0 deletions

46
ipt2socks/Makefile Normal file
View File

@ -0,0 +1,46 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=ipt2socks
PKG_VERSION:=1.1.3
PKG_RELEASE:=17
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/zfl9/ipt2socks/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=skip
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
PKG_BUILD_FLAGS:=no-mips16
PKG_LICENSE:=AGPL-3.0
PKG_LICENSE_FILE:=LICENSE
include $(INCLUDE_DIR)/package.mk
define Package/ipt2socks
SECTION:=net
CATEGORY:=Network
TITLE:=Convert iptables to socks5
URL:=https://github.com/zfl9/ipt2socks
DEPENDS:=+libpthread
endef
define Package/ipt2socks/description
Utility for converting iptables (redirect/tproxy) to socks5.
endef
TARGET_CFLAGS+= $(FPIC) -flto
MAKE_FLAGS+= \
CFLAGS="-std=c99 -pthread $(TARGET_CFLAGS)" \
EVCFLAGS="$(TARGET_CFLAGS)"
define Package/ipt2socks/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ipt2socks $(1)/usr/bin
endef
$(eval $(call BuildPackage,ipt2socks))

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019-2020 johnrosen1
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,20 @@
# Copyright (C) 2019-2023 sirpdboy https://github.com/sirpdboy/luci-app-autotimeset
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for Scheduled Time setting
LUCI_PKGARCH:=all
define Package/$(PKG_NAME)/conffiles
/etc/config/autotimeset
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,113 @@
[![若部分图片无法正常显示,请挂上机场浏览或点这里到末尾看修复教程](https://visitor-badge-deno.deno.dev/sirpdboy.sirpdboy.svg)](#解决-github-网页上图片显示失败的问题) [![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ)
[autotimeset 定时设置插件](https://github.com/sirpdboy/luci-app-autotimeset)
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明1.jpg)
**认真阅读完毕** 本页面,本页面包含注意事项和如何使用。
## 功能说明:
### 定时设置2.0版
#### 2023.5.23 定时设置2.0版:定时执行任务设置和开机启动任务设置二合一版,并增加自定义脚本功能。
### 定时设置1.9版
#### 2023.4.1 定时设置1.9版加入定时断网重连、定时检测WAN3重启等服务。
### 定时设置1.6版
#### 2023.1.15 定时设置1.6版:重新代码制作优化。在之前的版本上新增加:定时清理内存、定时清理系统垃圾、定时断网、定时重启网络共享、定时重拨 等 8大功能
### 定时设置1.4版
#### 2021.2.7 新增功能定时重启网络。现包括:定时重启、定时关机、定时重启网络,各功能可一起使用。
### 定时设置1.3版
#### 2020.10.6 原来重定关机正式改名为定时设置,实现定时重启和定时关机功能二合一。
### 定时关机1.1版
#### 2020.7.19 定时关机功能,彻底解决需要保存二次才生效的问题。
### 定时关机1.0版
#### 2019.2.24 定时关机功能借鉴前辈们的开源代码首发。
## 编译使用方法 [![](https://img.shields.io/badge/-编译使用方法-F5F5F5.svg)](#编译使用方法-)
将luci-app-autotimeset添加至 LEDE/OpenWRT 源码的方法。
### 下载源码方法一:
编辑源码文件夹根目录feeds.conf.default并加入如下内容:
```Brach
# feeds获取源码
src-git autotimeset https://github.com/sirpdboy/luci-app-autotimeset
```
```Brach
# 更新feeds并安装主题
scripts/feeds update autotimeset
scripts/feeds install luci-app-autotimeset
```
### 下载源码方法二:
```Brach
# 下载源码
git clone https://github.com/sirpdboy/luci-app-autotimeset package/luci-app-autotimeset
make menuconfig
```
### 配置菜单
```Brach
make menuconfig
# 找到 LuCI -> Applications, 选择 luci-app-autotimeset, 保存后退出。
```
### 编译
```Brach
# 编译固件
make package/luci-app-autotimeset/compile V=s
```
## 说明 [![](https://img.shields.io/badge/-说明-F5F5F5.svg)](#说明-)
源码来源https://github.com/sirpdboy/luci-app-autotimeset
## 使用与授权相关说明
- 本人开源的所有源码,任何引用需注明本处出处,如需修改二次发布必告之本人,未经许可不得做于任何商用用途。
# My other project
- 网络速度测试 https://github.com/sirpdboy/NetSpeedTest
- 任务设置(定时和开机二合一)插件 : https://github.com/sirpdboy/luci-app-autotimeset
- 关机功能插件 : https://github.com/sirpdboy/luci-app-poweroffdevice
- opentopd主题 : https://github.com/sirpdboy/luci-theme-opentopd
- kucat 主题: https://github.com/sirpdboy/luci-theme-kucat
- 家长控制: https://github.com/sirpdboy/luci-theme-parentcontrol
- 系统高级设置 : https://github.com/sirpdboy/luci-app-advanced
- ddns-go动态域名: https://github.com/sirpdboy/luci-app-ddns-go
- 进阶设置(系统高级设置+主题设置kucat/agron/opentopd: https://github.com/sirpdboy/luci-app-advancedplus
- 设置向导: https://github.com/sirpdboy/luci-app-wizard
- 分区扩容: https://github.com/sirpdboy/luci-app-partexp
- lukcy大吉: https://github.com/sirpdboy/luci-app-lukcy
## 捐助
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明3.jpg)
| <img src="https://img.shields.io/badge/-支付宝-F5F5F5.svg" href="#赞助支持本项目-" height="25" alt="图飞了😂"/> | <img src="https://img.shields.io/badge/-微信-F5F5F5.svg" height="25" alt="图飞了😂" href="#赞助支持本项目-"/> |
| :-----------------: | :-------------: |
|![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/支付宝.png) | ![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/微信.png) |
<a href="#readme">
<img src="https://img.shields.io/badge/-返回顶部-orange.svg" alt="图飞了😂" title="返回顶部" align="right"/>
</a>

View File

@ -0,0 +1,35 @@
module("luci.controller.autotimeset",package.seeall)
local fs=require"nixio.fs"
local http=require"luci.http"
function index()
if not nixio.fs.access("/etc/config/autotimeset") then
return
end
entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false
entry({"admin", "control", "autotimeset"}, alias("admin", "control", "autotimeset", "base"), _("Scheduled Setting"), 20).dependent = true
entry({"admin", "control", "autotimeset", "base"}, cbi("autotimeset/base"), _("Scheduled Setting"), 1).leaf = true
entry({"admin", "control", "autotimeset", "log"}, form("autotimeset/log"), _("Log"), 2).leaf = true
entry({"admin","control","autotimeset","dellog"},call("dellog"))
entry({"admin","control","autotimeset","getlog"},call("getlog"))
end
function getlog()
logfile="/etc/autotimeset/autotimeset.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
function dellog()
fs.writefile("/etc/autotimeset/autotimeset.log","")
http.prepare_content("application/json")
http.write('')
end

View File

@ -0,0 +1,56 @@
local o=require"luci.dispatcher"
local e=require("luci.model.ipkg")
local s=require"nixio.fs"
local e=luci.model.uci.cursor()
local m,s,e
m=Map("autotimeset",translate("Scheduled Setting"),translate("Timing settings include: timing restart, timing shutdown, timing restart network, all functions can be used together."))
s=m:section(TypedSection,"stime","")
s.addremove=true
s.anonymous=true
s.template = "cbi/tblsection"
e=s:option(ListValue,"stype",translate("Scheduled Type"))
e:value(1,translate("Scheduled Reboot"))
e:value(2,translate("Scheduled Poweroff"))
e:value(3,translate("Scheduled ReNetwork"))
e:value(4,translate("Scheduled RestartSamba"))
e:value(5,translate("Scheduled Restartwan"))
e:value(6,translate("Scheduled Closewan"))
e:value(7,translate("Scheduled Clearmem"))
e:value(8,translate("Scheduled Sysfree"))
e:value(9,translate("Scheduled DisReconn"))
e.default=2
week=s:option(ListValue,"week",translate("Week Day"))
week.rmempty = true
week:value('*',translate("Everyday"))
week:value(0,translate("Sunday"))
week:value(1,translate("Monday"))
week:value(2,translate("Tuesday"))
week:value(3,translate("Wednesday"))
week:value(4,translate("Thursday"))
week:value(5,translate("Friday"))
week:value(6,translate("Saturday"))
week.default='*'
e=s:option(Value,"hour",translate("Hour"))
e.datatype = "range(0,23)"
e.rmempty = false
e.default = 4
e=s:option(Value,"minute",translate("Minute"))
e.datatype = "range(0,59)"
e.rmempty = false
e.default = 0
e=s:option(Flag,"enable",translate("Enable"))
e.rmempty = false
e.default=0
m.apply_on_parse = true
m.on_after_apply = function(self,map)
io.popen("/etc/init.d/autotimeset start")
end
return m

View File

@ -0,0 +1,83 @@
local o=require"luci.dispatcher"
local e=require("luci.model.ipkg")
local s=require"nixio.fs"
local e=luci.model.uci.cursor()
local m,s,e
m=Map("autotimeset",translate("Scheduled task/startup task settings"),translate("<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>") ..
translate("N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours.") ..
translate("&nbsp;&nbsp;&nbsp;<input class=\"cbi-button cbi-button-apply\" type=\"button\" value=\"" ..
translate("Test/Verify Settings") ..
" \" onclick=\"window.open('https://tool.lu/crontab/')\"/>"))
s = m:section(TypedSection, 'global')
s.anonymous=true
e=s:option(TextValue, "customscript" ,translate("Edit Custom Script"))
e.description = translate("Only by editing the content of the custom script well and scheduling the custom script task can it be executed effectively.")
e.rows = 5
e.default = '#!/bin/sh'
e.rmempty = false
s=m:section(TypedSection,"stime","")
s.addremove=true
s.anonymous=true
s.template = "cbi/tblsection"
e=s:option(ListValue,"stype",translate("Scheduled Type"))
e:value(1,translate("Scheduled Reboot"))
e:value(2,translate("Scheduled Poweroff"))
e:value(3,translate("Scheduled ReNetwork"))
e:value(4,translate("Scheduled RestartSamba"))
e:value(5,translate("Scheduled Restartwan"))
e:value(6,translate("Scheduled Closewan"))
e:value(7,translate("Scheduled Clearmem"))
e:value(8,translate("Scheduled Sysfree"))
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.default=2
e=s:option(ListValue,"ttype",translate("Task Type"))
e:value(0,translate("Scheduled task execution"))
e:value(1,translate("Startup task"))
e.default=0
e=s:option(Value,"delay",translate("Startup delay time"))
e.default=10
e=s:option(Value,"month",translate("Month(0~11)"))
e.rmempty = false
e.default = '*'
week=s:option(Value,"week",translate("Week Day(0~6)"))
week.rmempty = true
week:value('*',translate("Everyday"))
week:value(0,translate("Sunday"))
week:value(1,translate("Monday"))
week:value(2,translate("Tuesday"))
week:value(3,translate("Wednesday"))
week:value(4,translate("Thursday"))
week:value(5,translate("Friday"))
week:value(6,translate("Saturday"))
week.default='*'
e=s:option(Value,"hour",translate("Hour(0~23)"))
e.rmempty = false
e.default = 0
e=s:option(Value,"minute",translate("Minute(0~59)"))
e.rmempty = false
e.default = 0
e=s:option(Flag,"enable",translate("Enable"))
e.rmempty = false
e.default=0
m.apply_on_parse = true
m.on_after_apply = function(self,map)
luci.sys.exec("/etc/init.d/autotimeset start")
end
return m

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="autotimeset/log"
t.readonly="readonly"
return f

View File

@ -0,0 +1,54 @@
<%+cbi/valueheader%>
<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">//<![CDATA[
var islogreverse=false;
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]],[[control]],[[autotimeset]],[[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]],[[control]],[[autotimeset]],[[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%>

View File

@ -0,0 +1,91 @@
msgid "<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>"
msgstr "<b>任务设置包括定时任务执行和开机启动任务执行预置重启、关机、重启网络、释放内存、系统清理、网络共享、关闭网络、自动检测断网重连、自动检测断网重启、MWAN3负载均衡检测重连、自定义脚本等10多个功能.</b></br>"
msgid "N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours."
msgstr "N1-N5连续N1,N3,N5不连续*/N表示每N小时或每N分钟。月份范围0-11星期范围06小时范围023分钟范围059不可用72小时或者90分钟等连续范围。"
msgid "Scheduled task/startup task settings"
msgstr "定时执行任务/开机启动任务设置"
msgid "Scheduled Setting"
msgstr "任务设置"
msgid "Test/Verify Settings"
msgstr "测试/验证设置"
msgid "Scheduled Type"
msgstr "任务名称"
msgid "Task Type"
msgstr "任务类型"
msgid "Scheduled task execution"
msgstr "定时执行任务"
msgid "Startup task"
msgstr "开机启动任务"
msgid "Startup delay time"
msgstr "延迟时间【开机用】"
msgid "Log"
msgstr "日志"
msgid "Scheduled Reboot"
msgstr "重启机器"
msgid "Scheduled Poweroff"
msgstr "关闭机器"
msgid "Scheduled ReNetwork"
msgstr "重启网络"
msgid "Scheduled RestartSamba"
msgstr "重启网络共享"
msgid "Scheduled Restartwan"
msgstr "重启WAN"
msgid "Scheduled Closewan"
msgstr "关闭网络"
msgid "Scheduled Clearmem"
msgstr "释放内存"
msgid "Scheduled Sysfree"
msgstr "系统清理(会重启机器)"
msgid "Scheduled DisReconn"
msgstr "检测断网重连"
msgid "Scheduled DisRereboot"
msgstr "检测断网重启"
msgid "Scheduled Restartmwan3"
msgstr "检测MWAN3失联重启服务"
msgid "Edit Custom Script"
msgstr "编辑自定义脚本"
msgid "Scheduled Customscript"
msgstr "自定义脚本"
msgid "Only by editing the content of the custom script well and scheduling the custom script task can it be executed effectively."
msgstr "编辑好自定义脚本内容,自定义脚本任务才能有效执行。"
msgid "Month(0~11)"
msgstr "月份(0~11)【定时用】"
msgid "Week Day(0~6)"
msgstr "星期(0~6)【定时用】"
msgid "Everyday"
msgstr "每天【定时用】"
msgid "Hour(0~23)"
msgstr "小时(0~23)【定时用】"
msgid "Minute(0~59)"
msgstr "分钟(0~59)【定时用】"

View File

@ -0,0 +1 @@
zh-cn

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1,75 @@
config global
option enabled '0'
option customscript '#!/bin/sh'
config stime
option hour '*/4'
option stype '7'
option week '*'
option minute '0'
option month '*'
option enable '0'
option ttype '0'
option delay '10'
config stime
option minute '0'
option month '*'
option hour '*/5'
option enable '0'
option week '1,3,5'
option ttype '1'
option delay '10'
option stype '1'
config stime
option week '*'
option month '*'
option enable '0'
option ttype '0'
option delay '10'
option stype '10'
option hour '0'
option minute '*/5'
config stime
option week '*'
option minute '0'
option stype '2'
option hour '1'
option month '*'
option enable '0'
option ttype '0'
option delay '10'
config stime
option week '*'
option minute '0'
option hour '3'
option month '*'
option enable '0'
option ttype '0'
option delay '10'
option stype '6'
config stime
option week '*'
option hour '0'
option minute '*/5'
option month '*'
option stype '11'
option ttype '1'
option delay '20'
option enable '0'
config stime
option month '*'
option week '*'
option hour '0'
option enable '0'
option minute '*/5'
option stype '12'
option ttype '1'
option delay '30'

View File

@ -0,0 +1,117 @@
#!/bin/sh /etc/rc.common
#copyright by sirpdboy
START=95
STOP=10
TMP=/etc/autotimeset
LOG=$TMP/autotimeset.log
TT=/etc/init.d/autotimesetrun
CR=/etc/crontabs/root
[ ! -d $TMP ] && mkdir -p $TMP 2>/dev/null
[ -s $LOG ] && echo ' ' >> $LOG
run_autotimeset()
{
ssum=$(grep -c stime /etc/config/autotimeset)
customscript=$(uci -q get autotimeset.@global[0].customscript ) || customscript='#!/bin/sh'
script=`echo $customscript | grep '#!/bin/sh'` >/dev/null 2>&1
[ $script ] && echo $script > /etc/autotimeset/timesetcustomscript || {
echo '#!/bin/sh' >/etc/autotimeset/timesetcustomscript
echo $customscript >>/etc/autotimeset/timesetcustomscript
}
echo 'start(){' >>$TT
for i in $(seq 0 $((ssum-1)))
do
enable=$(uci -q get autotimeset.@stime[$i].enable )
if [ "x$enable" = "x1" ]; then
month=$(uci -q get autotimeset.@stime[$i].month ) || month="*"
stype=$(uci -q get autotimeset.@stime[$i].stype )
week=$(uci -q get autotimeset.@stime[$i].week ) || week="*"
minute=$(uci -q get autotimeset.@stime[$i].minute ) || minute="00"
hour=$(uci -q get autotimeset.@stime[$i].hour ) || hour="*"
ttype=$(uci -q get autotimeset.@stime[$i].ttype ) || ttype=0
delay=$(uci -q get autotimeset.@stime[$i].delay ) || delay=10
[ "x$hour" = "x0" ] && hour="00"
[ "x$minute" = "x0" ] && minute="00"
case "$stype" in
1)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler reboot Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler reboot Startup_task" >>$TT
;;
2)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler poweroff Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler poweroff Startup_task" >>$TT
;;
3)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler network Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler network Startup_task" >>$TT
;;
4)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartsamba Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler restartsamba Startup_task" >>$TT
;;
5)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartwan Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler restartwan Startup_task" >>$TT
;;
6)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler closewan Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler closewan Startup_task" >>$TT
;;
7)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler clearmem Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler clearmem Startup_task" >>$TT
;;
8)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler sysfree Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler reboot Startup_task" >>$TT
;;
9)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler disreconn Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler disreconn Startup_task" >>$TT
;;
10)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler disrereboot Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler disrereboot Startup_task" >>$TT
;;
11)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartmwan3 Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler restartmwan3 Startup_task" >>$TT
;;
12)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript Startup_task" >>$TT
;;
esac
fi
done
echo '}' >>$TT
}
start()
{
del_cru
[ -n "`tail -c1 $CR`" ] && echo >> $CR
run_autotimeset
/etc/init.d/cron reload
}
stop()
{
del_cru
/etc/init.d/cron reload
}
restart()
{
start
}
del_cru()
{
echo -e '#!/bin/sh /etc/rc.common\n\nSTART=99\n' > $TT
sed -i '/timesethandler/d' $CR >/dev/null 2>&1
}

View File

@ -0,0 +1,6 @@
#!/bin/sh /etc/rc.common
START=99
start(){
}

View File

@ -0,0 +1,10 @@
#!/bin/sh
chmod +x /etc/init.d/autotimeset /usr/bin/timesethandler
uci -q batch <<-EOF >/dev/null
delete ucitrack.@autotimeset[-1]
add ucitrack autotimeset
set ucitrack.@autotimeset[-1].init=autotimeset
commit ucitrack
EOF
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
exit 0

View File

@ -0,0 +1,14 @@
#!/bin/sh
chmod +x /etc/init.d/autotimeset /usr/bin/timesethandler /etc/init.d/autotimesetrun
uci -q batch <<-EOF >/dev/null
delete ucitrack.@autotimeset[-1]
add ucitrack autotimeset
set ucitrack.@autotimeset[-1].init="autotimeset"
commit ucitrack
delete ucitrack.@autotimesetrun[-1]
add ucitrack autotimesetrun
set ucitrack.@autotimesetrun[-1].init=autotimesetrun
commit ucitrack
EOF
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
exit 0

View File

@ -0,0 +1,127 @@
#!/bin/sh
# author 2021 jjm2473
# author 2020-2023 sirpdboy
TMP_T=/var/autotimeset/autotimeset.tmp
LOG=/etc/autotimeset/autotimeset.log
log(){
echo "$(date +'%Y-%m-%d %H:%M:%S') $*" >> $LOG
}
limit_log() {
local logf=$1
[ ! -f "$logf" ] && return
local sc=100
[ -n "$2" ] && sc=$2
local count=$(grep -c "" $logf)
if [ $count -gt $sc ];then
let count=count-$sc
sed -i "1,$count d" $logf
fi
}
remwan3() {
while true; do
status=$(/usr/sbin/mwan3 status | grep error)
if [ -z $status ]; then
log "Mwan3 is OK"
exit 1
else
log "mwan3 restarting ..."
/usr/sbin/mwan3 restart
fi
sleep 60
done
}
disreconnwan() {
i=0
PingA=114.114.114.114
PingB=223.5.5.5
while [[ $i -lt 5 ]]
do
if /bin/ping -c 1 $PingA >/dev/null
then
PingErr=0
break
else
if /bin/ping -c 1 $PingB >/dev/null
then
PingErr=0
break
else
i=$(($i + 1))
PingErr=1
sleep 10
fi
fi
done
}
trigger() {
case "$1" in
reboot)
reboot
;;
poweroff)
poweroff
;;
network)
/etc/init.d/network restart
;;
clearmem)
sync && echo 3 > /proc/sys/vm/drop_caches
;;
sysfree)
cd /overlay
rm -rf `ls | egrep -v '(upper|.fs_state)'`
cd upper
rm -rf `ls | egrep -v '(etc)'`
cd etc
rm -rf `ls | egrep -v '(config|ssr|bench.log|shadow)'`
rm -rf /var/luci-modulecache
rm -rf /var/luci-indexcache
rm -rf /tmp/cache/*
reboot
;;
restartsamba)
/etc/init.d/ksmdb restart
/etc/init.d/samba restart
/etc/init.d/samba4 restart
;;
restartwan)
ifup wan
log "Redial succeeded!"
;;
closewan)
ifdown wan
;;
disreconn)
disreconnwan
if [ $PingErr = 1 ]; then
ifup wan
log "Redial succeeded!"
fi
;;
disrereboot)
disreconnwan
if [ $PingErr = 1 ]; then
log "Reboot succeeded!"
reboot
fi
;;
restartmwan3)
[ -s /usr/sbin/mwan3 ] && remwan3
;;
customscript)
script=`cat /etc/autotimeset/timesetcustomscript ` >/dev/null 2>&1
[ $script ] && source /etc/autotimeset/timesetcustomscript
log "CustomScript succeeded!"
;;
esac
}
limit_log $LOG 500
PingErr=0
log "Scheduled operation $2: $1" && trigger $1

View File

@ -0,0 +1,119 @@
#! /bin/bash
#允许尝试错误的次数
tryErrNum=10
#允许尝试错误在多长时间范围单位秒与tryErrNum一起生效
tryTimeOut=300
#需要被封禁的多个ip字符串逗号隔开,这里为空
dropIpList=""
#logread里面标识字符串Bad password attempt for 是ssh root登录密码错误logluci: failed login on 是登录web错误log
errStr=("Bad password attempt for" "luci: failed login on")
#查询logread 日志的时间间隔,单位秒
timesleep=30
#从根据字符串从日志里面提取要封禁的ip追加到 dropIpList 变量
getdropip() {
#对过滤的日志倒叙
lines=$(logread | grep $1 | sed -n '1!G;h;$p')
linesNum=$(echo -n "$lines" | wc -l)
#定义字典变量
declare -A dict
#
if [ "$linesNum" -gt "$tryErrNum" ];then
while read line;
do
ip=$(echo -n "$line" | awk '{print $NF}' | awk -F":" '{print $1}')
time=$(echo -n "$line" | awk '{print $4}' | awk -F":" '{sum += $1*3600 + $2*60 + $3};END {print sum}')
ok=${dict[$ip]}
if [ -z $ok ];then
dict[$ip]=1
time=$(date | awk '{print $4}' | awk -F":" '{sum += $1*3600 + $2*60+ $3};END {print sum}')
dict[${ip}_endtime]=$time
else
if [ ${dict[$ip]} -lt "$tryErrNum" ];then
dict[$ip]=$(expr ${dict[$ip]} + 1)
dict[${ip}_starttime]=$time
fi
fi
done < <(echo -n "$lines")
for key in ${!dict[@]};
do
if ! [[ "$key" =~ "starttime" ]] && ! [[ "$key" =~ "endtime" ]];then
if [ ${dict[$key]} -eq "$tryErrNum" ];then
timeDiff=$(expr ${dict[${key}_endtime]} - ${dict[${key}_starttime]})
if [ "$timeDiff" -gt 0 ] && [ "$timeDiff" -lt "$tryTimeOut" ];then
#追加需要封禁的ip到变量
dropIpList=$dropIpList,$key
fi
fi
fi
done
fi
}
#errStr 字符串遍历分别从log里面匹配提取要封禁ip
startGetDropIp(){
i=0
while :
do
errstr=${errStr[$i]}
if [ -z "$errstr" ];then
break
fi
i=$(expr $i + 1)
getdropip $errstr
done
}
#初始化ipset iptable
intEnv(){
ipset list BlockIpList
if ! [ "$?" == 0 ];
then
ipset create BlockIpList hash:net timeout 300
iptables -I INPUT -m set --match-set BlockIpList src -p tcp -m tcp --dport 22 -j DROP
iptables -I INPUT -m set --match-set BlockIpList src -p tcp -m tcp --dport 80 -j DROP
iptables -I INPUT -s 192.168.0.0/16 -j ACCEPT
fi
}
#把要封禁的ip添加到ipset BlockIpList集合
ipsetAddIp(){
dropIpListNew=""
for ip in $(echo -n "$dropIpList" | sed 's/,/ /g')
do
ipset add BlockIpList $ip
if [ "$?" -eq 0 ];then
dropIpListNew=$dropIpListNew,$ip
fi
done
}
sendlogger(){
if [ -n "$dropIpListNew" ];then
echo -e "autotimeset:MyOpenwrt IP封禁提醒:$dropIpListNew"
logger -p warn -t "autotimeset" ",定时设置提醒: IP封禁:$dropIpListNew ---- 时间:`date `"
fi
}
#检查当前进程是否存在
PocessNum=$(ps | grep timesetsecurity | grep -v grep | wc -l)
if [ "$PocessNum" -gt 2 ];then
#已经存在进程,直接退出当前进程
kill -9 $$
else
intEnv
while :
do
sleep $timesleep
dropIpList=""
startGetDropIp
ipsetAddIp
sendlogger
done
fi

View File

@ -0,0 +1,11 @@
{
"luci-app-autotimeset": {
"description": "Grant UCI access for luci-app-autotimeset",
"read": {
"uci": [ "autotimeset" ]
},
"write": {
"uci": [ "autotimeset" ]
}
}
}

67
trojan/Makefile Normal file
View File

@ -0,0 +1,67 @@
#
# 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.16.0
PKG_RELEASE:=9
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/trojan-gfw/trojan/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=skip
PKG_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=openssl
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILE:=LICENSE
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
TARGET_CXXFLAGS += -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections
CMAKE_OPTIONS += \
-DENABLE_MYSQL=OFF \
-DENABLE_NAT=ON \
-DENABLE_REUSE_PORT=ON \
-DENABLE_SSL_KEYLOG=ON \
-DENABLE_TLS13_CIPHERSUITES=ON \
-DFORCE_TCP_FASTOPEN=OFF \
-DSYSTEMD_SERVICE=OFF \
-DOPENSSL_USE_STATIC_LIBS=FALSE \
-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 +libopenssl \
+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
endef
$(eval $(call BuildPackage,trojan))

View File

@ -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.1.0 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)

44
xray-plugin/Makefile Normal file
View File

@ -0,0 +1,44 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=xray-plugin
PKG_VERSION:=1.8.6
PKG_RELEASE:=61
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/teddysun/xray-plugin/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=skip
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
PKG_BUILD_FLAGS:=no-mips16
GO_PKG:=github.com/teddysun/xray-plugin
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
define Package/xray-plugin
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=SIP003 plugin for Shadowsocks, based on Xray
URL:=https://github.com/teddysun/xray-plugin
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
endef
define Package/xray-plugin/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/xray-plugin $(1)/usr/bin/xray-plugin
endef
$(eval $(call GoBinPackage,xray-plugin))
$(eval $(call BuildPackage,xray-plugin))