@@ -86,20 +86,27 @@ const vpnInterface = (address: string) => [
8686 } ,
8787] ;
8888
89- const virtualInterface = ( address : string ) => [
89+ const virtualInterface = ( address : string , mac = "02:42:ac:11:00:01" ) => [
9090 {
9191 address,
9292 netmask : "255.255.0.0" ,
9393 family : "IPv4" as const ,
94- mac : "02:42:ac:11:00:01" ,
94+ mac,
9595 internal : false ,
9696 cidr : `${ address } /16` ,
9797 } ,
9898] ;
9999
100100describe ( "resolveBoundEndpoints" , ( ) => {
101101 it ( "lists every external IPv4 address for a wildcard bind, tagging the tailnet one" , ( ) => {
102- expect ( resolveBoundEndpoints ( { host : "0.0.0.0" , port : 3773 , interfaces : INTERFACES } ) ) . toEqual ( [
102+ expect (
103+ resolveBoundEndpoints ( {
104+ platform : "linux" ,
105+ host : "0.0.0.0" ,
106+ port : 3773 ,
107+ interfaces : INTERFACES ,
108+ } ) ,
109+ ) . toEqual ( [
103110 { kind : "lan" , httpBaseUrl : "http://192.168.1.10:3773/" } ,
104111 { kind : "tailnet" , httpBaseUrl : "http://100.101.102.103:3773/" } ,
105112 ] ) ;
@@ -115,21 +122,56 @@ describe("resolveBoundEndpoints", () => {
115122 bridge100 : virtualInterface ( "192.168.64.1" ) ,
116123 vmbr0 : virtualInterface ( "192.168.1.20" ) ,
117124 } ;
118- expect ( resolveBoundEndpoints ( { host : "0.0.0.0" , port : 3773 , interfaces } ) ) . toEqual ( [
125+ expect (
126+ resolveBoundEndpoints ( { platform : "linux" , host : "0.0.0.0" , port : 3773 , interfaces } ) ,
127+ ) . toEqual ( [
119128 { kind : "lan" , httpBaseUrl : "http://192.168.1.10:3773/" } ,
120129 { kind : "tailnet" , httpBaseUrl : "http://100.101.102.103:3773/" } ,
121130 { kind : "lan" , httpBaseUrl : "http://192.168.1.20:3773/" } ,
122131 ] ) ;
123132 } ) ;
124133
134+ it ( "omits Windows host-only adapters without excluding guest NICs or explicit binds" , ( ) => {
135+ const interfaces = {
136+ ...INTERFACES ,
137+ "VirtualBox-Host-Only-Netzwerk" : virtualInterface ( "192.168.56.1" , "0A:00:27:00:01:01" ) ,
138+ "Ethernet 2" : virtualInterface ( "192.168.150.1" , "00:50:56:c0:00:01" ) ,
139+ "Renamed network" : virtualInterface ( "192.168.151.1" , "00:50:56:c0:00:08" ) ,
140+ guest1 : virtualInterface ( "192.168.1.30" , "08:00:27:5e:1a:22" ) ,
141+ guest2 : virtualInterface ( "192.168.1.31" , "00:50:56:2b:8c:01" ) ,
142+ guest3 : virtualInterface ( "192.168.1.32" , "00:0c:29:4f:8e:35" ) ,
143+ guest4 : virtualInterface ( "192.168.1.33" , "00:50:56:80:8c:01" ) ,
144+ } ;
145+ const input = { host : "0.0.0.0" , port : 3773 , interfaces } ;
146+ const retained = [
147+ { kind : "lan" , httpBaseUrl : "http://192.168.1.10:3773/" } ,
148+ { kind : "tailnet" , httpBaseUrl : "http://100.101.102.103:3773/" } ,
149+ ...[ 30 , 31 , 32 , 33 ] . map ( ( last ) => ( {
150+ kind : "lan" ,
151+ httpBaseUrl : `http://192.168.1.${ last } :3773/` ,
152+ } ) ) ,
153+ ] ;
154+ expect ( resolveBoundEndpoints ( { ...input , platform : "win32" } ) ) . toEqual ( retained ) ;
155+ for ( const platform of [ "linux" , "darwin" ] as const ) {
156+ expect ( resolveBoundEndpoints ( { ...input , platform } ) ) . toHaveLength ( retained . length + 3 ) ;
157+ }
158+ for ( const host of [ "192.168.56.1" , "192.168.150.1" , "192.168.151.1" ] ) {
159+ expect ( resolveBoundEndpoints ( { ...input , platform : "win32" , host } ) ) . toEqual ( [
160+ { kind : "lan" , httpBaseUrl : `http://${ host } :3773/` } ,
161+ ] ) ;
162+ }
163+ } ) ;
164+
125165 it ( "tags only addresses on Tailscale's interface as tailnet, not other VPNs in its range" , ( ) => {
126166 const interfaces = {
127167 en0 : INTERFACES . en0 ,
128168 tailscale0 : vpnInterface ( "100.70.1.2" ) ,
129169 CloudflareWARP : vpnInterface ( "100.96.0.1" ) ,
130170 utun7 : vpnInterface ( "100.85.0.1" ) ,
131171 } ;
132- expect ( resolveBoundEndpoints ( { host : "0.0.0.0" , port : 3773 , interfaces } ) ) . toEqual ( [
172+ expect (
173+ resolveBoundEndpoints ( { platform : "linux" , host : "0.0.0.0" , port : 3773 , interfaces } ) ,
174+ ) . toEqual ( [
133175 { kind : "lan" , httpBaseUrl : "http://192.168.1.10:3773/" } ,
134176 { kind : "tailnet" , httpBaseUrl : "http://100.70.1.2:3773/" } ,
135177 { kind : "lan" , httpBaseUrl : "http://100.96.0.1:3773/" } ,
@@ -139,19 +181,27 @@ describe("resolveBoundEndpoints", () => {
139181
140182 it ( "never reports a host name, which can resolve to another machine per client" , ( ) => {
141183 for ( const host of [ "server.local" , "devbox" , "devbox.home.arpa" ] ) {
142- expect ( resolveBoundEndpoints ( { host, port : 3773 , interfaces : INTERFACES } ) ) . toEqual ( [ ] ) ;
184+ expect (
185+ resolveBoundEndpoints ( { platform : "linux" , host, port : 3773 , interfaces : INTERFACES } ) ,
186+ ) . toEqual ( [ ] ) ;
143187 }
144188 } ) ;
145189
146190 it ( "never reports a public address, which would carry the credential over plain HTTP" , ( ) => {
147191 expect (
148- resolveBoundEndpoints ( { host : "203.0.113.20" , port : 3773 , interfaces : INTERFACES } ) ,
192+ resolveBoundEndpoints ( {
193+ platform : "linux" ,
194+ host : "203.0.113.20" ,
195+ port : 3773 ,
196+ interfaces : INTERFACES ,
197+ } ) ,
149198 ) . toEqual ( [ ] ) ;
150199 } ) ;
151200
152201 it ( "reports only the tailnet address on a cloud VM, whose private network no client shares" , ( ) => {
153202 expect (
154203 resolveBoundEndpoints ( {
204+ platform : "linux" ,
155205 host : "0.0.0.0" ,
156206 port : 3773 ,
157207 interfaces : INTERFACES ,
@@ -162,7 +212,12 @@ describe("resolveBoundEndpoints", () => {
162212
163213 it ( "never reports an IPv4-mapped host, which can name the client's own loopback" , ( ) => {
164214 expect (
165- resolveBoundEndpoints ( { host : "::ffff:127.0.0.1" , port : 3773 , interfaces : INTERFACES } ) ,
215+ resolveBoundEndpoints ( {
216+ platform : "linux" ,
217+ host : "::ffff:127.0.0.1" ,
218+ port : 3773 ,
219+ interfaces : INTERFACES ,
220+ } ) ,
166221 ) . toEqual ( [ ] ) ;
167222 } ) ;
168223} ) ;
0 commit comments