mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
server: changed interface definition and implementation
This commit is contained in:
1 parent
2813e80a98
commit
d37c2e2a35
14 files changed
+207
-240
No files matched your search
+8
-5
@@ -11,11 +11,14 @@ import (
|
||||
|
||||
// Server interface
|
||||
type Server interface {
|
||||
// ListenAndServe as proxy server, use only in server mode.
|
||||
ListenAndServe(net.Conn)
|
||||
// ListenAndServe sets up a listener and serve on it
|
||||
ListenAndServe()
|
||||
|
||||
// Serve serves a connection
|
||||
Serve(c net.Conn)
|
||||
}
|
||||
|
||||
// ServerCreator is a function to create proxy servers.
|
||||
// ServerCreator is a function to create proxy servers
|
||||
type ServerCreator func(s string, dialer Dialer) (Server, error)
|
||||
|
||||
var (
|
||||
@@ -27,8 +30,8 @@ func RegisterServer(name string, c ServerCreator) {
|
||||
serverMap[name] = c
|
||||
}
|
||||
|
||||
// ServerFromURL calls the registered creator to create proxy servers.
|
||||
// dialer is the default upstream dialer so cannot be nil, we can use Default when calling this function.
|
||||
// ServerFromURL calls the registered creator to create proxy servers
|
||||
// dialer is the default upstream dialer so cannot be nil, we can use Default when calling this function
|
||||
func ServerFromURL(s string, dialer Dialer) (Server, error) {
|
||||
if dialer == nil {
|
||||
return nil, errors.New("ServerFromURL: dialer cannot be nil")
|
||||
|
||||
Reference in new issue
Block a user