mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 12:53:41 +00:00
feat: support proxy (#284)
This commit is contained in:
45 files changed
+1017
-1124
No files matched your search
@@ -2,6 +2,7 @@ package util
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
@@ -37,3 +38,16 @@ func ParseDataUri(uri string) (string, []byte) {
|
||||
}
|
||||
return mime, data
|
||||
}
|
||||
|
||||
// BuildProxyUrl builds a proxy url with given host, username and password.
|
||||
func BuildProxyUrl(scheme, host, usr, pwd string) *url.URL {
|
||||
var user *url.Userinfo
|
||||
if usr != "" && pwd != "" {
|
||||
user = url.UserPassword(usr, pwd)
|
||||
}
|
||||
return &url.URL{
|
||||
Scheme: scheme,
|
||||
User: user,
|
||||
Host: host,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user