diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..26383de --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,20 @@ +# Changes here need the maintainer's review: these parts run with system rights, +# decide what leaves the device, or decide what gets installed on it. + +# the service and who may talk to it +/core/cmd/mistgate-clientd/ @limeflash +/core/internal/ipc/ @limeflash + +# kill switch +/core/internal/firewall/ @limeflash + +# adapter, routes, DNS, tunnel engines +/core/internal/netcfg/ @limeflash +/core/internal/engine/ @limeflash + +# updates and signing +/ui/src-tauri/tauri.conf.json @limeflash +/ui/tools/ @limeflash + +# CI and repository rules +/.github/ @limeflash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74e5e03..35842bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,26 @@ jobs: - run: go vet ./... - run: go test ./... + # No macOS engine or service yet: this keeps the shared packages building and their tests passing there. + # cmd/mistgate-clientd does not build for darwin; widen to ./... when it does. + service-macos: + name: service (Go, macOS) + runs-on: macos-15 + defaults: + run: + working-directory: core + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-go@v5 + with: + go-version-file: core/go.mod + cache-dependency-path: core/go.sum + - run: go vet ./internal/... + - run: go build ./internal/... + - run: go test ./internal/... + window: name: window (TypeScript, Rust) runs-on: windows-latest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3037b96 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,57 @@ +# Contributing + +Thanks for wanting to help. This is a VPN client: part of it runs with system rights and all of it sits between a +person and a network that may be hostile, so changes are reviewed slowly and in small pieces. + +## Before you start + +For anything larger than a fix, open an issue first and say what you want to change. It saves you from writing +something that cannot be taken in. + +Security problems do not go into public issues: use "Report a vulnerability" on the repository's Security tab. + +Never put real subscription links, server addresses, domains, keys or logs with them into issues, pull requests, +commits or tests. Use `example.com`, `192.0.2.0/24`, `2001:db8::/32`. + +## Pull requests + +- **Small, one topic each.** A rough limit is 500 changed lines of code, tests aside. A large piece of work comes as a + series of pull requests that each build and pass on their own. +- **No refactoring mixed with behaviour.** Moving or renaming code is one pull request, changing what it does is + another. +- **Windows behaviour stays as it is** unless the change is the point of the pull request and its description says so. + Code shared between platforms counts: say what changes for Windows, even if the answer is "nothing". +- **Tests.** New behaviour and fixed bugs come with tests. `go vet ./...` and `go test ./...` in `core/`, + `pnpm exec tsc --noEmit` in `ui/`, `cargo check --locked` in `ui/src-tauri/` must pass; CI runs them on Windows and + the service's packages on macOS as well. +- **Say how it was checked** on a real machine: system and version, which protocols, what you looked at. "Works for + me" without that is not enough for anything that touches the network. +- **No tool leftovers**: editor and agent folders, code indexes, plans written for an assistant, local notes, build + output. +- **New dependencies** are discussed first: what for, its licence, what the alternative is. +- **Based on the current `main`**, commit messages in English, one line saying what changed, in the style of + `git log --oneline`. + +## Parts that need the maintainer + +`.github/CODEOWNERS` lists them: the service and its IPC (who may give it commands), the kill switch, the network +layer and tunnel engines, updates and signing, CI. Changes there are welcome but get a separate, stricter review; +keep them apart from everything else. + +These stay with the maintainers and are not accepted in pull requests: code signing and notarization, the release +builds and their publication, the update signing key and the public key in `ui/src-tauri/tauri.conf.json`, CI secrets. + +## Licence and sign-off + +The project is under AGPL-3.0 (`LICENSE`); your contribution is taken under the same licence. Every commit carries a +sign-off line (`git commit -s`), by which you state the +[Developer Certificate of Origin 1.1](https://developercertificate.org/): you wrote the change or otherwise have the +right to submit it under this licence. If you write code as part of your job, make sure your employer lets you +contribute it. + +Code copied or adapted from another project is named in the pull request, with its licence, and keeps its notices. + +## Code written with AI tools + +Allowed, and it must be said: note in the pull request which parts an assistant wrote. You answer for such code as +for your own - you have read it, you understand it, you tested it, and the sign-off covers it. diff --git a/core/internal/auto/asn_test.go b/core/internal/auto/asn_test.go index b98c1f3..5e940fe 100644 --- a/core/internal/auto/asn_test.go +++ b/core/internal/auto/asn_test.go @@ -16,6 +16,7 @@ func TestASNNet(t *testing.T) { if again.ASNNet("s1") != "" { t.Fatal("an unknown network left the old note") } + again.Flush() // the change above started a save of its own: it must be over before the directory goes var none *Memory // a nil memory remembers nothing none.SetASNNet("s1", "net-a") if none.ASNNet("s1") != "" { diff --git a/core/internal/engine/gvisor_bridge_windows.go b/core/internal/engine/gvisor_bridge_windows.go index bd8a317..3db9904 100644 --- a/core/internal/engine/gvisor_bridge_windows.go +++ b/core/internal/engine/gvisor_bridge_windows.go @@ -1038,11 +1038,6 @@ var directIPv6 = func() bool { // a variable for the tests return ok == 1 } -func directAddressAllowed(address netip.Addr) bool { - return address.IsValid() && !address.IsPrivate() && !address.IsLoopback() && !address.IsLinkLocalUnicast() && - !address.IsLinkLocalMulticast() && !address.IsMulticast() && !address.IsUnspecified() -} - // hasGlobalIPv6 says whether the interface has an address that IPv6 on the Internet can use. func hasGlobalIPv6(index uint32) bool { iface, err := net.InterfaceByIndex(int(index)) diff --git a/core/internal/engine/site.go b/core/internal/engine/site.go index 409de4b..08b3594 100644 --- a/core/internal/engine/site.go +++ b/core/internal/engine/site.go @@ -579,3 +579,9 @@ func (entry dnsEntry) hasLiveName(now time.Time) bool { } return false } + +// directAddressAllowed says whether an address may leave past the tunnel at all: only public unicast ones. +func directAddressAllowed(address netip.Addr) bool { + return address.IsValid() && !address.IsPrivate() && !address.IsLoopback() && !address.IsLinkLocalUnicast() && + !address.IsLinkLocalMulticast() && !address.IsMulticast() && !address.IsUnspecified() +} diff --git a/core/internal/firewall/blocker.go b/core/internal/firewall/blocker.go index f5d7e49..1c7b848 100644 --- a/core/internal/firewall/blocker.go +++ b/core/internal/firewall/blocker.go @@ -1,3 +1,5 @@ +//go:build windows + /* SPDX-License-Identifier: MIT * * Copyright (C) 2019-2026 WireGuard LLC. All Rights Reserved. diff --git a/core/internal/firewall/helpers.go b/core/internal/firewall/helpers.go index 4adedaf..53ec1dc 100644 --- a/core/internal/firewall/helpers.go +++ b/core/internal/firewall/helpers.go @@ -1,3 +1,5 @@ +//go:build windows + /* SPDX-License-Identifier: MIT * * Copyright (C) 2019-2026 WireGuard LLC. All Rights Reserved. diff --git a/core/internal/firewall/lan.go b/core/internal/firewall/lan.go index 625072c..638f4d7 100644 --- a/core/internal/firewall/lan.go +++ b/core/internal/firewall/lan.go @@ -1,3 +1,5 @@ +//go:build windows + /* SPDX-License-Identifier: MIT * * Mistgate's addition to the WireGuard for Windows firewall package (see README.md here). diff --git a/core/internal/firewall/rules.go b/core/internal/firewall/rules.go index d265477..61e7a8f 100644 --- a/core/internal/firewall/rules.go +++ b/core/internal/firewall/rules.go @@ -1,3 +1,5 @@ +//go:build windows + /* SPDX-License-Identifier: MIT * * Copyright (C) 2019-2026 WireGuard LLC. All Rights Reserved. diff --git a/core/internal/firewall/types_windows_32.go b/core/internal/firewall/types_windows_32.go index dc4ddeb..07ddc8e 100644 --- a/core/internal/firewall/types_windows_32.go +++ b/core/internal/firewall/types_windows_32.go @@ -1,4 +1,4 @@ -//go:build 386 || arm +//go:build windows && (386 || arm) /* SPDX-License-Identifier: MIT * diff --git a/core/internal/firewall/types_windows_64.go b/core/internal/firewall/types_windows_64.go index 176699f..c9a2a7b 100644 --- a/core/internal/firewall/types_windows_64.go +++ b/core/internal/firewall/types_windows_64.go @@ -1,4 +1,4 @@ -//go:build amd64 || arm64 +//go:build windows && (amd64 || arm64) /* SPDX-License-Identifier: MIT * diff --git a/core/internal/ipc/server_other.go b/core/internal/ipc/server_other.go new file mode 100644 index 0000000..e8964bc --- /dev/null +++ b/core/internal/ipc/server_other.go @@ -0,0 +1,13 @@ +//go:build !windows + +package ipc + +import ( + "context" + "errors" +) + +// runPipeServer exists so the package builds and its tests run off Windows; there is no transport there yet. +func runPipeServer(context.Context, *Server) error { + return errors.New("ipc: no transport on this platform") +}