Skip to content

Commit 5a4e837

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

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
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: 30 additions & 3 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;
@@ -77,7 +78,9 @@ export class Tailscale {
7778

7879
async init() {
7980
return new Promise<null>((resolve) => {
80-
this.socket = vscode.workspace.getConfiguration(EXTENSION_NS).get<string>('socketPath');
81+
this.socket = vscode.workspace
82+
.getConfiguration(EXTENSION_NS)
83+
.get<string>('portDiscovery.enabled');
8184
let binPath = this.tsrelayPath();
8285
let args = this.defaultArgs();
8386
let cwd = __dirname;
@@ -363,13 +366,30 @@ export class Tailscale {
363366
if (msg.type != 'newPort') {
364367
return;
365368
}
369+
if (this.snoozing) {
370+
return;
371+
}
366372
const shouldServe = await this._vscode.window.showInformationMessage(
367373
msg.message,
368374
{ modal: false },
369-
'Serve'
375+
'Serve',
376+
'Snooze Notifications'
370377
);
371-
if (shouldServe) {
378+
if (shouldServe === 'Serve') {
372379
await this.runFunnel(msg.port);
380+
} else if (shouldServe === 'Snooze Notifications') {
381+
this.snooze();
382+
const openSettings = await this._vscode.window.showInformationMessage(
383+
'Snoozed for 15 minutes. You can fully turn off port discovery in the settings',
384+
{ modal: false },
385+
'Open Settings'
386+
);
387+
if (openSettings) {
388+
this._vscode.commands.executeCommand(
389+
'workbench.action.openSettings',
390+
'tailscale.portDiscovery.enabled'
391+
);
392+
}
373393
}
374394
});
375395
this._vscode.window.onDidOpenTerminal(async (e: vscode.Terminal) => {
@@ -401,6 +421,13 @@ export class Tailscale {
401421
});
402422
}
403423

424+
async snooze() {
425+
this.snoozing = true;
426+
setTimeout(() => {
427+
this.snoozing = false;
428+
}, 900000); // fifteen minutes
429+
}
430+
404431
async runFunnel(port: number) {
405432
await this.serveAdd({
406433
protocol: 'https',

0 commit comments

Comments
 (0)