Skip to content

Commit 6b1d651

Browse files
marwan-at-worktylersmalley
authored andcommitted
Make port discovery optional via settings
1 parent d1e0ef1 commit 6b1d651

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ If the extension isn't working, we recommend following these steps to troublesho
8484
2. Ensure that your Tailnet access controls (ACLs) are [configured to allow Tailscale Funnel](https://tailscale.com/kb/1223/tailscale-funnel/#setup) on your device.
8585
3. Ensure that [magicDNS and HTTPS Certificates are enabled](https://tailscale.com/kb/1153/enabling-https/) on your tailnet.
8686
4. If you are running `tailscaled` in a non-default path, you can set its path via the `tailscale.socketPath` setting in VS Code.
87-
87+
(Make port discovery optional via settings)
8888
## Contribute
8989

9090
We appreciate your help! For information on contributing to this extension, refer to the [CONTRIBUTING](CONTRIBUTING.md) document.

src/tailscale/cli.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class Tailscale {
3535
private notifyExit?: () => void;
3636
private socket?: string;
3737
private ws?: WebSocket;
38+
private snoozing?: boolean;
3839

3940
constructor(vscode: vscodeModule) {
4041
this._vscode = vscode;
@@ -363,13 +364,30 @@ export class Tailscale {
363364
if (msg.type != 'newPort') {
364365
return;
365366
}
367+
if (this.snoozing) {
368+
return;
369+
}
366370
const shouldServe = await this._vscode.window.showInformationMessage(
367371
msg.message,
368372
{ modal: false },
369-
'Serve'
373+
'Serve',
374+
'Snooze Notifications'
370375
);
371-
if (shouldServe) {
376+
if (shouldServe === 'Serve') {
372377
await this.runFunnel(msg.port);
378+
} else if (shouldServe === 'Snooze Notifications') {
379+
this.snooze();
380+
const openSettings = await this._vscode.window.showInformationMessage(
381+
'Snoozed for 15 minutes. You can fully turn off port discovery in the settings',
382+
{ modal: false },
383+
'Open Settings'
384+
);
385+
if (openSettings) {
386+
this._vscode.commands.executeCommand(
387+
'workbench.action.openSettings',
388+
'tailscale.portDiscovery.enabled'
389+
);
390+
}
373391
}
374392
});
375393
this._vscode.window.onDidOpenTerminal(async (e: vscode.Terminal) => {
@@ -401,6 +419,13 @@ export class Tailscale {
401419
});
402420
}
403421

422+
async snooze() {
423+
this.snoozing = true;
424+
setTimeout(() => {
425+
this.snoozing = false;
426+
}, 900000); // fifteen minutes
427+
}
428+
404429
async runFunnel(port: number) {
405430
await this.serveAdd({
406431
protocol: 'https',

0 commit comments

Comments
 (0)