Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions net/darkstat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=darkstat
PKG_VERSION:=3.0.719
PKG_RELEASE:=6
PKG_VERSION:=3.0.722
PKG_RELEASE:=1

PKG_MAINTAINER:=Jean-Michel Lacroix <lacroix@lepine-lacroix.info>
PKG_MAINTAINER:=Paul Doran <RuralRoots@gmail.com>

PKG_LICENSE:=GPL-2.0 BSD-ISC

PKG_LICENSE_FILES:=COPYING.GPL LICENSE

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://unix4lyfe.org/darkstat
PKG_HASH:=aeaf909585f7f43dc032a75328fdb62114e58405b06a92a13c0d3653236dedd7
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/emikulic/darkstat/archive/refs/tags/$(PKG_VERSION).tar.gz?
PKG_HASH:=5c8e66d4c478b6d7e58f4c842823a09125509bf6851017ff70e32b32ce95b01b

PKG_INSTALL:=1

Expand All @@ -31,9 +32,9 @@ define Package/darkstat
endef

define Package/darkstat/description
darkstat is a packet sniffer that runs as a background process on a cable/DSL
router, gathers all sorts of statistics about network usage, and serves them
over HTTP.
darkstat is a packet sniffer that runs as a background process on an OpenWrt
router. It captures multiple statistics about network usage, and serves them
over HTTP.
endef

define Package/darkstat/conffiles
Expand All @@ -49,9 +50,20 @@ CONFIGURE_VARS += \
ac_cv_search_strlcpy=no \
ac_cv_search_strlcat=no

define Build/Configure
( cd $(PKG_BUILD_DIR) && autoreconf -fi )
$(call Build/Configure/Default)
endef
Comment on lines +53 to +56

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this now? 🤔

@ruralroots ruralroots May 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. You are correct on all three points. The
PKG_SOURCE_SUBDIR, PKG_BUILD_DIR, and Build/Configure additions were workarounds for the GitHub raw tag tarball format which lacks a pre-generated configure script. Using the '?' suffix on PKG_SOURCE_URL causes the build system to treat it as a properly named release tarball, making all three workarounds unnecessary. They have been removed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this ( cd $(PKG_BUILD_DIR) && autoreconf -fi )?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies. I did comment on this aspect of your original comment (#29343 (comment)) without context. I re-post it verbatim:
@BKPepe
The ? suffix approach was investigated but darkstat's GitHub releases only provide raw source snapshots without a pre-generated configure script. The autoreconf step is therefore necessary. unix4lyfe.org is no longer hosting releases and no alternative source for a proper release tarball has been found. Requesting guidance on the preferred approach for packages where upstream only provides raw source snapshots via GitHub tags.


define Build/Compile
$(HOSTCC) $(PKG_BUILD_DIR)/static/c-ify.c \
-o $(PKG_BUILD_DIR)/c-ify
$(HOSTCC) $(HOST_CFLAGS) $(PKG_BUILD_DIR)/static/c-ify.c \
-o $(PKG_BUILD_DIR)/c-ify $(HOST_LDFLAGS)
$(HOSTCC) $(HOST_CFLAGS) $(PKG_BUILD_DIR)/static/hex-ify.c \
-o $(PKG_BUILD_DIR)/hex-ify $(HOST_LDFLAGS)
( cd $(PKG_BUILD_DIR) && \
./c-ify style_css <static/style.css >stylecss.h && \
./c-ify graph_js <static/graph.js >graphjs.h && \
./hex-ify favicon_png <static/favicon.png >favicon.h )
Comment on lines +59 to +66

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this now?

@ruralroots ruralroots Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Build/Compile block is necessary because darkstat 3.0.721
introduced hex-ify to replace xxd, reducing build dependencies. In a cross-compilation environment the host cannot execute target binaries, so c-ify and hex-ify must be compiled natively using $(HOSTCC) and run on the host before the cross-compiler processes http.c. HOST_CFLAGS and HOST_LDFLAGS were added per CoPilot suggestion to respect host toolchain
hardening settings. If this is not required or follows a different convention in the OpenWrt tree, I am happy to revert it.

$(call Build/Compile/Default)
endef

Expand Down
6 changes: 3 additions & 3 deletions net/darkstat/files/darkstat.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ config darkstat
# option ports_max '60'
# option ports_keep '30'
# option highest_port '65534'
# option export_file 'darkstat_export.log'
# option import_file 'darkstat_export.log'
# option daylog_file 'darkstat_daylog.log'
option export_file 'darkstat_export.log'
option import_file 'darkstat_export.log'
option daylog_file 'darkstat_daylog.log'
Comment on lines +19 to +21

@ruralroots ruralroots May 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default RUN_D points to /var/darkstat which is on tmpfs (volatile RAM). Export, import and daylog files written there have no flash wear impact. A user would have to explicitly reconfigure RUN_D to a persistent path to affect flash storage, which is a deliberate choice. Leaving the options uncommented documents the available functionality while maintaining safe defaults.

14 changes: 9 additions & 5 deletions net/darkstat/files/darkstat.init
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ export_bool () {
}

set_config_string(){
mkdir -p $RUN_D
mkdir -p "$RUN_D"
chown "$USER:$GROUP" "$RUN_D"
. /lib/functions/network.sh
Comment on lines 31 to 34
config_load $CONFIGNAME
config_foreach build_config_string darkstat
}

build_config_string() {
local cfg="$1"
local cfg="$1"
config_get interface $cfg interface
network_get_device ifname "$interface"
network_get_device ifname "$interface"
CONFIGSTR=" -i $ifname "
export_bool syslog $cfg "--syslog"
export_bool verbose $cfg "--verbose"
# We need the --no-daemon parameter as with PROCD the process has to run in the background
CONFIGSTR="$CONFIGSTR--no-daemon "
CONFIGSTR="$CONFIGSTR--no-daemon " # required for procd; keep process in foreground
export_bool no_promisc $cfg "--no-promisc"
export_bool no_dns $cfg "--no-dns"
export_bool no_macs $cfg "--no-macs"
Expand All @@ -58,6 +58,10 @@ build_config_string() {
config_get hosts_max $cfg hosts_max
CONFIGSTR="$CONFIGSTR${hosts_max:+--hosts-max "$hosts_max"} "
config_get hosts_keep $cfg hosts_keep
CONFIGSTR="$CONFIGSTR${hosts_keep:+--hosts-keep "$hosts_keep"} "
config_get ports_max $cfg ports_max
CONFIGSTR="$CONFIGSTR${ports_max:+--ports-max "$ports_max"} "
config_get ports_keep $cfg ports_keep
CONFIGSTR="$CONFIGSTR${ports_keep:+--ports-keep "$ports_keep"} "
Comment on lines 58 to 65

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quoted argument pattern in CONFIGSTR is consistent with the existing script style throughout build_config_string(). The four added lines follow the same convention as hosts_max, highest_port, and other existing options. Changing this pattern would require refactoring the entire function which is beyond the scope of this PR.

config_get highest_port $cfg highest_port
CONFIGSTR="$CONFIGSTR${highest_port:+--highest-port "$highest_port"} "
Expand Down
8 changes: 7 additions & 1 deletion net/darkstat/patches/100-do-not-use-NI_IDN.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jean-Michel Lacroix <lacroix@lepine-lacroix.info>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@padre-lacroix Any plans to upstream this or letting the upstream know about this issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As incoming maintainer I will follow up with upstream regarding this
patch if @padre-lacroix has not already done so.

@ruralroots ruralroots Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As incoming maintainer I will take responsibility for this patch.
The last change to dns.c upstream was approximately 10 years ago and NI_IDN appears to be consistently defined, making upstreaming unlikely to be accepted. The patch will remain as necessary maintenance.

Date: Mon, 1 Jan 2018 00:00:00 +0000
Subject: [PATCH] darkstat: do not use NI_IDN

---
--- a/dns.c
+++ b/dns.c
@@ -347,9 +347,6 @@ dns_main(void)
@@ -346,9 +346,6 @@ dns_main(void)

reply.addr = ip;
flags = NI_NAMEREQD;
Expand Down
70 changes: 0 additions & 70 deletions net/darkstat/patches/101-allow-multiple-local-interfaces.patch

This file was deleted.

3 changes: 3 additions & 0 deletions net/darkstat/test-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version-check override is in a location CI won't discover, so it won't take effect. Every test-version.sh in this repo (65 of them, e.g. libs/expat/test-version.sh) sits in the package root, not in a tests/ subdirectory. The only three tests/ subdirs that exist (net/pbr, net/adblock-fast, net/https-dns-proxy) are unrelated run_tests.sh suites, a different mechanism. Placed here at net/darkstat/tests/test-version.sh, the generic version check will still run and fail (darkstat has no --version). Move the file to net/darkstat/test-version.sh.


Generated by Claude Code

# darkstat does not implement a --version flag
exit 0