cmd/tailscale{,d}: combine into a single binary

To reduce size, combine tailscaled and tailscale into a single
binary which will figure out what it should do based on argv[0].

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
This commit is contained in:
Denton Gentry 2021-05-17 08:15:50 -07:00
parent 25df067dd0
commit 1dc90404f3
19 changed files with 20 additions and 4 deletions

16
cmd/tailscaled/main.go Normal file
View File

@ -0,0 +1,16 @@
package main
import (
"os"
"strings"
)
func main() {
if strings.HasSuffix(os.Args[0], "tailscaled") {
tailscaled_main()
} else if strings.HasSuffix(os.Args[0], "tailscale") {
tailscale_main()
} else {
panic(os.Args[0])
}
}

View File

@ -4,7 +4,7 @@
// The tailscale command is the Tailscale command-line client. It interacts
// with the tailscaled node agent.
package main // import "tailscale.com/cmd/tailscale"
package main // import "tailscale.com/cmd/tailscaled"
import (
"fmt"
@ -12,10 +12,10 @@
"path/filepath"
"strings"
"tailscale.com/cmd/tailscale/cli"
"tailscale.com/cmd/tailscaled/cli"
)
func main() {
func tailscale_main() {
args := os.Args[1:]
if name, _ := os.Executable(); strings.HasSuffix(filepath.Base(name), ".cgi") {
args = []string{"web", "-cgi"}

View File

@ -101,7 +101,7 @@ func defaultTunName() string {
"debug": &debugModeFunc,
}
func main() {
func tailscaled_main() {
// We aren't very performance sensitive, and the parts that are
// performance sensitive (wireguard) try hard not to do any memory
// allocations. So let's be aggressive about garbage collection,