Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into poc_DNS_on_peer_sta…
Browse files Browse the repository at this point in the history
…te_change

* upstream/main: (55 commits)
  [client] Account different policiy rules for routes firewall rules (netbirdio#2939)
  Add guide when signing key is not found (netbirdio#2942)
  [tests] Enable benchmark tests on github actions (netbirdio#2961)
  [management] Add performance test for login and sync calls (netbirdio#2960)
  [management] refactor to use account object instead of separate db calls for peer update (netbirdio#2957)
  [client] Code cleaning in net pkg and fix exit node feature on Android(netbirdio#2932)
  [management] Refactor nameserver groups to use store methods (netbirdio#2888)
  [management] Refactor DNS settings to use store methods (netbirdio#2883)
  [management] Refactor policy to use store methods (netbirdio#2878)
  [management] Refactor posture check to use store methods (netbirdio#2874)
  [client] Allow routing to fallback to exclusion routes if rules are not supported (netbirdio#2909)
  [client] Set up sysctl and routing table name only if routing rules are available (netbirdio#2933)
  [client] Test nftables for incompatible iptables rules (netbirdio#2948)
  [client] Don't return error in userspace mode without firewall (netbirdio#2924)
  Import time package (netbirdio#2940)
  [misc] Renew slack link (netbirdio#2938)
  [relay] Refactor initial Relay connection (netbirdio#2800)
  [management] Fix getSetupKey call (netbirdio#2927)
  [client] Fix allow netbird rule verdict (netbirdio#2925)
  [management] Add activity events to group propagation flow (netbirdio#2916)
  ...
  • Loading branch information
hurricanehrndz committed Nov 29, 2024
2 parents 614c542 + f9723c9 commit 5d12e64
Show file tree
Hide file tree
Showing 120 changed files with 5,473 additions and 2,313 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/golang-test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,47 @@ jobs:
- name: Test
run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true go test -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 10m -p 1 ./...

benchmark:
strategy:
fail-fast: false
matrix:
arch: [ '386','amd64' ]
store: [ 'sqlite', 'postgres' ]
runs-on: ubuntu-22.04
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.23.x"


- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt update && sudo apt install -y -q libgtk-3-dev libayatana-appindicator3-dev libgl1-mesa-dev xorg-dev gcc-multilib libpcap-dev

- name: Install 32-bit libpcap
if: matrix.arch == '386'
run: sudo dpkg --add-architecture i386 && sudo apt update && sudo apt-get install -y libpcap0.8-dev:i386

- name: Install modules
run: go mod tidy

- name: check git status
run: git --no-pager diff --exit-code

- name: Test
run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true go test -run=^$ -bench=. -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 10m -p 1 ./...

test_client_on_docker:
runs-on: ubuntu-20.04
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:

env:
SIGN_PIPE_VER: "v0.0.16"
SIGN_PIPE_VER: "v0.0.17"
GORELEASER_VER: "v2.3.2"
PRODUCT_NAME: "NetBird"
COPYRIGHT: "Wiretrustee UG (haftungsbeschreankt)"
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
<img src="https://img.shields.io/badge/license-BSD--3-blue" />
</a>
<br>
<a href="https://join.slack.com/t/netbirdio/shared_invite/zt-2p5zwhm4g-8fHollzrQa5y4PZF5AEpvQ">
<a href="https://join.slack.com/t/netbirdio/shared_invite/zt-2utg2ncdz-W7LEB6toRBLE1Jca37dYpg">
<img src="https://img.shields.io/badge/slack-@netbird-red.svg?logo=slack"/>
</a>
<br>
<a href="https://gurubase.io/g/netbird">
<img src="https://img.shields.io/badge/Gurubase-Ask%20NetBird%20Guru-006BFF"/>
</a>
</p>
</div>
Expand All @@ -30,7 +34,7 @@
<br/>
See <a href="https://netbird.io/docs/">Documentation</a>
<br/>
Join our <a href="https://join.slack.com/t/netbirdio/shared_invite/zt-2p5zwhm4g-8fHollzrQa5y4PZF5AEpvQ">Slack channel</a>
Join our <a href="https://join.slack.com/t/netbirdio/shared_invite/zt-2utg2ncdz-W7LEB6toRBLE1Jca37dYpg">Slack channel</a>
<br/>

</strong>
Expand Down
2 changes: 2 additions & 0 deletions client/anonymize/anonymize.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ func isWellKnown(addr netip.Addr) bool {
"2606:4700:4700::1111", "2606:4700:4700::1001", // Cloudflare DNS IPv6
"9.9.9.9", "149.112.112.112", // Quad9 DNS IPv4
"2620:fe::fe", "2620:fe::9", // Quad9 DNS IPv6

"128.0.0.0", "8000::", // 2nd split subnet for default routes
}

if slices.Contains(wellKnown, addr.String()) {
Expand Down
10 changes: 6 additions & 4 deletions client/cmd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"sync"

"github.com/kardianos/service"
log "github.com/sirupsen/logrus"
Expand All @@ -13,10 +14,11 @@ import (
)

type program struct {
ctx context.Context
cancel context.CancelFunc
serv *grpc.Server
serverInstance *server.Server
ctx context.Context
cancel context.CancelFunc
serv *grpc.Server
serverInstance *server.Server
serverInstanceMu sync.Mutex
}

func newProgram(ctx context.Context, cancel context.CancelFunc) *program {
Expand Down
4 changes: 4 additions & 0 deletions client/cmd/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ func (p *program) Start(svc service.Service) error {
}
proto.RegisterDaemonServiceServer(p.serv, serverInstance)

p.serverInstanceMu.Lock()
p.serverInstance = serverInstance
p.serverInstanceMu.Unlock()

log.Printf("started daemon server: %v", split[1])
if err := p.serv.Serve(listen); err != nil {
Expand All @@ -72,13 +74,15 @@ func (p *program) Start(svc service.Service) error {
}

func (p *program) Stop(srv service.Service) error {
p.serverInstanceMu.Lock()
if p.serverInstance != nil {
in := new(proto.DownRequest)
_, err := p.serverInstance.Down(p.ctx, in)
if err != nil {
log.Errorf("failed to stop daemon: %v", err)
}
}
p.serverInstanceMu.Unlock()

p.cancel()

Expand Down
4 changes: 2 additions & 2 deletions client/firewall/iptables/acl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,14 @@ func (m *aclManager) seedInitialEntries() {
func (m *aclManager) seedInitialOptionalEntries() {
m.optionalEntries["FORWARD"] = []entry{
{
spec: []string{"-m", "mark", "--mark", fmt.Sprintf("%#x", nbnet.PreroutingFwmark), "-j", chainNameInputRules},
spec: []string{"-m", "mark", "--mark", fmt.Sprintf("%#x", nbnet.PreroutingFwmarkRedirected), "-j", chainNameInputRules},
position: 2,
},
}

m.optionalEntries["PREROUTING"] = []entry{
{
spec: []string{"-t", "mangle", "-i", m.wgIface.Name(), "-m", "addrtype", "--dst-type", "LOCAL", "-j", "MARK", "--set-mark", fmt.Sprintf("%#x", nbnet.PreroutingFwmark)},
spec: []string{"-t", "mangle", "-i", m.wgIface.Name(), "-m", "addrtype", "--dst-type", "LOCAL", "-j", "MARK", "--set-mark", fmt.Sprintf("%#x", nbnet.PreroutingFwmarkRedirected)},
position: 1,
},
}
Expand Down
8 changes: 5 additions & 3 deletions client/firewall/iptables/manager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ func (m *Manager) Init(stateManager *statemanager.Manager) error {
}

// persist early to ensure cleanup of chains
if err := stateManager.PersistState(context.Background()); err != nil {
log.Errorf("failed to persist state: %v", err)
}
go func() {
if err := stateManager.PersistState(context.Background()); err != nil {
log.Errorf("failed to persist state: %v", err)
}
}()

return nil
}
Expand Down
Loading

0 comments on commit 5d12e64

Please sign in to comment.