Skip to content

Commit

Permalink
Prevent 0.0.0.0/8 from being looked up, correct spelling issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
IPQualityScore authored Feb 29, 2024
1 parent 9d5a4f3 commit 51a8e76
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions FileReader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ func (file *FileReader) Fetch(ip string) (*IPQSRecord, error){
record := &IPQSRecord{};

if(file.IPv6 && strings.Contains(ip, ".")){
return record, errors.New("Attemtped to look up IPv4 using IPv6 database file. Aborting.");
return record, errors.New("Attempted to look up IPv4 using IPv6 database file. Aborting.");
} else if(!file.IPv6 && strings.Contains(ip, ":")){
return record, errors.New("Attemtped to look up IPv6 using IPv4 database file. Aborting.");
return record, errors.New("Attempted to look up IPv6 using IPv4 database file. Aborting.");
}

if(!file.IPv6){
_, subnet, _ := net.ParseCIDR("0.0.0.0/8")
incomingIP := net.ParseIP(ip)
if(subnet.Contains(incomingIP)) {
return record, errors.New("Attempted to look up ip in 0.0.0.0/8 range. Aborting.")
}
}

position := 0;
Expand Down

0 comments on commit 51a8e76

Please sign in to comment.