Documentation ¶
Index ¶
- func AutoSync(ctx context.Context, c *Client, realtime bool, ...) error
- func ReadCacheFrom(c *Client, r io.Reader) error
- func SaveOnChange(ctx context.Context, c *Client, w io.Writer) error
- func WriteCacheInto(c *Client, w io.Writer) error
- type Client
- func (c *Client) Check(domain string) bool
- func (c *Client) Close() error
- func (c *Client) Domains() []string
- func (c *Client) FullSync() error
- func (c *Client) FuzzyCheck(domain string) bool
- func (c *Client) ListenForUpdates(ctx context.Context) error
- func (c *Client) MarshalJSON() ([]byte, error)
- func (c *Client) Raw() RawClient
- func (c *Client) Size() int
- func (c *Client) UnmarshalJSON(data []byte) error
- func (c *Client) Update() error
- func (c *Client) UpdateChannel() chan struct{}
- type DomainUpdate
- type Option
- type RawClient
- func (c RawClient) After(after time.Time) ([]DomainUpdate, error)
- func (c RawClient) All() ([]string, error)
- func (c RawClient) Check(domain string) (bool, error)
- func (c RawClient) Feed(ctx context.Context, modFeed chan DomainUpdate) error
- func (c RawClient) Recent(seconds int) ([]DomainUpdate, error)
- func (c RawClient) Size() (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoSync ¶
func AutoSync(ctx context.Context, c *Client, realtime bool, recentInterval, fullSyncInterval time.Duration) error
AutoSync is a helper that setup auto syncing functionality for Client this function blocks and return only when cancelled by ctx, or occurrence of an error you can use 0 to disable recent syncing and full syncing though it's recommended to use full sync, especially when realtime is enabled the recent interval is only useful when realtime is disabled
func ReadCacheFrom ¶
ReadCacheFrom loads stored cache from the reader into Client
func SaveOnChange ¶
SaveOnChange register listen for updates and writes it into the writer this function blocks and returns only when update channel gets closed, use ctx to cancel
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Check ¶
Check if a domain is phishing parent domains will not be checked, FuzzyCheck should be used instead
func (*Client) Domains ¶
Domains return a list of known phishing domains. there are no specific order of the domains.
func (*Client) FuzzyCheck ¶
FuzzyCheck if a domain is phishing fuzzy check includes checking parent domains (foo.bar.bad.com will check bar.bad.com and bad.com) and returns true if any of the domains is phishing
func (*Client) ListenForUpdates ¶
ListenForUpdates starts a wss connection to the api and listens for updates. use ctx to cancel close the connection
func (*Client) MarshalJSON ¶
MarshalJSON marshal the Client's cache to JSON
func (*Client) UnmarshalJSON ¶
UnmarshalJSON unmarshal the Client's cache from JSON
func (*Client) Update ¶
Update updates the list of known phishing domains from the api based on last update time.
func (*Client) UpdateChannel ¶
func (c *Client) UpdateChannel() chan struct{}
UpdateChannel returns a channel that emits empty struct whenever Client's domain get updated calls will unregister the previous channel update may get dropped if channel is full, sends do not wait for receiver
type DomainUpdate ¶
type DomainUpdate struct { //Add defines if it is adding or removing domains Add bool //Domains is a slice of domains Domains []string }
DomainUpdate represent an update to the domains list, which depending on type, it could mean adding or deleting domains
func (*DomainUpdate) UnmarshalJSON ¶
func (m *DomainUpdate) UnmarshalJSON(bytes []byte) error
type Option ¶
type Option func(client *RawClient)
Option is a function that can configure a RawClient Option should only be used by NewRawClient, using it in any other way may risk race error and undefined behaviour
func WithFeedTimeout ¶
WithFeedTimeout sets a custom feed timeout for dialing to the websocket update feed
func WithHeader ¶
func WithHeaders ¶
WithHeaders sets a custom header to RawClient, if "X-Identity" is present, it will be overwritten by RawClient's identity
func WithoutHeader ¶
type RawClient ¶
type RawClient struct {
// contains filtered or unexported fields
}
RawClient is the low level api to sinking yachts it does not cache and all responses are blocking it is safe for concurrent use
func NewRawClient ¶
NewRawClient creates a new RawClient the endpoint should point to the root of api, without trailing slashes for example "https://example.com" no trailing versions the identity is something that identifies your application, and your contact for example "Foo Bot (foobar@example.com)" or "Foo Bot (foobar#12345 on discord)" the api may error if identity is incorrect or missing webClient is the http.Client that will be used by RawClient, you probably don't want to use default http as there's no timeouts! Option is a variadic of optional options to further configure the RawClient Note that X-Identity cannot be overwritten with it
func (RawClient) After ¶
func (c RawClient) After(after time.Time) ([]DomainUpdate, error)
After will return a slice of changes that are after said time the underlying api uses seconds, therefore anything with finer will be rounded up
func (RawClient) All ¶
All get all phishing domains from the api and return it as a slice of domains
func (RawClient) Check ¶
Check will check if a domain is a phishing domain true if it's flagged as phishing, false otherwise
func (RawClient) Feed ¶
func (c RawClient) Feed(ctx context.Context, modFeed chan DomainUpdate) error
Feed connects into the wss endpoint to get live updates Feed will block forever, and only returns if ctx cancels it, or there's an error to cancel use context.WithCancel as ctx error will be nil when process exited cleanly