🐛compile error( FreeBSD )
Hi, I used FreeBSD 14. Compile error now. Please help
gmake cloudflared
GOOS=freebsd GOARCH=amd64 go build -mod=vendor -ldflags='-X "main.Version=2024.11.1-11-gb3304bf0" -X "main.BuildTime=2024-11-30-2155 UTC" ' github.com/cloudflare/cloudflared/cmd/cloudflared
github.com/cloudflare/cloudflared/cmd/cloudflared/tunnel
cmd/cloudflared/tunnel/cmd.go:559:15: undefined: diagnostic.NewSystemCollectorImpl gmake: *** [Makefile:138: cloudflared] Error 1
I am on TrueNAS Core Jail with FreeBSD 13.4-RELEASE-p2 and having similar issues with latest and 2024.12.2 tag
gmake cloudflared
GOOS=freebsd GOARCH=amd64 go build -mod=vendor -ldflags='-X "main.Version=2024.12.2-1-g2714d10d" -X "main.BuildTime=2025-01-05-2240 UTC" ' github.com/cloudflare/cloudflared/cmd/cloudflared
# github.com/cloudflare/cloudflared/diagnostic
diagnostic/diagnostic.go:170:30: undefined: network.NetworkCollectorImpl
gmake: *** [Makefile:138: cloudflared] Error 1
Switching to 2024.11.1 tag helped to build.
This looks like related to folder "diagnostic" which has been added after "2024.11.1" tag. Is it even compatible with FreeBSD?
Hi, The diagnostic code seems to support the official builds only and burns on all the coded but unofficially supported OS like the BSDs. By adding a FreeBSD flavour to the compile and duplicating the Mac SystemCollectorImpl implementation resulted in a successful compile. These steps were tested on the 2025.02.0 release. I would not use the current FreeBSD port version of cloudflared.
Make sure to utilise the Cloudflare GO fork installed using .teamcity/install-cloudflare-go.sh else unsupported crypto messages will prevent connection to CF.
- Patch 1
--- diagnostic/network/collector_unix.go.orig 2025-02-19 03:35:58 UTC
+++ diagnostic/network/collector_unix.go
@@ -1,4 +1,4 @@
-//go:build darwin || linux
+//go:build darwin || linux || freebsd
package diagnostic
- Patch 2
--- diagnostic/network/collector_unix_test.go.orig 2025-02-19 03:36:14 UTC
+++ diagnostic/network/collector_unix_test.go
@@ -1,4 +1,4 @@
-//go:build darwin || linux
+//go:build darwin || linux || freebsd
package diagnostic_test
-
Copy diagnostic/system_collector_macos.go to diagnostic/system_collector_freebsd.go
-
Patch 3
--- diagnostic/system_collector_freebsd.go.orig 2025-02-19 03:35:59 UTC
+++ diagnostic/system_collector_freebsd.go
@@ -1,4 +1,4 @@
-//go:build darwin
+//go:build freebsd
package diagnostic
A similar set of changes is needed for OpenBSD.
Hi, NothingTooSerious
Great thank you for your comment. Patch is good. I made latest cloudflared for FreeBSD. Thank you again.
Thanks a lot @NothingTooSerious
Happy to hear it was of use.
Ah, I didn't notice this issue. I submitted a PR back in January to resolve this for my OPNsense firewall. https://github.com/cloudflare/cloudflared/pull/1396
I just reworked my fork, so I've closed my PR and will leave https://github.com/cloudflare/cloudflared/pull/1421 to handle it.
I didn't need any modifications to the Makefile myself, but I am compiling on FreeBSD 14.1, not cross-compiling, so that could matter. I also made system_collector_unix.go in an attempt to not actually be FreeBSD specific; it was confirmed to compile on FreeBSD 14.1 and openBSD 7.6 for amd64.
Here's my cleaned up release https://github.com/kjake/cloudflared/releases/tag/2025.2.1, which correctly reports version to not confuse the Tunnels dashboard.