mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
feat: migrate from opkg to ipkg and restructure package files for ua3f service
This commit is contained in:
parent
c29f0b2cd7
commit
d91b4c9e04
11
build.sh
11
build.sh
@ -59,8 +59,17 @@ for file in ./*; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
opkg_template=./opkg
|
opkg_template=./ipkg
|
||||||
ipkg_build=ipkg-build.sh
|
ipkg_build=ipkg-build.sh
|
||||||
|
mkdir -p $opkg_template/usr/bin
|
||||||
|
mkdir -p $opkg_template/usr/lib/lua/luci/controller
|
||||||
|
mkdir -p $opkg_template/usr/lib/lua/luci/model/cbi
|
||||||
|
mkdir -p $opkg_template/etc/init.d
|
||||||
|
mkdir -p $opkg_template/etc/config
|
||||||
|
cp openwrt/files/luci/controller.lua $opkg_template/usr/lib/lua/luci/controller/
|
||||||
|
cp openwrt/files/luci/cbi.lua $opkg_template/usr/lib/lua/luci/model/cbi/
|
||||||
|
cp openwrt/files/ua3f.init $opkg_template/etc/init.d/ua3f
|
||||||
|
cp openwrt/files/ua3f.uci $opkg_template/etc/config/ua3f
|
||||||
for goarch in "amd64" "arm" "arm64" "mipsle" "mips64" "riscv64" "386" "mipsle-softfloat" "mipsle-hardfloat" "armv7" "armv8"; do
|
for goarch in "amd64" "arm" "arm64" "mipsle" "mips64" "riscv64" "386" "mipsle-softfloat" "mipsle-hardfloat" "armv7" "armv8"; do
|
||||||
obj_name=$project_name-$release_version-$goarch
|
obj_name=$project_name-$release_version-$goarch
|
||||||
mv $dist/bin/$obj_name $opkg_template/usr/bin/ua3f
|
mv $dist/bin/$obj_name $opkg_template/usr/bin/ua3f
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
Package: ua3f
|
Package: ua3f
|
||||||
Version: 0.6.0-1
|
Version: 0.6.0-1
|
||||||
Depends: libc, luci-compat
|
Depends: luci-compat
|
||||||
Source: /feed/openwrt
|
Source: /feed/openwrt
|
||||||
SourceName: UA3F
|
SourceName: UA3F
|
||||||
License: GPL-3.0-only
|
License: GPL-3.0-only
|
||||||
Section: net
|
Section: net
|
||||||
SourceDateEpoch: 1711267200
|
SourceDateEpoch: 1711267200
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Installed-Size: 2775040
|
Installed-Size: 3563520
|
||||||
Description: Implementation of the next generation of HTTP User-Agent modification methodology.
|
Description: Implementation of the next generation of HTTP User-Agent modification methodology.
|
||||||
@ -1,11 +1,11 @@
|
|||||||
Package: ua3f
|
Package: ua3f
|
||||||
Version: 0.6.0-1
|
Version: 0.6.0-1
|
||||||
Depends: libc, luci-compat
|
Depends: luci-compat
|
||||||
Source: /feed/openwrt
|
Source: /feed/openwrt
|
||||||
SourceName: UA3F
|
SourceName: UA3F
|
||||||
License: GPL-3.0-only
|
License: GPL-3.0-only
|
||||||
Section: net
|
Section: net
|
||||||
SourceDateEpoch: 1711267200
|
SourceDateEpoch: 1711267200
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Installed-Size: 2775040
|
Installed-Size: 3686400
|
||||||
Description: Implementation of the next generation of HTTP User-Agent modification methodology.
|
Description: Implementation of the next generation of HTTP User-Agent modification methodology.
|
||||||
@ -1,10 +0,0 @@
|
|||||||
config 'ua3f' 'enabled'
|
|
||||||
option enabled '0'
|
|
||||||
|
|
||||||
config 'ua3f' 'main'
|
|
||||||
option port '1080'
|
|
||||||
option bind '127.0.0.1'
|
|
||||||
option ua 'FFF'
|
|
||||||
option ua_regex '(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X)'
|
|
||||||
option partial_replace false
|
|
||||||
option log_level 'info'
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
|
||||||
|
|
||||||
USE_PROCD=1
|
|
||||||
|
|
||||||
START=99
|
|
||||||
|
|
||||||
NAME="ua3f"
|
|
||||||
PROG="/usr/bin/$NAME"
|
|
||||||
|
|
||||||
start_service() {
|
|
||||||
config_load "$NAME"
|
|
||||||
|
|
||||||
local enabled
|
|
||||||
config_get_bool enabled "enabled" "enabled" "0"
|
|
||||||
if [ "$enabled" -ne "1" ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local port
|
|
||||||
local bind
|
|
||||||
local ua
|
|
||||||
local log_level
|
|
||||||
local ua_regex
|
|
||||||
local partial_replace
|
|
||||||
config_get port "main" "port" "1080"
|
|
||||||
config_get bind "main" "bind" "127.0.0.1"
|
|
||||||
config_get ua "main" "ua" "FFF"
|
|
||||||
config_get ua_regex "main" "ua_regex" "(iPhone|iPad|Android|Macintosh|Windows|Linux)"
|
|
||||||
config_get_bool partial_replace "main" "partial_replace" 0
|
|
||||||
config_get log_level "main" "log_level" "info"
|
|
||||||
|
|
||||||
mkdir -p /var/log/ua3f
|
|
||||||
chmod o+w /var/log/ua3f
|
|
||||||
|
|
||||||
procd_open_instance "$NAME"
|
|
||||||
procd_set_param command "$PROG"
|
|
||||||
procd_append_param command -b "$bind"
|
|
||||||
procd_append_param command -p $port
|
|
||||||
procd_append_param command -f "$ua"
|
|
||||||
procd_append_param command -r "$ua_regex"
|
|
||||||
procd_append_param command -l $log_level
|
|
||||||
[ "$partial_replace" = "1" ] && procd_append_param command -s
|
|
||||||
|
|
||||||
procd_set_param respawn
|
|
||||||
procd_set_param stdout 1
|
|
||||||
procd_set_param stderr 1
|
|
||||||
|
|
||||||
if id -u shellclash >/dev/null 2>&1; then
|
|
||||||
procd_set_param user shellclash
|
|
||||||
elif id -u shellcrash >/dev/null 2>&1; then
|
|
||||||
procd_set_param user shellcrash
|
|
||||||
elif id -u nobody >/dev/null 2>&1; then
|
|
||||||
procd_set_param user nobody
|
|
||||||
fi
|
|
||||||
|
|
||||||
procd_close_instance
|
|
||||||
}
|
|
||||||
|
|
||||||
reload_service() {
|
|
||||||
stop
|
|
||||||
start
|
|
||||||
}
|
|
||||||
|
|
||||||
service_triggers() {
|
|
||||||
procd_add_reload_trigger "$NAME"
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
module("luci.controller.ua3f", package.seeall)
|
|
||||||
|
|
||||||
function index()
|
|
||||||
entry({ "admin", "services", "ua3f" }, cbi("ua3f"), "UA3F", 1)
|
|
||||||
end
|
|
||||||
@ -1,70 +0,0 @@
|
|||||||
local uci = require("luci.model.uci").cursor()
|
|
||||||
|
|
||||||
ua3f = Map("ua3f",
|
|
||||||
"UA3F",
|
|
||||||
[[
|
|
||||||
<a href="https://github.com/SunBK201/UA3F" target="_blank">Version: 0.6.0</a>
|
|
||||||
<br>
|
|
||||||
Across the Campus we can reach every corner in the world.
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
|
|
||||||
enable = ua3f:section(NamedSection, "enabled", "ua3f", "Status")
|
|
||||||
main = ua3f:section(NamedSection, "main", "ua3f", "Settings")
|
|
||||||
|
|
||||||
enable:option(Flag, "enabled", "Enabled")
|
|
||||||
status = enable:option(DummyValue, "status", "Status")
|
|
||||||
status.rawhtml = true
|
|
||||||
status.cfgvalue = function(self, section)
|
|
||||||
local pid = luci.sys.exec("pidof ua3f")
|
|
||||||
if pid == "" then
|
|
||||||
return "<span style='color:red'>" .. "Stopped" .. "</span>"
|
|
||||||
else
|
|
||||||
return "<span style='color:green'>" .. "Running" .. "</span>"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
main:tab("general", "General Settings")
|
|
||||||
main:tab("log", "Log")
|
|
||||||
|
|
||||||
port = main:taboption("general", Value, "port", "Port")
|
|
||||||
port.placeholder = "1080"
|
|
||||||
|
|
||||||
bind = main:taboption("general", Value, "bind", "Bind Address")
|
|
||||||
bind:value("127.0.0.1")
|
|
||||||
bind:value("0.0.0.0")
|
|
||||||
|
|
||||||
log_level = main:taboption("general", ListValue, "log_level", "Log Level")
|
|
||||||
log_level:value("debug")
|
|
||||||
log_level:value("info")
|
|
||||||
log_level:value("warn")
|
|
||||||
log_level:value("error")
|
|
||||||
log_level:value("fatal")
|
|
||||||
log_level:value("panic")
|
|
||||||
log = main:taboption("log", TextValue, "")
|
|
||||||
log.readonly = true
|
|
||||||
log.cfgvalue = function(self, section)
|
|
||||||
return luci.sys.exec("cat /var/log/ua3f/ua3f.log")
|
|
||||||
end
|
|
||||||
log.rows = 30
|
|
||||||
|
|
||||||
ua = main:taboption("general", Value, "ua", "User-Agent")
|
|
||||||
ua.placeholder = "FFF"
|
|
||||||
|
|
||||||
uaRegexPattern = main:taboption("general", Value, "ua_regex", "User-Agent Regex Pattern")
|
|
||||||
uaRegexPattern.placeholder = "(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X)"
|
|
||||||
uaRegexPattern.description = "Regular expression pattern for matching User-Agent"
|
|
||||||
|
|
||||||
partialRepalce = main:taboption("general", Flag, "partial_replace", "Partial Replace")
|
|
||||||
partialRepalce.description =
|
|
||||||
"Replace only the matched part of the User-Agent, only works when User-Agent Regex Pattern is not empty"
|
|
||||||
partialRepalce.default = "0"
|
|
||||||
|
|
||||||
--[[
|
|
||||||
local apply = luci.http.formvalue("cbi.apply")
|
|
||||||
if apply then
|
|
||||||
io.popen("/etc/init.d/ua3f restart")
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
|
|
||||||
return ua3f
|
|
||||||
Loading…
Reference in New Issue
Block a user