Documentation ¶
Index ¶
- Constants
- Variables
- func DbConnect(host string, port int, user, password, database string) *pgx.ConnPool
- func DbInit(pool *pgx.ConnPool)
- func Fetch(link string, headers ...[]string) ([]byte, error)
- func FetchJson(link string, v interface{}, raw *[]byte, headers ...[]string) error
- func FindImagesByHash(ctx context.Context, hash []byte, hashType HashType, ...) ([]byte, error)
- func Init()
- func IsImageLink(link string) bool
- func Store(entry *Entry)
- func TransformLink(link string, meta *[]Meta) []string
- type Config
- type Entry
- type HashReq
- type HashType
- type Hashes
- type Image
- type ImageHasMeta
- type ImageList
- type ImgurAlbumResp
- type ImgurImg
- type ImgurImgResp
- type MatchTrigger
- type Meta
- type QueryReq
- type QueryResp
Constants ¶
const MaxDistance = 100
const MaxLimit = 1000
const UserAgent = "imhashdb/v1.0"
Variables ¶
var HashTypes = []HashType{ DHash8, DHash16, DHash32, MHash8, MHash16, MHash32, PHash8, PHash16, PHash32, WHash8Haar, WHash16Haar, WHash32Haar, }
var ImageBlackList = []string{}
var ImageSuffixes = []string{
".jpeg", ".jpg", ".png",
".jpeg:orig", ".jpg:orig", ".png:orig",
".bmp", ".webp",
}
var Logger *zap.Logger
var MatchTriggers = []MatchTrigger{ { HashType: PHash16, MinDistance: 25, Id: 2, }, }
var Pgdb *pgx.ConnPool
var Rdb *redis.Client
var ReImgurAlbum = regexp.MustCompile("(?:https?://)?(?:www\\.|[im]\\.)?imgur\\.com/a/(\\w{7}|\\w{5})")
var ReImgurImg = regexp.MustCompile("(?:https?://)?(?:www\\.|[im]\\.)?imgur\\.com/(\\w{7}|\\w{5})[sbtmlh]?")
Functions ¶
func FindImagesByHash ¶
func IsImageLink ¶
func TransformLink ¶
Types ¶
type Config ¶
type Config struct { PgUser string PgPassword string PgDb string PgHost string PgPort int RedisAddr string RedisPassword string RedisDb int ApiAddr string HasherConcurrency int QueryConcurrency int Store string ImgurClientId string HasherPattern string }
var Conf Config
type HashReq ¶
type HashReq struct {
Data []byte `json:"data"`
}
func (HashReq) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (HashReq) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*HashReq) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*HashReq) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type HashType ¶
type HashType string
const ( DHash8 HashType = "dhash8" DHash16 HashType = "dhash16" DHash32 HashType = "dhash32" MHash8 HashType = "mhash8" MHash16 HashType = "mhash16" MHash32 HashType = "mhash32" PHash8 HashType = "phash8" PHash16 HashType = "phash16" PHash32 HashType = "phash32" WHash8Haar HashType = "whash8haar" WHash16Haar HashType = "whash16haar" WHash32Haar HashType = "whash32haar" )
func (HashType) HashLength ¶
type Hashes ¶
type Hashes struct { DHash8 *fastimagehash.Hash `json:"dhash8"` DHash16 *fastimagehash.Hash `json:"dhash16"` DHash32 *fastimagehash.Hash `json:"dhash32"` MHash8 *fastimagehash.Hash `json:"mhash8"` MHash16 *fastimagehash.Hash `json:"mhash16"` MHash32 *fastimagehash.Hash `json:"mhash32"` PHash8 *fastimagehash.Hash `json:"phash8"` PHash16 *fastimagehash.Hash `json:"phash16"` PHash32 *fastimagehash.Hash `json:"phash32"` WHash8 *fastimagehash.Hash `json:"whash8haar"` WHash16 *fastimagehash.Hash `json:"whash16haar"` WHash32 *fastimagehash.Hash `json:"whash32haar"` }
func ComputeHash ¶
func (Hashes) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Hashes) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Hashes) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Hashes) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type Image ¶
type Image struct { Size int `json:"size"` Sha1 []byte `json:"sha1"` Md5 []byte `json:"md5"` Sha256 []byte `json:"sha256"` Crc32 uint32 `json:"crc32"` Meta []ImageHasMeta `json:"meta"` // contains filtered or unexported fields }
func (Image) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Image) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Image) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Image) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type ImageHasMeta ¶
func (ImageHasMeta) MarshalEasyJSON ¶
func (v ImageHasMeta) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ImageHasMeta) MarshalJSON ¶
func (v ImageHasMeta) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ImageHasMeta) UnmarshalEasyJSON ¶
func (v *ImageHasMeta) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ImageHasMeta) UnmarshalJSON ¶
func (v *ImageHasMeta) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type ImageList ¶
type ImageList struct {
Images []*Image `json:"images"`
}
func (ImageList) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (ImageList) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*ImageList) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ImageList) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type ImgurAlbumResp ¶
type ImgurAlbumResp struct { Data struct { Images []ImgurImg `json:"images"` } `json:"data"` }
type ImgurImgResp ¶
type ImgurImgResp struct {
Data ImgurImg `json:"data"`
}
type MatchTrigger ¶
type Meta ¶
type Meta struct { RetrievedAt int64 `json:"retrieved_at"` Id string `json:"id"` Meta interface{} `json:"meta"` }
func (Meta) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Meta) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Meta) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Meta) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type QueryReq ¶
type QueryReq struct { HashType HashType `json:"type"` Hash []byte `json:"hash"` Distance uint `json:"distance"` Limit uint `json:"limit"` Offset uint `json:"offset"` }
func (QueryReq) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (QueryReq) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*QueryReq) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*QueryReq) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type QueryResp ¶
type QueryResp struct {
Err string `json:"err,omitempty"`
}
func (QueryResp) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (QueryResp) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*QueryResp) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*QueryResp) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface