netx

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

from https://github.com/freshcn/qqwry

Index

Constants

View Source
const (
	INDEX_LEN       = 7    // INDEX_LEN 索引长度
	REDIRECT_MODE_1 = 0x01 // REDIRECT_MODE_1 国家的类型, 指向另一个指向
	REDIRECT_MODE_2 = 0x02 // REDIRECT_MODE_2 国家的类型, 指向一个指向
)

Variables

View Source
var UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1541.0 Safari/537.36"

Functions

func Base64Decode

func Base64Decode(str string) (string, error)

base64 decode

func Base64Encode

func Base64Encode(str string) string

base64 encode

func ExternalIP

func ExternalIP() (net.IP, error)

func FetchFiles

func FetchFiles(client *http.Client, files []RawFile, header http.Header) error

FetchFiles fetches files specified by the rawURL field in parallel.

func FetchFilesCurl

func FetchFilesCurl(files []RawFile, curlOptions ...string) error

FetchFilesCurl uses command `curl` to fetch files specified by the rawURL field in parallel.

func HttpCall

func HttpCall(client *http.Client, method, url string, header http.Header, body io.Reader) (io.ReadCloser, error)

HttpCall makes HTTP method call.

func HttpGet

func HttpGet(client *http.Client, url string, header http.Header) (io.ReadCloser, error)

HttpGet gets the specified resource. ErrNotFound is returned if the server responds with status 404.

func HttpGetBytes

func HttpGetBytes(client *http.Client, url string, header http.Header) ([]byte, error)

HttpGetBytes gets the specified resource. ErrNotFound is returned if the server responds with status 404.

func HttpGetJSON

func HttpGetJSON(client *http.Client, url string, v interface{}) error

HttpGetJSON gets the specified resource and mapping to struct. ErrNotFound is returned if the server responds with status 404.

func HttpGetToFile

func HttpGetToFile(client *http.Client, url string, header http.Header, fileName string) error

HttpGetToFile gets the specified resource and writes to file. ErrNotFound is returned if the server responds with status 404.

func HttpPost

func HttpPost(client *http.Client, url string, header http.Header, body []byte) (io.ReadCloser, error)

HttpPost posts the specified resource. ErrNotFound is returned if the server responds with status 404.

func HttpPostJSON

func HttpPostJSON(client *http.Client, url string, body, v interface{}) error

HttpPostJSON posts the specified resource with struct values, and maps results to struct. ErrNotFound is returned if the server responds with status 404.

func UrlDecode

func UrlDecode(str string) (string, error)

url decode string

func UrlEncode

func UrlEncode(str string) string

url encode string, is + not %20

Types

type NotFoundError

type NotFoundError struct {
	Message string
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type QQwry

type QQwry struct {
	Ip      string
	Lng     float64
	Lat     float64
	Address string
	Ips     string

	FileData []byte
	NumIp    int64
	Offset   int64
	Enc      mahonia.Decoder
	// contains filtered or unexported fields
}

func NewQQwry

func NewQQwry(path_file string) (qqwry *QQwry)

func (*QQwry) Find

func (q *QQwry) Find(ip string) string

Find ip地址查询对应归属地信息

func (*QQwry) ReadData

func (q *QQwry) ReadData(num int, offset ...int64) (rs []byte)

ReadData 从文件中读取数据

func (*QQwry) SetOffset

func (q *QQwry) SetOffset(offset int64)

SetOffset 设置偏移量

type RawFile

type RawFile interface {
	Name() string
	RawUrl() string
	Data() []byte
	SetData([]byte)
}

A RawFile describes a file that can be downloaded.

type RemoteError

type RemoteError struct {
	Host string
	Err  error
}

func (*RemoteError) Error

func (e *RemoteError) Error() string

Jump to

Keyboard shortcuts

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