diff options
| author | Mikhail Osipov <mike.osipov@gmail.com> | 2020-12-16 15:27:48 +0300 |
|---|---|---|
| committer | Mikhail Osipov <mike.osipov@gmail.com> | 2020-12-16 15:27:48 +0300 |
| commit | 6fed9dd0dd62718f78eca11e30a71c2712636fbd (patch) | |
| tree | 8d1f90b96efbe8ea8aea350c283325adc216ef9d /pkg/server/hook/auth.go | |
| parent | 050ea053dd549f0dd01beddfcd74989858391fd7 (diff) | |
hook and socket args check fix, tests
Diffstat (limited to 'pkg/server/hook/auth.go')
| -rw-r--r-- | pkg/server/hook/auth.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/pkg/server/hook/auth.go b/pkg/server/hook/auth.go index 5910b56..dbfc9bc 100644 --- a/pkg/server/hook/auth.go +++ b/pkg/server/hook/auth.go @@ -7,8 +7,8 @@ import ( "io" "sync" "time" + "tunnel/pkg/server/env" - "tunnel/pkg/server/opts" "tunnel/pkg/server/queue" ) @@ -17,6 +17,10 @@ const authTimeout = 5 * time.Second const saltSize = 16 const hashSize = md5.Size +type authHook struct { + m sync.Map +} + type auth struct { h *authHook @@ -42,10 +46,6 @@ var errDupSalt = errors.New("peer repeats salt") var errAuthFail = errors.New("peer auth fail") var errTimeout = errors.New("timeout") -type authHook struct { - m sync.Map -} - func (a *auth) Init() error { b := make([]byte, saltSize) if _, err := rand.Read(b); err != nil { @@ -149,7 +149,7 @@ func (a *auth) Close() { a.h.m.Delete(a.salt.self) } -func (h *authHook) Open(env env.Env) (interface{}, error) { +func (h *authHook) New(env env.Env) (interface{}, error) { a := &auth{ h: h, secret: env.Value("secret"), @@ -169,10 +169,6 @@ func (h *authHook) Open(env env.Env) (interface{}, error) { return a, nil } -func newAuthHook(opts.Opts) (hook, error) { - return &authHook{}, nil -} - func init() { - register("auth", newAuthHook) + register("auth", authHook{}) } |
