Documentation
¶
Overview ¶
Package xlget implements a blacklist downloader.
This package is a work in progress and makes no API stability promises.
Index ¶
- Variables
- func SetHTTPClient(h *grab.Client)
- func ValidCompression(c Compression) bool
- func ValidFormatSource(f FormatSource) bool
- func ValidURI(uri string) bool
- func ValidateEntry(e Entry) error
- type AccountItem
- type CancelFunc
- type Client
- type Compression
- type Config
- type Duration
- type Entry
- type EntryStatus
- type FormatOpts
- type FormatSource
- type Manager
- type Option
- type Response
- type Source
- type State
- type TransformOpts
Constants ¶
This section is empty.
Variables ¶
var (
ErrCanceled = errors.New("download canceled")
)
Common errors
Functions ¶
func ValidCompression ¶
func ValidCompression(c Compression) bool
ValidCompression returns true if is valid compression.
func ValidFormatSource ¶
func ValidFormatSource(f FormatSource) bool
ValidFormatSource returns true if is a valid format.
Types ¶
type AccountItem ¶
AccountItem stores accounting info I can't use a simple map[xlist.Resources] because this issue: //https://github.com/golang/go/issues/29732
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client downloads requests
type Compression ¶
type Compression int
Compression defines compression algs
const ( None Compression = iota Gzip Zip )
List of compression values
func (Compression) MarshalJSON ¶
func (c Compression) MarshalJSON() ([]byte, error)
MarshalJSON implements interface for struct marshalling.
func (Compression) String ¶
func (c Compression) String() string
func (*Compression) UnmarshalJSON ¶
func (c *Compression) UnmarshalJSON(data []byte) error
UnmarshalJSON implements interface for struct unmarshalling.
type Duration ¶
Duration is used for unmarshalling durations. tip from: https://robreid.io/json-time-duration/
func (Duration) MarshalJSON ¶
MarshalJSON implements interface
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements interface
type Entry ¶
type Entry struct {
ID string `json:"id"`
Disabled bool `json:"disabled,omitempty"`
Removed bool `json:"removed,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Update Duration `json:"update"`
Sources []Source `json:"sources"`
Transforms *TransformOpts `json:"transforms,omitempty"`
NoClean bool `json:"noclean,omitempty"`
NoHash bool `json:"nohash,omitempty"`
Output string `json:"output,omitempty"`
}
Entry defines configuration entries format
func EntryDefsFromFile ¶
EntryDefsFromFile returns an Entry slice of configuration
type EntryStatus ¶
type EntryStatus struct {
ID string `json:"id"`
// First sync and last sync
First time.Time `json:"first"`
Last time.Time `json:"last"`
// Updates stores only successful syncs
Updates int `json:"updates"`
LastUpdate *time.Time `json:"lastupdate,omitempty"`
// Changes stores changes in list (md5 changed)
Changes int `json:"changes"`
LastChange *time.Time `json:"lastchange,omitempty"`
// Errors stores number of sync errors (not errors in file)
Errors int `json:"errors"`
LastError *time.Time `json:"lasterror,omitempty"`
// Last sync state
UpdatedOK bool `json:"updatedok"`
Account []AccountItem `json:"account,omitempty"`
ErrorMsg string `json:"errormsg,omitempty"`
}
EntryStatus stores status information
func EntryStatusFromFile ¶
func EntryStatusFromFile(path string) (EntryStatus, error)
EntryStatusFromFile returns an EntryStatus
type FormatOpts ¶
type FormatOpts struct {
Comma string `json:"comma,omitempty"`
Comment string `json:"comment,omitempty"`
HasHeader bool `json:"header,omitempty"`
Indexes []int `json:"indexes,omitempty"`
LazyQuotes bool `json:"lazyquotes,omitempty"`
}
FormatOpts defines format options for conversors
type FormatSource ¶
type FormatSource int
FormatSource defines source formats
const ( XList FormatSource = iota Flat CSV Hosts )
List of source format values
func (FormatSource) MarshalJSON ¶
func (f FormatSource) MarshalJSON() ([]byte, error)
MarshalJSON implements interface for struct marshalling.
func (FormatSource) String ¶
func (f FormatSource) String() string
func (*FormatSource) UnmarshalJSON ¶
func (f *FormatSource) UnmarshalJSON(data []byte) error
UnmarshalJSON implements interface for struct unmarshalling.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager processes configuration entries and checks for required updates
func NewManager ¶
NewManager creates a new manager
func (*Manager) Deprecated ¶
Deprecated returns an slice with ids deprecated
func (*Manager) NeedsUpdate ¶
NeedsUpdate returns an slice with ids that must be updated
func (*Manager) Update ¶
func (m *Manager) Update() (CancelFunc, <-chan struct{}, error)
Update entries registered in backbround, it returns a cancelation function, a done channel (it will close when process done) and an error.
type Response ¶
type Response struct {
ID string
Done chan struct{}
Start, End time.Time
Account map[xlist.Resource]int
Updated bool
Output string
Hash string
// contains filtered or unexported fields
}
Response stores information about download and conversion
func (*Response) IsComplete ¶
IsComplete returns true if completed
type Source ¶
type Source struct {
URI string `json:"uri"`
Filename string `json:"filename,omitempty"`
Compression Compression `json:"compression,omitempty"`
Format FormatSource `json:"format"`
FormatOpts *FormatOpts `json:"formatopts,omitempty"`
Resources []xlist.Resource `json:"resources,omitempty"`
Limit int `json:"limit,omitempty"`
}
Source defines configuration for sources
type TransformOpts ¶
type TransformOpts struct {
TLDPlusOne bool `json:"tldplusone,omitempty"`
}
TransformOpts defines transformations.