Add site contacts/FAQ and accept AWG 2.0 / naive pastes in Add config.
ImportSubscription no longer requires only http(s): paste awg://, AWG .conf/JSON, or naive links; subscription parser also reads hosted AWG and Clash wireguard/naive. Site lists support emails and FAQ; Store listing texts/tools updated. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+23
-2
@@ -476,8 +476,14 @@ var allowedLinkHosts = map[string]bool{
|
||||
"t.me": true,
|
||||
}
|
||||
|
||||
// allowedMailto are support addresses the UI may open via mailto:.
|
||||
var allowedMailto = map[string]bool{
|
||||
"animegold3@gmail.com": true,
|
||||
"admin@evilfox.win": true,
|
||||
}
|
||||
|
||||
// LinkAllowed validates that raw is an http(s) URL pointing at one of the
|
||||
// allowed hosts; returns the normalized URL.
|
||||
// allowed hosts, or a mailto: address from the allowlist; returns the normalized URL.
|
||||
func LinkAllowed(raw string) (string, error) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
@@ -487,8 +493,23 @@ func LinkAllowed(raw string) (string, error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("некорректная ссылка")
|
||||
}
|
||||
if strings.EqualFold(u.Scheme, "mailto") {
|
||||
addr := strings.TrimSpace(u.Opaque)
|
||||
if addr == "" {
|
||||
addr = strings.TrimSpace(u.Path)
|
||||
}
|
||||
addr = strings.TrimPrefix(addr, "//")
|
||||
if i := strings.IndexAny(addr, "?#"); i >= 0 {
|
||||
addr = addr[:i]
|
||||
}
|
||||
addr = strings.ToLower(addr)
|
||||
if !allowedMailto[addr] {
|
||||
return "", fmt.Errorf("почта %s не разрешена", addr)
|
||||
}
|
||||
return "mailto:" + addr, nil
|
||||
}
|
||||
if u.Scheme != "https" && u.Scheme != "http" {
|
||||
return "", fmt.Errorf("разрешены только http(s) ссылки")
|
||||
return "", fmt.Errorf("разрешены только http(s) и mailto ссылки")
|
||||
}
|
||||
if !allowedLinkHosts[strings.ToLower(u.Hostname())] {
|
||||
return "", fmt.Errorf("ссылка на %s не разрешена", u.Hostname())
|
||||
|
||||
Reference in New Issue
Block a user