Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "strings"
- )
- // List of ad domains to block
- var blockedDomains = []string{
- "adserver.com",
- "adservice.net",
- "exampleads.com",
- }
- func main() {
- // Simulating network requests
- requests := []string{
- "https://example.com",
- "https://adserver.com/ad1",
- "https://exampleads.com/banner",
- }
- numRequests := len(requests)
- numDomains := len(blockedDomains)
- // Check each request
- for i := 0; i < numRequests; i++ {
- blocked := false
- // Check against each blocked domain
- for j := 0; j < numDomains; j++ {
- if strings.Contains(requests[i], blockedDomains[j]) {
- blocked = true
- break
- }
- }
- // Print the result
- if blocked {
- fmt.Printf("%s: Blocked\n", requests[i])
- } else {
- fmt.Printf("%s: Allowed\n", requests[i])
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement