mirror of
https://github.com/cunnie/sslip.io.git
synced 2025-10-05 15:46:50 +08:00
"[Bb]lockList" → "[Bb]locklist"
We conform to the modern usage of "blacklist". In Google search, "blacklist" appears 45 million times, "black list", 7 million. Yes, I'm aware that we're using "block", not "black", for the variable name, but keep in mind that we're using "block" as a drop-in replacement for "black". And the newer "blocklist" has a puny 1 million appearances to "blacklist"'s 45.
This commit is contained in:
@@ -115,14 +115,14 @@ func readFrom(conn *net.UDPConn, wg *sync.WaitGroup, x xip.Xip, blocklistURL str
|
||||
}()
|
||||
go func() {
|
||||
for {
|
||||
blockListStrings, blockListCDIRs, err := readBlocklist(blocklistURL)
|
||||
blocklistStrings, blocklistCDIRs, err := readBlocklist(blocklistURL)
|
||||
if err != nil {
|
||||
log.Println(fmt.Errorf("couldn't get blocklist at %s: %w", blocklistURL, err))
|
||||
} else {
|
||||
log.Printf("Successfully downloaded blocklist from %s: %v, %v", blocklistURL, blockListStrings, blockListCDIRs)
|
||||
x.BlockListStrings = blockListStrings
|
||||
x.BlockListCDIRS = blockListCDIRs
|
||||
x.BlockListUpdated = time.Now()
|
||||
log.Printf("Successfully downloaded blocklist from %s: %v, %v", blocklistURL, blocklistStrings, blocklistCDIRs)
|
||||
x.BlocklistStrings = blocklistStrings
|
||||
x.BlocklistCDIRS = blocklistCDIRs
|
||||
x.BlocklistUpdated = time.Now()
|
||||
}
|
||||
time.Sleep(1 * time.Hour)
|
||||
}
|
||||
|
@@ -38,11 +38,12 @@ type Xip struct {
|
||||
Etcd V3client // etcd client for `k-v.io`
|
||||
DnsAmplificationAttackDelay chan struct{} // for throttling metrics.status.sslip.io
|
||||
Metrics *Metrics // DNS server metrics
|
||||
BlockListStrings []string // list of blacklisted strings that shouldn't appear in public hostnames
|
||||
BlockListCDIRS []net.IPNet // list of blacklisted strings that shouldn't appear in public hostnames
|
||||
BlockListUpdated time.Time // The most recent time the BlockList was updated
|
||||
BlocklistStrings []string // list of blacklisted strings that shouldn't appear in public hostnames
|
||||
BlocklistCDIRS []net.IPNet // list of blacklisted strings that shouldn't appear in public hostnames
|
||||
BlocklistUpdated time.Time // The most recent time the Blocklist was updated
|
||||
}
|
||||
|
||||
// Metrics contains the counters of the important/interesting queries
|
||||
type Metrics struct {
|
||||
Start time.Time
|
||||
Queries int
|
||||
@@ -891,7 +892,7 @@ func (a Metrics) MostlyEquals(b Metrics) bool {
|
||||
|
||||
// ReadBlocklist "sanitizes" the block list, removing comments, invalid characters
|
||||
// and lowercasing the names to be blocked
|
||||
func ReadBlocklist(blocklist io.Reader) (stringBlocklists []string, cidrBlockLists []net.IPNet, err error) {
|
||||
func ReadBlocklist(blocklist io.Reader) (stringBlocklists []string, cidrBlocklists []net.IPNet, err error) {
|
||||
scanner := bufio.NewScanner(blocklist)
|
||||
comments := regexp.MustCompile(`#.*`)
|
||||
invalidDNSchars := regexp.MustCompile(`[^-_0-9a-z]`)
|
||||
@@ -910,13 +911,13 @@ func ReadBlocklist(blocklist io.Reader) (stringBlocklists []string, cidrBlockLis
|
||||
}
|
||||
stringBlocklists = append(stringBlocklists, line)
|
||||
} else {
|
||||
cidrBlockLists = append(cidrBlockLists, *ipcidr)
|
||||
cidrBlocklists = append(cidrBlocklists, *ipcidr)
|
||||
}
|
||||
}
|
||||
if err = scanner.Err(); err != nil {
|
||||
return []string{}, []net.IPNet{}, err
|
||||
}
|
||||
return stringBlocklists, cidrBlockLists, nil
|
||||
return stringBlocklists, cidrBlocklists, nil
|
||||
}
|
||||
|
||||
func (x Xip) isEtcdNil() bool {
|
||||
@@ -944,7 +945,7 @@ func (x Xip) blocklist(hostname string) bool {
|
||||
if ip.IsPrivate() {
|
||||
return false
|
||||
}
|
||||
for _, blockstring := range x.BlockListStrings {
|
||||
for _, blockstring := range x.BlocklistStrings {
|
||||
if strings.Contains(hostname, blockstring) {
|
||||
return true
|
||||
}
|
||||
|
@@ -17,6 +17,11 @@ To find the domains queried (95% sslip.io):
|
||||
# find all successful queries of A & AAAA records
|
||||
grep -v '\. \? nil' < sslip.io.log |\
|
||||
egrep "TypeA | TypeAAAA " |\
|
||||
cut -d " " -f 10 > hosts.log
|
||||
cut -d " " -f 10 > /tmp/hosts.log
|
||||
sed -E 's=.*(\.[^.]+\.[^.]+\.$)=\1=' < hosts.log | tr 'A-Z' 'a-z' | sort | uniq -c | sort -n
|
||||
```
|
||||
|
||||
```zsh
|
||||
# find the most looked-up IP addresses using the above hosts.log
|
||||
sort < /tmp/hosts.log | uniq -c | sort -n | tail -50
|
||||
```
|
||||
|
Reference in New Issue
Block a user