-
Notifications
You must be signed in to change notification settings - Fork 0
feat(networking): add captive-portal helper for tailnet-owned DNS #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Bad3r
wants to merge
63
commits into
main
Choose a base branch
from
feat/captive-portal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
7a88bd1
feat(networking): add captive-portal helper for tailnet-owned DNS
Bad3r 7cee48b
fix(captive-portal): keep the first prefs snapshot and survive an unr…
Bad3r 1a45cb3
fix(captive-portal): classify each canary on its own answer
Bad3r 45e7d1a
fix(captive-portal): give each outcome its own exit status and never …
Bad3r dfad85e
docs(networking): scope the resolver chain to the host that runs dnsmasq
Bad3r db14441
test(captive-portal): pin classification and restore behaviour under …
Bad3r 327abed
fix(captive-portal): return the documented status for a gateway guess
Bad3r 87d1318
docs(captive-portal): describe the resolver the helper actually displ…
Bad3r 3901756
fix(captive-portal): print the gateway guess instead of opening it
Bad3r 8c34353
fix(tailscale): declare the operator user for non-root state changes
Bad3r c232c92
fix(captive-portal): stop at a refused tailscaled change instead of f…
Bad3r 499e343
fix(captive-portal): put DNS back before the run state, and never sta…
Bad3r 7e8f831
test(captive-portal): isolate a refused subcommand and cover the path…
Bad3r 7198ed9
fix(captive-portal): report a refused `tailscale up` as itself, not t…
Bad3r b7560a8
test(captive-portal): pin what --down changes and what --restore owes…
Bad3r 23f44cd
fix(captive-portal): keep one snapshot path across the sudo boundary
Bad3r 324dbec
fix(captive-portal): stop leaking the probe payload on every run
Bad3r 98f077d
test(captive-portal): make the hijack-range scenario actually reach i…
Bad3r 86eafeb
fix(captive-portal): stop releasing DNS when nothing recorded what to…
Bad3r 84386da
fix(captive-portal): keep nmcli's and rm's exit codes out of the stat…
Bad3r d01f47b
fix(captive-portal): stop classifying a canary from a transfer that f…
Bad3r 506ae29
fix(captive-portal): stop reporting DNS as handed back on the run tha…
Bad3r 988a5a5
fix(captive-portal): tell an unknown --device apart from one with no …
Bad3r 0f0a722
feat(captive-portal): declare package meta
Bad3r 424545f
fix(captive-portal): take the sign-in target from a link, not the fir…
Bad3r 7677a19
feat(captive-portal): detect the proxy portal that answers 511
Bad3r e49413c
fix(captive-portal): keep mktemp's exit code out of the status table
Bad3r 89d0e41
fix(captive-portal): pin the probe's destination past any inherited p…
Bad3r 9d26dfd
fix(captive-portal): guard the other bare unlink on the refusal path
Bad3r 00b9bdd
fix(captive-portal): stop calling a loopback answer a portal
Bad3r 039f6da
fix(captive-portal): only ever open an http or https target
Bad3r 3665b9a
fix(captive-portal): stop a portal's own page from clearing the canary
Bad3r 2da650c
test(captive-portal): cover the reload failure the run is meant to su…
Bad3r b3413e8
fix(captive-portal): anchor the url= alternative and close the w3.org…
Bad3r 55aea8c
fix(captive-portal): bound the body a hostile portal can write
Bad3r a5a475b
fix(captive-portal): anchor every attribute name, not just url=
Bad3r 38b5e12
fix(captive-portal): refuse --probe and --restore together instead of…
Bad3r ab108b3
fix(captive-portal): declare the license the repository actually grants
Bad3r 0fa66d4
fix(captive-portal): refuse --down where nothing stops the node
Bad3r 435f9bb
docs(captive-portal): record the flag pairings that are now usage errors
Bad3r 9a5bfec
fix(captive-portal): drop a canary that resolves to this machine
Bad3r 28eb90a
fix(captive-portal): let a submit target outrank any other link on th…
Bad3r 2e114a5
fix(captive-portal): decode the entity HTML requires in an attribute …
Bad3r 6c27bf1
fix(captive-portal): let only the canary that expects no payload be c…
Bad3r 8210588
fix(captive-portal): create the scratch file before anything is released
Bad3r 4043c3a
test(captive-portal): pin --resolve, the flag the whole classificatio…
Bad3r d1b37f4
fix(captive-portal): give the meta refresh its own tier ahead of a pl…
Bad3r cc0d5c4
fix(captive-portal): stop reporting every tailscaled failure as a ref…
Bad3r bca36ce
test(captive-portal): make the tailscale stub stateful so --down can …
Bad3r ca8e324
fix(captive-portal): refuse to write the snapshot through a symlinked…
Bad3r fe46ce7
test(captive-portal): pin @resolver, dig's half of the --resolve cont…
Bad3r 7df8b4c
fix(captive-portal): reject a redirect or extracted link that names t…
Bad3r 85082fd
fix(captive-portal): stop a stylesheet href from beating a relative f…
Bad3r d903108
docs(captive-portal): scope the exit-3 contract to when a gateway gue…
Bad3r 08b2cf2
docs(captive-portal): document the host check on Location and an extr…
Bad3r 2f23361
fix(captive-portal): refuse to read or unlink the snapshot through a …
Bad3r 7348ebb
fix(captive-portal): strip userinfo before matching a redirect or ext…
Bad3r f54f7e2
fix(captive-portal): strip <link> elements before extract_url reads t…
Bad3r 19f2911
Update captive-portal.sh
Bad3r a668adc
Update captive-portal.sh
Bad3r c9fcb65
Update captive-portal.sh
Bad3r f14c8a4
test(captive-portal): cover wrapped metadata and loopback aliases
Bad3r 0acca35
fix(captive-portal): reject control bytes in portal targets
Bad3r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| Package: captive-portal | ||
| Description: Sign in to a captive portal on a host whose DNS is claimed by Tailscale. | ||
| Homepage: https://github.com/Bad3r/nixos | ||
| Documentation: docs/networking/README.md | ||
| Repository: https://github.com/Bad3r/nixos | ||
|
|
||
| Summary: | ||
| * Releases DNS from Tailscale back to NetworkManager's dnsmasq so the access point's resolver answers again. | ||
| * Locates the sign-in page through the access point's own resolver and HTTP probes, then opens it. | ||
| * Restores the saved Tailscale DNS and run state once the portal accepts the session. | ||
|
|
||
| Options: | ||
| captive-portal: Release DNS, find the portal, and open it in the default browser. | ||
| captive-portal --probe: Report portal state and URL without changing DNS. | ||
| captive-portal --restore: Hand DNS back to Tailscale after signing in. | ||
| --device DEV: Inspect a specific device instead of the first connected wifi/ethernet. | ||
| --no-open: Print the portal URL instead of launching a browser. | ||
| --down: Stop Tailscale entirely rather than only releasing DNS. | ||
|
|
||
| Example Usage: | ||
| * `captive-portal --probe` -- Check whether the current network intercepts DNS or HTTP. | ||
| * `captive-portal` -- Sign in to a hotel or campus network. | ||
| * `captive-portal --restore` -- Return to tailnet DNS after the portal accepts the session. | ||
| */ | ||
| _: | ||
| let | ||
| CaptivePortalModule = | ||
| { | ||
| config, | ||
| lib, | ||
| pkgs, | ||
| ... | ||
| }: | ||
| let | ||
| cfg = config.programs.captive-portal.extended; | ||
| in | ||
| { | ||
| options.programs.captive-portal.extended = { | ||
| enable = lib.mkOption { | ||
| type = lib.types.bool; | ||
| default = false; | ||
| description = "Whether to enable captive-portal."; | ||
| }; | ||
|
|
||
| package = lib.mkPackageOption pkgs "captive-portal" { }; | ||
| }; | ||
|
|
||
| config = lib.mkIf cfg.enable { | ||
| environment.systemPackages = [ cfg.package ]; | ||
| }; | ||
| }; | ||
| in | ||
| { | ||
| flake.nixosModules.apps.captive-portal = CaptivePortalModule; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| _: | ||
| let | ||
| Overlay = | ||
| { config, lib, ... }: | ||
| let | ||
| cfg = config.programs.captive-portal.extended; | ||
| in | ||
| { | ||
| config = lib.mkIf cfg.enable { | ||
| nixpkgs.overlays = [ | ||
| (final: _prev: { | ||
| captive-portal = final.callPackage ../../packages/captive-portal { }; | ||
| }) | ||
| ]; | ||
| }; | ||
| }; | ||
| in | ||
| { | ||
| flake.customOverlays.captive-portal = Overlay; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.