mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Handle generated errors in broker
This commit is contained in:
parent
ed3d42e1ec
commit
3cfceb3755
4 changed files with 39 additions and 22 deletions
|
@ -93,7 +93,7 @@ func (table *GeoIPv6Table) Unlock() { (*table).lock.Unlock() }
|
|||
func geoipStringToIP(ipStr string) (net.IP, error) {
|
||||
ip, err := strconv.ParseUint(ipStr, 10, 32)
|
||||
if err != nil {
|
||||
return net.IPv4(0, 0, 0, 0), fmt.Errorf("Error parsing IP %s", ipStr)
|
||||
return net.IPv4(0, 0, 0, 0), fmt.Errorf("error parsing IP %s", ipStr)
|
||||
}
|
||||
var bytes [4]byte
|
||||
bytes[0] = byte(ip & 0xFF)
|
||||
|
@ -115,7 +115,7 @@ func (table *GeoIPv4Table) parseEntry(candidate string) (*GeoIPEntry, error) {
|
|||
parsedCandidate := strings.Split(candidate, ",")
|
||||
|
||||
if len(parsedCandidate) != 3 {
|
||||
return nil, fmt.Errorf("Provided geoip file is incorrectly formatted. Could not parse line:\n%s", parsedCandidate)
|
||||
return nil, fmt.Errorf("provided geoip file is incorrectly formatted. Could not parse line:\n%s", parsedCandidate)
|
||||
}
|
||||
|
||||
low, err := geoipStringToIP(parsedCandidate[0])
|
||||
|
@ -190,7 +190,7 @@ func GeoIPLoadFile(table GeoIPTable, pathname string) error {
|
|||
for scanner.Scan() {
|
||||
entry, err := table.parseEntry(scanner.Text())
|
||||
if err != nil {
|
||||
return fmt.Errorf("Provided geoip file is incorrectly formatted. Line is: %+q", scanner.Text())
|
||||
return fmt.Errorf("provided geoip file is incorrectly formatted. Line is: %+q", scanner.Text())
|
||||
}
|
||||
|
||||
if entry != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue