mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
log: add a default implement of func F
This commit is contained in:
1 parent
3adf3b30b5
commit
36246d9d08
7 files changed
+29
-8
No files matched your search
+4
-1
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/nadoo/glider/common/log"
|
||||
)
|
||||
|
||||
// A proxy.Dialer means to establish a connection and relay it.
|
||||
// Dialer means to establish a connection and relay it.
|
||||
type Dialer interface {
|
||||
// Addr()
|
||||
Addr() string
|
||||
@@ -24,16 +24,19 @@ type Dialer interface {
|
||||
NextDialer(dstAddr string) Dialer
|
||||
}
|
||||
|
||||
// DialerCreator is a function to create dialers.
|
||||
type DialerCreator func(s string, dialer Dialer) (Dialer, error)
|
||||
|
||||
var (
|
||||
dialerMap = make(map[string]DialerCreator)
|
||||
)
|
||||
|
||||
// RegisterDialer is used to register a dialer
|
||||
func RegisterDialer(name string, c DialerCreator) {
|
||||
dialerMap[name] = c
|
||||
}
|
||||
|
||||
// DialerFromURL calls the registered creator to create dialers.
|
||||
func DialerFromURL(s string, dialer Dialer) (Dialer, error) {
|
||||
u, err := url.Parse(s)
|
||||
if err != nil {
|
||||
|
||||
@@ -14,16 +14,19 @@ type Server interface {
|
||||
ListenAndServe()
|
||||
}
|
||||
|
||||
// ServerCreator is a function to create proxy servers.
|
||||
type ServerCreator func(s string, dialer Dialer) (Server, error)
|
||||
|
||||
var (
|
||||
serverMap = make(map[string]ServerCreator)
|
||||
)
|
||||
|
||||
// RegisterServer is used to register a proxy server
|
||||
func RegisterServer(name string, c ServerCreator) {
|
||||
serverMap[name] = c
|
||||
}
|
||||
|
||||
// ServerFromURL calls the registered creator to create proxy servers.
|
||||
func ServerFromURL(s string, dialer Dialer) (Server, error) {
|
||||
if !strings.Contains(s, "://") {
|
||||
s = "mixed://" + s
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/nadoo/glider/proxy"
|
||||
)
|
||||
|
||||
// Version: socks5 version
|
||||
const Version = 5
|
||||
|
||||
// SOCKS5 struct
|
||||
|
||||
Reference in new issue
Block a user