From 38b515c5470b74099b85a4f30aef2dce65600818 Mon Sep 17 00:00:00 2001 From: Mikhail Osipov Date: Thu, 9 Apr 2020 02:15:56 +0300 Subject: add socket path config option, fix env find order --- IDEA | 28 ++++++++++++++++++++++++ TODO | 59 +++++++-------------------------------------------- cmd/tunnel/main.go | 5 +++++ cmd/tunneld/main.go | 7 +++++- pkg/server/env/env.go | 10 +++++---- scripts/build.mk | 2 +- 6 files changed, 54 insertions(+), 57 deletions(-) create mode 100644 IDEA diff --git a/IDEA b/IDEA new file mode 100644 index 0000000..17c558b --- /dev/null +++ b/IDEA @@ -0,0 +1,28 @@ +add simple tcp proxy: + in add tcp [host] port + out add tcp host port + + stream add in-tcp-1 out-tcp-1 + stream add in-tcp-2 mixer out-tcp-2 + stream add in-tcp-3 packer out-tcp-2 + + module add + + stream add tcp-listen/80 tcp/mikeos.ru:22 + stream add tcp-listen/80 hex tcp/mikeos.ru:22 + stream add tcp-listen/80 packer mixer tcp/mikeos.ru:22 + + stream add tcp-listen/80 >hex tcp/mikeos.ru:22 + stream add tcp-listen/80 hex tcp/mikeos.ru:22 - stream add tcp-listen/80 0 { + if *configFlag != "" { c = *configFlag } else { c = config.GetConfigPath() diff --git a/pkg/server/env/env.go b/pkg/server/env/env.go index 16f5760..5a49532 100644 --- a/pkg/server/env/env.go +++ b/pkg/server/env/env.go @@ -51,13 +51,15 @@ func (e *env) Find(key string) (string, bool) { } func (e Env) Find(key string) (string, bool) { + if v, ok := e.env.Find(key); ok { + return v, ok + } + if e.p != nil { - if v, ok := e.p.Find(key); ok { - return v, ok - } + return e.p.Find(key) } - return e.env.Find(key) + return "", false } func (e Env) Get(key string) string { diff --git a/scripts/build.mk b/scripts/build.mk index 480ce13..06363c0 100644 --- a/scripts/build.mk +++ b/scripts/build.mk @@ -12,5 +12,5 @@ clean: go clean .PHONY: install -install: build +install: install $(BIN) /usr/local/bin -- cgit v1.2.3-70-g09d2