iFargle / headscale-webui

A simple Headscale web UI for small-scale deployments.
Other
619 stars 56 forks source link

Historic values from routing list are still clickable #108

Open technodrome opened 1 year ago

technodrome commented 1 year ago

If a TS client advertises a route, this is kept in the routes list on Headscale server. However, if a client is restarted with tailscale --reset and consecutively launched with a different --advertise-routes value, Headscale web UI still shows old route and makes it clickable, even announces success. Which, in fact, leads to this error on the Headscale server side:

2023-06-05T10:52:17Z ERR unary error="route (machine-2) is not available on node 192.168.0.0/24: route is not available on machine" code=Unknown details=[] dur=2.146846 md={":authority":"/var/run/headscale/headscale.sock","authorization":"Bearer xxxxxx","content-type":"application/grpc","grpcgateway-accept":"application/json","grpcgateway-authorization":"Bearer xxxxxx","grpcgateway-user-agent":"python-requests/2.30.0","user-agent":"grpc-go/1.54.0","x-forwarded-for":"172.26.0.1, 172.26.0.7","x-forwarded-host":"headscale.myserver.com"} method=EnableRoute msg="route (machine-2) is not available on node 192.168.0.0/24: route is not available on machine" req={"routeId":"3"} service=headscale.v1.HeadscaleService

In this case, client was previously launched with --advertise-routes=192.168.0.0/24 and then with --advertise-routes=192.168.0.0/16 which replaced previous value and therefore should not be made available anymore in the UI (or clickable for that matter).

ID | Machine      | Prefix         | Advertised | Enabled | Primary
...shortened ...
3  | machine-2    | 192.168.0.0/24 | false      | false   | true
4  | machine-2    | 0.0.0.0/0      | false      | false   | -
5  | machine-2    | ::/0           | false      | false   | -
6  | machine-2    | 192.168.0.0/16 | true       | true    | true

The same error scenario applies to exit routes - historic records are still clickable and turn to green upon clicking them.

Expected behavior: Prefixes which are no longer activatable (e.g. clients do not advertise them anymore) should not be clickable and even lead to success message "Route enabled".