geotor

package module
v0.0.0-...-6554995 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

README

Polychromatic

Go Report Card GoDoc

GeoTor provides a high performance, async, auto updating interface to MaxMind's GeoIP databases, and further augments this data with up to date data from the Tor project about if nodes are tor members.

Contact: developer@tenta.io

Installation

go get github.com/tenta-browser/geotor

Usage

Call StartGeo to startup a geo gorouting as well as tor and geodb updaters. Call Shutdown (blocking) before exiting. It will be necessary to specify at the very least the MaxMind API key in the config struct passed to StartGeo.

Call Geo.Query(net.IP) to perform an async query, which will be available from the returned Query object.

Performance

This is a high performance component designed for heavy duty production use. We use it in Tenta DNS. The async API is not as easy to use as the underlying maxminddb package which it relies on, but allows programs to make progress while a goroutine performs the lookup.

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

For any questions, please contact developer@tenta.io

Contributing

We welcome contributions, feedback and plain old complaining. Feel free to open an issue or shoot us a message to developer@tenta.io. If you'd like to contribute, please open a pull request and send us an email to sign a contributor agreement.

About Tenta

This geo library is brought to you by Team Tenta. Tenta is your private, encrypted browser that protects your data instead of selling. We're building a next-generation browser that combines all the privacy tools you need, including built-in OpenVPN. Everything is encrypted by default. That means your bookmarks, saved tabs, web history, web traffic, downloaded files, IP address and DNS. A truly incognito browser that's fast and easy.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRequestTimeout = errors.New("unable to queue the geo request for processing")

Functions

This section is empty.

Types

type Config

type Config struct {
	GeoDBPath             string
	MaxMindUrlTemplate    string
	MaxMindKey            string
	TorUrl                string
	MaxMindUpdateInterval time.Duration
	TorUpdateInterval     time.Duration
}

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates a sane config with daily maxmind checks and hourly tor checks

type ExitAddress

type ExitAddress struct {
	IP   net.IP
	Date time.Time
}

Type ExitAddress represents an IP address and active time

type Geo

type Geo struct {
	// contains filtered or unexported fields
}

func StartGeo

func StartGeo(cfg Config) *Geo

func (*Geo) Loaded

func (g *Geo) Loaded() bool

func (*Geo) Query

func (g *Geo) Query(ip net.IP) (*Query, error)

func (*Geo) Shutdown

func (g *Geo) Shutdown()

type GeoLocation

type GeoLocation struct {
	Position     *Position         `json:"position"`
	ISP          *ISP              `json:"network"`
	City         string            `json:"city"`
	Country      string            `json:"country"`
	CountryISO   string            `json:"iso_country"`
	Location     string            `json:"location"`
	LocationI18n map[string]string `json:"localized_location"`
	TorNode      *string           `json:"tor_node"`
}

type ISP

type ISP struct {
	Organization   string `maxminddb:"organization" json:"organization"`
	ASNumber       uint   `maxminddb:"autonomous_system_number" json:"as_number"`
	ASOrganization string `maxminddb:"autonomous_system_organization" json:"as_owner"`
	ISP            string `maxminddb:"isp" json:"isp"`
}

type Position

type Position struct {
	Latitude  float32 `maxminddb:"latitude" json:"latitude"`
	Longitude float32 `maxminddb:"longitude" json:"longitude"`
	Radius    uint    `maxminddb:"accuracy_radius" json:"uncertainty_km"`
	TimeZone  string  `maxminddb:"time_zone" json:"time_zone"`
}

type Query

type Query struct {
	// contains filtered or unexported fields
}

func (*Query) Response

func (q *Query) Response(ctx context.Context) (*GeoLocation, error)

type TorHash

type TorHash struct {
	// contains filtered or unexported fields
}

Type TorHash implements a hash structure for TorNodes. It is not thread safe for writes, but will tolerate concurrent readers.

func NewTorHash

func NewTorHash() *TorHash

func (*TorHash) Add

func (t *TorHash) Add(node *TorNode)

Adds a TorNode to the hash

func (*TorHash) Exists

func (t *TorHash) Exists(ip net.IP) (string, bool)

Looks up the specified IP to see if it exists and returns the node id if it does.

func (*TorHash) Len

func (t *TorHash) Len() int

Indicates the number of entries in this hash

func (*TorHash) Lookup

func (t *TorHash) Lookup(ip net.IP) (*TorNode, bool)

Looks up the specified ip to see if it's a tor node. Returns a TorNode or nil and a boolean

func (TorHash) String

func (t TorHash) String() string

type TorNode

type TorNode struct {
	NodeId    string
	Published time.Time
	Updated   time.Time
	Addresses []ExitAddress
}

Type TorNode represents a single node in the tor network.

func NewTorNode

func NewTorNode() *TorNode

func (TorNode) String

func (t TorNode) String() string

type VersionData

type VersionData struct {
	City string
	Isp  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL