mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-22 13:17:30 +00:00
Compare commits
21 Commits
v0.23.0-be
...
kradalby/b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
46ccfff71d | ||
![]() |
71607ae13c | ||
![]() |
8e26fcfeea | ||
![]() |
610223df67 | ||
![]() |
10a9eda893 | ||
![]() |
9a4c7e4446 | ||
![]() |
aba61ceb1b | ||
![]() |
1efb817acc | ||
![]() |
49952dda40 | ||
![]() |
53a08e5ab6 | ||
![]() |
52cce46cd8 | ||
![]() |
68669238f9 | ||
![]() |
0d6a25d6ee | ||
![]() |
e1416a72cb | ||
![]() |
cec46716b6 | ||
![]() |
fcd1183805 | ||
![]() |
ece907d878 | ||
![]() |
948d53f934 | ||
![]() |
06f07053eb | ||
![]() |
4ad3f3c484 | ||
![]() |
db7a4358e9 |
71
.github/workflows/build-docker-pr.yml
vendored
Normal file
71
.github/workflows/build-docker-pr.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: dorny/paths-filter@v3
|
||||
with:
|
||||
filters: |
|
||||
files:
|
||||
- '*.nix'
|
||||
- 'go.*'
|
||||
- '**/*.go'
|
||||
- 'integration_test/'
|
||||
- 'config-example.yaml'
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
|
||||
- name: Run build
|
||||
id: build
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
run: |
|
||||
nix build |& tee build-result
|
||||
BUILD_STATUS="${PIPESTATUS[0]}"
|
||||
|
||||
OLD_HASH=$(cat build-result | grep specified: | awk -F ':' '{print $2}' | sed 's/ //g')
|
||||
NEW_HASH=$(cat build-result | grep got: | awk -F ':' '{print $2}' | sed 's/ //g')
|
||||
|
||||
echo "OLD_HASH=$OLD_HASH" >> $GITHUB_OUTPUT
|
||||
echo "NEW_HASH=$NEW_HASH" >> $GITHUB_OUTPUT
|
||||
|
||||
exit $BUILD_STATUS
|
||||
|
||||
- name: Nix gosum diverging
|
||||
uses: actions/github-script@v6
|
||||
if: failure() && steps.build.outcome == 'failure'
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
github.rest.pulls.createReviewComment({
|
||||
pull_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: 'Nix build failed with wrong gosum, please update "vendorSha256" (${{ steps.build.outputs.OLD_HASH }}) for the "headscale" package in flake.nix with the new SHA: ${{ steps.build.outputs.NEW_HASH }}'
|
||||
})
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
with:
|
||||
name: headscale-linux
|
||||
path: result/bin/headscale
|
60
.github/workflows/build.yml
vendored
60
.github/workflows/build.yml
vendored
@@ -1,10 +1,7 @@
|
||||
name: Build
|
||||
name: Build Docker images for PRs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -31,41 +28,34 @@ jobs:
|
||||
- '**/*.go'
|
||||
- 'integration_test/'
|
||||
- 'config-example.yaml'
|
||||
- '.ko.yaml'
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
|
||||
- name: Run build
|
||||
# - uses: actions/github-script@v7
|
||||
# id: get_pr_data
|
||||
# with:
|
||||
# script: |
|
||||
# return (
|
||||
# await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
||||
# commit_sha: context.sha,
|
||||
# owner: context.repo.owner,
|
||||
# repo: context.repo.repo,
|
||||
# })
|
||||
# ).data[0];
|
||||
|
||||
# - name: Pull Request data
|
||||
# run: |
|
||||
# echo '${{steps.get_pr_data.outputs.result}}'
|
||||
|
||||
- name: Run ko build
|
||||
id: build
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
env:
|
||||
KO_DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/headscale
|
||||
# TAG_PR_NAME: pr-${{ fromJson(steps.get_pr_data.outputs.result).number }}
|
||||
TAG_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
nix build |& tee build-result
|
||||
BUILD_STATUS="${PIPESTATUS[0]}"
|
||||
|
||||
OLD_HASH=$(cat build-result | grep specified: | awk -F ':' '{print $2}' | sed 's/ //g')
|
||||
NEW_HASH=$(cat build-result | grep got: | awk -F ':' '{print $2}' | sed 's/ //g')
|
||||
|
||||
echo "OLD_HASH=$OLD_HASH" >> $GITHUB_OUTPUT
|
||||
echo "NEW_HASH=$NEW_HASH" >> $GITHUB_OUTPUT
|
||||
|
||||
exit $BUILD_STATUS
|
||||
|
||||
- name: Nix gosum diverging
|
||||
uses: actions/github-script@v6
|
||||
if: failure() && steps.build.outcome == 'failure'
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
github.rest.pulls.createReviewComment({
|
||||
pull_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: 'Nix build failed with wrong gosum, please update "vendorSha256" (${{ steps.build.outputs.OLD_HASH }}) for the "headscale" package in flake.nix with the new SHA: ${{ steps.build.outputs.NEW_HASH }}'
|
||||
})
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
with:
|
||||
name: headscale-linux
|
||||
path: result/bin/headscale
|
||||
nix develop --command -- ko build --sbom=none --tags=$TAG_SHA ./cmd/headscale
|
||||
|
@@ -27,8 +27,6 @@ builds:
|
||||
- -mod=readonly
|
||||
ldflags:
|
||||
- -s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=v{{.Version}}
|
||||
tags:
|
||||
- ts2019
|
||||
|
||||
archives:
|
||||
- id: golang-cross
|
||||
|
16
.ko.yaml
Normal file
16
.ko.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
defaultBaseImage: gcr.io/distroless/base-debian12:debug
|
||||
defaultPlatforms:
|
||||
- linux/arm64
|
||||
- linux/arm/v7
|
||||
- linux/amd64
|
||||
- linux/386
|
||||
|
||||
builds:
|
||||
- id: headscale
|
||||
main: ./cmd/headscale
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
flags:
|
||||
- -mod=readonly
|
||||
ldflags:
|
||||
- -s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=v{{.Git.ShortCommit}}
|
@@ -211,9 +211,8 @@ policy:
|
||||
# The mode can be "file" or "database" that defines
|
||||
# where the ACL policies are stored and read from.
|
||||
mode: file
|
||||
# If the mode is set to "file", the
|
||||
# path to a file containing ACL policies.
|
||||
# The file can be in YAML or HuJSON format.
|
||||
# If the mode is set to "file", the path to a
|
||||
# HuJSON file containing ACL policies.
|
||||
path: ""
|
||||
|
||||
## DNS
|
||||
|
6
flake.lock
generated
6
flake.lock
generated
@@ -20,11 +20,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1721466660,
|
||||
"narHash": "sha256-pFSxgSZqZ3h+5Du0KvEL1ccDZBwu4zvOil1zzrPNb3c=",
|
||||
"lastModified": 1723221148,
|
||||
"narHash": "sha256-7pjpeQlZUNQ4eeVntytU3jkw9dFK3k1Htgk2iuXjaD8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "6e14bbce7bea6c4efd7adfa88a40dac750d80100",
|
||||
"rev": "154bcb95ad51bc257c2ce4043a725de6ca700ef6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@@ -600,8 +600,11 @@ func (s *Suite) TestAutoApproveRoutes(c *check.C) {
|
||||
func TestEphemeralGarbageCollectorOrder(t *testing.T) {
|
||||
want := []types.NodeID{1, 3}
|
||||
got := []types.NodeID{}
|
||||
var mu sync.Mutex
|
||||
|
||||
e := NewEphemeralGarbageCollector(func(ni types.NodeID) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
got = append(got, ni)
|
||||
})
|
||||
go e.Start()
|
||||
@@ -617,6 +620,9 @@ func TestEphemeralGarbageCollectorOrder(t *testing.T) {
|
||||
|
||||
e.Close()
|
||||
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
if diff := cmp.Diff(want, got); diff != "" {
|
||||
t.Errorf("wrong nodes deleted, unexpected result (-want +got):\n%s", diff)
|
||||
}
|
||||
@@ -629,8 +635,8 @@ func TestEphemeralGarbageCollectorLoads(t *testing.T) {
|
||||
want := 1000
|
||||
|
||||
e := NewEphemeralGarbageCollector(func(ni types.NodeID) {
|
||||
defer mu.Unlock()
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
time.Sleep(time.Duration(generateRandomNumber(t, 3)) * time.Millisecond)
|
||||
got = append(got, ni)
|
||||
@@ -644,6 +650,10 @@ func TestEphemeralGarbageCollectorLoads(t *testing.T) {
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
e.Close()
|
||||
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
if len(got) != want {
|
||||
t.Errorf("expected %d, got %d", want, len(got))
|
||||
}
|
||||
|
@@ -125,10 +125,5 @@ func GetDERPMap(cfg types.DERPConfig) *tailcfg.DERPMap {
|
||||
|
||||
log.Trace().Interface("derpMap", derpMap).Msg("DERPMap loaded")
|
||||
|
||||
if len(derpMap.Regions) == 0 {
|
||||
log.Warn().
|
||||
Msg("DERP map is empty, not a single DERP map datasource was loaded correctly or contained a region")
|
||||
}
|
||||
|
||||
return derpMap
|
||||
}
|
||||
|
@@ -4,7 +4,9 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/juanfont/headscale/hscontrol/util"
|
||||
"github.com/juanfont/headscale/integration/dockertestutil"
|
||||
@@ -33,8 +35,7 @@ func TestDERPServerScenario(t *testing.T) {
|
||||
defer scenario.Shutdown()
|
||||
|
||||
spec := map[string]int{
|
||||
"user1": 10,
|
||||
// "user1": len(MustTestVersions),
|
||||
"user1": len(MustTestVersions),
|
||||
}
|
||||
|
||||
err = scenario.CreateHeadscaleEnv(
|
||||
@@ -44,24 +45,75 @@ func TestDERPServerScenario(t *testing.T) {
|
||||
hsic.WithEmbeddedDERPServerOnly(),
|
||||
hsic.WithTLS(),
|
||||
hsic.WithHostnameAsServerURL(),
|
||||
hsic.WithConfigEnv(map[string]string{
|
||||
"HEADSCALE_DERP_AUTO_UPDATE_ENABLED": "true",
|
||||
"HEADSCALE_DERP_UPDATE_FREQUENCY": "10s",
|
||||
}),
|
||||
)
|
||||
assertNoErrHeadscaleEnv(t, err)
|
||||
|
||||
allClients, err := scenario.ListTailscaleClients()
|
||||
assertNoErrListClients(t, err)
|
||||
|
||||
allIps, err := scenario.ListTailscaleClientsIPs()
|
||||
assertNoErrListClientIPs(t, err)
|
||||
|
||||
err = scenario.WaitForTailscaleSync()
|
||||
assertNoErrSync(t, err)
|
||||
|
||||
allHostnames, err := scenario.ListTailscaleClientsFQDNs()
|
||||
assertNoErrListFQDN(t, err)
|
||||
|
||||
for _, client := range allClients {
|
||||
status, err := client.Status()
|
||||
assertNoErr(t, err)
|
||||
|
||||
for _, health := range status.Health {
|
||||
if strings.Contains(health, "could not connect to any relay server") {
|
||||
t.Errorf("expected to be connected to derp, found: %s", health)
|
||||
}
|
||||
if strings.Contains(health, "could not connect to the 'Headscale Embedded DERP' relay server.") {
|
||||
t.Errorf("expected to be connected to derp, found: %s", health)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
success := pingDerpAllHelper(t, allClients, allHostnames)
|
||||
|
||||
t.Logf("%d successful pings out of %d", success, len(allClients)*len(allIps))
|
||||
for _, client := range allClients {
|
||||
status, err := client.Status()
|
||||
assertNoErr(t, err)
|
||||
|
||||
for _, health := range status.Health {
|
||||
if strings.Contains(health, "could not connect to any relay server") {
|
||||
t.Errorf("expected to be connected to derp, found: %s", health)
|
||||
}
|
||||
if strings.Contains(health, "could not connect to the 'Headscale Embedded DERP' relay server.") {
|
||||
t.Errorf("expected to be connected to derp, found: %s", health)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.Logf("Run 1: %d successful pings out of %d", success, len(allClients)*len(allHostnames))
|
||||
|
||||
// Let the DERP updater run a couple of times to ensure it does not
|
||||
// break the DERPMap.
|
||||
time.Sleep(30 * time.Second)
|
||||
|
||||
success = pingDerpAllHelper(t, allClients, allHostnames)
|
||||
|
||||
for _, client := range allClients {
|
||||
status, err := client.Status()
|
||||
assertNoErr(t, err)
|
||||
|
||||
for _, health := range status.Health {
|
||||
if strings.Contains(health, "could not connect to any relay server") {
|
||||
t.Errorf("expected to be connected to derp, found: %s", health)
|
||||
}
|
||||
if strings.Contains(health, "could not connect to the 'Headscale Embedded DERP' relay server.") {
|
||||
t.Errorf("expected to be connected to derp, found: %s", health)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.Logf("Run2: %d successful pings out of %d", success, len(allClients)*len(allHostnames))
|
||||
}
|
||||
|
||||
func (s *EmbeddedDERPServerScenario) CreateHeadscaleEnv(
|
||||
|
Reference in New Issue
Block a user