utils

package
v0.0.0-...-1db1413 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CEpoch         = 1474802888000
	CWorkerIdBits  = 10 // Num of WorkerId Bits
	CSenquenceBits = 12 // Num of Sequence Bits

	CWorkerIdShift  = 12
	CTimeStampShift = 22

	CSequenceMask = 0xfff // equal as getSequenceMask()
	CMaxWorker    = 0x3ff // equal as getMaxWorkerId()
)

Variables

This section is empty.

Functions

func Format

func Format(format string, date time.Time) string

Format formats a date based on joda conventions for performance this method recommended to be used

func GetLongID

func GetLongID() (i int64)

func GetPublicIP

func GetPublicIP() string

func Lock

func Lock(key string)

func NextID

func NextID() int64

func ParseId

func ParseId(id int64) (t time.Time, ts int64, workerId int64, seq int64)

ParseId Func: reverse uid to timestamp, workid, seq

func RLock

func RLock(key string)

func RUnLock

func RUnLock(key string)

func UnLock

func UnLock(key string)

Types

type IP

type IP struct {
	IP        string `json:"ip"`
	Country   string `json:"country"`
	Area      string `json:"area"`
	Region    string `json:"region"`
	City      string `json:"city"`
	Isp       string `json:"isp"`
	CountryID string `json:"country_id"`
	AreaID    string `json:"area_id"`
	RegionID  string `json:"region_id"`
	CityID    string `json:"city_id"`
	IspID     string `json:"isp_id"`
}

func WatchIP

func WatchIP(addr string) (*IP, error)

type IPInfo

type IPInfo struct {
	Code int `json:"code"`
	Data IP  `json:"data`
}

type IdWorker

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

IdWorker Struct

var IW *IdWorker

func NewIdWorker

func NewIdWorker(workerid int64) (iw *IdWorker, err error)

NewIdWorker Func: Generate NewIdWorker with Given workerid

func (*IdWorker) NextId

func (iw *IdWorker) NextId() (ts int64, err error)

NewId Func: Generate next id

type SS_Scheme

type SS_Scheme struct {
	Method   string `json:"method"`
	Password string `json:"password"`
	Hostname string `json:"hostname"`
	Port     int    `json:"port"`
}

func Parse_SIP002_URI_Scheme

func Parse_SIP002_URI_Scheme(s string) (*SS_Scheme, error)

Directories

Path Synopsis
Package socksproxy implements essential parts of SOCKS protocol.
Package socksproxy implements essential parts of SOCKS protocol.

Jump to

Keyboard shortcuts

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