|
|
@ -28,6 +28,7 @@ import ( |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"os/signal" |
|
|
|
"os/signal" |
|
|
|
"path/filepath" |
|
|
|
"path/filepath" |
|
|
|
|
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
"unbewohnte/wecr/config" |
|
|
|
"unbewohnte/wecr/config" |
|
|
|
"unbewohnte/wecr/logger" |
|
|
|
"unbewohnte/wecr/logger" |
|
|
@ -175,7 +176,12 @@ func main() { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for index, blacklistedDomain := range conf.BlacklistedDomains { |
|
|
|
var sanitizedBlacklistedDomains []string |
|
|
|
|
|
|
|
for _, blacklistedDomain := range conf.BlacklistedDomains { |
|
|
|
|
|
|
|
if strings.TrimSpace(blacklistedDomain) == "" { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
parsedURL, err := url.Parse(blacklistedDomain) |
|
|
|
parsedURL, err := url.Parse(blacklistedDomain) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
logger.Warning("Failed to parse blacklisted \"%s\": %s", blacklistedDomain, err) |
|
|
|
logger.Warning("Failed to parse blacklisted \"%s\": %s", blacklistedDomain, err) |
|
|
@ -188,10 +194,16 @@ func main() { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
conf.BlacklistedDomains[index] = parsedURL.Host |
|
|
|
sanitizedBlacklistedDomains = append(sanitizedBlacklistedDomains, parsedURL.Host) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
conf.BlacklistedDomains = sanitizedBlacklistedDomains |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sanitizedAllowedDomains []string |
|
|
|
|
|
|
|
for _, allowedDomain := range conf.AllowedDomains { |
|
|
|
|
|
|
|
if strings.TrimSpace(allowedDomain) == "" { |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for index, allowedDomain := range conf.AllowedDomains { |
|
|
|
|
|
|
|
parsedURL, err := url.Parse(allowedDomain) |
|
|
|
parsedURL, err := url.Parse(allowedDomain) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
logger.Warning("Failed to parse allowed \"%s\": %s", allowedDomain, err) |
|
|
|
logger.Warning("Failed to parse allowed \"%s\": %s", allowedDomain, err) |
|
|
@ -204,8 +216,9 @@ func main() { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
conf.AllowedDomains[index] = parsedURL.Host |
|
|
|
sanitizedAllowedDomains = append(sanitizedAllowedDomains, parsedURL.Host) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
conf.AllowedDomains = sanitizedAllowedDomains |
|
|
|
|
|
|
|
|
|
|
|
if conf.Depth <= 0 { |
|
|
|
if conf.Depth <= 0 { |
|
|
|
conf.Depth = 1 |
|
|
|
conf.Depth = 1 |
|
|
|