mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
general: add global setting interface
This commit is contained in:
1 parent
edd5964a1e
commit
8daa7784b0
8 files changed
+45
-26
No files matched your search
+5
-4
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user