From 25f0a0dbe98c764dc0d812a624d0c5c95b3d7d57 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 11 Mar 2024 12:51:28 +1100 Subject: [PATCH 01/17] Dont show large precision for large durations It just makes the display more crowded - and does not significantly add to the information shown. --- scripts/n3nctl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/n3nctl b/scripts/n3nctl index 8bf653d3..85667d9f 100755 --- a/scripts/n3nctl +++ b/scripts/n3nctl @@ -177,15 +177,20 @@ def num2timestr(seconds): hours, seconds = divmod(seconds, (60*60)) minutes, seconds = divmod(seconds, 60) + fields = 0 r = [] if days: r += [f"{days}d"] - if hours: + fields += 1 + if fields < 2 and hours: r += [f"{hours}h"] - if minutes: + fields += 1 + if fields < 2 and minutes: r += [f"{minutes}m"] - if seconds: + fields += 1 + if fields < 2 and seconds: r += [f"{seconds}s"] + fields += 1 return "".join(r) From 820851090b3a0f555c670047faa41fb21c7ac2da Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 20 Mar 2024 14:46:57 +1100 Subject: [PATCH 02/17] Rename applications to use the project name By prefixing the two main application binaries ("n3n-edge" and "n3n-supernode") with the name of the project, it makes it clear that these generic names are associated with a specific project. This change has been suggested in the past, but was always avoided as it was a configuration-breaking change. Since the new n3n release is making other breaking changes, now is the right time to perform this rename. --- Makefile | 17 +++++++------ apps/Makefile | 8 +++---- apps/{edge.c => n3n-edge.c} | 0 apps/{supernode.c => n3n-supernode.c} | 0 debian/n3n.postinst | 4 ++-- doc/Advanced.md | 6 ++--- doc/Authentication.md | 4 ++-- doc/Communities.md | 2 +- doc/ConfigurationFiles.md | 10 ++++---- doc/TrafficRestrictions.md | 2 +- edge.8 => n3n-edge.8 | 24 +++++++++---------- supernode.8 => n3n-supernode.8 | 14 +++++------ n3n.7 | 5 ++-- .../system/{edge.service => n3n-edge.service} | 0 .../{edge@.service => n3n-edge@.service} | 0 ...upernode.service => n3n-supernode.service} | 0 packages/openwrt/Makefile | 12 ++++++---- .../openwrt/etc/init.d/{edge => n3n-edge} | 4 ++-- .../etc/init.d/{supernode => n3n-supernode} | 4 ++-- packages/rpm/n3n.spec | 14 +++++------ scripts/test_builtin_edge.sh | 8 +++---- scripts/test_integration_edge.sh | 4 ++-- scripts/test_integration_packets.sh | 2 +- scripts/test_integration_supernode.sh | 4 ++-- tests/test_builtin_edge.sh.expected | 8 +++---- tests/test_integration_edge.sh.expected | 2 +- tests/test_integration_supernode.sh.expected | 4 ++-- 27 files changed, 82 insertions(+), 80 deletions(-) rename apps/{edge.c => n3n-edge.c} (100%) rename apps/{supernode.c => n3n-supernode.c} (100%) rename edge.8 => n3n-edge.8 (95%) rename supernode.8 => n3n-supernode.8 (92%) rename packages/lib/systemd/system/{edge.service => n3n-edge.service} (100%) rename packages/lib/systemd/system/{edge@.service => n3n-edge@.service} (100%) rename packages/lib/systemd/system/{supernode.service => n3n-supernode.service} (100%) rename packages/openwrt/etc/init.d/{edge => n3n-edge} (83%) rename packages/openwrt/etc/init.d/{supernode => n3n-supernode} (81%) diff --git a/Makefile b/Makefile index d786b9a9..0061d472 100644 --- a/Makefile +++ b/Makefile @@ -210,7 +210,7 @@ LINT_CCODE=\ # TODO: change either the files or the linter to remove these failures LINT_EXCLUDE=include/uthash.h|include/lzodefs.h|src/minilzo.c -DOCS=edge.8.gz supernode.8.gz n3n.7.gz +DOCS=n3n-edge.8.gz n3n-supernode.8.gz n3n.7.gz # This is the list of Debian/Ubuntu packages that are needed during the build. # Mostly of use in automated build systems. @@ -346,7 +346,7 @@ distclean: rm -f tests/*.out src/*.indent src/*.unc-backup* rm -rf autom4te.cache/ rm -f config.mak config.log config.status configure include/config.h include/config.h.in - rm -f edge.8.gz n3n.7.gz supernode.8.gz + rm -f n3n-edge.8.gz n3n.7.gz n3n-supernode.8.gz rm -f packages/debian/config.log packages/debian/config.status rm -rf packages/debian/autom4te.cache/ rm -f packages/rpm/config.log packages/rpm/config.status @@ -368,16 +368,15 @@ install.bin: apps .PHONY: install.systemd install.systemd: $(INSTALL) -d $(CONFIG_SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/edge@.service $(CONFIG_SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/edge.service $(CONFIG_SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/supernode.service $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/n3n-edge@.service $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/n3n-edge.service $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/n3n-supernode.service $(CONFIG_SYSTEMDDIR) .PHONY: install.doc -install: edge.8.gz supernode.8.gz n3n.7.gz +install: n3n-edge.8.gz n3n-supernode.8.gz n3n.7.gz $(INSTALL) -d $(MAN7DIR) $(MAN8DIR) $(CONFIG_DOCDIR) - $(INSTALL_DOC) edge.8.gz $(MAN8DIR)/ - $(INSTALL_DOC) supernode.8.gz $(MAN8DIR)/ - $(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/ + $(INSTALL_DOC) n3n-edge.8.gz $(MAN8DIR)/ + $(INSTALL_DOC) n3n-supernode.8.gz $(MAN8DIR)/ $(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/ $(INSTALL_DOC) doc/*.md doc/*.sample $(CONFIG_DOCDIR)/ diff --git a/apps/Makefile b/apps/Makefile index 794a4435..d2c3fbb0 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -18,8 +18,8 @@ # LDFLAGS+=-L../libs/connslot # LDLIBS_LOCAL+=-lconnslot -APPS+=edge -APPS+=supernode +APPS+=n3n-edge +APPS+=n3n-supernode EXAMPLES+=example_edge_embed_quick_edge_init EXAMPLES+=example_edge_embed @@ -38,8 +38,8 @@ $(APPS) $(EXAMPLES): ../src/libn3n.a .PHONY: install install: $(addsuffix $(EXE),$(APPS)) $(INSTALL) -d $(CONFIG_SBINDIR) - $(INSTALL_PROG) supernode$(EXE) $(CONFIG_SBINDIR)/ - $(INSTALL_PROG) edge$(EXE) $(CONFIG_SBINDIR)/ + $(INSTALL_PROG) n3n-supernode$(EXE) $(CONFIG_SBINDIR)/ + $(INSTALL_PROG) n3n-edge$(EXE) $(CONFIG_SBINDIR)/ # See comments in the topdir Makefile about how to generate coverage data. gcov: diff --git a/apps/edge.c b/apps/n3n-edge.c similarity index 100% rename from apps/edge.c rename to apps/n3n-edge.c diff --git a/apps/supernode.c b/apps/n3n-supernode.c similarity index 100% rename from apps/supernode.c rename to apps/n3n-supernode.c diff --git a/debian/n3n.postinst b/debian/n3n.postinst index a816ffee..59784060 100644 --- a/debian/n3n.postinst +++ b/debian/n3n.postinst @@ -27,8 +27,8 @@ if [ "$1" = "configure" ]; then # TODO: It would be nice if the dh_systemd_start handled templated services if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then - if systemctl is-active --quiet 'edge@*.service'; then - systemctl try-restart 'edge@*.service' + if systemctl is-active --quiet 'n3n-edge@*.service'; then + systemctl try-restart 'n3n-edge@*.service' fi fi fi diff --git a/doc/Advanced.md b/doc/Advanced.md index 55dade72..7373f550 100644 --- a/doc/Advanced.md +++ b/doc/Advanced.md @@ -10,11 +10,11 @@ Read about [Configuration Files](ConfigurationFiles.md) as they might come in ha edge can also be run as a service instead of cli: 1. Edit `/etc/n3n/edge.conf` with your custom options. See [a sample](edge.conf.sample). -2. Start the service: `sudo systemctl start edge` -3. Optionally enable edge start on boot: `sudo systemctl enable edge` +2. Start the service: `sudo systemctl start n3n-edge` +3. Optionally enable edge start on boot: `sudo systemctl enable n3n-edge` You can run multiple edge service instances by creating `/etc/n3n/instance1.conf` and -starting it with `sudo systemctl start edge@instance1`. +starting it with `sudo systemctl start n3n-edge@instance1`. ## Communities diff --git a/doc/Authentication.md b/doc/Authentication.md index 68828a7a..a9698a22 100644 --- a/doc/Authentication.md +++ b/doc/Authentication.md @@ -101,7 +101,7 @@ environment. The password is set with the `auth.password` options. Continuing the given example, the edge could be invoked by: ``` -[user@host n3n]$ sudo ./edge \ +[user@host n3n]$ sudo ./n3n-edge \ start \ -l \ -c netleo \ @@ -131,7 +131,7 @@ auth.pubkey=opIyaWhWjKLJSNOHNpKnGmelhHWRqkmY5pAx7lbDHp4 Considering all this, our example expands to: ``` -[user@host n3n]$ sudo ./edge \ +[user@host n3n]$ sudo ./n3n-edge \ start \ -l \ -c netleo \ diff --git a/doc/Communities.md b/doc/Communities.md index dfe19988..819f085c 100644 --- a/doc/Communities.md +++ b/doc/Communities.md @@ -11,7 +11,7 @@ of 20 bytes. Hence, the community name can never contain a NUL byte. There are some other characters that cannot be used, namely `. * + ? [ ] \`. To make full use of character space, hex values could be used, e.g. from Linux -bash applying something like `edge … -c $(echo -en '\x3a\x3b\x4a\x6a\xfa') …` +bash applying something like `n3n-edge … -c $(echo -en '\x3a\x3b\x4a\x6a\xfa') …` as the command line syntax. If used with a configuration file, the bytes must be directly filled as characters into the corresponding `community.name` option diff --git a/doc/ConfigurationFiles.md b/doc/ConfigurationFiles.md index 232e882c..a28e96f2 100644 --- a/doc/ConfigurationFiles.md +++ b/doc/ConfigurationFiles.md @@ -1,7 +1,7 @@ # Configuration Files To help deployment and better handle locally different configurations, n3n -supports the use of configuration files for `edge` and `supernode`. +supports the use of configuration files for `n3n-edge` and `n3n-supernode`. The daemon will attempt to locate a configuration file based on the "sessionname" - which defaults to "edge" for the edge daemon. This would @@ -12,7 +12,7 @@ They are plain text files formatted very similar to INI files. To generate the help documentation for all current options: ```bash -edge help config +n3n-edge help config ``` If you created the following `/etc/n3n/testing.conf` file: @@ -35,7 +35,7 @@ address_mode = static which can be loaded by ``` -sudo ./edge start testing +sudo ./n3n-edge start testing ``` If needed, the settings from the config file can all be overridden using a @@ -44,7 +44,7 @@ command line parameter: If required, additional command line parameters can also be supplied: ``` -sudo edge start testing \ +sudo n3n-edge start testing \ -Oconnection.description=myComputer \ -O community.compression=lzo ``` @@ -53,5 +53,5 @@ Some of the most common options also have a shortcut version, you can see all these with: ``` -edge help options +n3n-edge help options ``` diff --git a/doc/TrafficRestrictions.md b/doc/TrafficRestrictions.md index 110cc0a7..7d27f877 100644 --- a/doc/TrafficRestrictions.md +++ b/doc/TrafficRestrictions.md @@ -25,7 +25,7 @@ The `filter.rule` option can be used multiple times to add multiple rules. Each `filter.rule` definition adds one rule. for example: ``` -edge \ +n3n-edge \ -c xxxx \ -k xxxx \ -a 192.168.100.5 \ diff --git a/edge.8 b/n3n-edge.8 similarity index 95% rename from edge.8 rename to n3n-edge.8 index 835d8bb7..47acebde 100644 --- a/edge.8 +++ b/n3n-edge.8 @@ -1,23 +1,23 @@ -.TH edge 8 "5 Jan 2024" "version 3" "SUPERUSER COMMANDS" +.TH n3n-edge 8 "5 Jan 2024" "version 3" "SUPERUSER COMMANDS" .SH NAME -edge \- n3n edge node daemon +n3n-edge \- VPN edge node daemon .SH SYNOPSIS .B edge [\fIoptions..\fR] [command] [\fIcommand args\fR] .br -.B edge start +.B n3n-edge start [\fIsessionname\fR] [\fB\-c \fR<\fIcommunity\fR>] [\fB\-l \fR<\fIsupernode host:port\fR>] .br -.B edge --help +.B n3n-edge --help .SH DESCRIPTION n3n is a peer-to-peer VPN system - it is the LAN you have when you have noLAN. -.B edge +.B n3n-edge is a daemon for n3n which creates a TAP interface to expose the n3n virtual LAN, providing an "edge node". On startup -.B edge +.B n3n-edge will load any config file, then any environment variables and then load the settings from the command line. Once it has the full config loaded, it will register with the supernode and create and setup the TAP @@ -30,7 +30,7 @@ Some of the most common options also have a shortcut version and you can see all of them with: .RS -.B edge help options +.B n3n-edge help options .RE .TP .SH Generic Options @@ -105,7 +105,7 @@ This file is an INI style file and a full description of the options is available with the commandline: .RS -.B edge help config +.B n3n-edge help config .RE .SH ENVIRONMENT After loading any config file, some settings are loaded from the environment. @@ -130,7 +130,7 @@ set the password for user-password authentication (Equivalent to auth.password) For the simplest testing, without any encryption: .RS -.B edge start -c mynetwork -l supernode.ntop.org:7777 +.B n3n-edge start -c mynetwork -l supernode.ntop.org:7777 .RE .TP .SH Config file example @@ -150,14 +150,14 @@ supernode=supernode.ntop.org:7777 Then start the daemon in the foreground: .RS -.B edge start mynetwork +.B n3n-edge start mynetwork .RE .TP .SH Complex example .nf -.B edge start \\\\ +.B n3n-edge start \\\\ \--daemon \\ \-O tuntap.name=n3n0 \\ \-c mynetwork \\ @@ -181,7 +181,7 @@ after the TAP device is successfully configured. On a second computer setup another edge with similar parameters, eg: .nf -.B edge start \\\\ +.B n3n-edge start \\\\ \-O tuntap.name=n3n0 \\ \-c mynetwork \\ \-k encryptme \\ diff --git a/supernode.8 b/n3n-supernode.8 similarity index 92% rename from supernode.8 rename to n3n-supernode.8 index ddc86316..767a515e 100644 --- a/supernode.8 +++ b/n3n-supernode.8 @@ -1,14 +1,14 @@ -.TH supernode 8 "5 Jan 2024" "version 3" "USER COMMANDS" +.TH n3n-supernode 8 "5 Jan 2024" "version 3" "USER COMMANDS" .SH NAME -supernode \- n3n supernode daemon +n3n-supernode \- n3n supernode daemon .SH SYNOPSIS -.B supernode +.B n3n-supernode [\fIoptions..\fR] [command] [\fIcommand args\fR] .br -.B supernode start +.B n3n-supernode start [\fIsessionname\fR] .br -.B supernode --help +.B n3n-supernode --help .SH DESCRIPTION N3N is a peer-to-peer VPN system - it is the LAN you have when you have noLAN. @@ -31,7 +31,7 @@ Some of the most common options also have a shortcut version and you can see all of them with: .RS -.B supernode help options +.B n3n-supernode help options .RE .TP .SH OPTIONS @@ -76,7 +76,7 @@ Communities.md and Authentication.md documentation included with this package. set the federation name so it is not visible at the command line .SH EXAMPLES .TP -.B supernode start -v +.B n3n-supernode start -v Start supernode listening on default UDP port (7654) with verbose output. .PP .SH RESTART diff --git a/n3n.7 b/n3n.7 index 1f442a98..ef6c16b6 100644 --- a/n3n.7 +++ b/n3n.7 @@ -1,6 +1,7 @@ .TH "n3n_v3" 7 "Sep 27, 2021" "version 3" "Background" .SH NAME -edge, n3nctl, supernode \- the n3n decentralised peer-to-peer network overlay VPN +n3n-edge, n3nctl, n3n-supernode \- the n3n decentralised peer-to-peer network +overlay VPN .SH DESCRIPTION n3n is a peer-to-peer network overlay or VPN system that provides layer 2 over layer 3 encapsulation with data transform capabilities such as encryption and @@ -129,7 +130,7 @@ deri (at) ntop.org - original author of n2n Don Bindner (--) - significant contributions to n2n-1 .SH SEE ALSO -ifconfig(8) edge(8) supernode(8) +ifconfig(8) n3n-edge(8) n3n-supernode(8) .br the documentation contained in the source code .br diff --git a/packages/lib/systemd/system/edge.service b/packages/lib/systemd/system/n3n-edge.service similarity index 100% rename from packages/lib/systemd/system/edge.service rename to packages/lib/systemd/system/n3n-edge.service diff --git a/packages/lib/systemd/system/edge@.service b/packages/lib/systemd/system/n3n-edge@.service similarity index 100% rename from packages/lib/systemd/system/edge@.service rename to packages/lib/systemd/system/n3n-edge@.service diff --git a/packages/lib/systemd/system/supernode.service b/packages/lib/systemd/system/n3n-supernode.service similarity index 100% rename from packages/lib/systemd/system/supernode.service rename to packages/lib/systemd/system/n3n-supernode.service diff --git a/packages/openwrt/Makefile b/packages/openwrt/Makefile index e4940e56..25cb8f16 100644 --- a/packages/openwrt/Makefile +++ b/packages/openwrt/Makefile @@ -76,9 +76,11 @@ endef define Package/n3n-edge/install $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/edge $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/n3nctl $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/n3n-edge $(1)/usr/sbin/ $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_BIN) $(PKG_BUILD_DIR)/packages/openwrt/etc/init.d/edge $(1)/etc/init.d/edge + $(INSTALL_BIN) $(PKG_BUILD_DIR)/packages/openwrt/etc/init.d/n3n-edge $(1)/etc/init.d/n3n-edge $(INSTALL_DIR) $(1)/etc/n3n $(INSTALL_CONF) $(PKG_BUILD_DIR)/doc/edge.conf.sample $(1)/etc/n3n/edge.conf endef @@ -88,10 +90,10 @@ define Package/n3n-supernode/conffiles endef define Package/n3n-supernode/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/supernode $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/n3n-supernode $(1)/usr/sbin/ $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_BIN) $(PKG_BUILD_DIR)/packages/openwrt/etc/init.d/supernode $(1)/etc/init.d/supernode + $(INSTALL_BIN) $(PKG_BUILD_DIR)/packages/openwrt/etc/init.d/n3n-supernode $(1)/etc/init.d/n3n-supernode $(INSTALL_DIR) $(1)/etc/n3n $(INSTALL_CONF) $(PKG_BUILD_DIR)/doc/supernode.conf.sample $(1)/etc/n3n/supernode.conf endef diff --git a/packages/openwrt/etc/init.d/edge b/packages/openwrt/etc/init.d/n3n-edge similarity index 83% rename from packages/openwrt/etc/init.d/edge rename to packages/openwrt/etc/init.d/n3n-edge index 016819ab..90bc7e05 100644 --- a/packages/openwrt/etc/init.d/edge +++ b/packages/openwrt/etc/init.d/n3n-edge @@ -3,7 +3,7 @@ START=90 STOP=10 USE_PROCD=1 -PROG=/usr/bin/edge +PROG=/usr/sbin/n3n-edge CONFIGFILE=/etc/n3n/edge.conf start_service() { @@ -21,5 +21,5 @@ stop_service() service_triggers() { - procd_add_reload_trigger "edge" + procd_add_reload_trigger "n3n-edge" } diff --git a/packages/openwrt/etc/init.d/supernode b/packages/openwrt/etc/init.d/n3n-supernode similarity index 81% rename from packages/openwrt/etc/init.d/supernode rename to packages/openwrt/etc/init.d/n3n-supernode index 616c7db5..4d394ff2 100644 --- a/packages/openwrt/etc/init.d/supernode +++ b/packages/openwrt/etc/init.d/n3n-supernode @@ -3,7 +3,7 @@ START=90 STOP=10 USE_PROCD=1 -PROG=/usr/bin/supernode +PROG=/usr/sbin/n3n-supernode CONFIGFILE=/etc/n3n/supernode.conf start_service() { @@ -21,5 +21,5 @@ stop_service() service_triggers() { - procd_add_reload_trigger "supernode" + procd_add_reload_trigger "n3n-supernode" } diff --git a/packages/rpm/n3n.spec b/packages/rpm/n3n.spec index dd1da6e1..1018f1ef 100644 --- a/packages/rpm/n3n.spec +++ b/packages/rpm/n3n.spec @@ -43,12 +43,12 @@ chmod u+w $RPM_BUILD_ROOT/usr/sbin/* rm -fr $RPM_BUILD_ROOT %files -/lib/systemd/system/edge.service -/lib/systemd/system/edge@.service -/lib/systemd/system/supernode.service +/lib/systemd/system/n3n-edge.service +/lib/systemd/system/n3n-edge@.service +/lib/systemd/system/n3n-supernode.service /usr/bin/n3nctl -/usr/sbin/edge -/usr/sbin/supernode +/usr/sbin/n3n-edge +/usr/sbin/n3n-supernode /usr/share/doc/n3n/Advanced.md /usr/share/doc/n3n/Authentication.md /usr/share/doc/n3n/Bridging.md @@ -112,7 +112,7 @@ fi if [ -f /bin/systemctl ]; then if [ ! -f /.dockerenv ]; then # possibly remove the installed services - %systemd_preun supernode.service edge.service 'edge@*.service' + %systemd_preun supernode.service n3n-edge.service 'edge@*.service' fi fi @@ -120,6 +120,6 @@ fi if [ -f /bin/systemctl ]; then if [ ! -f /.dockerenv ]; then # possibly restart the running services - %systemd_postun_with_restart supernode.service edge.service 'edge@*.service' + %systemd_postun_with_restart n3n-supernode.service n3n-edge.service 'n3n-edge@*.service' fi fi diff --git a/scripts/test_builtin_edge.sh b/scripts/test_builtin_edge.sh index e9f6773b..cdd2ddd1 100755 --- a/scripts/test_builtin_edge.sh +++ b/scripts/test_builtin_edge.sh @@ -16,9 +16,9 @@ docmd() { return $S } -docmd "$BINDIR"/apps/edge test hashing +docmd "$BINDIR"/apps/n3n-edge test hashing -docmd "$BINDIR"/apps/edge test config roundtrip +docmd "$BINDIR"/apps/n3n-edge test config roundtrip -docmd "$BINDIR"/apps/edge tools keygen logan 007 -docmd "$BINDIR"/apps/edge tools keygen secretFed +docmd "$BINDIR"/apps/n3n-edge tools keygen logan 007 +docmd "$BINDIR"/apps/n3n-edge tools keygen secretFed diff --git a/scripts/test_integration_edge.sh b/scripts/test_integration_edge.sh index 4f14b540..06173d82 100755 --- a/scripts/test_integration_edge.sh +++ b/scripts/test_integration_edge.sh @@ -25,10 +25,10 @@ sudo mkdir -p /run/n3n sudo chown "$USER" /run/n3n # start a supernode -docmd "${BINDIR}"/apps/supernode start ci_sn -v --daemon +docmd "${BINDIR}"/apps/n3n-supernode start ci_sn -v --daemon # Start the edge in the background -docmd sudo "${BINDIR}"/apps/edge start ci_edge1 \ +docmd sudo "${BINDIR}"/apps/n3n-edge start ci_edge1 \ --daemon \ -l localhost:7654 \ -c test \ diff --git a/scripts/test_integration_packets.sh b/scripts/test_integration_packets.sh index f530c159..68bd5ef5 100755 --- a/scripts/test_integration_packets.sh +++ b/scripts/test_integration_packets.sh @@ -26,7 +26,7 @@ sudo chown "$USER" /run/n3n # start a supernode echo -e "### supernode started\n" -apps/supernode \ +apps/n3n-supernode \ -vv \ -Oconnection.bind=7001 \ -Osupernode.macaddr=02:00:00:00:00:01 \ diff --git a/scripts/test_integration_supernode.sh b/scripts/test_integration_supernode.sh index e10f7446..398f76a3 100755 --- a/scripts/test_integration_supernode.sh +++ b/scripts/test_integration_supernode.sh @@ -23,11 +23,11 @@ sudo mkdir -p /run/n3n sudo chown "$USER" /run/n3n # start it running in the background -docmd "${BINDIR}"/apps/supernode start ci_sn1 \ +docmd "${BINDIR}"/apps/n3n-supernode start ci_sn1 \ --daemon \ -Oconnection.bind=7001 \ -Osupernode.peer=localhost:7002 -docmd "${BINDIR}"/apps/supernode start ci_sn2 \ +docmd "${BINDIR}"/apps/n3n-supernode start ci_sn2 \ --daemon \ -Oconnection.bind=7002 \ -Osupernode.peer=localhost:7001 diff --git a/tests/test_builtin_edge.sh.expected b/tests/test_builtin_edge.sh.expected index 6b955403..6566326f 100644 --- a/tests/test_builtin_edge.sh.expected +++ b/tests/test_builtin_edge.sh.expected @@ -1,7 +1,7 @@ -### test: ./apps/edge test hashing +### test: ./apps/n3n-edge test hashing OK -### test: ./apps/edge test config roundtrip +### test: ./apps/n3n-edge test config roundtrip # Autogenerated config dump [auth] @@ -50,9 +50,9 @@ address_mode=auto metric=0 mtu=0 -### test: ./apps/edge tools keygen logan 007 +### test: ./apps/n3n-edge tools keygen logan 007 * logan nHWum+r42k1qDXdIeH-WFKeylK5UyLStRzxofRNAgpG -### test: ./apps/edge tools keygen secretFed +### test: ./apps/n3n-edge tools keygen secretFed auth.pubkey=opIyaWhWjKLJSNOHNpKnGmelhHWRqkmY5pAx7lbDHp4 diff --git a/tests/test_integration_edge.sh.expected b/tests/test_integration_edge.sh.expected index 1de4f142..059ce86b 100644 --- a/tests/test_integration_edge.sh.expected +++ b/tests/test_integration_edge.sh.expected @@ -1,4 +1,4 @@ -### test: ./apps/supernode start ci_sn -v --daemon +### test: ./apps/n3n-supernode start ci_sn -v --daemon ### test: ./scripts/n3nctl -s ci_edge1 get_communities [ diff --git a/tests/test_integration_supernode.sh.expected b/tests/test_integration_supernode.sh.expected index af42537d..8b442e7a 100644 --- a/tests/test_integration_supernode.sh.expected +++ b/tests/test_integration_supernode.sh.expected @@ -1,6 +1,6 @@ -### test: ./apps/supernode start ci_sn1 --daemon -Oconnection.bind=7001 -Osupernode.peer=localhost:7002 +### test: ./apps/n3n-supernode start ci_sn1 --daemon -Oconnection.bind=7001 -Osupernode.peer=localhost:7002 -### test: ./apps/supernode start ci_sn2 --daemon -Oconnection.bind=7002 -Osupernode.peer=localhost:7001 +### test: ./apps/n3n-supernode start ci_sn2 --daemon -Oconnection.bind=7002 -Osupernode.peer=localhost:7001 ### test: ./scripts/n3nctl -s ci_sn1 get_communities [ From af66842b64dc774482b2976f4c12d18c57fef47d Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 20 Mar 2024 15:06:26 +1100 Subject: [PATCH 03/17] Change missed filenames in rpm build --- packages/rpm/n3n.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rpm/n3n.spec b/packages/rpm/n3n.spec index 1018f1ef..8b433dcd 100644 --- a/packages/rpm/n3n.spec +++ b/packages/rpm/n3n.spec @@ -71,8 +71,8 @@ rm -fr $RPM_BUILD_ROOT /usr/share/doc/n3n/edge.conf.sample /usr/share/doc/n3n/supernode.conf.sample /usr/share/man/man7/n3n.7.gz -/usr/share/man/man8/edge.8.gz -/usr/share/man/man8/supernode.8.gz +/usr/share/man/man8/n3n-edge.8.gz +/usr/share/man/man8/n3n-supernode.8.gz # Set the default attributes of all of the files specified to have an # owner and group of root and to inherit the permissions of the file From bac58ca681287c0aa27a9d31af8636319fe0a339 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 20 Mar 2024 15:15:32 +1100 Subject: [PATCH 04/17] Fixup the openwrt build to use the correct version numbers --- .github/workflows/slow_openwrt.yml | 8 ++++---- packages/openwrt/Makefile | 22 ++++++---------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.github/workflows/slow_openwrt.yml b/.github/workflows/slow_openwrt.yml index e80764a2..d70ca741 100644 --- a/.github/workflows/slow_openwrt.yml +++ b/.github/workflows/slow_openwrt.yml @@ -48,7 +48,7 @@ jobs: - name: Set ref run: | - echo "N2N_REF=$(./scripts/version.sh)" >> $GITHUB_ENV + echo "N3N_REF=$(./scripts/version.sh)" >> $GITHUB_ENV ./scripts/version.sh working-directory: src @@ -91,10 +91,10 @@ jobs: - name: Build openwrt packages env: - N2N_PKG_VERSION: ${{ env.N2N_REF }} + PKG_VERSION: ${{ env.N3N_REF }} run: | - echo "Build for $N2N_PKG_VERSION" - export N2N_PKG_VERSION + echo "Build for $PKG_VERSION" + export PKG_VERSION make package/n3n/clean V=s make package/n3n/prepare USE_SOURCE_DIR=$GITHUB_WORKSPACE/n3n V=s make package/n3n/compile V=s diff --git a/packages/openwrt/Makefile b/packages/openwrt/Makefile index 25cb8f16..b0a56ec4 100644 --- a/packages/openwrt/Makefile +++ b/packages/openwrt/Makefile @@ -5,31 +5,21 @@ include $(TOPDIR)/rules.mk PKG_NAME:=n3n -PKG_VERSION:=HEAD PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://github.com/n42n/n3n + # These are defaults for compiling without any environmental overrides # (eg, the github action calculates the correct overrides for each build) -PKG_SOURCE_URL:=https://github.com/n42n/n3n -PKG_SOURCE_VERSION:=main +PKG_VERSION?=FIXME +PKG_SOURCE_VERSION?=main PKG_MIRROR_HASH:=skip -# Apply overrides from the build environment -ifdef N2N_PKG_SOURCE_URL - PKG_SOURCE_URL:=$(N2N_PKG_SOURCE_URL) -endif -ifdef N2N_PKG_SOURCE_VERSION - PKG_SOURCE_VERSION:=$(N2N_PKG_SOURCE_VERSION) -endif -ifdef N2N_PKG_VERSION - PKG_VERSION:=$(N2N_PKG_VERSION) -endif - -PKG_MAINTAINER:=Emanuele Faranda -PKG_LICENSE:=GPL3 +PKG_MAINTAINER:=Hamish Coleman +PKG_LICENSE:=GPL-3.0-only # autogen fix PKG_FIXUP:=autoreconf From da8bcaf5f827c674e262a99d08d6d21d3ecd903f Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 20 Mar 2024 15:43:45 +1100 Subject: [PATCH 05/17] More effort to fix the openwrt test by using the right variables --- .github/workflows/tests.yml | 2 ++ packages/openwrt/Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 51f16e40..7c04524d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -413,6 +413,8 @@ jobs: - name: Build openwrt packages run: | export PKG_VERSION=$(../n3n/scripts/version.sh) + export PKG_SOURCE_URL=https://github.com/${{github.repository}} + export PKG_SOURCE_VERSION=$GITHUB_REF echo "Build for $PKG_VERSION" make package/n3n/clean V=s make package/n3n/prepare USE_SOURCE_DIR=$GITHUB_WORKSPACE/n3n V=s diff --git a/packages/openwrt/Makefile b/packages/openwrt/Makefile index b0a56ec4..706c3a89 100644 --- a/packages/openwrt/Makefile +++ b/packages/openwrt/Makefile @@ -10,11 +10,11 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/n42n/n3n # These are defaults for compiling without any environmental overrides # (eg, the github action calculates the correct overrides for each build) PKG_VERSION?=FIXME +PKG_SOURCE_URL?=https://github.com/n42n/n3n PKG_SOURCE_VERSION?=main PKG_MIRROR_HASH:=skip From 2f5220cf45a93c805aa9ef1bb1d2e4c6e0ab9a8f Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 20 Mar 2024 15:51:21 +1100 Subject: [PATCH 06/17] Dont override the vars used by other packages --- .github/workflows/tests.yml | 6 +++--- packages/openwrt/Makefile | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c04524d..3d2ddb77 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -412,9 +412,9 @@ jobs: - name: Build openwrt packages run: | - export PKG_VERSION=$(../n3n/scripts/version.sh) - export PKG_SOURCE_URL=https://github.com/${{github.repository}} - export PKG_SOURCE_VERSION=$GITHUB_REF + export BUILD_VERSION=$(../n3n/scripts/version.sh) + export BUILD_SOURCE_URL=https://github.com/${{github.repository}} + export BUILD_SOURCE_REF=$GITHUB_REF echo "Build for $PKG_VERSION" make package/n3n/clean V=s make package/n3n/prepare USE_SOURCE_DIR=$GITHUB_WORKSPACE/n3n V=s diff --git a/packages/openwrt/Makefile b/packages/openwrt/Makefile index 706c3a89..31c2e65b 100644 --- a/packages/openwrt/Makefile +++ b/packages/openwrt/Makefile @@ -13,9 +13,9 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz # These are defaults for compiling without any environmental overrides # (eg, the github action calculates the correct overrides for each build) -PKG_VERSION?=FIXME -PKG_SOURCE_URL?=https://github.com/n42n/n3n -PKG_SOURCE_VERSION?=main +PKG_VERSION:=$(BUILD_VERSION) +PKG_SOURCE_URL?=$(BUILD_SOURCE_URL) +PKG_SOURCE_VERSION?=$(BUILD_SOURCE_REF) PKG_MIRROR_HASH:=skip PKG_MAINTAINER:=Hamish Coleman From 96d4cdd6a41ec320c6175c0d0d032e2592f38e29 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 20 Mar 2024 16:21:41 +1100 Subject: [PATCH 07/17] Fix systemd units for new app names --- packages/lib/systemd/system/n3n-edge.service | 2 +- packages/lib/systemd/system/n3n-edge@.service | 2 +- packages/lib/systemd/system/n3n-supernode.service | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/lib/systemd/system/n3n-edge.service b/packages/lib/systemd/system/n3n-edge.service index 73e4cdc4..f0cea9fb 100644 --- a/packages/lib/systemd/system/n3n-edge.service +++ b/packages/lib/systemd/system/n3n-edge.service @@ -6,7 +6,7 @@ Wants=network-online.target [Service] Type=simple ExecStartPre= -ExecStart=/usr/sbin/edge start +ExecStart=/usr/sbin/n3n-edge start Restart=on-abnormal RestartSec=5 diff --git a/packages/lib/systemd/system/n3n-edge@.service b/packages/lib/systemd/system/n3n-edge@.service index 178cfa08..c6601253 100644 --- a/packages/lib/systemd/system/n3n-edge@.service +++ b/packages/lib/systemd/system/n3n-edge@.service @@ -6,7 +6,7 @@ Wants=network-online.target [Service] Type=simple ExecStartPre= -ExecStart=/usr/sbin/edge start %i +ExecStart=/usr/sbin/n3n-edge start %i Restart=on-abnormal RestartSec=5 diff --git a/packages/lib/systemd/system/n3n-supernode.service b/packages/lib/systemd/system/n3n-supernode.service index 57c399de..fe304bae 100644 --- a/packages/lib/systemd/system/n3n-supernode.service +++ b/packages/lib/systemd/system/n3n-supernode.service @@ -8,7 +8,7 @@ Type=simple User=n3n Group=n3n RuntimeDirectory=n3n -ExecStart=/usr/sbin/supernode start +ExecStart=/usr/sbin/n3n-supernode start Restart=on-abnormal RestartSec=5 From f6e3cec13038339f1677e9b5bf4e02b91f4b3d69 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 27 Mar 2024 13:39:04 +1100 Subject: [PATCH 08/17] Fix install instruction --- doc/INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/INSTALL b/doc/INSTALL index f0a9bad4..6b0329e2 100644 --- a/doc/INSTALL +++ b/doc/INSTALL @@ -12,7 +12,7 @@ $ make install or -$ make PREFIX=/usr install +$ make CONFIG_PREFIX=/usr install Debian Package -------------- From 5834859d11d96f1c05785b67f54305b864ae97d3 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 27 Mar 2024 13:39:53 +1100 Subject: [PATCH 09/17] Replace obsolete commandline option with current equivalent --- doc/Routing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Routing.md b/doc/Routing.md index cc79b3dc..acb01176 100644 --- a/doc/Routing.md +++ b/doc/Routing.md @@ -47,7 +47,7 @@ As an alternative to the `tools/n3n-route` utility, the `ip route` linux command `net.ipv4.ip_forward=1` could be added in /etc/sysctl.d/ – your distro may vary. - To allow n3n to forward packets, both edge nodes need to be started - with `-r` option on their command line. All other regular network + with the `filter.allow_routing=true` option on. All other regular network interfaces usually already allow packet forwarding and thus do not need any further configuration. From a51e3d2c7587bfd03c552f1dc1819e295d593644 Mon Sep 17 00:00:00 2001 From: Simon Brodeur Date: Tue, 26 Mar 2024 14:32:12 -0400 Subject: [PATCH 10/17] Update tuntap_linux.c Let the kernel takes care of assigning the port ID of the netlink socket. The netlink socket id uses the same namespace in all docker containers, so if the userspace code assigns the nl_pid then there is a possiblity of a collision, resulting in errors like: "Could not bind NETLINK socket: Address already in use [98]" Cherry-picked from 0df939ed5b0a7013a73f2df78f6a805b5ec555b3 in https://github.com/ntop/n2n/pull/1169 Thanks @sbrodeur --- src/tuntap_linux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tuntap_linux.c b/src/tuntap_linux.c index d193ca5d..fa990aeb 100644 --- a/src/tuntap_linux.c +++ b/src/tuntap_linux.c @@ -189,7 +189,6 @@ int tuntap_open (tuntap_dev *device, memset(&sa, 0, sizeof(sa)); sa.nl_family = PF_NETLINK; sa.nl_groups = RTMGRP_LINK; - sa.nl_pid = getpid(); memset(&msg, 0, sizeof(msg)); msg.msg_name = &sa; From c118c7f56d49c60ece6dbb35d3735261d52abc59 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 27 Mar 2024 13:48:33 +1100 Subject: [PATCH 11/17] Ensure we are ignoring the generated outputs --- apps/.gitignore | 8 ++++---- tools/.gitignore | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/.gitignore b/apps/.gitignore index c32e38bf..acf39cdd 100644 --- a/apps/.gitignore +++ b/apps/.gitignore @@ -1,8 +1,8 @@ # Main apps -edge -supernode -edge.exe -supernode.exe +n3n-edge +n3n-supernode +n3n-edge.exe +n3n-supernode.exe # Examples example_edge_embed_quick_edge_init diff --git a/tools/.gitignore b/tools/.gitignore index 6f62b5a3..cba937a1 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -1,9 +1,11 @@ # Tools +crypto_helper n3n-benchmark n3n-decode n3n-portfwd n3n-route +crypto_helper.exe n3n-benchmark.exe n3n-decode.exe n3n-portfwd.exe From f27e3440b85013a6c0df50cfce352e10aca8e33c Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 27 Mar 2024 14:12:50 +1100 Subject: [PATCH 12/17] Continue simplifying the available commandline options --- apps/n3n-edge.c | 2 -- doc/Authentication.md | 6 +++--- doc/BuildConfig.md | 7 ++++--- doc/Crypto.md | 17 +++++++++-------- doc/Faq.md | 6 +++++- n3n-edge.8 | 9 --------- 6 files changed, 21 insertions(+), 26 deletions(-) diff --git a/apps/n3n-edge.c b/apps/n3n-edge.c index f67b2e07..b5d67ddb 100644 --- a/apps/n3n-edge.c +++ b/apps/n3n-edge.c @@ -102,7 +102,6 @@ static const struct option long_options[] = { }; static const struct n3n_config_getopt option_map[] = { - { 'A', "community", "cipher", NULL }, { 'O', NULL, NULL, NULL, "
.