Просмотр исходного кода

cmd/tailscaled, net/tstun: add build tags to omit BIRD and TAP

Signed-off-by: Andrew Dunham <[email protected]>
Change-Id: I7a39f4eeeb583b73ecffaf4c5f086a38e3a53e2e
Andrew Dunham 3 лет назад
Родитель
Сommit
c2d7940ec0
5 измененных файлов с 8 добавлено и 3 удалено
  1. 1 1
      build_dist.sh
  2. 1 1
      cmd/tailscaled/tailscaled_bird.go
  3. 2 0
      net/tstun/tap_linux.go
  4. 1 1
      net/tstun/tap_unsupported.go
  5. 3 0
      net/tstun/tun.go

+ 1 - 1
build_dist.sh

@@ -54,7 +54,7 @@ while [ "$#" -gt 1 ]; do
 	--extra-small)
 		shift
 		ldflags="$ldflags -w -s"
-		tags="${tags:+$tags,}ts_omit_aws"
+		tags="${tags:+$tags,}ts_omit_aws,ts_omit_bird,ts_omit_tap"
 		;;
 	--box)
 		shift

+ 1 - 1
cmd/tailscaled/tailscaled_bird.go

@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build go1.19 && (linux || darwin || freebsd || openbsd)
+//go:build go1.19 && (linux || darwin || freebsd || openbsd) && !ts_omit_bird
 
 package main
 

+ 2 - 0
net/tstun/tap_linux.go

@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build !ts_omit_tap
+
 package tstun
 
 import (

+ 1 - 1
net/tstun/tap_unsupported.go

@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !linux
+//go:build !linux || ts_omit_tap
 
 package tstun
 

+ 3 - 0
net/tstun/tun.go

@@ -31,6 +31,9 @@ func New(logf logger.Logf, tunName string) (tun.Device, string, error) {
 		if runtime.GOOS != "linux" {
 			return nil, "", errors.New("tap only works on Linux")
 		}
+		if createTAP == nil { // if the ts_omit_tap tag is used
+			return nil, "", errors.New("tap is not supported in this build")
+		}
 		f := strings.Split(tunName, ":")
 		var tapName, bridgeName string
 		switch len(f) {