Add connect-on-launch and notarized desktop release packaging
This commit is contained in:
@@ -48,7 +48,7 @@ func TestNormalizeTarget(t *testing.T) {
|
||||
func TestConfigRoundTrip(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "config.json")
|
||||
cfg := &Config{API: "https://tunnel.example", Routes: map[string]Route{}}
|
||||
cfg := &Config{API: "https://tunnel.example", AutoConnect: true, Routes: map[string]Route{}}
|
||||
if err := cfg.AddRoute("api", "4096", ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func TestConfigRoundTrip(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if loaded.API != cfg.API || loaded.Routes["api"].Target != "127.0.0.1:4096" {
|
||||
if loaded.API != cfg.API || !loaded.AutoConnect || loaded.Routes["api"].Target != "127.0.0.1:4096" {
|
||||
t.Errorf("round trip: %+v", loaded)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ type Config struct {
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
CertificateExpiry string `json:"certificate_expiry,omitempty"`
|
||||
AutoConnect bool `json:"auto_connect,omitempty"`
|
||||
Routes map[string]Route `json:"routes,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ func Run(version string, autostart bool) {
|
||||
fyne.Do(a.refresh)
|
||||
}
|
||||
}()
|
||||
if autostart {
|
||||
if autostart || a.cfg.AutoConnect {
|
||||
a.start()
|
||||
}
|
||||
a.app.Run()
|
||||
@@ -370,8 +370,13 @@ func (a *App) settingsDialog() {
|
||||
api := widget.NewEntry()
|
||||
api.SetText(a.cfg.API)
|
||||
api.SetPlaceHolder("https://tunnel.example.com")
|
||||
autoConnect := widget.NewCheck("Connect on launch", nil)
|
||||
autoConnect.SetChecked(a.cfg.AutoConnect)
|
||||
dialog.NewForm("Settings", "Save", "Cancel",
|
||||
[]*widget.FormItem{widget.NewFormItem("API", api)},
|
||||
[]*widget.FormItem{
|
||||
widget.NewFormItem("API", api),
|
||||
widget.NewFormItem("Startup", autoConnect),
|
||||
},
|
||||
func(ok bool) {
|
||||
if !ok {
|
||||
return
|
||||
@@ -382,6 +387,7 @@ func (a *App) settingsDialog() {
|
||||
return
|
||||
}
|
||||
a.cfg.API = normalized
|
||||
a.cfg.AutoConnect = autoConnect.Checked
|
||||
if err := a.cfg.Save(a.configPath); err != nil {
|
||||
a.showError(err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user