From aa0a2b3441297a3bf9d817fbea1a64eef3e5e136 Mon Sep 17 00:00:00 2001 From: Guass23 Date: Tue, 4 Feb 2025 21:32:11 +0100 Subject: [PATCH 1/3] Netbird port for OPNsense with a patch to report as FakeBSD to the Netbird management server --- net/netbird/Makefile | 29 ++++++++++++++++++++++ net/netbird/distinfo | 5 ++++ net/netbird/files/netbird.in | 41 ++++++++++++++++++++++++++++++++ net/netbird/files/patch-opnsense | 13 ++++++++++ net/netbird/pkg-descr | 1 + 5 files changed, 89 insertions(+) create mode 100644 net/netbird/Makefile create mode 100644 net/netbird/distinfo create mode 100644 net/netbird/files/netbird.in create mode 100644 net/netbird/files/patch-opnsense create mode 100644 net/netbird/pkg-descr diff --git a/net/netbird/Makefile b/net/netbird/Makefile new file mode 100644 index 00000000000..e4462ee5dc6 --- /dev/null +++ b/net/netbird/Makefile @@ -0,0 +1,29 @@ +PORTNAME= netbird +DISTVERSION= 0.36.5 +DISTVERSIONPREFIX= v +PORTREVISION= 1 +CATEGORIES= net security net-vpn + +WRKSRC= ${WRKDIR}/netbird-${PORTVERSION} + +MAINTAINER= opn-netbird@sun-ri.se +COMMENT= Mesh VPN +WWW= https://netbird.io/ + +LICENSE= BSD3CLAUSE +LICENSE_FILE= ${WRKSRC}/LICENSE + +USES= go:1.23,modules + +GO_MODULE= github.com/netbirdio/netbird + +USE_RC_SUBR= netbird + +GO_TARGET= ./client:netbird +GO_BUILDFLAGS= -tags freebsd -o ${PORTNAME} -ldflags "\ + -s -w -X github.com/netbirdio/netbird/version.version=${PORTVERSION}" + +PLIST_FILES= bin/netbird + + +.include diff --git a/net/netbird/distinfo b/net/netbird/distinfo new file mode 100644 index 00000000000..eab318b9cf5 --- /dev/null +++ b/net/netbird/distinfo @@ -0,0 +1,5 @@ +TIMESTAMP = 1738694930 +SHA256 (go/net_netbird/netbird-v0.36.5/v0.36.5.mod) = 38b5ac547788f793c20e3048c172c3c39be580b34934d6e835cd0e3a57ed432d +SIZE (go/net_netbird/netbird-v0.36.5/v0.36.5.mod) = 12035 +SHA256 (go/net_netbird/netbird-v0.36.5/v0.36.5.zip) = 435127808dd41a80609ec1923090e34bc757f9ff94111aa5985145ef99bf16e2 +SIZE (go/net_netbird/netbird-v0.36.5/v0.36.5.zip) = 2465547 \ No newline at end of file diff --git a/net/netbird/files/netbird.in b/net/netbird/files/netbird.in new file mode 100644 index 00000000000..8864e7934dc --- /dev/null +++ b/net/netbird/files/netbird.in @@ -0,0 +1,41 @@ +#!/bin/sh + +# PROVIDE: netbird +# REQUIRE: FILESYSTEMS devfs +# BEFORE: pf ipfw +# KEYWORD: shutdown + +. /etc/rc.subr + +name="netbird" +rcvar=netbird_enable +load_rc_config $name +desc="netbird mesh vpn" +pidfile="/var/run/${name}.pid" +netbird_tun_dev="wt0" +procname="/usr/local/bin/netbird" +start_cmd="${name}_start" +stop_postcmd="${name}_poststop" + +netbird_start() +{ + logger -s -t netbird "Starting ${name}." + # Check for orphaned netbird network interface + # And if it exists, then destroy it + /sbin/ifconfig ${netbird_tun_dev} >/dev/null 2>&1 && ( + /sbin/ifconfig ${netbird_tun_dev} | fgrep -qw PID || + /sbin/ifconfig ${netbird_tun_dev} destroy + ) + + /usr/sbin/daemon -p ${pidfile} -f -t ${name} /usr/local/bin/netbird service run --config /usr/local/etc/netbird/config.json --log-level info --log-file syslog +} + +netbird_poststop() +{ + /sbin/ifconfig ${netbird_tun_dev} >/dev/null 2>&1 && ( + logger -s -t netbird "Destroying ${netbird_tun_dev} adapter" + /sbin/ifconfig ${netbird_tun_dev} destroy || logger -s -t netbird "Failed to destroy ${netbird_tun_dev} adapter" + ) +} + +run_rc_command "$1" diff --git a/net/netbird/files/patch-opnsense b/net/netbird/files/patch-opnsense new file mode 100644 index 00000000000..6ba83c35595 --- /dev/null +++ b/net/netbird/files/patch-opnsense @@ -0,0 +1,13 @@ +--- client/system/info_freebsd.go ++++ client/system/info_freebsd.go +@@ -39,7 +39,7 @@ func GetInfo(ctx context.Context) *Info { + systemHostname, _ := os.Hostname() + + return &Info{ +- GoOS: runtime.GOOS, ++ GoOS: "linux", + Kernel: osInfo[0], + Platform: runtime.GOARCH, +- OS: osName, ++ OS: strings.Replace(osName, "FreeBSD", "FakeBSD", -1), + diff --git a/net/netbird/pkg-descr b/net/netbird/pkg-descr new file mode 100644 index 00000000000..bbc9e535a6b --- /dev/null +++ b/net/netbird/pkg-descr @@ -0,0 +1 @@ +Netbird mesh VPN From 1bc3cbb3463380e5fca4d508ab4d1f4d30a265c5 Mon Sep 17 00:00:00 2001 From: Gauss23 Date: Sun, 9 Feb 2025 22:05:22 +0100 Subject: [PATCH 2/3] Update pkg-descr --- net/netbird/pkg-descr | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/netbird/pkg-descr b/net/netbird/pkg-descr index bbc9e535a6b..fd9ba723b7a 100644 --- a/net/netbird/pkg-descr +++ b/net/netbird/pkg-descr @@ -1 +1,10 @@ -Netbird mesh VPN +Netbird is an open-source, peer-to-peer VPN built on top of WireGuard. It enables secure and private networking between devices across different locations without the need for complex configurations. + +Key features: +Zero-config VPN: Easily create secure connections between devices without manual network setup. +Built on WireGuard: Leverages WireGuard’s high-performance encryption for fast and secure communication. +Self-hosted or Cloud-managed: Users can deploy their own Netbird management server or use Netbird Cloud for centralized control. +Access Control & Routing: Fine-grained access control policies and automatic network routing simplify connectivity. +This FreeBSD port provides the Netbird client daemon and CLI tools, allowing FreeBSD systems to join a Netbird mesh network and securely communicate with other peers. + +For more details, visit: https://netbird.io From 9dfab5f5e760b064dfc3ca20b1b18198d45bafc8 Mon Sep 17 00:00:00 2001 From: Gauss23 Date: Mon, 10 Feb 2025 21:27:05 +0100 Subject: [PATCH 3/3] Fixed problems shown by portlint --- net/netbird/Makefile | 35 +++++++++---------- net/netbird/distinfo | 2 +- ...e => patch-client_system_info__freebsd.go} | 10 +++--- net/netbird/pkg-descr | 20 +++++++---- 4 files changed, 37 insertions(+), 30 deletions(-) rename net/netbird/files/{patch-opnsense => patch-client_system_info__freebsd.go} (51%) diff --git a/net/netbird/Makefile b/net/netbird/Makefile index e4462ee5dc6..4d63f400361 100644 --- a/net/netbird/Makefile +++ b/net/netbird/Makefile @@ -1,29 +1,26 @@ -PORTNAME= netbird -DISTVERSION= 0.36.5 +PORTNAME= netbird DISTVERSIONPREFIX= v -PORTREVISION= 1 -CATEGORIES= net security net-vpn +DISTVERSION= 0.36.5 +CATEGORIES= net security net-vpn -WRKSRC= ${WRKDIR}/netbird-${PORTVERSION} +MAINTAINER= opn-netbird@sun-ri.se +COMMENT= Mesh VPN +WWW= https://netbird.io/ -MAINTAINER= opn-netbird@sun-ri.se -COMMENT= Mesh VPN -WWW= https://netbird.io/ +LICENSE= BSD3CLAUSE +LICENSE_FILE= ${WRKSRC}/LICENSE -LICENSE= BSD3CLAUSE -LICENSE_FILE= ${WRKSRC}/LICENSE +USES= go:1.23,modules +WRKSRC= ${WRKDIR}/netbird-${PORTVERSION} -USES= go:1.23,modules +GO_MODULE= github.com/netbirdio/netbird -GO_MODULE= github.com/netbirdio/netbird +USE_RC_SUBR= netbird -USE_RC_SUBR= netbird - -GO_TARGET= ./client:netbird -GO_BUILDFLAGS= -tags freebsd -o ${PORTNAME} -ldflags "\ - -s -w -X github.com/netbirdio/netbird/version.version=${PORTVERSION}" - -PLIST_FILES= bin/netbird +GO_TARGET= ./client:netbird +GO_BUILDFLAGS= -tags freebsd -o ${PORTNAME} -ldflags "\ + -s -w -X github.com/netbirdio/netbird/version.version=${PORTVERSION}" +PLIST_FILES= bin/netbird .include diff --git a/net/netbird/distinfo b/net/netbird/distinfo index eab318b9cf5..e9f68be4728 100644 --- a/net/netbird/distinfo +++ b/net/netbird/distinfo @@ -2,4 +2,4 @@ TIMESTAMP = 1738694930 SHA256 (go/net_netbird/netbird-v0.36.5/v0.36.5.mod) = 38b5ac547788f793c20e3048c172c3c39be580b34934d6e835cd0e3a57ed432d SIZE (go/net_netbird/netbird-v0.36.5/v0.36.5.mod) = 12035 SHA256 (go/net_netbird/netbird-v0.36.5/v0.36.5.zip) = 435127808dd41a80609ec1923090e34bc757f9ff94111aa5985145ef99bf16e2 -SIZE (go/net_netbird/netbird-v0.36.5/v0.36.5.zip) = 2465547 \ No newline at end of file +SIZE (go/net_netbird/netbird-v0.36.5/v0.36.5.zip) = 2465547 diff --git a/net/netbird/files/patch-opnsense b/net/netbird/files/patch-client_system_info__freebsd.go similarity index 51% rename from net/netbird/files/patch-opnsense rename to net/netbird/files/patch-client_system_info__freebsd.go index 6ba83c35595..fe8b230d3f4 100644 --- a/net/netbird/files/patch-opnsense +++ b/net/netbird/files/patch-client_system_info__freebsd.go @@ -1,6 +1,6 @@ ---- client/system/info_freebsd.go +--- client/system/info_freebsd.go.orig 1979-11-30 00:00:00 UTC +++ client/system/info_freebsd.go -@@ -39,7 +39,7 @@ func GetInfo(ctx context.Context) *Info { +@@ -39,10 +39,10 @@ func GetInfo(ctx context.Context) *Info { systemHostname, _ := os.Hostname() return &Info{ @@ -8,6 +8,8 @@ + GoOS: "linux", Kernel: osInfo[0], Platform: runtime.GOARCH, -- OS: osName, +- OS: osName, + OS: strings.Replace(osName, "FreeBSD", "FakeBSD", -1), - + OSVersion: osVersion, + Hostname: extractDeviceName(ctx, systemHostname), + CPUs: runtime.NumCPU(), diff --git a/net/netbird/pkg-descr b/net/netbird/pkg-descr index fd9ba723b7a..b21911f6de9 100644 --- a/net/netbird/pkg-descr +++ b/net/netbird/pkg-descr @@ -1,10 +1,18 @@ -Netbird is an open-source, peer-to-peer VPN built on top of WireGuard. It enables secure and private networking between devices across different locations without the need for complex configurations. +Netbird is an open-source, peer-to-peer VPN built on top of WireGuard. +It enables secure and private networking between devices across different +locations without the need for complex configurations. Key features: -Zero-config VPN: Easily create secure connections between devices without manual network setup. -Built on WireGuard: Leverages WireGuard’s high-performance encryption for fast and secure communication. -Self-hosted or Cloud-managed: Users can deploy their own Netbird management server or use Netbird Cloud for centralized control. -Access Control & Routing: Fine-grained access control policies and automatic network routing simplify connectivity. -This FreeBSD port provides the Netbird client daemon and CLI tools, allowing FreeBSD systems to join a Netbird mesh network and securely communicate with other peers. +- Zero-config VPN: Easily create secure connections between devices without +manual network setup. +- Built on WireGuard: Leverages WireGuard?s high-performance encryption for +fast and secure communication. +- Self-hosted or Cloud-managed: Users can deploy their own Netbird management +server or use Netbird Cloud for centralized control. +- Access Control & Routing: Fine-grained access control policies and automatic +network routing simplify connectivity. +- This FreeBSD port provides the Netbird client daemon and CLI tools, allowing +FreeBSD systems to join a Netbird mesh network and securely communicate with +other peers. For more details, visit: https://netbird.io