geosite

package module
v1.0.20240505 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 13 Imported by: 0

README

geosite - a golang geosite library

godoc release goreport

Getting Started

try on https://play.golang.org/p/Hp5zEc2XhwM

package main

import (
	"context"
	"net/http"

	"github.com/phuslu/geosite"
)

func main() {
	dlc := &geosite.DomainListCommunity{Transport: http.DefaultTransport}
	dlc.Load(context.Background(), geosite.OnlineTarball)
	
	println(dlc.Site("chat.openai.com"))
}

// Output: openai
Benchmarks
goos: windows
goarch: amd64
pkg: github.com/phuslu/geosite
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
BenchmarkSite
BenchmarkSite-8            25392           42935 ns/op             0 B/op        0 allocs/op
BenchmarkSiteAttrs
BenchmarkSiteAttrs-8       27147           43925 ns/op             0 B/op        0 allocs/op
PASS
ok      github.com/phuslu/geosite       4.288s
Acknowledgment

This site or product uses dlc data available from http://github.com/v2fly/domain-list-community

Documentation

Overview

Package geosite provides a geo site library for Go.

package main

import (
	"context"

	"github.com/phuslu/geosite"
)

func main() {
	dlc := &geosite.DomainListCommunity{Transport: http.DefaultTransport}
	dlc.Load(context.Backgroud(), geosite.OnlineTarball)
	println(dlc.Site("chat.openai.com"))
}

// Output: openai

Index

Constants

View Source
const OnlineTarball = "https://codeload.github.com/v2fly/domain-list-community/legacy.tar.gz/refs/heads/master"
View Source
const Version = "v1.0.20240505"

Variables

View Source
var InlineTarball string

Functions

This section is empty.

Types

type DomainListCommunity added in v1.0.20231219

type DomainListCommunity struct {
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

func (*DomainListCommunity) Load added in v1.0.20231219

func (d *DomainListCommunity) Load(ctx context.Context, tarball string) error

Load loads dlc data from repo url to memory.

func (*DomainListCommunity) Site added in v1.0.20231219

func (d *DomainListCommunity) Site(domain string) (site string)

Site return geo site of domain.

func (*DomainListCommunity) SiteAttrs added in v1.0.20240101

func (d *DomainListCommunity) SiteAttrs(domain string) (site string, attrs []string)

SiteAttrs return geo site of domain and its attrs.

Jump to

Keyboard shortcuts

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