From b6a2488d2e1d9a42c4fefd20875af7f245e8a4b7 Mon Sep 17 00:00:00 2001 From: e1732a364fed <75717694+e1732a364fed@users.noreply.github.com> Date: Sat, 1 Jan 2000 00:00:00 +0000 Subject: [PATCH] =?UTF-8?q?cmd/verysimple=E7=9A=84=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=92=8Cminor=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/verysimple/cmd.go | 9 +++++---- cmd/verysimple/main.go | 1 + cmd/verysimple/tun.go | 2 +- machine/apiServer.go | 5 +++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/verysimple/cmd.go b/cmd/verysimple/cmd.go index 8ad3590..7ff5218 100644 --- a/cmd/verysimple/cmd.go +++ b/cmd/verysimple/cmd.go @@ -23,7 +23,7 @@ import ( var ( download bool - extra_preCommands []func() + preCommands []func() exitCmds = []exitCmd{ {name: "sp", desc: "print supported protocols", f: printSupportedProtocols}, @@ -81,16 +81,17 @@ func runExitCommands() (atLeastOneCalled bool) { return } +// 运行 一些 在 加载配置文件前 执行的 命令 func runPreCommands() { - if len(extra_preCommands) > 0 { - for _, f := range extra_preCommands { + if len(preCommands) > 0 { + for _, f := range preCommands { f() } } } -// 在开始正式代理前, 先运行一些需要运行的命令与函数 +// 运行一些 在 加载配置文件后 、开始正式代理前 执行的 命令 func runPreCommandsAfterLoadConf() { if download { diff --git a/cmd/verysimple/main.go b/cmd/verysimple/main.go index 9265d16..3bc74f9 100644 --- a/cmd/verysimple/main.go +++ b/cmd/verysimple/main.go @@ -342,6 +342,7 @@ func exitBySignal() { stopMachineAndExit(mainM) } +// splice, pprof, urlFormat, dialtimeout func setupSystemParemeters() { if disableSplice { netLayer.SystemCanSplice = false diff --git a/cmd/verysimple/tun.go b/cmd/verysimple/tun.go index 8f08b13..d5cafc5 100644 --- a/cmd/verysimple/tun.go +++ b/cmd/verysimple/tun.go @@ -14,7 +14,7 @@ import ( ) func init() { - extra_preCommands = append(extra_preCommands, func() { + preCommands = append(preCommands, func() { if download { if runtime.GOOS == "windows" { //自动下载wintun.dll diff --git a/machine/apiServer.go b/machine/apiServer.go index 1b350c2..9fe98a7 100644 --- a/machine/apiServer.go +++ b/machine/apiServer.go @@ -18,6 +18,8 @@ import ( "go.uber.org/zap" ) +const eIllegalParameter = "illegal parameter" + /* curl -k https://127.0.0.1:48345/api/allstate */ @@ -38,6 +40,7 @@ func NewApiServerConf() (ac ApiServerConf) { return } +// if fs == nil, flag.CommandLine will be used func (asc *ApiServerConf) SetupFlags(fs *flag.FlagSet) { if fs == nil { fs = flag.CommandLine @@ -92,8 +95,6 @@ func (m *M) TryRunApiServer() { } -const eIllegalParameter = "illegal parameter" - // 阻塞 func (m *M) runApiServer() {