Listen on loopback and tailnet by default; make the plain-HTTP LAN opt-in
The web proxy binds the wildcard and drops connections that are not loopback or Tailscale at both ends. A LAN listener is opt-in (web.lan) and refuses sign-in and signed-in pages over plain HTTP unless web.lan_plain_login is set. Existing installs keep their bind address with a warning. Without the LAN the mDNS advert carries only the tailnet and public routes (lan=0).
This commit is contained in:
@@ -113,11 +113,16 @@ class DiscoveredServer {
|
||||
DiscoveredAddress(route: DiscoveredRoute.public, endpoint: public),
|
||||
);
|
||||
}
|
||||
// lan=0: the web proxy refuses LAN connections, so the address record is
|
||||
// not a LAN route; the first tailnet or public route is the endpoint.
|
||||
if (attributes['lan'] == '0') routes.removeAt(0);
|
||||
if (routes.isEmpty) return null;
|
||||
final first = routes.first.endpoint;
|
||||
return DiscoveredServer(
|
||||
name: name.isEmpty ? instance : name,
|
||||
host: host,
|
||||
port: port,
|
||||
secure: secure,
|
||||
host: first.host,
|
||||
port: first.port,
|
||||
secure: first.scheme == 'wss',
|
||||
path: cleanPath,
|
||||
passwordRequired: attributes['auth'] != 'none',
|
||||
version: attributes['v'],
|
||||
|
||||
@@ -125,4 +125,35 @@ void main() {
|
||||
expect(DiscoveredServer.isTailscaleIPv4('100.127.0.1'), isTrue);
|
||||
expect(DiscoveredServer.isTailscaleIPv4('100.128.0.1'), isFalse);
|
||||
});
|
||||
|
||||
test('lan=0 drops the LAN route and dials the tailnet first', () {
|
||||
final server = DiscoveredServer.fromRecord(
|
||||
instance: 'Pipelines-box',
|
||||
addresses: ['100.85.25.33'],
|
||||
port: 8083,
|
||||
attributes: {
|
||||
'name': 'box',
|
||||
'path': '/connect',
|
||||
'tls': '0',
|
||||
'auth': 'password',
|
||||
'lan': '0',
|
||||
'ts': '100.85.25.33',
|
||||
'public': 'https://box.tail1.ts.net:8443',
|
||||
},
|
||||
)!;
|
||||
expect(server.addresses.map((a) => a.route), [
|
||||
DiscoveredRoute.tailscale,
|
||||
DiscoveredRoute.public,
|
||||
]);
|
||||
expect(server.endpoint, Uri.parse('ws://100.85.25.33:8083/connect'));
|
||||
expect(
|
||||
DiscoveredServer.fromRecord(
|
||||
instance: 'Pipelines-box',
|
||||
addresses: ['100.85.25.33'],
|
||||
port: 8083,
|
||||
attributes: {'lan': '0'},
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user