summaryrefslogtreecommitdiff
path: root/pkg/server/module/auth.go
blob: 05761ed2ec0dfb5789e55bee3ca205b77cda5af2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package module

import (
	"tunnel/pkg/server/queue"
	"tunnel/pkg/server/opts"
	"tunnel/pkg/server/env"
)

type auth struct {
	secret string
}

type authModule struct{}

func (a *auth) Send(rq, wq queue.Q) error {
	return queue.Copy(rq, wq)
}

func (a *auth) Recv(rq, wq queue.Q) error {
	return queue.Copy(rq, wq)
}

func (m authModule) Open(env env.Env) (Pipe, Pipe) {
	a := &auth{env.Get("secret")}
	return a.Send, a.Recv
}

func init() {
	register("auth", func (opts.Opts, env.Env) (module, error) {
		return authModule{}, nil
	})
}