summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Osipov <mike.osipov@gmail.com>2020-04-09 02:15:56 +0300
committerMikhail Osipov <mike.osipov@gmail.com>2020-04-09 16:03:13 +0300
commit38b515c5470b74099b85a4f30aef2dce65600818 (patch)
tree10a9e2399fd1db3a5f3a17110755144d4dac464c
parent3c4432e0f2fb8ddf54a2e441063d584b99572a4e (diff)
add socket path config option, fix env find order
-rw-r--r--IDEA28
-rw-r--r--TODO59
-rw-r--r--cmd/tunnel/main.go5
-rw-r--r--cmd/tunneld/main.go7
-rw-r--r--pkg/server/env/env.go10
-rw-r--r--scripts/build.mk2
6 files changed, 54 insertions, 57 deletions
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 <unhex tcp/mikeos.ru:22
+
+ stream add tcp-listen/80 hex - unhex proxy/host:port tcp/mikeos.ru:22
+
+ in show
+ out show
+ module show
+ stream show
+
+note:
+ client connection maybe created on accept client or
+ created on stream creation.
+ In the latter case client will be multiplexer
diff --git a/TODO b/TODO
index 6039ba3..4c7ebf5 100644
--- a/TODO
+++ b/TODO
@@ -1,51 +1,8 @@
-1. DONE ./pkg/server/server.go make request
-2. DONE make chain commands
-3. DONE add help command
-4. DONE env set/get
-5. 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 <unhex tcp/mikeos.ru:22
-
- stream add tcp-listen/80 hex - unhex proxy/host:port tcp/mikeos.ru:22
-
- in show
- out show
- module show
- stream show
-
-note:
- client connection maybe created on accept client or
- created on stream creation.
- In the latter case client will be multiplexer
-
-6. DONE check variable name
-7. DONE substitute variable over query (maybe)
-8. CloseRead or CloseWriter
-9. tunnel enable/disable
-10. DONE config from file
-11. DONE system/user? unix control socket location
-12. DONE modules: auth(chap), enc, dec
-13. DONE print module name when stream closed by error
-14. stream.run check errors on Open
-15. per tunnel, per stream statistics
-16. http connect proxy module
-17. unix socket path from config file
- DONE group owner of socket dir/file
- command line option for socket
-18. systemd socket activation
-19. implement simple client, server protocol instead of unixpacket
-20. tun: separate data and control packets (route)
-21. tun: auto created interface and auto ip address from pool
+- CloseRead or CloseWriter
+- tunnel enable/disable
+- stream.run check errors on Open
+- per tunnel, per stream statistics
+- http connect server proxy module
+- systemd socket activation
+- tun: separate data and control packets (route)
+- tun: auto created interface and auto ip address from pool
diff --git a/cmd/tunnel/main.go b/cmd/tunnel/main.go
index dc94974..b6a4ee4 100644
--- a/cmd/tunnel/main.go
+++ b/cmd/tunnel/main.go
@@ -14,6 +14,7 @@ import (
var (
systemFlag = flag.Bool("system", false, "use system instance")
+ socketFlag = flag.String("S", "", "path to control socket")
)
func init() {
@@ -21,6 +22,10 @@ func init() {
}
func getSocketPath() string {
+ if *socketFlag != "" {
+ return *socketFlag
+ }
+
if *systemFlag {
return config.GetSystemSocketPath()
}
diff --git a/cmd/tunneld/main.go b/cmd/tunneld/main.go
index 4ff23ba..e56dd12 100644
--- a/cmd/tunneld/main.go
+++ b/cmd/tunneld/main.go
@@ -25,6 +25,7 @@ var (
forceFlag = flag.Bool("f", false, "try start with force")
syslogFlag = flag.Bool("s", false, "write log to syslog instead of stdout")
configFlag = flag.String("c", "", "path to configuration file")
+ socketFlag = flag.String("S", "", "path to control socket")
)
func initLog() {
@@ -69,6 +70,10 @@ func initSignals(s *server.Server) {
}
func getSocketPath() string {
+ if *socketFlag != "" {
+ return *socketFlag
+ }
+
s := config.GetSocketPath()
if err := os.Mkdir(path.Dir(s), 0700); err != nil {
@@ -83,7 +88,7 @@ func getSocketPath() string {
func openConfig() (*os.File, error) {
var c string
- if len(*configFlag) > 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