diff options
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{}) } |
