feat: support http and socks5 upstream node uris
This commit is contained in:
@@ -495,14 +495,16 @@ func extractHostFromURI(uri string) string {
|
||||
// Handle different URI schemes
|
||||
lowerURI := strings.ToLower(uri)
|
||||
|
||||
// vmess:// vless:// trojan:// ss:// ssr:// hysteria:// hysteria2:// hy2:// anytls://
|
||||
// Standard URL formats, including HTTP and SOCKS upstream proxies.
|
||||
if strings.HasPrefix(lowerURI, "vmess://") ||
|
||||
strings.HasPrefix(lowerURI, "vless://") ||
|
||||
strings.HasPrefix(lowerURI, "trojan://") ||
|
||||
strings.HasPrefix(lowerURI, "hysteria://") ||
|
||||
strings.HasPrefix(lowerURI, "hysteria2://") ||
|
||||
strings.HasPrefix(lowerURI, "hy2://") ||
|
||||
strings.HasPrefix(lowerURI, "anytls://") {
|
||||
strings.HasPrefix(lowerURI, "anytls://") ||
|
||||
strings.HasPrefix(lowerURI, "http://") ||
|
||||
strings.HasPrefix(lowerURI, "socks5://") {
|
||||
// Standard URL format: scheme://user@host:port?params#fragment
|
||||
parsed, err := url.Parse(uri)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package geoip
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestExtractHostFromURISupportsHTTPAndSOCKS5(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
uri string
|
||||
want string
|
||||
}{
|
||||
{name: "http", uri: "http://alice:secret@example.com:8080", want: "example.com"},
|
||||
{name: "socks5", uri: "socks5://alice:secret@99.144.123.135:30350", want: "99.144.123.135"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
if got := extractHostFromURI(tt.uri); got != tt.want {
|
||||
t.Fatalf("%s: extractHostFromURI(%q) = %q, want %q", tt.name, tt.uri, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user