Skip to content

Commit

Permalink
Merge Official Source
Browse files Browse the repository at this point in the history
Signed-off-by: Tianling Shen <[email protected]>
  • Loading branch information
1715173329 committed Dec 11, 2024
2 parents c6f3504 + 571510a commit 24e1497
Show file tree
Hide file tree
Showing 21 changed files with 742 additions and 387 deletions.
4 changes: 2 additions & 2 deletions libs/libdeflate/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=libdeflate
PKG_VERSION:=1.18
PKG_VERSION:=1.22
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/ebiggers/libdeflate/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=225d982bcaf553221c76726358d2ea139bb34913180b20823c782cede060affd
PKG_HASH:=7834d9adbc9a809e0fb0d7b486060a9ae5f7819eb7f55bb8c22b10d7b3bed8da

PKG_LICENSE:=COPYING
PKG_LICENSE_FILES:=MIT
Expand Down
4 changes: 2 additions & 2 deletions net/adblock-fast/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=adblock-fast
PKG_VERSION:=1.1.2
PKG_RELEASE:=5
PKG_RELEASE:=18
PKG_MAINTAINER:=Stan Grishin <[email protected]>
PKG_LICENSE:=AGPL-3.0-or-later

Expand All @@ -28,7 +28,7 @@ define Package/adblock-fast
endef

define Package/adblock-fast/description
Fast AdBlocking script to block ad or abuse/malware domains with DNSMASQ or Unbound.
Fast AdBlocking script to block ad or abuse/malware domains with Dnsmasq, SmartDNS or Unbound.
Script supports local/remote list of domains and hosts-files for both block-listing and allow-listing.
Please see https://docs.openwrt.melmac.net/adblock-fast/ for more information.
endef
Expand Down
619 changes: 396 additions & 223 deletions net/adblock-fast/files/etc/init.d/adblock-fast

Large diffs are not rendered by default.

51 changes: 25 additions & 26 deletions net/adblock-fast/files/etc/uci-defaults/90-adblock-fast
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _enable_url() {
config_get u "$cfg" 'url'
config_get a "$cfg" 'action' 'block'
if [ "$u" = "$url" ] && [ "$a" = "$action" ]; then
uci del "${packageName}.${cfg}.enabled" && _found=1
uci_remove "$packageName" "$cfg" 'enabled' && _found=1
fi
}

Expand All @@ -26,32 +26,32 @@ enable_add_url() {
config_load "$packageName"
config_foreach _enable_url 'file_url' "$url" "$action"
if [ -z "$_found" ]; then
uci add "${packageName}" 'file_url' >/dev/null 2>&1
uci set "${packageName}.@file_url[-1].url=$url"
uci set "${packageName}.@file_url[-1].size=$(get_url_filesize "$url")"
uci set "${packageName}.@file_url[-1].action=$action"
uci_add "$packageName" 'file_url'
uci_set "$packageName" '@file_url[-1]' 'url' "$url"
uci_set "$packageName" '@file_url[-1]' 'size' "$(get_url_filesize "$url")"
uci_set "$packageName" '@file_url[-1]' 'action' "$action"
fi
}

if [ -s '/etc/config/simple-adblock' ] \
&& [ ! -s '/etc/config/adblock-fast-opkg' ] \
&& [ "$(uci get adblock-fast.config.enabled)" = '0' ]; then
&& [ "$(uci_get adblock-fast config enabled)" = '0' ]; then
cp -f '/etc/config/adblock-fast' '/etc/config/adblock-fast-opkg'
enabled="$(uci get simple-adblock.config.enabled)"
enabled="$(uci_get simple-adblock config enabled)"
if [ -x '/etc/init.d/simple-adblock' ]; then
output "Stopping and disabling simple-adblock "
if /etc/init.d/simple-adblock stop >/dev/null 2>&1 \
&& /etc/init.d/simple-adblock disable \
&& uci set simple-adblock.config.enabled=0 \
&& uci commit simple-adblock; then
&& uci_set simple-adblock config enabled 0 \
&& uci_commit simple-adblock; then
output_okn
else
output_failn
fi
else
output "Disabling simple-adblock."
if uci set simple-adblock.config.enabled=0 \
&& uci commit simple-adblock; then
if uci_set simple-adblock config enabled 0 \
&& uci_commit simple-adblock; then
output_okn
else
output_failn
Expand All @@ -63,31 +63,30 @@ if [ -s '/etc/config/simple-adblock' ] \
curl_additional_param curl_max_file_size curl_retry download_timeout \
debug dns dns_instance dnsmasq_config_file_url force_dns led \
parallel_downloads procd_trigger_wan6 procd_boot_wan_timeout verbosity; do
j="$(uci -q get simple-adblock.config.${i})"
[ -n "$j" ] && uci set "${packageName}.config.${i}=${j}"
j="$(uci_get simple-adblock.config.${i})"
[ -n "$j" ] && uci_set "$packageName" config "$i" "$j"
done
[ -n "$enabled" ] && uci set "${packageName}.config.enabled=${enabled}"
j="$(uci -q get simple-adblock.config.config_update_url)"
[ -n "$enabled" ] && uci_set "$packageName" config enabled "$enabled"
j="$(uci_get simple-adblock config config_update_url)"
if [ "${j//simple-adblock/}" = "$j" ]; then
uci set "${packageName}.config.config_update_url=$j"
uci_set "$packageName" config config_update_url "$j"
fi
ccd="$(uci get simple-adblock.config.compressed_cache_dir)"
ccd="${ccd:-/etc}"
for j in $(uci -q get simple-adblock.config.allowed_domain); do
[ -n "$j" ] && uci add_list "${packageName}.config.allowed_domain=${j}"
ccd="$(uci_get simple-adblock config compressed_cache_dir '/etc')"
for j in $(uci_get simple-adblock config allowed_domain); do
[ -n "$j" ] && uci_add_list "$packageName" config allowed_domain "$j"
done
for j in $(uci -q get simple-adblock.config.blocked_domain); do
[ -n "$j" ] && uci add_list "${packageName}.config.blocked_domain=${j}"
for j in $(uci_get simple-adblock config blocked_domain); do
[ -n "$j" ] && uci_add_list "$packageName" config blocked_domain "$j"
done
for j in $(uci -q get simple-adblock.config.force_dns_port); do
[ -n "$j" ] && uci add_list "${packageName}.config.force_dns_port=${j}"
for j in $(uci_get simple-adblock config force_dns_port); do
[ -n "$j" ] && uci_add_list "$packageName" config force_dns_port "$j"
done
output_okn

for i in allowed_domains_url blocked_adblockplus_url blocked_domains_url \
blocked_hosts_url; do
output "Migrating simple-adblock ${i} "
for j in $(uci -q get simple-adblock.config.${i}); do
for j in $(uci_get simple-adblock config "$i"); do
if [ "$i" = 'allowed_domains_url' ]; then
enable_add_url "$j" 'allow'
else
Expand All @@ -96,7 +95,7 @@ if [ -s '/etc/config/simple-adblock' ] \
done
output_okn
done
uci commit "$packageName"
uci_commit "$packageName"
output "Migrating simple-adblock cache file(s) "
for i in '/var/run/simple-adblock/dnsmasq.addnhosts.cache' \
'/var/run/simple-adblock/dnsmasq.conf.cache' \
Expand Down
4 changes: 3 additions & 1 deletion net/iperf3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=iperf
PKG_VERSION:=3.17.1
PKG_RELEASE:=2
PKG_RELEASE:=4

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.es.net/pub/iperf
Expand Down Expand Up @@ -66,6 +66,8 @@ else
CONFIGURE_ARGS += --without-openssl
endif

CONFIGURE_ARGS += --without-sctp

MAKE_FLAGS += noinst_PROGRAMS=

define Package/iperf3/description
Expand Down
19 changes: 19 additions & 0 deletions net/iperf3/patches/030-musl-crash.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From 3da07ae96f5b40f76b75e1ccd4b20267f6a5988e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= <[email protected]>
Date: Wed, 28 Aug 2024 09:43:04 +0200
Subject: [PATCH] remove incorrect freeaddrinfo call

---
src/net.c | 1 -
1 file changed, 1 deletion(-)

--- a/src/net.c
+++ b/src/net.c
@@ -145,7 +145,6 @@ create_socket(int domain, int proto, con
if ((gerror = getaddrinfo(server, portstr, &hints, &server_res)) != 0) {
if (local)
freeaddrinfo(local_res);
- freeaddrinfo(server_res);
return -1;
}

6 changes: 3 additions & 3 deletions net/ksmbd-tools/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=ksmbd-tools
PKG_VERSION:=3.5.1
PKG_RELEASE:=2
PKG_VERSION:=3.5.3
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/cifsd-team/ksmbd-tools/releases/download/$(PKG_VERSION)
PKG_HASH:=ab377b3044c48382303f3f7ec95f2e1a17592c774d70b2a11f32952099dbb214
PKG_HASH:=e8d55cc53825170d7e5213d48a92b8251dc0d1351601283f6d0995cfd789b4d0

PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=COPYING
Expand Down
2 changes: 1 addition & 1 deletion net/ksmbd-tools/patches/030-glib.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@@ -21,6 +21,7 @@ include_dirs = include_directories(
glib_dep = dependency(
'glib-2.0',
version: '>= 2.44',
version: '>= 2.58',
+ static: true,
)
libnl_dep = dependency(
Expand Down
2 changes: 1 addition & 1 deletion net/microsocks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=microsocks
PKG_VERSION:=1.0.4
PKG_RELEASE:=1
PKG_RELEASE:=2

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/rofl0r/microsocks/tar.gz/v$(PKG_VERSION)?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From c81760cc3f1b6db22c7c9694efe7f3be115c2caf Mon Sep 17 00:00:00 2001
From: rofl0r <[email protected]>
Date: Fri, 17 May 2024 14:38:16 +0000
Subject: [PATCH] use a bigger thread stack by default

apparently newer musl versions require more stack for the TCP-based
DNS resolver.

closes #73
---
sockssrv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/sockssrv.c
+++ b/sockssrv.c
@@ -47,7 +47,7 @@
#endif

#ifdef PTHREAD_STACK_MIN
-#define THREAD_STACK_SIZE MAX(8*1024, PTHREAD_STACK_MIN)
+#define THREAD_STACK_SIZE MAX(16*1024, PTHREAD_STACK_MIN)
#else
#define THREAD_STACK_SIZE 64*1024
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From 0343813e0410b469d591bc61b9a546ee2c2c15f6 Mon Sep 17 00:00:00 2001
From: rofl0r <[email protected]>
Date: Fri, 17 May 2024 14:40:11 +0000
Subject: [PATCH] mute warning about shadow declaration of bind_addr

---
sockssrv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/sockssrv.c
+++ b/sockssrv.c
@@ -112,8 +112,8 @@ struct thread {
static void dolog(const char* fmt, ...) { }
#endif

-static struct addrinfo* addr_choose(struct addrinfo* list, union sockaddr_union* bind_addr) {
- int af = SOCKADDR_UNION_AF(bind_addr);
+static struct addrinfo* addr_choose(struct addrinfo* list, union sockaddr_union* bindaddr) {
+ int af = SOCKADDR_UNION_AF(bindaddr);
if(af == AF_UNSPEC) return list;
struct addrinfo* p;
for(p=list; p; p=p->ai_next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
From 98421a21c4adc4c77c0cf3a5d650cc28ad3e0107 Mon Sep 17 00:00:00 2001
From: rofl0r <[email protected]>
Date: Fri, 24 May 2024 23:02:34 +0000
Subject: [PATCH] improve throughput in copyloop() using bigger buffer

- refactored clientthread to put the handshake code into its own
function, since it used its own 1K stack buffer.
by returning from the function before calling copyloop, we have
that space available in the new stackframe.
- since getaddrinfo() was the main stack consumer in the entire
code, we can safely use at least half the available thread
stack size for the copyloop to achieve higher throughput.
in my testing with pyhttpd it turned out that 64k is the sweet
spot to have minimal syscall overhead, but 16k is very close,
and it allows us to keep the minimal memory usage profile.

this is in response to https://github.com/rofl0r/microsocks/issues/58#issuecomment-2118389063
which links to a repo that tests different socks5 servers
performance on gigabit links.

also closes #10
---
sockssrv.c | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)

--- a/sockssrv.c
+++ b/sockssrv.c
@@ -44,6 +44,7 @@

#ifndef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif

#ifdef PTHREAD_STACK_MIN
@@ -282,7 +283,10 @@ static void copyloop(int fd1, int fd2) {
}
int infd = (fds[0].revents & POLLIN) ? fd1 : fd2;
int outfd = infd == fd2 ? fd1 : fd2;
- char buf[1024];
+ /* since the biggest stack consumer in the entire code is
+ libc's getaddrinfo(), we can safely use at least half the
+ available stacksize to improve throughput. */
+ char buf[MIN(16*1024, THREAD_STACK_SIZE/2)];
ssize_t sent = 0, n = read(infd, buf, sizeof buf);
if(n <= 0) return;
while(sent < n) {
@@ -310,14 +314,12 @@ static enum errorcode check_credentials(
return EC_NOT_ALLOWED;
}

-static void* clientthread(void *data) {
- struct thread *t = data;
- t->state = SS_1_CONNECTED;
+static int handshake(struct thread *t) {
unsigned char buf[1024];
ssize_t n;
int ret;
- int remotefd = -1;
enum authmethod am;
+ t->state = SS_1_CONNECTED;
while((n = recv(t->client.fd, buf, sizeof buf, 0)) > 0) {
switch(t->state) {
case SS_1_CONNECTED:
@@ -325,13 +327,13 @@ static void* clientthread(void *data) {
if(am == AM_NO_AUTH) t->state = SS_3_AUTHED;
else if (am == AM_USERNAME) t->state = SS_2_NEED_AUTH;
send_auth_response(t->client.fd, 5, am);
- if(am == AM_INVALID) goto breakloop;
+ if(am == AM_INVALID) return -1;
break;
case SS_2_NEED_AUTH:
ret = check_credentials(buf, n);
send_auth_response(t->client.fd, 1, ret);
if(ret != EC_SUCCESS)
- goto breakloop;
+ return -1;
t->state = SS_3_AUTHED;
if(auth_ips && !pthread_rwlock_wrlock(&auth_ips_lock)) {
if(!is_in_authed_list(&t->client.addr))
@@ -343,23 +345,24 @@ static void* clientthread(void *data) {
ret = connect_socks_target(buf, n, &t->client);
if(ret < 0) {
send_error(t->client.fd, ret*-1);
- goto breakloop;
+ return -1;
}
- remotefd = ret;
send_error(t->client.fd, EC_SUCCESS);
- copyloop(t->client.fd, remotefd);
- goto breakloop;
-
+ return ret;
}
}
-breakloop:
+ return -1;
+}

- if(remotefd != -1)
+static void* clientthread(void *data) {
+ struct thread *t = data;
+ int remotefd = handshake(t);
+ if(remotefd != -1) {
+ copyloop(t->client.fd, remotefd);
close(remotefd);
-
+ }
close(t->client.fd);
t->done = 1;
-
return 0;
}

Loading

0 comments on commit 24e1497

Please sign in to comment.