@ -136,12 +136,16 @@ var (
createBIRDClient func ( string ) ( wgengine . BIRDClient , error ) // non-nil on some platforms
createBIRDClient func ( string ) ( wgengine . BIRDClient , error ) // non-nil on some platforms
)
)
var subCommands = map [ string ] func ( [ ] string ) error {
// Note - we use function pointers for subcommands so that subcommands like
"install-system-daemon" : installSystemDaemon ,
// installSystemDaemon and uninstallSystemDaemon can be assigned platform-
"uninstall-system-daemon" : uninstallSystemDaemon ,
// specific variants.
"debug" : debugModeFunc ,
"be-child" : beChild ,
var subCommands = map [ string ] * func ( [ ] string ) error {
"serve-tailfs" : serveTailFS ,
"install-system-daemon" : & installSystemDaemon ,
"uninstall-system-daemon" : & uninstallSystemDaemon ,
"debug" : & debugModeFunc ,
"be-child" : & beChildFunc ,
"serve-tailfs" : & serveTailFSFunc ,
}
}
var beCLI func ( ) // non-nil if CLI is linked in
var beCLI func ( ) // non-nil if CLI is linked in
@ -173,12 +177,12 @@ func main() {
if len ( os . Args ) > 1 {
if len ( os . Args ) > 1 {
sub := os . Args [ 1 ]
sub := os . Args [ 1 ]
if f n , ok := subCommands [ sub ] ; ok {
if f p , ok := subCommands [ sub ] ; ok {
if f n == nil {
if f p == nil {
log . SetFlags ( 0 )
log . SetFlags ( 0 )
log . Fatalf ( "%s not available on %v" , sub , runtime . GOOS )
log . Fatalf ( "%s not available on %v" , sub , runtime . GOOS )
}
}
if err := fn ( os . Args [ 2 : ] ) ; err != nil {
if err := ( * fp ) ( os . Args [ 2 : ] ) ; err != nil {
log . SetFlags ( 0 )
log . SetFlags ( 0 )
log . Fatal ( err )
log . Fatal ( err )
}
}
@ -799,6 +803,8 @@ func mustStartProxyListeners(socksAddr, httpAddr string) (socksListener, httpLis
return socksListener , httpListener
return socksListener , httpListener
}
}
var beChildFunc = beChild
func beChild ( args [ ] string ) error {
func beChild ( args [ ] string ) error {
if len ( args ) == 0 {
if len ( args ) == 0 {
return errors . New ( "missing mode argument" )
return errors . New ( "missing mode argument" )
@ -811,6 +817,8 @@ func beChild(args []string) error {
return f ( args [ 1 : ] )
return f ( args [ 1 : ] )
}
}
var serveTailFSFunc = serveTailFS
// serveTailFS serves one or more tailfs on localhost using the WebDAV
// serveTailFS serves one or more tailfs on localhost using the WebDAV
// protocol. On UNIX and MacOS tailscaled environment, tailfs spawns child
// protocol. On UNIX and MacOS tailscaled environment, tailfs spawns child
// tailscaled processes in serve-tailfs mode in order to access the fliesystem
// tailscaled processes in serve-tailfs mode in order to access the fliesystem