mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-08 09:07:44 +00:00
tsconnect: add flag to specify control server (#5294)
To improve the local development experience, this change allows a control url to be passed in with the `--dev-control=` flag. If the flag is passed in when not specifying dev, an error is returned. If no flag is passed, the default remains the Tailscale controlled control server set by `ipn.DefaultControlURL`. Co-authored-by: Maisem Ali <maisem@tailscale.com> Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@tailscale.com>
This commit is contained in:
parent
f371a1afd9
commit
5055e00cf1
@ -88,9 +88,14 @@ func buildWasm(dev bool) error {
|
|||||||
log.Printf("Building wasm...\n")
|
log.Printf("Building wasm...\n")
|
||||||
args := []string{"build", "-tags", "tailscale_go,osusergo,netgo,nethttpomithttp2,omitidna,omitpemdecrypt"}
|
args := []string{"build", "-tags", "tailscale_go,osusergo,netgo,nethttpomithttp2,omitidna,omitpemdecrypt"}
|
||||||
if !dev {
|
if !dev {
|
||||||
|
if *devControl != "" {
|
||||||
|
return fmt.Errorf("Development control URL can only be used in dev mode.")
|
||||||
|
}
|
||||||
// Omit long paths and debug symbols in release builds, to reduce the
|
// Omit long paths and debug symbols in release builds, to reduce the
|
||||||
// generated WASM binary size.
|
// generated WASM binary size.
|
||||||
args = append(args, "-trimpath", "-ldflags", "-s -w")
|
args = append(args, "-trimpath", "-ldflags", "-s -w")
|
||||||
|
} else if *devControl != "" {
|
||||||
|
args = append(args, "-ldflags", fmt.Sprintf("-X 'main.ControlURL=%v'", *devControl))
|
||||||
}
|
}
|
||||||
args = append(args, "-o", "src/main.wasm", "./wasm")
|
args = append(args, "-o", "src/main.wasm", "./wasm")
|
||||||
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...)
|
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
distDir = flag.String("distdir", "./dist", "path of directory to place build output in")
|
distDir = flag.String("distdir", "./dist", "path of directory to place build output in")
|
||||||
yarnPath = flag.String("yarnpath", "../../tool/yarn", "path yarn executable used to install JavaScript dependencies")
|
yarnPath = flag.String("yarnpath", "../../tool/yarn", "path yarn executable used to install JavaScript dependencies")
|
||||||
fastCompression = flag.Bool("fast-compression", false, "Use faster compression when building, to speed up build time. Meant to iterative/debugging use only.")
|
fastCompression = flag.Bool("fast-compression", false, "Use faster compression when building, to speed up build time. Meant to iterative/debugging use only.")
|
||||||
|
devControl = flag.String("dev-control", "", "URL of a development control server to be used with dev. If provided without specifying dev, an error will be returned.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -42,6 +42,9 @@
|
|||||||
"tailscale.com/words"
|
"tailscale.com/words"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ControlURL defines the URL to be used for connection to Control.
|
||||||
|
var ControlURL = ipn.DefaultControlURL
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
js.Global().Set("newIPN", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
js.Global().Set("newIPN", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
@ -244,7 +247,7 @@ func (i *jsIPN) run(jsCallbacks js.Value) {
|
|||||||
err := i.lb.Start(ipn.Options{
|
err := i.lb.Start(ipn.Options{
|
||||||
StateKey: "wasm",
|
StateKey: "wasm",
|
||||||
UpdatePrefs: &ipn.Prefs{
|
UpdatePrefs: &ipn.Prefs{
|
||||||
ControlURL: ipn.DefaultControlURL,
|
ControlURL: ControlURL,
|
||||||
RouteAll: false,
|
RouteAll: false,
|
||||||
AllowSingleHosts: true,
|
AllowSingleHosts: true,
|
||||||
WantRunning: true,
|
WantRunning: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user