compile client under freebsd
Describe your changes
Compile netbird client under freebsd and now support netstack and userspace modes. Refactoring linux specific code to share same code with FreeBSD, move to *_unix.go files.
Not implemented yet:
- Kernel mode not supported
- DNS probably does not work yet
- Routing also probably does not work yet
- SSH support did not tested yet
- Lack of test environment for freebsd (dedicated VM for github runners under FreeBSD required)
- Lack of tests for freebsd specific code
- info reporting need to review and also implement, for example OS reported as GENERIC instead of FreeBSD (lack of FreeBSD icon in management interface)
- Lack of proper client setup under FreeBSD
- Lack of FreeBSD port/package
Issue ticket number and link
https://github.com/netbirdio/netbird/issues/1505
Checklist
- [ ] Is it a bug fix
- [ ] Is a typo/documentation fix
- [x] Is a feature enhancement
- [x] It is a refactor
- [ ] Created tests that fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
Great stuff @skillcoder! Thank you for the contribution.
P.S. Would you like to get a NetBird t-shirt? Ping me on Slack
I need help from core team to setup github checks (tests, linters) for freebsd os. And seems currents test required root to run + do not cleanup all created interfaces Also need take into account following test warnings and error
time="2024-03-31T16:01:29Z" level=warning msg="the network 192.168.0.0/24 has not been assigned a routing peer as no peers from the list [peer1] are currently connected"
time="2024-03-31T16:01:29Z" level=warning msg="received a route to manage, but agent doesn't support router mode on freebsd OS"
time="2024-03-31T16:01:29Z" level=warning msg="the network 8.8.20.0/24 has not been assigned a routing peer as no peers from the list [remote1 remote1] are currently connected"
time="2024-03-31T16:01:29Z" level=error msg="this agent version: development, doesn't support default routes, received 0.0.0.0/0, skipping this route"
--- FAIL: TestAddRemoveRoutes (0.09s)
--- FAIL: TestAddRemoveRoutes/Should_Not_Add_Or_Remove_Route_127.0.0.1/32 (0.03s)
systemops_nonandroid_test.go:58:
Error Trace: /usr/home/jeff/github/skillcoder/netbird/client/internal/routemanager/systemops_nonandroid_test.go:58
Error: Received unexpected error:
exit status 1
Test: TestAddRemoveRoutes/Should_Not_Add_Or_Remove_Route_127.0.0.1/32
Messages: addToRouteTableIfNoExists should not return err
--- FAIL: TestAddExistAndRemoveRouteNonAndroid (0.14s)
systemops_nonandroid_test.go:133: defaultGateway: 192.168.1.1
--- FAIL: TestAddExistAndRemoveRouteNonAndroid/Should_Add_And_Remove_random_Route (0.02s)
systemops_nonandroid_test.go:208:
Error Trace: /usr/home/jeff/github/skillcoder/netbird/client/internal/routemanager/systemops_nonandroid_test.go:208
Error: Should be true
Test: TestAddExistAndRemoveRouteNonAndroid/Should_Add_And_Remove_random_Route
Messages: route should exist
--- FAIL: TestExistsInRouteTable (0.00s)
systemops_nonandroid_test.go:247: address 127.0.0.0/8 should exist in route table
FAIL
FAIL github.com/netbirdio/netbird/client/internal/routemanager 0.445s
I did not touch routes on freebsd yet. And did not check dns management so highly likely it also does not work properly.
Actually running tests locally is very risky. You MUST run them only in isolated VM. I noticed tests changed system state and keep it inconsistent. For example /etc/resolv.conf
manager.go:224 needs another case for freebsd
Hi! I tested the PR on FreeBSD and it works fine. Could you fix the conflict and then we will merge the PR?
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
No data about Duplication