mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 16:55:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 muink
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,96 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# Copyright (C) 2023-2025 Anya Lin <hukk1996@gmail.com>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alwaysonline
|
||||
PKG_UPSTREAM_VERSION:=1.2.1
|
||||
PKG_UPSTREAM_GITHASH:=206292ca68e4d6c81b215163a7bbd0cd2eb36860
|
||||
PKG_VERSION:=$(PKG_UPSTREAM_VERSION)~$(call version_abbrev,$(PKG_UPSTREAM_GITHASH))
|
||||
PKG_RELEASE:=1
|
||||
UCI_VERSION:=0.2025.01.25
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/Jamesits/alwaysonline.git
|
||||
PKG_SOURCE_VERSION:=fc4faba4a73ffdb93745b02a816ea5c883bfbb34
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_UPSTREAM_VERSION)
|
||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
|
||||
PKG_MAINTAINER:=Anya Lin <hukk1996@gmail.com>
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_FLAGS:=no-mips16
|
||||
|
||||
GO_PKG:=github.com/jamesits/alwaysonline/v2
|
||||
|
||||
AWOL_COMMIT_HASH:=$(shell echo $(PKG_SOURCE_VERSION)|cut -c -8)
|
||||
AWOL_BUILD_TIME:=$(shell date -d @$(SOURCE_DATE_EPOCH) -u +%FT%TZ%z)
|
||||
GO_PKG_LDFLAGS_X:=\
|
||||
main.versionGitCommitHash=$(AWOL_COMMIT_HASH) \
|
||||
main.versionCompileTime=$(AWOL_BUILD_TIME) \
|
||||
main.versionCompileHost=OpenWrt \
|
||||
main.versionGitStatus=clean
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=Hijack/bypass Windows NCSI and iOS portal detection on a network level.
|
||||
URL:=https://github.com/Jamesits/alwaysonline
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS)
|
||||
USERID:=alwaysonline:alwaysonline
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
AlwaysOnline is a HTTP and DNS server which mocks a lot network/internet/portal detection servers.
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(PKG_NAME) $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/uci-$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=alwaysonline uci metapackage
|
||||
DEPENDS:=+alwaysonline +kmod-tun +ip-full +rgmac
|
||||
USERID:=alwaysonline:alwaysonline
|
||||
VERSION:=$(UCI_VERSION)
|
||||
endef
|
||||
|
||||
define Package/uci-$(PKG_NAME)/conffiles/Default
|
||||
/etc/config/alwaysonline
|
||||
endef
|
||||
|
||||
Package/uci-$(PKG_NAME)/conffiles = $(Package/uci-$(PKG_NAME)/conffiles/Default)
|
||||
|
||||
define Package/uci-$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(CURDIR)/files/alwaysonline.config $(1)/etc/config/alwaysonline
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(CURDIR)/files/alwaysonline.init $(1)/etc/init.d/alwaysonline
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) $(CURDIR)/files/alwaysonline.defaults $(1)/etc/uci-defaults/99_alwaysonline
|
||||
endef
|
||||
|
||||
$(eval $(call GoBinPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,uci-$(PKG_NAME)))
|
||||
@@ -0,0 +1,38 @@
|
||||
openwrt-alwaysonline
|
||||
====================
|
||||
|
||||
> AlwaysOnline is a HTTP and DNS server which mocks a lot network/internet/portal detection servers.
|
||||
|
||||
## Introduction
|
||||
This project is the software package of [alwaysonline][] running on OpenWrt
|
||||
|
||||
## Releases
|
||||
You can find the prebuilt-ipks [here](https://fantastic-packages.github.io/releases/)
|
||||
|
||||
## Build
|
||||
|
||||
```shell
|
||||
# Take the x86_64 platform as an example
|
||||
tar xjf openwrt-sdk-21.02.3-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz
|
||||
# Go to the SDK root dir
|
||||
cd OpenWrt-sdk-*-x86_64_*
|
||||
# First run to generate a .config file
|
||||
make menuconfig
|
||||
./scripts/feeds update -a
|
||||
./scripts/feeds install -a
|
||||
# Get Makefile
|
||||
git clone --depth 1 --branch master --single-branch --no-checkout https://github.com/muink/openwrt-alwaysonline.git package/alwaysonline
|
||||
pushd package/alwaysonline
|
||||
umask 022
|
||||
git checkout
|
||||
popd
|
||||
# Select the package Network -> alwaysonline
|
||||
make menuconfig
|
||||
# Start compiling
|
||||
make package/alwaysonline/compile V=99
|
||||
```
|
||||
|
||||
## License
|
||||
This project is licensed under the MIT license
|
||||
|
||||
[alwaysonline]: https://github.com/Jamesits/alwaysonline
|
||||
@@ -0,0 +1,130 @@
|
||||
# See https://github.com/Jamesits/alwaysonline/blob/master/http_server.go
|
||||
config alwaysonline 'global'
|
||||
option tun_name 'awoltun0'
|
||||
option tun_addr4 '172.25.26.1/30'
|
||||
option tun_addr6 'fdfe:aead:2526::1/126'
|
||||
option port '8083'
|
||||
option enabled '0'
|
||||
|
||||
config domain
|
||||
option name 'www.msftncsi.com'
|
||||
option group 'windows'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'ipv6.msftncsi.com'
|
||||
option group 'windows'
|
||||
option family '6'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'www.msftconnecttest.com'
|
||||
option group 'windows'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'ipv6.msftconnecttest.com'
|
||||
option group 'windows'
|
||||
option family '6'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'dns.msftncsi.com'
|
||||
option group 'windows'
|
||||
option family '4'
|
||||
option overwrite '131.107.255.255'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'dns.msftncsi.com'
|
||||
option group 'windows'
|
||||
option family '6'
|
||||
option overwrite 'fd3e:4f5a:5b81::1'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'captive.apple.com'
|
||||
option group 'apple'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'clients3.google.com'
|
||||
option group 'android'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'connectivitycheck.gstatic.com'
|
||||
option group 'android'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'connectivitycheck.android.com'
|
||||
option group 'android'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'connect.rom.miui.com'
|
||||
option group 'android'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'connectivitycheck.platform.hicloud.com'
|
||||
option group 'android'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'network-test.debian.org'
|
||||
option group 'linux'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'nmcheck.gnome.org'
|
||||
option group 'linux'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'www.archlinux.org'
|
||||
option group 'linux'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'ping.archlinux.org'
|
||||
option group 'linux'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'networkcheck.kde.org'
|
||||
option group 'linux'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'detectportal.firefox.com'
|
||||
option group 'linux'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'start.ubuntu.com'
|
||||
option group 'linux'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
config domain
|
||||
option name 'capnet.elementary.io'
|
||||
option group 'linux'
|
||||
option family 'both'
|
||||
option enabled '1'
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -n "$(uci -q get alwaysonline.global)" ] || sed -i "s|^config alwaysonline|config alwaysonline 'global'|" /etc/config/alwaysonline
|
||||
|
||||
tun_name="$(uci -q get alwaysonline.global.tun_name)"
|
||||
tun_addr4="$(uci -q get alwaysonline.global.tun_addr4)"
|
||||
tun_addr6="$(uci -q get alwaysonline.global.tun_addr6)"
|
||||
port="$(uci -q get alwaysonline.global.port)"
|
||||
[ -n "$tun_name" ] || uci set alwaysonline.global.tun_name='awoltun0'
|
||||
[ -n "$tun_addr4" ] || uci set alwaysonline.global.tun_addr4='172.25.26.1/30'
|
||||
[ -n "$tun_addr6" ] || uci set alwaysonline.global.tun_addr6='fdfe:aead:2526::1/126'
|
||||
[ -n "$port" ] || uci set alwaysonline.global.port='8083'
|
||||
|
||||
[ -z "$(uci changes alwaysonline)" ] || uci commit alwaysonline
|
||||
@@ -0,0 +1,171 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2023-2025 muink
|
||||
#
|
||||
# depends rgmac
|
||||
|
||||
. "${IPKG_INSTROOT}/lib/functions/network.sh"
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
# alwaysonline
|
||||
[ -x "$(command -v nft)" ] && FW='fw4' || FW='fw3'
|
||||
PROG='/usr/sbin/alwaysonline'
|
||||
HOSTFILE='/var/hosts/alwaysonline'
|
||||
USERNAME=alwaysonline
|
||||
# uci
|
||||
CONFIG_NAME='alwaysonline'
|
||||
TYPEDSECTION='alwaysonline'
|
||||
DOMAINS='domain'
|
||||
|
||||
config_load "$CONFIG_NAME"
|
||||
|
||||
|
||||
find_op_ifnames() {
|
||||
local ifnames ifname iface _c
|
||||
|
||||
ifnames="lo $($FW -q zone $($FW -q device "br-lan"))"
|
||||
for _c in network_find_wan network_find_wan6; do
|
||||
$_c iface 1
|
||||
ifname=$($FW -q zone $($FW -q network "$iface"))
|
||||
ifnames="${ifnames:+$ifnames }$ifname"
|
||||
done
|
||||
echo $ifnames | sed 's|\s|\n|g' | sort -u
|
||||
}
|
||||
|
||||
gen_uhttpd_listen_ips() {
|
||||
local regexp
|
||||
|
||||
regexp=$(find_op_ifnames | tr '\n' '|' | sed 's,^|*,,;s,|*$,,')
|
||||
ip -o addr | grep -v "\bscope link\b" | sed -En -e "/^[0-9]+:\s*($regexp)\s/{s|^.*\binet6?\s+([^/]+)/.*|\1|p}" | sed '/:/{s|^|\[|;s|$|\]|}'
|
||||
}
|
||||
|
||||
validate_section_domain() {
|
||||
uci_load_validate $CONFIG_NAME $DOMAINS "$1" "$2" \
|
||||
'enabled:bool:0' \
|
||||
'name:hostname' \
|
||||
'group:string' \
|
||||
'family:or("4", "6", "both"):both' \
|
||||
'overwrite:ipaddr'
|
||||
}
|
||||
|
||||
init_hosts() {
|
||||
mkdir -p "${HOSTFILE%/*}" 2>/dev/null
|
||||
echo "# auto-generated config file from /etc/config/alwaysonline" > "${HOSTFILE}"
|
||||
}
|
||||
|
||||
gen_hosts() {
|
||||
[ "$2" == "0" ] || { >&2 echo "section $1 validation failed"; return 1; }
|
||||
[ "$enabled" == "0" ] && return 0
|
||||
|
||||
local _addr4="${tun_addr4%/*}"
|
||||
local _addr6="${tun_addr6%/*}"
|
||||
|
||||
local familys
|
||||
[ "$family" == "both" ] && familys="4 6" || familys="$family"
|
||||
|
||||
for v in $familys; do
|
||||
eval "domain_list=\"\${domain_list}\${overwrite:-\$_addr$v} \${name}\n\""
|
||||
done
|
||||
}
|
||||
|
||||
gen_eui64() {
|
||||
local mac=$(rgmac)
|
||||
local head=${mac:0:2}
|
||||
if [ "$(( 0x$head & 2 ))" = "0" ]; then
|
||||
printf "fe80::%x%s" $(( 0x$head | 2 )) "${mac:2:2}:${mac:4:2}ff:fe${mac:6:2}:${mac:8}"
|
||||
else
|
||||
printf "fe80::%x%s" $(( 0x$head & 0xfd )) "${mac:2:2}:${mac:4:2}ff:fe${mac:6:2}:${mac:8}"
|
||||
fi
|
||||
}
|
||||
|
||||
# set_uhttpd [host:port list]
|
||||
set_uhttpd() {
|
||||
local listen_http="${1:-0.0.0.0:80 [::]:80}" _v
|
||||
|
||||
uci -q delete uhttpd.main.listen_http
|
||||
for _v in $listen_http; do
|
||||
uci add_list uhttpd.main.listen_http="$_v"
|
||||
done
|
||||
uci commit uhttpd
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
# TUN
|
||||
ip tuntap add mode tun user "$USERNAME" name "$tun_name"
|
||||
sleep 1s
|
||||
ip link set "$tun_name" up
|
||||
|
||||
ip addr add "${tun_addr4}" dev "$tun_name"
|
||||
ip addr add "${tun_addr6}" dev "$tun_name"
|
||||
ip addr add "$(gen_eui64)/64" scope link dev "$tun_name"
|
||||
|
||||
procd_open_instance "$CONFIG_NAME"
|
||||
procd_set_param command "$PROG" -port 80
|
||||
procd_append_param command --disable-dns-server
|
||||
procd_append_param command -ipv4 "${tun_addr4%/*}" -ipv6 "${tun_addr6%/*}"
|
||||
procd_append_param netdev "br-lan"
|
||||
procd_append_param netdev "$tun_name"
|
||||
procd_set_param respawn
|
||||
procd_set_param user root
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local enabled tun_name tun_addr4 tun_addr6
|
||||
|
||||
config_get enabled global enabled 0
|
||||
[ "$enabled" == "0" ] && return 1
|
||||
config_get tun_name global tun_name 'awoltun0'
|
||||
config_get tun_addr4 global tun_addr4 '172.25.26.1/30'
|
||||
config_get tun_addr6 global tun_addr6 'fdfe:aead:2526::1/126'
|
||||
config_get port global port '8083'
|
||||
|
||||
# DNS
|
||||
init_hosts
|
||||
local domain_list
|
||||
config_foreach validate_section_domain "$DOMAINS" gen_hosts || return $?
|
||||
sed -Ei "1a$domain_list" "$HOSTFILE"
|
||||
|
||||
# HTTP
|
||||
/etc/init.d/uhttpd stop
|
||||
set_uhttpd "$(gen_uhttpd_listen_ips | sed 's|$|:80|')"
|
||||
start_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONFIG_NAME" 'network'
|
||||
|
||||
local iface=$(uci show network|grep "device='br-lan'"|cut -f2 -d'.'|head -n1)
|
||||
[ -n "$iface" ] && procd_add_reload_interface_trigger "$iface"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_started() {
|
||||
# DNS
|
||||
/etc/init.d/dnsmasq reload
|
||||
|
||||
# HTTP
|
||||
/etc/init.d/uhttpd start
|
||||
}
|
||||
|
||||
service_stopped() {
|
||||
# DNS
|
||||
init_hosts
|
||||
/etc/init.d/dnsmasq reload
|
||||
|
||||
# HTTP
|
||||
set_uhttpd
|
||||
/etc/init.d/uhttpd restart
|
||||
|
||||
# TUN
|
||||
local tun_name
|
||||
config_get tun_name global tun_name 'awoltun0'
|
||||
|
||||
ip link set "$tun_name" down 2>/dev/null
|
||||
ip tuntap del mode tun name "$tun_name" 2>/dev/null
|
||||
}
|
||||
Reference in new issue
Block a user