mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-23 17:04:25 +01:00
Compare commits
14 Commits
v1.7.0
...
add-http-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0af7e6a1dd | ||
|
|
c14ad0f27b | ||
|
|
af958676b8 | ||
|
|
70779b26ad | ||
|
|
90aa8efb29 | ||
|
|
dd7f12f7c0 | ||
|
|
8ba5d64dbc | ||
|
|
3bbf5f4e67 | ||
|
|
928731acfe | ||
|
|
57eb80e9fb | ||
|
|
96f4dcaab8 | ||
|
|
6d8c5f437c | ||
|
|
165b671e70 | ||
|
|
6be0bad68a |
17
.github/workflows/gofmt.yml
vendored
17
.github/workflows/gofmt.yml
vendored
@@ -14,21 +14,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.20
|
- uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- uses: actions/setup-go@v4
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
go-version-file: 'go.mod'
|
||||||
key: ${{ runner.os }}-gofmt1.20-${{ hashFiles('**/go.sum') }}
|
check-latest: true
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-gofmt1.20-
|
|
||||||
|
|
||||||
- name: Install goimports
|
- name: Install goimports
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
245
.github/workflows/release.yml
vendored
245
.github/workflows/release.yml
vendored
@@ -10,13 +10,12 @@ jobs:
|
|||||||
name: Build Linux All
|
name: Build Linux All
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go 1.20
|
- uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
|
|
||||||
- name: Checkout code
|
- uses: actions/setup-go@v4
|
||||||
uses: actions/checkout@v2
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
@@ -25,7 +24,7 @@ jobs:
|
|||||||
mv build/*.tar.gz release
|
mv build/*.tar.gz release
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: linux-latest
|
name: linux-latest
|
||||||
path: release
|
path: release
|
||||||
@@ -34,13 +33,12 @@ jobs:
|
|||||||
name: Build Windows
|
name: Build Windows
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go 1.20
|
- uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
|
|
||||||
- name: Checkout code
|
- uses: actions/setup-go@v4
|
||||||
uses: actions/checkout@v2
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
@@ -57,7 +55,7 @@ jobs:
|
|||||||
mv dist\windows\wintun build\dist\windows\
|
mv dist\windows\wintun build\dist\windows\
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: windows-latest
|
name: windows-latest
|
||||||
path: build
|
path: build
|
||||||
@@ -68,13 +66,12 @@ jobs:
|
|||||||
HAS_SIGNING_CREDS: ${{ secrets.AC_USERNAME != '' }}
|
HAS_SIGNING_CREDS: ${{ secrets.AC_USERNAME != '' }}
|
||||||
runs-on: macos-11
|
runs-on: macos-11
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go 1.20
|
- uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
|
|
||||||
- name: Checkout code
|
- uses: actions/setup-go@v4
|
||||||
uses: actions/checkout@v2
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
- name: Import certificates
|
- name: Import certificates
|
||||||
if: env.HAS_SIGNING_CREDS == 'true'
|
if: env.HAS_SIGNING_CREDS == 'true'
|
||||||
@@ -107,7 +104,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: darwin-latest
|
name: darwin-latest
|
||||||
path: ./release/*
|
path: ./release/*
|
||||||
@@ -117,12 +114,16 @@ jobs:
|
|||||||
needs: [build-linux, build-darwin, build-windows]
|
needs: [build-linux, build-darwin, build-windows]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
- name: Zip Windows
|
- name: Zip Windows
|
||||||
run: |
|
run: |
|
||||||
cd windows-latest
|
cd artifacts/windows-latest
|
||||||
cp windows-amd64/* .
|
cp windows-amd64/* .
|
||||||
zip -r nebula-windows-amd64.zip nebula.exe nebula-cert.exe dist
|
zip -r nebula-windows-amd64.zip nebula.exe nebula-cert.exe dist
|
||||||
cp windows-arm64/* .
|
cp windows-arm64/* .
|
||||||
@@ -130,6 +131,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Create sha256sum
|
- name: Create sha256sum
|
||||||
run: |
|
run: |
|
||||||
|
cd artifacts
|
||||||
for dir in linux-latest darwin-latest windows-latest
|
for dir in linux-latest darwin-latest windows-latest
|
||||||
do
|
do
|
||||||
(
|
(
|
||||||
@@ -159,195 +161,12 @@ jobs:
|
|||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: actions/create-release@v1
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
run: |
|
||||||
tag_name: ${{ github.ref }}
|
cd artifacts
|
||||||
release_name: Release ${{ github.ref }}
|
gh release create \
|
||||||
draft: false
|
--verify-tag \
|
||||||
prerelease: false
|
--title "Release ${{ github.ref_name }}" \
|
||||||
|
"${{ github.ref_name }}" \
|
||||||
##
|
SHASUM256.txt *-latest/*.zip *-latest/*.tar.gz
|
||||||
## Upload assets (I wish we could just upload the whole folder at once...
|
|
||||||
##
|
|
||||||
|
|
||||||
- name: Upload SHASUM256.txt
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./SHASUM256.txt
|
|
||||||
asset_name: SHASUM256.txt
|
|
||||||
asset_content_type: text/plain
|
|
||||||
|
|
||||||
- name: Upload darwin zip
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./darwin-latest/nebula-darwin.zip
|
|
||||||
asset_name: nebula-darwin.zip
|
|
||||||
asset_content_type: application/zip
|
|
||||||
|
|
||||||
- name: Upload windows-amd64
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./windows-latest/nebula-windows-amd64.zip
|
|
||||||
asset_name: nebula-windows-amd64.zip
|
|
||||||
asset_content_type: application/zip
|
|
||||||
|
|
||||||
- name: Upload windows-arm64
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./windows-latest/nebula-windows-arm64.zip
|
|
||||||
asset_name: nebula-windows-arm64.zip
|
|
||||||
asset_content_type: application/zip
|
|
||||||
|
|
||||||
- name: Upload linux-amd64
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-amd64.tar.gz
|
|
||||||
asset_name: nebula-linux-amd64.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-386
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-386.tar.gz
|
|
||||||
asset_name: nebula-linux-386.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-ppc64le
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-ppc64le.tar.gz
|
|
||||||
asset_name: nebula-linux-ppc64le.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-arm-5
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-arm-5.tar.gz
|
|
||||||
asset_name: nebula-linux-arm-5.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-arm-6
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-arm-6.tar.gz
|
|
||||||
asset_name: nebula-linux-arm-6.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-arm-7
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-arm-7.tar.gz
|
|
||||||
asset_name: nebula-linux-arm-7.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-arm64
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-arm64.tar.gz
|
|
||||||
asset_name: nebula-linux-arm64.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-mips
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-mips.tar.gz
|
|
||||||
asset_name: nebula-linux-mips.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-mipsle
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-mipsle.tar.gz
|
|
||||||
asset_name: nebula-linux-mipsle.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-mips64
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-mips64.tar.gz
|
|
||||||
asset_name: nebula-linux-mips64.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-mips64le
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-mips64le.tar.gz
|
|
||||||
asset_name: nebula-linux-mips64le.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-mips-softfloat
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-mips-softfloat.tar.gz
|
|
||||||
asset_name: nebula-linux-mips-softfloat.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload linux-riscv64
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-linux-riscv64.tar.gz
|
|
||||||
asset_name: nebula-linux-riscv64.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|
||||||
- name: Upload freebsd-amd64
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./linux-latest/nebula-freebsd-amd64.tar.gz
|
|
||||||
asset_name: nebula-freebsd-amd64.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|||||||
17
.github/workflows/smoke.yml
vendored
17
.github/workflows/smoke.yml
vendored
@@ -18,21 +18,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.20
|
- uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- uses: actions/setup-go@v4
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
go-version-file: 'go.mod'
|
||||||
key: ${{ runner.os }}-go1.20-${{ hashFiles('**/go.sum') }}
|
check-latest: true
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go1.20-
|
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: make bin-docker
|
run: make bin-docker
|
||||||
|
|||||||
51
.github/workflows/test.yml
vendored
51
.github/workflows/test.yml
vendored
@@ -18,21 +18,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.20
|
- uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- uses: actions/setup-go@v4
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
go-version-file: 'go.mod'
|
||||||
key: ${{ runner.os }}-go1.20-${{ hashFiles('**/go.sum') }}
|
check-latest: true
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go1.20-
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make all
|
run: make all
|
||||||
@@ -57,21 +48,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.20
|
- uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- uses: actions/setup-go@v4
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
go-version-file: 'go.mod'
|
||||||
key: ${{ runner.os }}-go1.20-${{ hashFiles('**/go.sum') }}
|
check-latest: true
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go1.20-
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make bin-boringcrypto
|
run: make bin-boringcrypto
|
||||||
@@ -90,21 +72,12 @@ jobs:
|
|||||||
os: [windows-latest, macos-11]
|
os: [windows-latest, macos-11]
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.20
|
- uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- uses: actions/setup-go@v4
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
go-version-file: 'go.mod'
|
||||||
key: ${{ runner.os }}-go1.20-${{ hashFiles('**/go.sum') }}
|
check-latest: true
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go1.20-
|
|
||||||
|
|
||||||
- name: Build nebula
|
- name: Build nebula
|
||||||
run: go build ./cmd/nebula
|
run: go build ./cmd/nebula
|
||||||
|
|||||||
17
CHANGELOG.md
17
CHANGELOG.md
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.7.2] - 2023-06-01
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix a freeze during config reload if the `static_host_map` config was changed. (#886)
|
||||||
|
|
||||||
|
## [1.7.1] - 2023-05-18
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix IPv4 addresses returned by `static_host_map` DNS lookup queries being
|
||||||
|
treated as IPv6 addresses. (#877)
|
||||||
|
|
||||||
## [1.7.0] - 2023-05-17
|
## [1.7.0] - 2023-05-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -475,7 +488,9 @@ created.)
|
|||||||
|
|
||||||
- Initial public release.
|
- Initial public release.
|
||||||
|
|
||||||
[Unreleased]: https://github.com/slackhq/nebula/compare/v1.7.0...HEAD
|
[Unreleased]: https://github.com/slackhq/nebula/compare/v1.7.2...HEAD
|
||||||
|
[1.7.2]: https://github.com/slackhq/nebula/releases/tag/v1.7.2
|
||||||
|
[1.7.1]: https://github.com/slackhq/nebula/releases/tag/v1.7.1
|
||||||
[1.7.0]: https://github.com/slackhq/nebula/releases/tag/v1.7.0
|
[1.7.0]: https://github.com/slackhq/nebula/releases/tag/v1.7.0
|
||||||
[1.6.1]: https://github.com/slackhq/nebula/releases/tag/v1.6.1
|
[1.6.1]: https://github.com/slackhq/nebula/releases/tag/v1.6.1
|
||||||
[1.6.0]: https://github.com/slackhq/nebula/releases/tag/v1.6.0
|
[1.6.0]: https://github.com/slackhq/nebula/releases/tag/v1.6.0
|
||||||
|
|||||||
10
Makefile
10
Makefile
@@ -44,10 +44,13 @@ ALL_LINUX = linux-amd64 \
|
|||||||
linux-mips-softfloat \
|
linux-mips-softfloat \
|
||||||
linux-riscv64
|
linux-riscv64
|
||||||
|
|
||||||
|
ALL_FREEBSD = freebsd-amd64 \
|
||||||
|
freebsd-arm64
|
||||||
|
|
||||||
ALL = $(ALL_LINUX) \
|
ALL = $(ALL_LINUX) \
|
||||||
|
$(ALL_FREEBSD) \
|
||||||
darwin-amd64 \
|
darwin-amd64 \
|
||||||
darwin-arm64 \
|
darwin-arm64 \
|
||||||
freebsd-amd64 \
|
|
||||||
windows-amd64 \
|
windows-amd64 \
|
||||||
windows-arm64
|
windows-arm64
|
||||||
|
|
||||||
@@ -75,7 +78,7 @@ release: $(ALL:%=build/nebula-%.tar.gz)
|
|||||||
|
|
||||||
release-linux: $(ALL_LINUX:%=build/nebula-%.tar.gz)
|
release-linux: $(ALL_LINUX:%=build/nebula-%.tar.gz)
|
||||||
|
|
||||||
release-freebsd: build/nebula-freebsd-amd64.tar.gz
|
release-freebsd: $(ALL_FREEBSD:%=build/nebula-%.tar.gz)
|
||||||
|
|
||||||
release-boringcrypto: build/nebula-linux-$(shell go env GOARCH)-boringcrypto.tar.gz
|
release-boringcrypto: build/nebula-linux-$(shell go env GOARCH)-boringcrypto.tar.gz
|
||||||
|
|
||||||
@@ -93,6 +96,9 @@ bin-darwin: build/darwin-amd64/nebula build/darwin-amd64/nebula-cert
|
|||||||
bin-freebsd: build/freebsd-amd64/nebula build/freebsd-amd64/nebula-cert
|
bin-freebsd: build/freebsd-amd64/nebula build/freebsd-amd64/nebula-cert
|
||||||
mv $? .
|
mv $? .
|
||||||
|
|
||||||
|
bin-freebsd-arm64: build/freebsd-arm64/nebula build/freebsd-arm64/nebula-cert
|
||||||
|
mv $? .
|
||||||
|
|
||||||
bin-boringcrypto: build/linux-$(shell go env GOARCH)-boringcrypto/nebula build/linux-$(shell go env GOARCH)-boringcrypto/nebula-cert
|
bin-boringcrypto: build/linux-$(shell go env GOARCH)-boringcrypto/nebula build/linux-$(shell go env GOARCH)-boringcrypto/nebula-cert
|
||||||
mv $? .
|
mv $? .
|
||||||
|
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ func Test_NewConnectionManagerTest(t *testing.T) {
|
|||||||
ifce := &Interface{
|
ifce := &Interface{
|
||||||
hostMap: hostMap,
|
hostMap: hostMap,
|
||||||
inside: &test.NoopTun{},
|
inside: &test.NoopTun{},
|
||||||
outside: &udp.Conn{},
|
outside: &udp.NoopConn{},
|
||||||
firewall: &Firewall{},
|
firewall: &Firewall{},
|
||||||
lightHouse: lh,
|
lightHouse: lh,
|
||||||
handshakeManager: NewHandshakeManager(l, vpncidr, preferredRanges, hostMap, lh, &udp.Conn{}, defaultHandshakeConfig),
|
handshakeManager: NewHandshakeManager(l, vpncidr, preferredRanges, hostMap, lh, &udp.NoopConn{}, defaultHandshakeConfig),
|
||||||
l: l,
|
l: l,
|
||||||
}
|
}
|
||||||
ifce.certState.Store(cs)
|
ifce.certState.Store(cs)
|
||||||
@@ -133,10 +133,10 @@ func Test_NewConnectionManagerTest2(t *testing.T) {
|
|||||||
ifce := &Interface{
|
ifce := &Interface{
|
||||||
hostMap: hostMap,
|
hostMap: hostMap,
|
||||||
inside: &test.NoopTun{},
|
inside: &test.NoopTun{},
|
||||||
outside: &udp.Conn{},
|
outside: &udp.NoopConn{},
|
||||||
firewall: &Firewall{},
|
firewall: &Firewall{},
|
||||||
lightHouse: lh,
|
lightHouse: lh,
|
||||||
handshakeManager: NewHandshakeManager(l, vpncidr, preferredRanges, hostMap, lh, &udp.Conn{}, defaultHandshakeConfig),
|
handshakeManager: NewHandshakeManager(l, vpncidr, preferredRanges, hostMap, lh, &udp.NoopConn{}, defaultHandshakeConfig),
|
||||||
l: l,
|
l: l,
|
||||||
}
|
}
|
||||||
ifce.certState.Store(cs)
|
ifce.certState.Store(cs)
|
||||||
@@ -252,10 +252,10 @@ func Test_NewConnectionManagerTest_DisconnectInvalid(t *testing.T) {
|
|||||||
ifce := &Interface{
|
ifce := &Interface{
|
||||||
hostMap: hostMap,
|
hostMap: hostMap,
|
||||||
inside: &test.NoopTun{},
|
inside: &test.NoopTun{},
|
||||||
outside: &udp.Conn{},
|
outside: &udp.NoopConn{},
|
||||||
firewall: &Firewall{},
|
firewall: &Firewall{},
|
||||||
lightHouse: lh,
|
lightHouse: lh,
|
||||||
handshakeManager: NewHandshakeManager(l, vpncidr, preferredRanges, hostMap, lh, &udp.Conn{}, defaultHandshakeConfig),
|
handshakeManager: NewHandshakeManager(l, vpncidr, preferredRanges, hostMap, lh, &udp.NoopConn{}, defaultHandshakeConfig),
|
||||||
l: l,
|
l: l,
|
||||||
disconnectInvalid: true,
|
disconnectInvalid: true,
|
||||||
caPool: ncp,
|
caPool: ncp,
|
||||||
|
|||||||
16
control.go
16
control.go
@@ -18,12 +18,12 @@ import (
|
|||||||
// core. This means copying IP objects, slices, de-referencing pointers and taking the actual value, etc
|
// core. This means copying IP objects, slices, de-referencing pointers and taking the actual value, etc
|
||||||
|
|
||||||
type Control struct {
|
type Control struct {
|
||||||
f *Interface
|
f *Interface
|
||||||
l *logrus.Logger
|
l *logrus.Logger
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
sshStart func()
|
sshStart func()
|
||||||
statsStart func()
|
httpStart func()
|
||||||
dnsStart func()
|
dnsStart func()
|
||||||
}
|
}
|
||||||
|
|
||||||
type ControlHostInfo struct {
|
type ControlHostInfo struct {
|
||||||
@@ -48,8 +48,8 @@ func (c *Control) Start() {
|
|||||||
if c.sshStart != nil {
|
if c.sshStart != nil {
|
||||||
go c.sshStart()
|
go c.sshStart()
|
||||||
}
|
}
|
||||||
if c.statsStart != nil {
|
if c.httpStart != nil {
|
||||||
go c.statsStart()
|
go c.httpStart()
|
||||||
}
|
}
|
||||||
if c.dnsStart != nil {
|
if c.dnsStart != nil {
|
||||||
go c.dnsStart()
|
go c.dnsStart()
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
func (c *Control) WaitForType(msgType header.MessageType, subType header.MessageSubType, pipeTo *Control) {
|
func (c *Control) WaitForType(msgType header.MessageType, subType header.MessageSubType, pipeTo *Control) {
|
||||||
h := &header.H{}
|
h := &header.H{}
|
||||||
for {
|
for {
|
||||||
p := c.f.outside.Get(true)
|
p := c.f.outside.(*udp.TesterConn).Get(true)
|
||||||
if err := h.Parse(p.Data); err != nil {
|
if err := h.Parse(p.Data); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ func (c *Control) WaitForType(msgType header.MessageType, subType header.Message
|
|||||||
func (c *Control) WaitForTypeByIndex(toIndex uint32, msgType header.MessageType, subType header.MessageSubType, pipeTo *Control) {
|
func (c *Control) WaitForTypeByIndex(toIndex uint32, msgType header.MessageType, subType header.MessageSubType, pipeTo *Control) {
|
||||||
h := &header.H{}
|
h := &header.H{}
|
||||||
for {
|
for {
|
||||||
p := c.f.outside.Get(true)
|
p := c.f.outside.(*udp.TesterConn).Get(true)
|
||||||
if err := h.Parse(p.Data); err != nil {
|
if err := h.Parse(p.Data); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -90,11 +90,11 @@ func (c *Control) GetFromTun(block bool) []byte {
|
|||||||
|
|
||||||
// GetFromUDP will pull a udp packet off the udp side of nebula
|
// GetFromUDP will pull a udp packet off the udp side of nebula
|
||||||
func (c *Control) GetFromUDP(block bool) *udp.Packet {
|
func (c *Control) GetFromUDP(block bool) *udp.Packet {
|
||||||
return c.f.outside.Get(block)
|
return c.f.outside.(*udp.TesterConn).Get(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Control) GetUDPTxChan() <-chan *udp.Packet {
|
func (c *Control) GetUDPTxChan() <-chan *udp.Packet {
|
||||||
return c.f.outside.TxPackets
|
return c.f.outside.(*udp.TesterConn).TxPackets
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Control) GetTunTxChan() <-chan []byte {
|
func (c *Control) GetTunTxChan() <-chan []byte {
|
||||||
@@ -103,7 +103,7 @@ func (c *Control) GetTunTxChan() <-chan []byte {
|
|||||||
|
|
||||||
// InjectUDPPacket will inject a packet into the udp side of nebula
|
// InjectUDPPacket will inject a packet into the udp side of nebula
|
||||||
func (c *Control) InjectUDPPacket(p *udp.Packet) {
|
func (c *Control) InjectUDPPacket(p *udp.Packet) {
|
||||||
c.f.outside.Send(p)
|
c.f.outside.(*udp.TesterConn).Send(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InjectTunUDPPacket puts a udp packet on the tun interface. Using UDP here because it's a simpler protocol
|
// InjectTunUDPPacket puts a udp packet on the tun interface. Using UDP here because it's a simpler protocol
|
||||||
@@ -143,7 +143,7 @@ func (c *Control) GetVpnIp() iputil.VpnIp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Control) GetUDPAddr() string {
|
func (c *Control) GetUDPAddr() string {
|
||||||
return c.f.outside.Addr.String()
|
return c.f.outside.(*udp.TesterConn).Addr.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Control) KillPendingTunnel(vpnIp net.IP) bool {
|
func (c *Control) KillPendingTunnel(vpnIp net.IP) bool {
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ tun:
|
|||||||
disabled: false
|
disabled: false
|
||||||
# Name of the device. If not set, a default will be chosen by the OS.
|
# Name of the device. If not set, a default will be chosen by the OS.
|
||||||
# For macOS: if set, must be in the form `utun[0-9]+`.
|
# For macOS: if set, must be in the form `utun[0-9]+`.
|
||||||
# For FreeBSD: Required to be set, must be in the form `tun[0-9]+`.
|
|
||||||
dev: nebula1
|
dev: nebula1
|
||||||
# Toggles forwarding of local broadcast packets, the address of which depends on the ip/mask encoded in pki.cert
|
# Toggles forwarding of local broadcast packets, the address of which depends on the ip/mask encoded in pki.cert
|
||||||
drop_local_broadcast: false
|
drop_local_broadcast: false
|
||||||
@@ -245,6 +244,9 @@ logging:
|
|||||||
# As an example, to log as RFC3339 with millisecond precision, set to:
|
# As an example, to log as RFC3339 with millisecond precision, set to:
|
||||||
#timestamp_format: "2006-01-02T15:04:05.000Z07:00"
|
#timestamp_format: "2006-01-02T15:04:05.000Z07:00"
|
||||||
|
|
||||||
|
#http:
|
||||||
|
#listen: 127.0.0.1:8080
|
||||||
|
|
||||||
#stats:
|
#stats:
|
||||||
#type: graphite
|
#type: graphite
|
||||||
#prefix: nebula
|
#prefix: nebula
|
||||||
@@ -253,7 +255,6 @@ logging:
|
|||||||
#interval: 10s
|
#interval: 10s
|
||||||
|
|
||||||
#type: prometheus
|
#type: prometheus
|
||||||
#listen: 127.0.0.1:8080
|
|
||||||
#path: /metrics
|
#path: /metrics
|
||||||
#namespace: prometheusns
|
#namespace: prometheusns
|
||||||
#subsystem: nebula
|
#subsystem: nebula
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ type HandshakeManager struct {
|
|||||||
pendingHostMap *HostMap
|
pendingHostMap *HostMap
|
||||||
mainHostMap *HostMap
|
mainHostMap *HostMap
|
||||||
lightHouse *LightHouse
|
lightHouse *LightHouse
|
||||||
outside *udp.Conn
|
outside udp.Conn
|
||||||
config HandshakeConfig
|
config HandshakeConfig
|
||||||
OutboundHandshakeTimer *LockingTimerWheel[iputil.VpnIp]
|
OutboundHandshakeTimer *LockingTimerWheel[iputil.VpnIp]
|
||||||
messageMetrics *MessageMetrics
|
messageMetrics *MessageMetrics
|
||||||
@@ -57,7 +57,7 @@ type HandshakeManager struct {
|
|||||||
trigger chan iputil.VpnIp
|
trigger chan iputil.VpnIp
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHandshakeManager(l *logrus.Logger, tunCidr *net.IPNet, preferredRanges []*net.IPNet, mainHostMap *HostMap, lightHouse *LightHouse, outside *udp.Conn, config HandshakeConfig) *HandshakeManager {
|
func NewHandshakeManager(l *logrus.Logger, tunCidr *net.IPNet, preferredRanges []*net.IPNet, mainHostMap *HostMap, lightHouse *LightHouse, outside udp.Conn, config HandshakeConfig) *HandshakeManager {
|
||||||
return &HandshakeManager{
|
return &HandshakeManager{
|
||||||
pendingHostMap: NewHostMap(l, "pending", tunCidr, preferredRanges),
|
pendingHostMap: NewHostMap(l, "pending", tunCidr, preferredRanges),
|
||||||
mainHostMap: mainHostMap,
|
mainHostMap: mainHostMap,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func Test_NewHandshakeManagerVpnIp(t *testing.T) {
|
|||||||
mainHM := NewHostMap(l, "test", vpncidr, preferredRanges)
|
mainHM := NewHostMap(l, "test", vpncidr, preferredRanges)
|
||||||
lh := newTestLighthouse()
|
lh := newTestLighthouse()
|
||||||
|
|
||||||
blah := NewHandshakeManager(l, tuncidr, preferredRanges, mainHM, lh, &udp.Conn{}, defaultHandshakeConfig)
|
blah := NewHandshakeManager(l, tuncidr, preferredRanges, mainHM, lh, &udp.NoopConn{}, defaultHandshakeConfig)
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
blah.NextOutboundHandshakeTimerTick(now, mw)
|
blah.NextOutboundHandshakeTimerTick(now, mw)
|
||||||
|
|||||||
34
http.go
Normal file
34
http.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package nebula
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/slackhq/nebula/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// startHttp returns a function to start an http server with pprof support and optionally a provided stats
|
||||||
|
// http handler.
|
||||||
|
func startHttp(l *logrus.Logger, c *config.C, listen string, statsHandler statsHandlerFunc) (func(), error) {
|
||||||
|
if listen == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var statsPath string
|
||||||
|
if statsHandler != nil {
|
||||||
|
statsPath = c.GetString("stats.path", "")
|
||||||
|
if statsPath == "" {
|
||||||
|
return nil, fmt.Errorf("stats.path should not be empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return func() {
|
||||||
|
l.Infof("Go pprof handler listening on %s at /debug/pprof", listen)
|
||||||
|
if statsHandler != nil {
|
||||||
|
http.Handle(statsPath, statsHandler(listen, statsPath))
|
||||||
|
}
|
||||||
|
l.Fatal(http.ListenAndServe(listen, nil))
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
10
interface.go
10
interface.go
@@ -26,7 +26,7 @@ const mtu = 9001
|
|||||||
|
|
||||||
type InterfaceConfig struct {
|
type InterfaceConfig struct {
|
||||||
HostMap *HostMap
|
HostMap *HostMap
|
||||||
Outside *udp.Conn
|
Outside udp.Conn
|
||||||
Inside overlay.Device
|
Inside overlay.Device
|
||||||
certState *CertState
|
certState *CertState
|
||||||
Cipher string
|
Cipher string
|
||||||
@@ -52,7 +52,7 @@ type InterfaceConfig struct {
|
|||||||
|
|
||||||
type Interface struct {
|
type Interface struct {
|
||||||
hostMap *HostMap
|
hostMap *HostMap
|
||||||
outside *udp.Conn
|
outside udp.Conn
|
||||||
inside overlay.Device
|
inside overlay.Device
|
||||||
certState atomic.Pointer[CertState]
|
certState atomic.Pointer[CertState]
|
||||||
cipher string
|
cipher string
|
||||||
@@ -80,7 +80,7 @@ type Interface struct {
|
|||||||
|
|
||||||
conntrackCacheTimeout time.Duration
|
conntrackCacheTimeout time.Duration
|
||||||
|
|
||||||
writers []*udp.Conn
|
writers []udp.Conn
|
||||||
readers []io.ReadWriteCloser
|
readers []io.ReadWriteCloser
|
||||||
|
|
||||||
metricHandshakes metrics.Histogram
|
metricHandshakes metrics.Histogram
|
||||||
@@ -167,7 +167,7 @@ func NewInterface(ctx context.Context, c *InterfaceConfig) (*Interface, error) {
|
|||||||
dropMulticast: c.DropMulticast,
|
dropMulticast: c.DropMulticast,
|
||||||
routines: c.routines,
|
routines: c.routines,
|
||||||
version: c.version,
|
version: c.version,
|
||||||
writers: make([]*udp.Conn, c.routines),
|
writers: make([]udp.Conn, c.routines),
|
||||||
readers: make([]io.ReadWriteCloser, c.routines),
|
readers: make([]io.ReadWriteCloser, c.routines),
|
||||||
caPool: c.caPool,
|
caPool: c.caPool,
|
||||||
disconnectInvalid: c.disconnectInvalid,
|
disconnectInvalid: c.disconnectInvalid,
|
||||||
@@ -243,7 +243,7 @@ func (f *Interface) run() {
|
|||||||
func (f *Interface) listenOut(i int) {
|
func (f *Interface) listenOut(i int) {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
|
||||||
var li *udp.Conn
|
var li udp.Conn
|
||||||
// TODO clean this up with a coherent interface for each outside connection
|
// TODO clean this up with a coherent interface for each outside connection
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
li = f.writers[i]
|
li = f.writers[i]
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ type LightHouse struct {
|
|||||||
myVpnIp iputil.VpnIp
|
myVpnIp iputil.VpnIp
|
||||||
myVpnZeros iputil.VpnIp
|
myVpnZeros iputil.VpnIp
|
||||||
myVpnNet *net.IPNet
|
myVpnNet *net.IPNet
|
||||||
punchConn *udp.Conn
|
punchConn udp.Conn
|
||||||
punchy *Punchy
|
punchy *Punchy
|
||||||
|
|
||||||
// Local cache of answers from light houses
|
// Local cache of answers from light houses
|
||||||
@@ -84,7 +84,7 @@ type LightHouse struct {
|
|||||||
|
|
||||||
// NewLightHouseFromConfig will build a Lighthouse struct from the values provided in the config object
|
// NewLightHouseFromConfig will build a Lighthouse struct from the values provided in the config object
|
||||||
// addrMap should be nil unless this is during a config reload
|
// addrMap should be nil unless this is during a config reload
|
||||||
func NewLightHouseFromConfig(ctx context.Context, l *logrus.Logger, c *config.C, myVpnNet *net.IPNet, pc *udp.Conn, p *Punchy) (*LightHouse, error) {
|
func NewLightHouseFromConfig(ctx context.Context, l *logrus.Logger, c *config.C, myVpnNet *net.IPNet, pc udp.Conn, p *Punchy) (*LightHouse, error) {
|
||||||
amLighthouse := c.GetBool("lighthouse.am_lighthouse", false)
|
amLighthouse := c.GetBool("lighthouse.am_lighthouse", false)
|
||||||
nebulaPort := uint32(c.GetInt("listen.port", 0))
|
nebulaPort := uint32(c.GetInt("listen.port", 0))
|
||||||
if amLighthouse && nebulaPort == 0 {
|
if amLighthouse && nebulaPort == 0 {
|
||||||
@@ -262,6 +262,18 @@ func (lh *LightHouse) reload(c *config.C, initial bool) error {
|
|||||||
|
|
||||||
//NOTE: many things will get much simpler when we combine static_host_map and lighthouse.hosts in config
|
//NOTE: many things will get much simpler when we combine static_host_map and lighthouse.hosts in config
|
||||||
if initial || c.HasChanged("static_host_map") || c.HasChanged("static_map.cadence") || c.HasChanged("static_map.network") || c.HasChanged("static_map.lookup_timeout") {
|
if initial || c.HasChanged("static_host_map") || c.HasChanged("static_map.cadence") || c.HasChanged("static_map.network") || c.HasChanged("static_map.lookup_timeout") {
|
||||||
|
// Clean up. Entries still in the static_host_map will be re-built.
|
||||||
|
// Entries no longer present must have their (possible) background DNS goroutines stopped.
|
||||||
|
if existingStaticList := lh.staticList.Load(); existingStaticList != nil {
|
||||||
|
lh.RLock()
|
||||||
|
for staticVpnIp := range *existingStaticList {
|
||||||
|
if am, ok := lh.addrMap[staticVpnIp]; ok && am != nil {
|
||||||
|
am.hr.Cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lh.RUnlock()
|
||||||
|
}
|
||||||
|
// Build a new list based on current config.
|
||||||
staticList := make(map[iputil.VpnIp]struct{})
|
staticList := make(map[iputil.VpnIp]struct{})
|
||||||
err := lh.loadStaticMap(c, lh.myVpnNet, staticList)
|
err := lh.loadStaticMap(c, lh.myVpnNet, staticList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/slackhq/nebula/test"
|
"github.com/slackhq/nebula/test"
|
||||||
"github.com/slackhq/nebula/udp"
|
"github.com/slackhq/nebula/udp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
//TODO: Add a test to ensure udpAddr is copied and not reused
|
//TODO: Add a test to ensure udpAddr is copied and not reused
|
||||||
@@ -242,8 +243,17 @@ func TestLighthouse_reload(t *testing.T) {
|
|||||||
lh, err := NewLightHouseFromConfig(context.Background(), l, c, &net.IPNet{IP: net.IP{10, 128, 0, 1}, Mask: net.IPMask{255, 255, 255, 0}}, nil, nil)
|
lh, err := NewLightHouseFromConfig(context.Background(), l, c, &net.IPNet{IP: net.IP{10, 128, 0, 1}, Mask: net.IPMask{255, 255, 255, 0}}, nil, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
c.Settings["static_host_map"] = map[interface{}]interface{}{"10.128.0.2": []interface{}{"1.1.1.1:4242"}}
|
nc := map[interface{}]interface{}{
|
||||||
lh.reload(c, false)
|
"static_host_map": map[interface{}]interface{}{
|
||||||
|
"10.128.0.2": []interface{}{"1.1.1.1:4242"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
rc, err := yaml.Marshal(nc)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
c.ReloadConfigString(string(rc))
|
||||||
|
|
||||||
|
err = lh.reload(c, false)
|
||||||
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLHHostRequest(fromAddr *udp.Addr, myVpnIp, queryVpnIp iputil.VpnIp, lhh *LightHouseHandler) testLhReply {
|
func newLHHostRequest(fromAddr *udp.Addr, myVpnIp, queryVpnIp iputil.VpnIp, lhh *LightHouseHandler) testLhReply {
|
||||||
|
|||||||
19
main.go
19
main.go
@@ -147,7 +147,7 @@ func Main(c *config.C, configTest bool, buildVersion string, logger *logrus.Logg
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set up our UDP listener
|
// set up our UDP listener
|
||||||
udpConns := make([]*udp.Conn, routines)
|
udpConns := make([]udp.Conn, routines)
|
||||||
port := c.GetInt("listen.port", 0)
|
port := c.GetInt("listen.port", 0)
|
||||||
|
|
||||||
if !configTest {
|
if !configTest {
|
||||||
@@ -324,14 +324,25 @@ func Main(c *config.C, configTest bool, buildVersion string, logger *logrus.Logg
|
|||||||
go lightHouse.LhUpdateWorker(ctx, ifce)
|
go lightHouse.LhUpdateWorker(ctx, ifce)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpListen := c.GetString("http.listen", "")
|
||||||
|
if httpListen == "" {
|
||||||
|
if httpListen = c.GetString("stats.listen", ""); httpListen != "" {
|
||||||
|
l.Warn("http.listen is undef, falling back to stats.listen. stats.listen will be deprecated in a future release.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO - stats third-party modules start uncancellable goroutines. Update those libs to accept
|
// TODO - stats third-party modules start uncancellable goroutines. Update those libs to accept
|
||||||
// a context so that they can exit when the context is Done.
|
// a context so that they can exit when the context is Done.
|
||||||
statsStart, err := startStats(l, c, buildVersion, configTest)
|
statsHTTPHandler, err := startStats(l, c, httpListen, buildVersion, configTest)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, util.NewContextualError("Failed to start stats emitter", nil, err)
|
return nil, util.NewContextualError("Failed to start stats emitter", nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpStart, err := startHttp(l, c, httpListen, statsHTTPHandler)
|
||||||
|
if err != nil {
|
||||||
|
return nil, util.NewContextualError("Failed to start http server", nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
if configTest {
|
if configTest {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
@@ -348,5 +359,5 @@ func Main(c *config.C, configTest bool, buildVersion string, logger *logrus.Logg
|
|||||||
dnsStart = dnsMain(l, hostMap, c)
|
dnsStart = dnsMain(l, hostMap, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Control{ifce, l, cancel, sshStart, statsStart, dnsStart}, nil
|
return &Control{ifce, l, cancel, sshStart, httpStart, dnsStart}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,14 +47,6 @@ type ifReq struct {
|
|||||||
pad [8]byte
|
pad [8]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func ioctl(a1, a2, a3 uintptr) error {
|
|
||||||
_, _, errno := unix.Syscall(unix.SYS_IOCTL, a1, a2, a3)
|
|
||||||
if errno != 0 {
|
|
||||||
return errno
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var sockaddrCtlSize uintptr = 32
|
var sockaddrCtlSize uintptr = 32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -194,10 +186,10 @@ func (t *tun) Activate() error {
|
|||||||
unix.SOCK_DGRAM,
|
unix.SOCK_DGRAM,
|
||||||
unix.IPPROTO_IP,
|
unix.IPPROTO_IP,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer unix.Close(s)
|
||||||
|
|
||||||
fd := uintptr(s)
|
fd := uintptr(s)
|
||||||
|
|
||||||
|
|||||||
@@ -4,21 +4,44 @@
|
|||||||
package overlay
|
package overlay
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/slackhq/nebula/cidr"
|
"github.com/slackhq/nebula/cidr"
|
||||||
"github.com/slackhq/nebula/iputil"
|
"github.com/slackhq/nebula/iputil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var deviceNameRE = regexp.MustCompile(`^tun[0-9]+$`)
|
const (
|
||||||
|
// FIODGNAME is defined in sys/sys/filio.h on FreeBSD
|
||||||
|
// For 32-bit systems, use FIODGNAME_32 (not defined in this file: 0x80086678)
|
||||||
|
FIODGNAME = 0x80106678
|
||||||
|
)
|
||||||
|
|
||||||
|
type fiodgnameArg struct {
|
||||||
|
length int32
|
||||||
|
pad [4]byte
|
||||||
|
buf unsafe.Pointer
|
||||||
|
}
|
||||||
|
|
||||||
|
type ifreqRename struct {
|
||||||
|
Name [16]byte
|
||||||
|
Data uintptr
|
||||||
|
}
|
||||||
|
|
||||||
|
type ifreqDestroy struct {
|
||||||
|
Name [16]byte
|
||||||
|
pad [16]byte
|
||||||
|
}
|
||||||
|
|
||||||
type tun struct {
|
type tun struct {
|
||||||
Device string
|
Device string
|
||||||
@@ -33,8 +56,23 @@ type tun struct {
|
|||||||
|
|
||||||
func (t *tun) Close() error {
|
func (t *tun) Close() error {
|
||||||
if t.ReadWriteCloser != nil {
|
if t.ReadWriteCloser != nil {
|
||||||
return t.ReadWriteCloser.Close()
|
if err := t.ReadWriteCloser.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, syscall.IPPROTO_IP)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer syscall.Close(s)
|
||||||
|
|
||||||
|
ifreq := ifreqDestroy{Name: t.deviceBytes()}
|
||||||
|
|
||||||
|
// Destroy the interface
|
||||||
|
err = ioctl(uintptr(s), syscall.SIOCIFDESTROY, uintptr(unsafe.Pointer(&ifreq)))
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,34 +81,87 @@ func newTunFromFd(_ *logrus.Logger, _ int, _ *net.IPNet, _ int, _ []Route, _ int
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newTun(l *logrus.Logger, deviceName string, cidr *net.IPNet, defaultMTU int, routes []Route, _ int, _ bool, _ bool) (*tun, error) {
|
func newTun(l *logrus.Logger, deviceName string, cidr *net.IPNet, defaultMTU int, routes []Route, _ int, _ bool, _ bool) (*tun, error) {
|
||||||
|
// Try to open existing tun device
|
||||||
|
var file *os.File
|
||||||
|
var err error
|
||||||
|
if deviceName != "" {
|
||||||
|
file, err = os.OpenFile("/dev/"+deviceName, os.O_RDWR, 0)
|
||||||
|
}
|
||||||
|
if errors.Is(err, fs.ErrNotExist) || deviceName == "" {
|
||||||
|
// If the device doesn't already exist, request a new one and rename it
|
||||||
|
file, err = os.OpenFile("/dev/tun", os.O_RDWR, 0)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
rawConn, err := file.SyscallConn()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("SyscallConn: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var name [16]byte
|
||||||
|
var ctrlErr error
|
||||||
|
rawConn.Control(func(fd uintptr) {
|
||||||
|
// Read the name of the interface
|
||||||
|
arg := fiodgnameArg{length: 16, buf: unsafe.Pointer(&name)}
|
||||||
|
ctrlErr = ioctl(fd, FIODGNAME, uintptr(unsafe.Pointer(&arg)))
|
||||||
|
})
|
||||||
|
if ctrlErr != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ifName := string(bytes.TrimRight(name[:], "\x00"))
|
||||||
|
if deviceName == "" {
|
||||||
|
deviceName = ifName
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the name doesn't match the desired interface name, rename it now
|
||||||
|
if ifName != deviceName {
|
||||||
|
s, err := syscall.Socket(
|
||||||
|
syscall.AF_INET,
|
||||||
|
syscall.SOCK_DGRAM,
|
||||||
|
syscall.IPPROTO_IP,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer syscall.Close(s)
|
||||||
|
|
||||||
|
fd := uintptr(s)
|
||||||
|
|
||||||
|
var fromName [16]byte
|
||||||
|
var toName [16]byte
|
||||||
|
copy(fromName[:], ifName)
|
||||||
|
copy(toName[:], deviceName)
|
||||||
|
|
||||||
|
ifrr := ifreqRename{
|
||||||
|
Name: fromName,
|
||||||
|
Data: uintptr(unsafe.Pointer(&toName)),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the device name
|
||||||
|
ioctl(fd, syscall.SIOCSIFNAME, uintptr(unsafe.Pointer(&ifrr)))
|
||||||
|
}
|
||||||
|
|
||||||
routeTree, err := makeRouteTree(l, routes, false)
|
routeTree, err := makeRouteTree(l, routes, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(deviceName, "/dev/") {
|
|
||||||
deviceName = strings.TrimPrefix(deviceName, "/dev/")
|
|
||||||
}
|
|
||||||
if !deviceNameRE.MatchString(deviceName) {
|
|
||||||
return nil, fmt.Errorf("tun.dev must match `tun[0-9]+`")
|
|
||||||
}
|
|
||||||
return &tun{
|
return &tun{
|
||||||
Device: deviceName,
|
ReadWriteCloser: file,
|
||||||
cidr: cidr,
|
Device: deviceName,
|
||||||
MTU: defaultMTU,
|
cidr: cidr,
|
||||||
Routes: routes,
|
MTU: defaultMTU,
|
||||||
routeTree: routeTree,
|
Routes: routes,
|
||||||
l: l,
|
routeTree: routeTree,
|
||||||
|
l: l,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tun) Activate() error {
|
func (t *tun) Activate() error {
|
||||||
var err error
|
var err error
|
||||||
t.ReadWriteCloser, err = os.OpenFile("/dev/"+t.Device, os.O_RDWR, 0)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("activate failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO use syscalls instead of exec.Command
|
// TODO use syscalls instead of exec.Command
|
||||||
t.l.Debug("command: ifconfig", t.Device, t.cidr.String(), t.cidr.IP.String())
|
t.l.Debug("command: ifconfig", t.Device, t.cidr.String(), t.cidr.IP.String())
|
||||||
if err = exec.Command("/sbin/ifconfig", t.Device, t.cidr.String(), t.cidr.IP.String()).Run(); err != nil {
|
if err = exec.Command("/sbin/ifconfig", t.Device, t.cidr.String(), t.cidr.IP.String()).Run(); err != nil {
|
||||||
@@ -120,3 +211,10 @@ func (t *tun) Name() string {
|
|||||||
func (t *tun) NewMultiQueueReader() (io.ReadWriteCloser, error) {
|
func (t *tun) NewMultiQueueReader() (io.ReadWriteCloser, error) {
|
||||||
return nil, fmt.Errorf("TODO: multiqueue not implemented for freebsd")
|
return nil, fmt.Errorf("TODO: multiqueue not implemented for freebsd")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *tun) deviceBytes() (o [16]byte) {
|
||||||
|
for i, c := range t.Device {
|
||||||
|
o[i] = byte(c)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,14 +43,6 @@ type ifReq struct {
|
|||||||
pad [8]byte
|
pad [8]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func ioctl(a1, a2, a3 uintptr) error {
|
|
||||||
_, _, errno := unix.Syscall(unix.SYS_IOCTL, a1, a2, a3)
|
|
||||||
if errno != 0 {
|
|
||||||
return errno
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type ifreqAddr struct {
|
type ifreqAddr struct {
|
||||||
Name [16]byte
|
Name [16]byte
|
||||||
Addr unix.RawSockaddrInet4
|
Addr unix.RawSockaddrInet4
|
||||||
|
|||||||
14
overlay/tun_notwin.go
Normal file
14
overlay/tun_notwin.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
//go:build !windows
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package overlay
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func ioctl(a1, a2, a3 uintptr) error {
|
||||||
|
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, a1, a2, a3)
|
||||||
|
if errno != 0 {
|
||||||
|
return errno
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -70,7 +70,7 @@ type hostnamesResults struct {
|
|||||||
hostnames []hostnamePort
|
hostnames []hostnamePort
|
||||||
network string
|
network string
|
||||||
lookupTimeout time.Duration
|
lookupTimeout time.Duration
|
||||||
stop chan struct{}
|
cancelFn func()
|
||||||
l *logrus.Logger
|
l *logrus.Logger
|
||||||
ips atomic.Pointer[map[netip.AddrPort]struct{}]
|
ips atomic.Pointer[map[netip.AddrPort]struct{}]
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,6 @@ func NewHostnameResults(ctx context.Context, l *logrus.Logger, d time.Duration,
|
|||||||
hostnames: make([]hostnamePort, len(hostPorts)),
|
hostnames: make([]hostnamePort, len(hostPorts)),
|
||||||
network: network,
|
network: network,
|
||||||
lookupTimeout: timeout,
|
lookupTimeout: timeout,
|
||||||
stop: make(chan (struct{})),
|
|
||||||
l: l,
|
l: l,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +114,8 @@ func NewHostnameResults(ctx context.Context, l *logrus.Logger, d time.Duration,
|
|||||||
|
|
||||||
// Time for the DNS lookup goroutine
|
// Time for the DNS lookup goroutine
|
||||||
if performBackgroundLookup {
|
if performBackgroundLookup {
|
||||||
|
newCtx, cancel := context.WithCancel(ctx)
|
||||||
|
r.cancelFn = cancel
|
||||||
ticker := time.NewTicker(d)
|
ticker := time.NewTicker(d)
|
||||||
go func() {
|
go func() {
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
@@ -154,9 +155,7 @@ func NewHostnameResults(ctx context.Context, l *logrus.Logger, d time.Duration,
|
|||||||
onUpdate()
|
onUpdate()
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-newCtx.Done():
|
||||||
return
|
|
||||||
case <-r.stop:
|
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
continue
|
continue
|
||||||
@@ -169,8 +168,8 @@ func NewHostnameResults(ctx context.Context, l *logrus.Logger, d time.Duration,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (hr *hostnamesResults) Cancel() {
|
func (hr *hostnamesResults) Cancel() {
|
||||||
if hr != nil {
|
if hr != nil && hr.cancelFn != nil {
|
||||||
hr.stop <- struct{}{}
|
hr.cancelFn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,20 +581,11 @@ func (r *RemoteList) unlockedCollect() {
|
|||||||
dnsAddrs := r.hr.GetIPs()
|
dnsAddrs := r.hr.GetIPs()
|
||||||
for _, addr := range dnsAddrs {
|
for _, addr := range dnsAddrs {
|
||||||
if r.shouldAdd == nil || r.shouldAdd(addr.Addr()) {
|
if r.shouldAdd == nil || r.shouldAdd(addr.Addr()) {
|
||||||
switch {
|
v6 := addr.Addr().As16()
|
||||||
case addr.Addr().Is4():
|
addrs = append(addrs, &udp.Addr{
|
||||||
v4 := addr.Addr().As4()
|
IP: v6[:],
|
||||||
addrs = append(addrs, &udp.Addr{
|
Port: addr.Port(),
|
||||||
IP: v4[:],
|
})
|
||||||
Port: addr.Port(),
|
|
||||||
})
|
|
||||||
case addr.Addr().Is6():
|
|
||||||
v6 := addr.Addr().As16()
|
|
||||||
addrs = append(addrs, &udp.Addr{
|
|
||||||
IP: v6[:],
|
|
||||||
Port: addr.Port(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
stats.go
34
stats.go
@@ -3,7 +3,6 @@ package nebula
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -19,10 +18,12 @@ import (
|
|||||||
"github.com/slackhq/nebula/config"
|
"github.com/slackhq/nebula/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type statsHandlerFunc func(listen, path string) http.Handler
|
||||||
|
|
||||||
// startStats initializes stats from config. On success, if any further work
|
// startStats initializes stats from config. On success, if any further work
|
||||||
// is needed to serve stats, it returns a func to handle that work. If no
|
// is needed to serve stats, it returns a statsHandlerFunc for that work. If
|
||||||
// work is needed, it'll return nil. On failure, it returns nil, error.
|
// no work is needed, it'll return nil. On failure, it returns nil, error.
|
||||||
func startStats(l *logrus.Logger, c *config.C, buildVersion string, configTest bool) (func(), error) {
|
func startStats(l *logrus.Logger, c *config.C, listen, buildVersion string, configTest bool) (f statsHandlerFunc, err error) {
|
||||||
mType := c.GetString("stats.type", "")
|
mType := c.GetString("stats.type", "")
|
||||||
if mType == "" || mType == "none" {
|
if mType == "" || mType == "none" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -33,7 +34,6 @@ func startStats(l *logrus.Logger, c *config.C, buildVersion string, configTest b
|
|||||||
return nil, fmt.Errorf("stats.interval was an invalid duration: %s", c.GetString("stats.interval", ""))
|
return nil, fmt.Errorf("stats.interval was an invalid duration: %s", c.GetString("stats.interval", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
var startFn func()
|
|
||||||
switch mType {
|
switch mType {
|
||||||
case "graphite":
|
case "graphite":
|
||||||
err := startGraphiteStats(l, interval, c, configTest)
|
err := startGraphiteStats(l, interval, c, configTest)
|
||||||
@@ -41,8 +41,7 @@ func startStats(l *logrus.Logger, c *config.C, buildVersion string, configTest b
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
case "prometheus":
|
case "prometheus":
|
||||||
var err error
|
f, err = startPrometheusStats(l, interval, c, listen, buildVersion, configTest)
|
||||||
startFn, err = startPrometheusStats(l, interval, c, buildVersion, configTest)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -56,7 +55,7 @@ func startStats(l *logrus.Logger, c *config.C, buildVersion string, configTest b
|
|||||||
go metrics.CaptureDebugGCStats(metrics.DefaultRegistry, interval)
|
go metrics.CaptureDebugGCStats(metrics.DefaultRegistry, interval)
|
||||||
go metrics.CaptureRuntimeMemStats(metrics.DefaultRegistry, interval)
|
go metrics.CaptureRuntimeMemStats(metrics.DefaultRegistry, interval)
|
||||||
|
|
||||||
return startFn, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func startGraphiteStats(l *logrus.Logger, i time.Duration, c *config.C, configTest bool) error {
|
func startGraphiteStats(l *logrus.Logger, i time.Duration, c *config.C, configTest bool) error {
|
||||||
@@ -79,18 +78,12 @@ func startGraphiteStats(l *logrus.Logger, i time.Duration, c *config.C, configTe
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func startPrometheusStats(l *logrus.Logger, i time.Duration, c *config.C, buildVersion string, configTest bool) (func(), error) {
|
func startPrometheusStats(l *logrus.Logger, i time.Duration, c *config.C, listen, buildVersion string, configTest bool) (statsHandlerFunc, error) {
|
||||||
namespace := c.GetString("stats.namespace", "")
|
namespace := c.GetString("stats.namespace", "")
|
||||||
subsystem := c.GetString("stats.subsystem", "")
|
subsystem := c.GetString("stats.subsystem", "")
|
||||||
|
|
||||||
listen := c.GetString("stats.listen", "")
|
|
||||||
if listen == "" {
|
if listen == "" {
|
||||||
return nil, fmt.Errorf("stats.listen should not be empty")
|
return nil, fmt.Errorf("http.listen or stats.listen must be defined to use Prometheus stats")
|
||||||
}
|
|
||||||
|
|
||||||
path := c.GetString("stats.path", "")
|
|
||||||
if path == "" {
|
|
||||||
return nil, fmt.Errorf("stats.path should not be empty")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pr := prometheus.NewRegistry()
|
pr := prometheus.NewRegistry()
|
||||||
@@ -114,14 +107,13 @@ func startPrometheusStats(l *logrus.Logger, i time.Duration, c *config.C, buildV
|
|||||||
pr.MustRegister(g)
|
pr.MustRegister(g)
|
||||||
g.Set(1)
|
g.Set(1)
|
||||||
|
|
||||||
var startFn func()
|
var startHandler statsHandlerFunc
|
||||||
if !configTest {
|
if !configTest {
|
||||||
startFn = func() {
|
startHandler = func(listen, path string) http.Handler {
|
||||||
l.Infof("Prometheus stats listening on %s at %s", listen, path)
|
l.Infof("Prometheus stats listening on %s at %s", listen, path)
|
||||||
http.Handle(path, promhttp.HandlerFor(pr, promhttp.HandlerOpts{ErrorLog: l}))
|
return promhttp.HandlerFor(pr, promhttp.HandlerOpts{ErrorLog: l})
|
||||||
log.Fatal(http.ListenAndServe(listen, nil))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return startFn, nil
|
return startHandler, nil
|
||||||
}
|
}
|
||||||
|
|||||||
27
udp/conn.go
27
udp/conn.go
@@ -1,6 +1,7 @@
|
|||||||
package udp
|
package udp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/slackhq/nebula/config"
|
||||||
"github.com/slackhq/nebula/firewall"
|
"github.com/slackhq/nebula/firewall"
|
||||||
"github.com/slackhq/nebula/header"
|
"github.com/slackhq/nebula/header"
|
||||||
)
|
)
|
||||||
@@ -18,3 +19,29 @@ type EncReader func(
|
|||||||
q int,
|
q int,
|
||||||
localCache firewall.ConntrackCache,
|
localCache firewall.ConntrackCache,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Conn interface {
|
||||||
|
Rebind() error
|
||||||
|
LocalAddr() (*Addr, error)
|
||||||
|
ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int)
|
||||||
|
WriteTo(b []byte, addr *Addr) error
|
||||||
|
ReloadConfig(c *config.C)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NoopConn struct{}
|
||||||
|
|
||||||
|
func (NoopConn) Rebind() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (NoopConn) LocalAddr() (*Addr, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
func (NoopConn) ListenOut(_ EncReader, _ LightHouseHandlerFunc, _ *firewall.ConntrackCacheTicker, _ int) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (NoopConn) WriteTo(_ []byte, _ *Addr) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (NoopConn) ReloadConfig(_ *config.C) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,6 +34,6 @@ func NewListenConfig(multi bool) net.ListenConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) Rebind() error {
|
func (u *GenericConn) Rebind() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func NewListenConfig(multi bool) net.ListenConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) Rebind() error {
|
func (u *GenericConn) Rebind() error {
|
||||||
file, err := u.File()
|
file, err := u.File()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -36,6 +36,6 @@ func NewListenConfig(multi bool) net.ListenConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) Rebind() error {
|
func (u *GenericConn) Rebind() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,30 +18,30 @@ import (
|
|||||||
"github.com/slackhq/nebula/header"
|
"github.com/slackhq/nebula/header"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Conn struct {
|
type GenericConn struct {
|
||||||
*net.UDPConn
|
*net.UDPConn
|
||||||
l *logrus.Logger
|
l *logrus.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewListener(l *logrus.Logger, ip net.IP, port int, multi bool, batch int) (*Conn, error) {
|
func NewListener(l *logrus.Logger, ip net.IP, port int, multi bool, batch int) (Conn, error) {
|
||||||
lc := NewListenConfig(multi)
|
lc := NewListenConfig(multi)
|
||||||
pc, err := lc.ListenPacket(context.TODO(), "udp", net.JoinHostPort(ip.String(), fmt.Sprintf("%v", port)))
|
pc, err := lc.ListenPacket(context.TODO(), "udp", net.JoinHostPort(ip.String(), fmt.Sprintf("%v", port)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if uc, ok := pc.(*net.UDPConn); ok {
|
if uc, ok := pc.(*net.UDPConn); ok {
|
||||||
return &Conn{UDPConn: uc, l: l}, nil
|
return &GenericConn{UDPConn: uc, l: l}, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("Unexpected PacketConn: %T %#v", pc, pc)
|
return nil, fmt.Errorf("Unexpected PacketConn: %T %#v", pc, pc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uc *Conn) WriteTo(b []byte, addr *Addr) error {
|
func (u *GenericConn) WriteTo(b []byte, addr *Addr) error {
|
||||||
_, err := uc.UDPConn.WriteToUDP(b, &net.UDPAddr{IP: addr.IP, Port: int(addr.Port)})
|
_, err := u.UDPConn.WriteToUDP(b, &net.UDPAddr{IP: addr.IP, Port: int(addr.Port)})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uc *Conn) LocalAddr() (*Addr, error) {
|
func (u *GenericConn) LocalAddr() (*Addr, error) {
|
||||||
a := uc.UDPConn.LocalAddr()
|
a := u.UDPConn.LocalAddr()
|
||||||
|
|
||||||
switch v := a.(type) {
|
switch v := a.(type) {
|
||||||
case *net.UDPAddr:
|
case *net.UDPAddr:
|
||||||
@@ -55,11 +55,11 @@ func (uc *Conn) LocalAddr() (*Addr, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) ReloadConfig(c *config.C) {
|
func (u *GenericConn) ReloadConfig(c *config.C) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUDPStatsEmitter(udpConns []*Conn) func() {
|
func NewUDPStatsEmitter(udpConns []Conn) func() {
|
||||||
// No UDP stats for non-linux
|
// No UDP stats for non-linux
|
||||||
return func() {}
|
return func() {}
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ type rawMessage struct {
|
|||||||
Len uint32
|
Len uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int) {
|
func (u *GenericConn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int) {
|
||||||
plaintext := make([]byte, MTU)
|
plaintext := make([]byte, MTU)
|
||||||
buffer := make([]byte, MTU)
|
buffer := make([]byte, MTU)
|
||||||
h := &header.H{}
|
h := &header.H{}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
|
|
||||||
//TODO: make it support reload as best you can!
|
//TODO: make it support reload as best you can!
|
||||||
|
|
||||||
type Conn struct {
|
type StdConn struct {
|
||||||
sysFd int
|
sysFd int
|
||||||
l *logrus.Logger
|
l *logrus.Logger
|
||||||
batch int
|
batch int
|
||||||
@@ -45,7 +45,7 @@ const (
|
|||||||
|
|
||||||
type _SK_MEMINFO [_SK_MEMINFO_VARS]uint32
|
type _SK_MEMINFO [_SK_MEMINFO_VARS]uint32
|
||||||
|
|
||||||
func NewListener(l *logrus.Logger, ip net.IP, port int, multi bool, batch int) (*Conn, error) {
|
func NewListener(l *logrus.Logger, ip net.IP, port int, multi bool, batch int) (Conn, error) {
|
||||||
syscall.ForkLock.RLock()
|
syscall.ForkLock.RLock()
|
||||||
fd, err := unix.Socket(unix.AF_INET6, unix.SOCK_DGRAM, unix.IPPROTO_UDP)
|
fd, err := unix.Socket(unix.AF_INET6, unix.SOCK_DGRAM, unix.IPPROTO_UDP)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -77,30 +77,30 @@ func NewListener(l *logrus.Logger, ip net.IP, port int, multi bool, batch int) (
|
|||||||
//v, err := unix.GetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_INCOMING_CPU)
|
//v, err := unix.GetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_INCOMING_CPU)
|
||||||
//l.Println(v, err)
|
//l.Println(v, err)
|
||||||
|
|
||||||
return &Conn{sysFd: fd, l: l, batch: batch}, err
|
return &StdConn{sysFd: fd, l: l, batch: batch}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) Rebind() error {
|
func (u *StdConn) Rebind() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) SetRecvBuffer(n int) error {
|
func (u *StdConn) SetRecvBuffer(n int) error {
|
||||||
return unix.SetsockoptInt(u.sysFd, unix.SOL_SOCKET, unix.SO_RCVBUFFORCE, n)
|
return unix.SetsockoptInt(u.sysFd, unix.SOL_SOCKET, unix.SO_RCVBUFFORCE, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) SetSendBuffer(n int) error {
|
func (u *StdConn) SetSendBuffer(n int) error {
|
||||||
return unix.SetsockoptInt(u.sysFd, unix.SOL_SOCKET, unix.SO_SNDBUFFORCE, n)
|
return unix.SetsockoptInt(u.sysFd, unix.SOL_SOCKET, unix.SO_SNDBUFFORCE, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) GetRecvBuffer() (int, error) {
|
func (u *StdConn) GetRecvBuffer() (int, error) {
|
||||||
return unix.GetsockoptInt(int(u.sysFd), unix.SOL_SOCKET, unix.SO_RCVBUF)
|
return unix.GetsockoptInt(int(u.sysFd), unix.SOL_SOCKET, unix.SO_RCVBUF)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) GetSendBuffer() (int, error) {
|
func (u *StdConn) GetSendBuffer() (int, error) {
|
||||||
return unix.GetsockoptInt(int(u.sysFd), unix.SOL_SOCKET, unix.SO_SNDBUF)
|
return unix.GetsockoptInt(int(u.sysFd), unix.SOL_SOCKET, unix.SO_SNDBUF)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) LocalAddr() (*Addr, error) {
|
func (u *StdConn) LocalAddr() (*Addr, error) {
|
||||||
sa, err := unix.Getsockname(u.sysFd)
|
sa, err := unix.Getsockname(u.sysFd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -119,7 +119,7 @@ func (u *Conn) LocalAddr() (*Addr, error) {
|
|||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int) {
|
func (u *StdConn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int) {
|
||||||
plaintext := make([]byte, MTU)
|
plaintext := make([]byte, MTU)
|
||||||
h := &header.H{}
|
h := &header.H{}
|
||||||
fwPacket := &firewall.Packet{}
|
fwPacket := &firewall.Packet{}
|
||||||
@@ -150,7 +150,7 @@ func (u *Conn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) ReadSingle(msgs []rawMessage) (int, error) {
|
func (u *StdConn) ReadSingle(msgs []rawMessage) (int, error) {
|
||||||
for {
|
for {
|
||||||
n, _, err := unix.Syscall6(
|
n, _, err := unix.Syscall6(
|
||||||
unix.SYS_RECVMSG,
|
unix.SYS_RECVMSG,
|
||||||
@@ -171,7 +171,7 @@ func (u *Conn) ReadSingle(msgs []rawMessage) (int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) ReadMulti(msgs []rawMessage) (int, error) {
|
func (u *StdConn) ReadMulti(msgs []rawMessage) (int, error) {
|
||||||
for {
|
for {
|
||||||
n, _, err := unix.Syscall6(
|
n, _, err := unix.Syscall6(
|
||||||
unix.SYS_RECVMMSG,
|
unix.SYS_RECVMMSG,
|
||||||
@@ -191,7 +191,7 @@ func (u *Conn) ReadMulti(msgs []rawMessage) (int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) WriteTo(b []byte, addr *Addr) error {
|
func (u *StdConn) WriteTo(b []byte, addr *Addr) error {
|
||||||
|
|
||||||
var rsa unix.RawSockaddrInet6
|
var rsa unix.RawSockaddrInet6
|
||||||
rsa.Family = unix.AF_INET6
|
rsa.Family = unix.AF_INET6
|
||||||
@@ -221,7 +221,7 @@ func (u *Conn) WriteTo(b []byte, addr *Addr) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) ReloadConfig(c *config.C) {
|
func (u *StdConn) ReloadConfig(c *config.C) {
|
||||||
b := c.GetInt("listen.read_buffer", 0)
|
b := c.GetInt("listen.read_buffer", 0)
|
||||||
if b > 0 {
|
if b > 0 {
|
||||||
err := u.SetRecvBuffer(b)
|
err := u.SetRecvBuffer(b)
|
||||||
@@ -253,7 +253,7 @@ func (u *Conn) ReloadConfig(c *config.C) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) getMemInfo(meminfo *_SK_MEMINFO) error {
|
func (u *StdConn) getMemInfo(meminfo *_SK_MEMINFO) error {
|
||||||
var vallen uint32 = 4 * _SK_MEMINFO_VARS
|
var vallen uint32 = 4 * _SK_MEMINFO_VARS
|
||||||
_, _, err := unix.Syscall6(unix.SYS_GETSOCKOPT, uintptr(u.sysFd), uintptr(unix.SOL_SOCKET), uintptr(unix.SO_MEMINFO), uintptr(unsafe.Pointer(meminfo)), uintptr(unsafe.Pointer(&vallen)), 0)
|
_, _, err := unix.Syscall6(unix.SYS_GETSOCKOPT, uintptr(u.sysFd), uintptr(unix.SOL_SOCKET), uintptr(unix.SO_MEMINFO), uintptr(unsafe.Pointer(meminfo)), uintptr(unsafe.Pointer(&vallen)), 0)
|
||||||
if err != 0 {
|
if err != 0 {
|
||||||
@@ -262,11 +262,11 @@ func (u *Conn) getMemInfo(meminfo *_SK_MEMINFO) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUDPStatsEmitter(udpConns []*Conn) func() {
|
func NewUDPStatsEmitter(udpConns []Conn) func() {
|
||||||
// Check if our kernel supports SO_MEMINFO before registering the gauges
|
// Check if our kernel supports SO_MEMINFO before registering the gauges
|
||||||
var udpGauges [][_SK_MEMINFO_VARS]metrics.Gauge
|
var udpGauges [][_SK_MEMINFO_VARS]metrics.Gauge
|
||||||
var meminfo _SK_MEMINFO
|
var meminfo _SK_MEMINFO
|
||||||
if err := udpConns[0].getMemInfo(&meminfo); err == nil {
|
if err := udpConns[0].(*StdConn).getMemInfo(&meminfo); err == nil {
|
||||||
udpGauges = make([][_SK_MEMINFO_VARS]metrics.Gauge, len(udpConns))
|
udpGauges = make([][_SK_MEMINFO_VARS]metrics.Gauge, len(udpConns))
|
||||||
for i := range udpConns {
|
for i := range udpConns {
|
||||||
udpGauges[i] = [_SK_MEMINFO_VARS]metrics.Gauge{
|
udpGauges[i] = [_SK_MEMINFO_VARS]metrics.Gauge{
|
||||||
@@ -285,7 +285,7 @@ func NewUDPStatsEmitter(udpConns []*Conn) func() {
|
|||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
for i, gauges := range udpGauges {
|
for i, gauges := range udpGauges {
|
||||||
if err := udpConns[i].getMemInfo(&meminfo); err == nil {
|
if err := udpConns[i].(*StdConn).getMemInfo(&meminfo); err == nil {
|
||||||
for j := 0; j < _SK_MEMINFO_VARS; j++ {
|
for j := 0; j < _SK_MEMINFO_VARS; j++ {
|
||||||
gauges[j].Update(int64(meminfo[j]))
|
gauges[j].Update(int64(meminfo[j]))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type rawMessage struct {
|
|||||||
Len uint32
|
Len uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) {
|
func (u *StdConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) {
|
||||||
msgs := make([]rawMessage, n)
|
msgs := make([]rawMessage, n)
|
||||||
buffers := make([][]byte, n)
|
buffers := make([][]byte, n)
|
||||||
names := make([][]byte, n)
|
names := make([][]byte, n)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type rawMessage struct {
|
|||||||
Pad0 [4]byte
|
Pad0 [4]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) {
|
func (u *StdConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) {
|
||||||
msgs := make([]rawMessage, n)
|
msgs := make([]rawMessage, n)
|
||||||
buffers := make([][]byte, n)
|
buffers := make([][]byte, n)
|
||||||
names := make([][]byte, n)
|
names := make([][]byte, n)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (u *Packet) Copy() *Packet {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
type Conn struct {
|
type TesterConn struct {
|
||||||
Addr *Addr
|
Addr *Addr
|
||||||
|
|
||||||
RxPackets chan *Packet // Packets to receive into nebula
|
RxPackets chan *Packet // Packets to receive into nebula
|
||||||
@@ -45,8 +45,8 @@ type Conn struct {
|
|||||||
l *logrus.Logger
|
l *logrus.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewListener(l *logrus.Logger, ip net.IP, port int, _ bool, _ int) (*Conn, error) {
|
func NewListener(l *logrus.Logger, ip net.IP, port int, _ bool, _ int) (Conn, error) {
|
||||||
return &Conn{
|
return &TesterConn{
|
||||||
Addr: &Addr{ip, uint16(port)},
|
Addr: &Addr{ip, uint16(port)},
|
||||||
RxPackets: make(chan *Packet, 10),
|
RxPackets: make(chan *Packet, 10),
|
||||||
TxPackets: make(chan *Packet, 10),
|
TxPackets: make(chan *Packet, 10),
|
||||||
@@ -57,7 +57,7 @@ func NewListener(l *logrus.Logger, ip net.IP, port int, _ bool, _ int) (*Conn, e
|
|||||||
// Send will place a UdpPacket onto the receive queue for nebula to consume
|
// Send will place a UdpPacket onto the receive queue for nebula to consume
|
||||||
// this is an encrypted packet or a handshake message in most cases
|
// this is an encrypted packet or a handshake message in most cases
|
||||||
// packets were transmitted from another nebula node, you can send them with Tun.Send
|
// packets were transmitted from another nebula node, you can send them with Tun.Send
|
||||||
func (u *Conn) Send(packet *Packet) {
|
func (u *TesterConn) Send(packet *Packet) {
|
||||||
h := &header.H{}
|
h := &header.H{}
|
||||||
if err := h.Parse(packet.Data); err != nil {
|
if err := h.Parse(packet.Data); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -74,7 +74,7 @@ func (u *Conn) Send(packet *Packet) {
|
|||||||
// Get will pull a UdpPacket from the transmit queue
|
// Get will pull a UdpPacket from the transmit queue
|
||||||
// nebula meant to send this message on the network, it will be encrypted
|
// nebula meant to send this message on the network, it will be encrypted
|
||||||
// packets were ingested from the tun side (in most cases), you can send them with Tun.Send
|
// packets were ingested from the tun side (in most cases), you can send them with Tun.Send
|
||||||
func (u *Conn) Get(block bool) *Packet {
|
func (u *TesterConn) Get(block bool) *Packet {
|
||||||
if block {
|
if block {
|
||||||
return <-u.TxPackets
|
return <-u.TxPackets
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ func (u *Conn) Get(block bool) *Packet {
|
|||||||
// Below this is boilerplate implementation to make nebula actually work
|
// Below this is boilerplate implementation to make nebula actually work
|
||||||
//********************************************************************************************************************//
|
//********************************************************************************************************************//
|
||||||
|
|
||||||
func (u *Conn) WriteTo(b []byte, addr *Addr) error {
|
func (u *TesterConn) WriteTo(b []byte, addr *Addr) error {
|
||||||
p := &Packet{
|
p := &Packet{
|
||||||
Data: make([]byte, len(b), len(b)),
|
Data: make([]byte, len(b), len(b)),
|
||||||
FromIp: make([]byte, 16),
|
FromIp: make([]byte, 16),
|
||||||
@@ -108,7 +108,7 @@ func (u *Conn) WriteTo(b []byte, addr *Addr) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int) {
|
func (u *TesterConn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int) {
|
||||||
plaintext := make([]byte, MTU)
|
plaintext := make([]byte, MTU)
|
||||||
h := &header.H{}
|
h := &header.H{}
|
||||||
fwPacket := &firewall.Packet{}
|
fwPacket := &firewall.Packet{}
|
||||||
@@ -126,17 +126,17 @@ func (u *Conn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) ReloadConfig(*config.C) {}
|
func (u *TesterConn) ReloadConfig(*config.C) {}
|
||||||
|
|
||||||
func NewUDPStatsEmitter(_ []*Conn) func() {
|
func NewUDPStatsEmitter(_ []Conn) func() {
|
||||||
// No UDP stats for non-linux
|
// No UDP stats for non-linux
|
||||||
return func() {}
|
return func() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) LocalAddr() (*Addr, error) {
|
func (u *TesterConn) LocalAddr() (*Addr, error) {
|
||||||
return u.Addr, nil
|
return u.Addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) Rebind() error {
|
func (u *TesterConn) Rebind() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,6 @@ func NewListenConfig(multi bool) net.ListenConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Conn) Rebind() error {
|
func (u *GenericConn) Rebind() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user