Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
txthinking committed May 4, 2024
1 parent 96c01f9 commit a8ff76e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cli/brook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2742,11 +2742,11 @@ func main() {
if ip == nil {
return errors.New(c.String("ip") + " is not IP")
}
b := iploc.Country(ip)
if b == nil {
s := iploc.Country(ip)
if s == "" {
return errors.New(c.String("ip") + " unknown")
}
fmt.Println(string(b))
fmt.Println(s)
return nil
},
},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/krolaw/dhcp4 v0.0.0-20190909130307-a50d88189771
github.com/miekg/dns v1.1.57
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/phuslu/iploc v1.0.20231031
github.com/phuslu/iploc v1.0.20240501
github.com/prometheus/client_golang v1.17.0
github.com/quic-go/quic-go v0.42.0
github.com/refraction-networking/utls v1.5.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaR
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/phuslu/iploc v1.0.20231031 h1:AsKT2PqStXV+gqJjNJ5mcUJ7YT9i09W+NVthhz5987s=
github.com/phuslu/iploc v1.0.20231031/go.mod h1:gsgExGWldwv1AEzZm+Ki9/vGfyjkL33pbSr9HGpt2Xg=
github.com/phuslu/iploc v1.0.20240501 h1:lX2dEFOQzxVpTH3dgJ+pcNEpLxwaJUhoCGMoajuAI5w=
github.com/phuslu/iploc v1.0.20240501/go.mod h1:VZqAWoi2A80YPvfk1AizLGHavNIG9nhBC8d87D/SeVs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
Expand Down
5 changes: 2 additions & 3 deletions list.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ func ListHasIP(c4, c6 []*net.IPNet, i net.IP, c *cache.Cache, geo []string) bool
}
}
if len(geo) != 0 {
b := iploc.Country(i)
if b != nil {
bs := string(b)
bs := iploc.Country(i)
if bs != "" {
for _, v := range geo {
if v == bs {
if c != nil {
Expand Down
6 changes: 4 additions & 2 deletions test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ package brook

import (
"log"
"net"
"testing"

"github.com/phuslu/iploc"
)

func TestTest(t *testing.T) {
l, err := CAC("/tmp/a")
log.Printf("%#v %v\n", l, err)
log.Printf("%#v\n", iploc.Country(net.ParseIP("8.8.8.8")))
}

0 comments on commit a8ff76e

Please sign in to comment.