@@ -502,6 +502,7 @@ describe("telegram user Crabbox proof log polling", () => {
502502 gatewayPort : 19042 ,
503503 inspect : {
504504 host : "proof.example" ,
505+ sshHost : "" ,
505506 sshKey : "/tmp/proof-key" ,
506507 sshPort : "2222" ,
507508 sshUser : "proof" ,
@@ -519,9 +520,9 @@ describe("telegram user Crabbox proof log polling", () => {
519520 env,
520521 } ) ;
521522 expect ( allowed . status ) . toBe ( 0 ) ;
522- expect ( JSON . parse ( fs . readFileSync ( argvPath , "utf8" ) ) ) . toContain (
523- "'tailscale' 'funnel' '--bg' '--yes' '19042'" ,
524- ) ;
523+ const fallbackArgv = JSON . parse ( fs . readFileSync ( argvPath , "utf8" ) ) ;
524+ expect ( fallbackArgv ) . toContain ( "[email protected] " ) ; 525+ expect ( fallbackArgv ) . toContain ( "'tailscale' 'funnel' '--bg' '--yes' '19042'" ) ;
525526
526527 const rejected = spawnSync ( proxyPath , [ "serve" , "--bg" , "19042" ] , {
527528 encoding : "utf8" ,
@@ -531,6 +532,44 @@ describe("telegram user Crabbox proof log polling", () => {
531532 expect ( rejected . stderr ) . toContain ( "unsupported proof Tailscale command" ) ;
532533 } ) ;
533534
535+ posixIt ( "prefers the inspect SSH host over the public host" , ( ) => {
536+ const root = makeTempDir ( ) ;
537+ const sshPath = path . join ( root , "ssh" ) ;
538+ const argvPath = path . join ( root , "ssh-argv.json" ) ;
539+ const proxyPath = path . join ( root , "tailscale" ) ;
540+ writeExecutable (
541+ sshPath ,
542+ `#!/usr/bin/env node\nimport fs from "node:fs";\nfs.writeFileSync(process.env.ARGV_PATH, JSON.stringify(process.argv.slice(2)));\n` ,
543+ ) ;
544+ writeExecutable (
545+ proxyPath ,
546+ renderTailscaleSshProxy ( {
547+ gatewayPort : 19042 ,
548+ inspect : {
549+ host : "public.example" ,
550+ sshHost : "ssh.example" ,
551+ sshKey : "/tmp/proof-key" ,
552+ sshPort : "2222" ,
553+ sshUser : "proof" ,
554+ } ,
555+ } ) ,
556+ ) ;
557+
558+ const result = spawnSync ( proxyPath , [ "status" , "--json" ] , {
559+ encoding : "utf8" ,
560+ env : {
561+ ...process . env ,
562+ ARGV_PATH : argvPath ,
563+ PATH : `${ root } ${ path . delimiter } ${ process . env . PATH ?? "" } ` ,
564+ } ,
565+ } ) ;
566+
567+ expect ( result . status ) . toBe ( 0 ) ;
568+ const argv = JSON . parse ( fs . readFileSync ( argvPath , "utf8" ) ) ;
569+ expect ( argv ) . toContain ( "[email protected] " ) ; 570+ expect ( argv ) . not . toContain ( "[email protected] " ) ; 571+ } ) ;
572+
534573 it ( "reads only the requested log tail" , ( ) => {
535574 const logPath = path . join ( makeTempDir ( ) , "gateway.log" ) ;
536575 fs . writeFileSync ( logPath , `${ "old\n" . repeat ( 2000 ) } ready\n` , "utf8" ) ;
0 commit comments