diff options
| author | Mark Rushakoff <[email protected]> | 2018-02-23 15:35:58 -0800 |
|---|---|---|
| committer | Mark Rushakoff <[email protected]> | 2018-02-23 15:42:08 -0800 |
| commit | 82a8f44a2f4cf0686635d2a23ebb41a8f445194e (patch) | |
| tree | 50be4dd4cf5a89eb40f43393def27e14bc777034 /server.go | |
| parent | 0fce9cb1f0426d07ce0967ecf2ed82bb4834084c (diff) | |
Simplify server bind functions
For our purposes, it doesn't need to route multiple functions across
different DNs, so use a simple function instead.
Diffstat (limited to 'server.go')
| -rw-r--r-- | server.go | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -11,9 +11,8 @@ import ( "github.com/mark-rushakoff/ldapserver/internal/asn1-ber" ) -type Binder interface { - Bind(bindDN, bindSimplePw string, conn net.Conn) (LDAPResultCode, error) -} +type BindFunc func(bindDN, bindSimplePw string, conn net.Conn) (LDAPResultCode, error) + type Searcher interface { Search(boundDN string, req SearchRequest, conn net.Conn) (ServerSearchResult, error) } @@ -47,7 +46,8 @@ type Closer interface { // type Server struct { - BindFns map[string]Binder + Bind BindFunc + SearchFns map[string]Searcher AddFns map[string]Adder ModifyFns map[string]Modifier @@ -84,7 +84,6 @@ func NewServer() *Server { s := new(Server) d := defaultHandler{} - s.BindFns = make(map[string]Binder) s.SearchFns = make(map[string]Searcher) s.AddFns = make(map[string]Adder) s.ModifyFns = make(map[string]Modifier) @@ -95,7 +94,9 @@ func NewServer() *Server { s.ExtendedFns = make(map[string]Extender) s.UnbindFns = make(map[string]Unbinder) s.CloseFns = make(map[string]Closer) - s.BindFunc("", d) + + s.Bind = d.Bind + s.SearchFunc("", d) s.AddFunc("", d) s.ModifyFunc("", d) @@ -111,9 +112,6 @@ func NewServer() *Server { s.closing = make(chan struct{}) return s } -func (server *Server) BindFunc(baseDN string, f Binder) { - server.BindFns[baseDN] = f -} func (server *Server) SearchFunc(baseDN string, f Searcher) { server.SearchFns[baseDN] = f } @@ -282,7 +280,7 @@ handler: case ApplicationBindRequest: server.Stats.countBinds(1) - ldapResultCode := HandleBindRequest(req, server.BindFns, conn) + ldapResultCode := HandleBindRequest(req, server.Bind, conn) if ldapResultCode == LDAPResultSuccess { boundDN, ok = req.Children[1].Value.(string) if !ok { |
