@@ -66,6 +66,11 @@ func getTCPListener(c context.Context, network string, host string, portRange st
6666 network = "tcp"
6767 }
6868
69+ // If host is empty (bind tailscale/), use default node name from binary name
70+ if host == "" {
71+ host = getDefaultNodeName ()
72+ }
73+
6974 // Get node reference for this listener (increments node reference count)
7075 node , err := getNode (ctx , host )
7176 if err != nil {
@@ -117,6 +122,11 @@ func getTLSListener(c context.Context, network string, host string, portRange st
117122 network = "tcp"
118123 }
119124
125+ // If host is empty (bind tailscale/), use default node name from binary name
126+ if host == "" {
127+ host = getDefaultNodeName ()
128+ }
129+
120130 // Get node reference for this listener (increments node reference count)
121131 node , err := getNode (ctx , host )
122132 if err != nil {
@@ -173,6 +183,11 @@ func getUDPListener(c context.Context, network string, host string, portRange st
173183 network = "udp"
174184 }
175185
186+ // If host is empty (bind tailscale/), use default node name from binary name
187+ if host == "" {
188+ host = getDefaultNodeName ()
189+ }
190+
176191 // Get node reference for this listener (increments node reference count)
177192 node , err := getNode (ctx , host )
178193 if err != nil {
@@ -252,6 +267,12 @@ var nodes = caddy.NewUsagePool()
252267// This ensures listeners are properly closed when removed from configuration.
253268var tailscaleListeners = caddy .NewUsagePool ()
254269
270+ // getDefaultNodeName returns the default node name when none is specified.
271+ // It uses the binary name (without path) as the default.
272+ func getDefaultNodeName () string {
273+ return filepath .Base (os .Args [0 ])
274+ }
275+
255276// getNode returns a tailscale node for Caddy apps to interface with.
256277//
257278// The specified name will be used to lookup the node configuration from the tailscale caddy app,
@@ -366,7 +387,7 @@ func getPort(name string, app *App) uint16 {
366387 return node .Port
367388 }
368389
369- return 0
390+ return app . Port
370391}
371392
372393func getStateDir (name string , app * App ) (string , error ) {
0 commit comments