NewServer returns a new server. The provided authFunc and cmdFunc must parse requests and return appropriate replies to clients.
(authFunc, cmdFunc func(io.ReadWriter, []byte) error)
| 181 | // The provided authFunc and cmdFunc must parse requests and return |
| 182 | // appropriate replies to clients. |
| 183 | func NewServer(authFunc, cmdFunc func(io.ReadWriter, []byte) error) (*Server, error) { |
| 184 | var err error |
| 185 | s := new(Server) |
| 186 | s.ln, err = nettest.NewLocalListener("tcp") |
| 187 | if err != nil { |
| 188 | return nil, err |
| 189 | } |
| 190 | go s.serve(authFunc, cmdFunc) |
| 191 | return s, nil |
| 192 | } |
| 193 | |
| 194 | // NoAuthRequired handles a no-authentication-required signaling. |
| 195 | func NoAuthRequired(rw io.ReadWriter, b []byte) error { |
searching dependent graphs…