GithubHelp home page GithubHelp logo

ip2location / ip2proxy-go Goto Github PK

View Code? Open in Web Editor NEW
22.0 5.0 6.0 123 KB

IP2Proxy Go package allows users to query an IP address to determine if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.

Home Page: https://www.ip2location.com/ip2proxy/developers/go

License: MIT License

Go 100.00%
ip2proxy ip2proxy-database go-lang go-package proxy-checker ip2location

ip2proxy-go's Introduction

Go Report Card PkgGoDev

IP2Proxy Go Package

This package allows user to query an IP address if it was being used as VPN anonymizer, open proxies, web proxies, Tor exits, data center, web hosting (DCH) range, search engine robots (SES), residential proxies (RES), consumer privacy networks (CPN), and enterprise private networks (EPN). It lookup the proxy IP address from IP2Proxy BIN Data file. This data file can be downloaded at

Developer Documentation

To learn more about installation, usage, and code examples, please visit the developer documentation at https://ip2proxy-go.readthedocs.io/en/latest/index.html.

ip2proxy-go's People

Contributors

ip2location avatar un000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ip2proxy-go's Issues

GetAll causes runtime exception

Hi,

We recently upgraded our ip2proxy package version from 2.2.0 to 2.3.0, and we started to get the following exception on calling db.GetAll("8.8.8.8"):

panic: runtime error: slice bounds out of range [:16] with capacity 12

goroutine 1 [running]:
github.com/ip2location/ip2proxy-go.(*DB).readuint32_row(0xc0001ce070, 0xc00049af10, 0xc, 0xc, 0xc, 0x0)
	/Users/USER/go/pkg/mod/github.com/ip2location/[email protected]+incompatible/ip2proxy.go:195 +0xbf
github.com/ip2location/ip2proxy-go.(*DB).query(0xc0001ce070, 0x177e7ea, 0x7, 0xc000000fff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/USER/go/pkg/mod/github.com/ip2location/[email protected]+incompatible/ip2proxy.go:874 +0x10f6
github.com/ip2location/ip2proxy-go.(*DB).GetAll(0xc0001ce070, 0x177e7ea, 0x7, 0x0, 0x0, 0x0)
	/Users/USER/go/pkg/mod/github.com/ip2location/[email protected]+incompatible/ip2proxy.go:636 +0xb5
...

After trying to debug it, I've found out that the exception is caused at:

ip2proxy-go/ip2proxy.go

Lines 871 to 877 in 5f6cbea

if mode&city != 0 && d.city_enabled {
// x.City = readstr(readuint32(rowoffset + city_position_offset))
// x.City = readstr(readuint32_row(row, city_position_offset))
if x.City, err = d.readstr(d.readuint32_row(row, d.city_position_offset)); err != nil {
return x, err
}
}

row is 12 bytes and d.readuint32_row tries to read range [12:16].

We need this fixed to use release v2.3.0 to benefit from concurrency improvements.

Some suggestion to reduce memory allocation for better performance

Background:

  • Recently, my company project is adopting ip2location vendor as the main IP DB source and we found that this package is running unexpectedly slow.

Findings:

  • A lot of memory allocation (Although there are some optimisation changes added to the latest version v3.4.1).
  • Map is abused as getter result even though fields are known.

Optimisation:

Benchmark:

  • Using Google Bot's IP:"66.249.66.1" as input:
goos: darwin
goarch: amd64
pkg: draft.65
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Benchmark2WithMemoryReader_PX11
Benchmark2WithMemoryReader_PX11-12        	  241352	      4778 ns/op	    7014 B/op	      80 allocs/op
Benchmark2WithMemoryReader_PX11_New
Benchmark2WithMemoryReader_PX11_New-12    	  804042	      1355 ns/op	    3928 B/op	      24 allocs/op
PASS

May I know if you guys are fine to accept my PR to know more? (incl. "https://github.com/ip2location/ip2location-go")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.