From 6fed9dd0dd62718f78eca11e30a71c2712636fbd Mon Sep 17 00:00:00 2001 From: Mikhail Osipov Date: Wed, 16 Dec 2020 15:27:48 +0300 Subject: hook and socket args check fix, tests --- pkg/server/hook/hex.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'pkg/server/hook/hex.go') diff --git a/pkg/server/hook/hex.go b/pkg/server/hook/hex.go index bc71bf2..362dbd4 100644 --- a/pkg/server/hook/hex.go +++ b/pkg/server/hook/hex.go @@ -2,14 +2,13 @@ package hook import ( "encoding/hex" - "tunnel/pkg/server/env" - "tunnel/pkg/server/opts" + "tunnel/pkg/server/queue" ) -type hexHook struct{} +type hexPipe struct{} -func (hexHook) Send(rq, wq queue.Q) error { +func (hexPipe) Send(rq, wq queue.Q) error { enc := hex.NewEncoder(wq.Writer()) for b := range rq { @@ -19,19 +18,11 @@ func (hexHook) Send(rq, wq queue.Q) error { return nil } -func (hexHook) Recv(rq, wq queue.Q) error { +func (hexPipe) Recv(rq, wq queue.Q) error { r := hex.NewDecoder(rq.Reader()) return queue.IoCopy(r, wq.Writer()) } -func (h hexHook) Open(env.Env) (interface{}, error) { - return h, nil -} - -func newHexHook(opts.Opts) (hook, error) { - return hexHook{}, nil -} - func init() { - register("hex", newHexHook) + registerPipe("hex", hexPipe{}) } -- cgit v1.2.3-70-g09d2