Documentation
¶
Index ¶
- Variables
- func Connect(uri string) error
- func Disconnect() error
- func GetStat() (int64, error)
- func Insert(d string) (bool, error)
- func InsertNotFound(d string) (bool, error)
- func InsertTopList(d string) (bool, error)
- func Lookup(d string) ([]string, error)
- func Starts(d string) ([]string, error)
- func TLD(d string) ([]string, error)
- type DomainSchema
- type NotFoundSchema
- type TopListSchema
Constants ¶
This section is empty.
Variables ¶
var ( Client *mongo.Client Domains *mongo.Collection // The main collection to store the entries NotFound *mongo.Collection // Store domains that not found by Lookup TopList *mongo.Collection // Store and count successful lookups )
Functions ¶
func Insert ¶
Insert inserts the given domain d to the *domains* database. Checks if d is valid, do a Clean() and then splits into sub|domain|tld parts.
Returns true if d is new and inserted into the database. If domain is invalid, returns fault.ErrInvalidDomain. If failed to get parts of d (eg.: d is a TLD), returns ault.ErrGetPartsFailed.
func InsertNotFound ¶ added in v0.14.0
InsertNotFound inserts the given domain d to the *notFound* database. Checks if d is valid, do a Clean() and removes the subdomain from d.
Returns true if d is new and inserted into the database. If domain is invalid or failed to remove the subdomain, returns fault.ErrInvalidDomain.
func InsertTopList ¶ added in v0.14.0
InsertTopList inserts the given domain d to the *topList* database or increase the counter if exists. Checks if d is valid, do a Clean() and removes the subdomain from d.
Returns true if d is new and inserted into the database. If domain is invalid or failed to remove the subdomain, returns fault.ErrInvalidDomain.
func Lookup ¶
Lookup query the DB and returns a list subdomains.
If d has a subdomain, removes it before the query.
If d is invalid return fault.ErrInvalidDomain. If failed to get parts of d (eg.: d is a TLD), returns ault.ErrGetPartsFailed.
func Starts ¶ added in v0.14.0
Starts query the DB and returns a list of Second Level Domains (eg.: example) that starts with d.
Domain d must be a valid Second Level Domain (eg.: "example"). This function validate with IsValidSLD() and Clean().
Returns fault.ErrInvalidDomain is d is not a valid Second Level Domain.
Types ¶
type DomainSchema ¶ added in v0.14.0
type DomainSchema struct { Domain string `bson:"domain" json:"domain"` TLD string `bson:"tld" json:"tld"` Sub string `bson:"sub" json:"sub"` }
Schema used in the "domains" collection.
func (*DomainSchema) FullDomain ¶ added in v0.14.0
func (d *DomainSchema) FullDomain() string
Returns the domain and tld only (eg.: domain.tld)
func (*DomainSchema) String ¶ added in v0.14.0
func (d *DomainSchema) String() string
Returns the full hostname (eg.: sub.domain.tld).
type NotFoundSchema ¶ added in v0.14.0
type NotFoundSchema struct {
Domain string `bson:"domain" json:"domain"`
}
Schema used in *notFound* collection.
type TopListSchema ¶ added in v0.14.0
type TopListSchema struct { Domain string `bson:"domain" json:"domain"` Count int `bson:"count" json:"count"` }
Schema used in *topList* collection.