general: add global setting interface

This commit is contained in:
nadoo committed 2018-08-20 22:23:00 +08:00
1 parent edd5964a1e
commit 8daa7784b0
8 files changed
+45 -26

No files matched your search

+5 -4
View File
@@ -27,7 +27,12 @@ func RegisterServer(name string, c ServerCreator) {
}
// 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")
}
if !strings.Contains(s, "://") {
s = "mixed://" + s
}
@@ -38,10 +43,6 @@ func ServerFromURL(s string, dialer Dialer) (Server, error) {
return nil, err
}
if dialer == nil {
dialer = Default
}
c, ok := serverMap[strings.ToLower(u.Scheme)]
if ok {
return c(s, dialer)