diff --git a/MainFormImpl.go b/MainFormImpl.go index 2b8e292..0370745 100644 --- a/MainFormImpl.go +++ b/MainFormImpl.go @@ -78,13 +78,16 @@ func (f *TMainForm) OnAboutMenuClick(sender vcl.IObject) { } func (f *TMainForm) OnPopStartMenuClick(sender vcl.IObject) { + proxy.Stop(currentServerName) currentServerName = MainForm.ServerListView.Selected().Caption() serverInfo := readConfig(currentServerName) configContent := buildConfig(serverInfo, " ") + //fmt.Println(configContent) MainForm.OutpuMemo.Lines().Clear() var loggerCallback proxy.LogCallback loggerCallback = new(MyLogCallback) errStr := proxy.StartWithLog(currentServerName, configContent, loggerCallback) + //errStr := proxy.Start(currentServerName, configContent) if errStr != "" { vcl.MessageDlg("启动失败:"+errStr, types.MtError, types.MbOK) } @@ -152,14 +155,18 @@ type MyLogCallback struct { } func (myLogCallback MyLogCallback) Write(line string) { - MainForm.OutpuMemo.Lines().Append(line) + go func() { + vcl.ThreadSync(func() { + MainForm.OutpuMemo.Lines().Append(line) + }) + }() } func (f *TMainForm) OnPopStopMenuClick(sender vcl.IObject) { - // 这里肯定有问题,我是乱写的 + // 这里估计有问题,我是乱写的 + proxy.Stop(currentServerName) go func() { vcl.ThreadSync(func() { - go proxy.Stop(currentServerName) cfg, _ := goconfig.LoadConfigFile(mainConfigName) cfg.SetValue(currentServerName, "Status", "false") _ = goconfig.SaveConfigFile(cfg, mainConfigName) diff --git a/NewProxyServerFormImpl.go b/NewProxyServerFormImpl.go index d4726b2..2830080 100644 --- a/NewProxyServerFormImpl.go +++ b/NewProxyServerFormImpl.go @@ -4,7 +4,6 @@ package main import ( - "fmt" "github.com/Unknwon/goconfig" "github.com/satori/go.uuid" "github.com/ying32/govcl/vcl" @@ -60,7 +59,7 @@ func (f *TNewProxyServerForm) OnOkButtonClick(sender vcl.IObject) { var key = "" if currentEditServerName == "" { u1 := uuid.Must(uuid.NewV4()) - fmt.Printf("UUIDv4: %s\n", u1) + //fmt.Printf("UUIDv4: %s\n", u1) key = u1.String() } else { key = currentEditServerName diff --git a/config.ini b/config.ini index 5620a26..8e14256 100644 --- a/config.ini +++ b/config.ini @@ -1,5 +1,5 @@ [common] autoRun = false sysProxy = false -sysProxyAddr = +sysProxyAddr = 127.0.0.1:1080