Documentation
¶
Index ¶
- Variables
- type ASCIIHandler
- type ASNHandler
- type Answer
- type AnswerType
- type BeautifyHandler
- type CVEHandler
- type CacheHandler
- type CaseHandler
- type CertHandler
- type CheatHandler
- type ChmodHandler
- type CountryHandler
- type CronHandler
- type DNSHandler
- type DictHandler
- type DiffHandler
- type DirectoryHandler
- type EmojiHandler
- type EscapeHandler
- type ExpandHandler
- type FeedHandler
- type HTMLHandler
- type HTTPHandler
- type Handler
- type HeadersHandler
- type JSONHandler
- type JWTHandler
- type LicenseHandler
- type LoremHandler
- type MIMEHandler
- type ManHandler
- type Manager
- func (m *Manager) GetHandler(answerType AnswerType) (Handler, bool)
- func (m *Manager) GetHandlerTypes() []AnswerType
- func (m *Manager) IsDirectAnswer(query string) bool
- func (m *Manager) Parse(query string) (AnswerType, string)
- func (m *Manager) Process(ctx context.Context, query string) (*Answer, error)
- func (m *Manager) ProcessType(ctx context.Context, answerType AnswerType, term string) (*Answer, error)
- func (m *Manager) Register(h Handler)
- type PkgHandler
- type PortHandler
- type QRHandler
- type RFCHandler
- type RegexHandler
- type ResolveHandler
- type RobotsHandler
- type Rule
- type RulesHandler
- type SafeHandler
- type SitemapHandler
- type SlangHandler
- type SlugHandler
- type SubnetHandler
- type TLDRHandler
- type TechHandler
- type ThesaurusHandler
- type TimestampHandler
- type UnicodeHandler
- type UserAgentHandler
- type WhoisHandler
- type WikiHandler
- type WordHandler
- type YAMLHandler
Constants ¶
This section is empty.
Variables ¶
var CacheDurations = map[AnswerType]time.Duration{ AnswerTypeTLDR: 7 * 24 * time.Hour, AnswerTypeMan: 30 * 24 * time.Hour, AnswerTypeCheat: 7 * 24 * time.Hour, AnswerTypeDNS: 1 * time.Hour, AnswerTypeWhois: 1 * time.Hour, AnswerTypeResolve: 1 * time.Hour, AnswerTypeCert: 6 * time.Hour, AnswerTypeHeaders: 1 * time.Hour, AnswerTypeASN: 24 * time.Hour, AnswerTypeSubnet: 0, AnswerTypeWiki: 24 * time.Hour, AnswerTypeDict: 24 * time.Hour, AnswerTypeThesaurus: 24 * time.Hour, AnswerTypePkg: 6 * time.Hour, AnswerTypeCVE: 24 * time.Hour, AnswerTypeRFC: 30 * 24 * time.Hour, AnswerTypeDirectory: 1 * time.Hour, AnswerTypeCache: 0, AnswerTypeHTML: 0, AnswerTypeUnicode: 0, AnswerTypeEmoji: 24 * time.Hour, AnswerTypeEscape: 0, AnswerTypeJSON: 0, AnswerTypeYAML: 0, AnswerTypeHTTP: 0, AnswerTypePort: 0, AnswerTypeCron: 0, AnswerTypeChmod: 0, AnswerTypeRegex: 0, AnswerTypeJWT: 0, AnswerTypeTimestamp: 0, AnswerTypeRobots: 1 * time.Hour, AnswerTypeSitemap: 1 * time.Hour, AnswerTypeTech: 6 * time.Hour, AnswerTypeFeed: 1 * time.Hour, AnswerTypeExpand: 24 * time.Hour, AnswerTypeSafe: 1 * time.Hour, AnswerTypeCase: 0, AnswerTypeSlug: 0, AnswerTypeLorem: 0, AnswerTypeWord: 0, AnswerTypeBeautify: 0, AnswerTypeDiff: 0, AnswerTypeUserAgent: 0, AnswerTypeMIME: 0, AnswerTypeLicense: 30 * 24 * time.Hour, AnswerTypeCountry: 30 * 24 * time.Hour, AnswerTypeSlang: 1 * time.Hour, AnswerTypeRules: 0, AnswerTypeASCII: 0, AnswerTypeQR: 0, }
CacheDurations defines how long to cache each answer type Per IDEA.md Direct Answer Caching rules
Functions ¶
This section is empty.
Types ¶
type ASCIIHandler ¶
type ASCIIHandler struct{}
ASCIIHandler handles ascii:{text} queries (ASCII art generator)
func NewASCIIHandler ¶
func NewASCIIHandler() *ASCIIHandler
NewASCIIHandler creates a new ASCII art handler
func (*ASCIIHandler) Type ¶
func (h *ASCIIHandler) Type() AnswerType
type ASNHandler ¶
type ASNHandler struct {
// contains filtered or unexported fields
}
ASNHandler handles asn:{number} queries
func (*ASNHandler) Type ¶
func (h *ASNHandler) Type() AnswerType
type Answer ¶
type Answer struct {
Type AnswerType `json:"type"`
Term string `json:"term"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Content string `json:"content"`
Data map[string]interface{} `json:"data,omitempty"`
Source string `json:"source,omitempty"`
SourceURL string `json:"source_url,omitempty"`
CacheTTL time.Duration `json:"cache_ttl,omitempty"`
Error string `json:"error,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
Answer represents a direct answer result (full page)
type AnswerType ¶
type AnswerType string
AnswerType represents the type of direct answer
const ( // Command reference AnswerTypeTLDR AnswerType = "tldr" AnswerTypeMan AnswerType = "man" AnswerTypeCheat AnswerType = "cheat" // Network AnswerTypeDNS AnswerType = "dns" AnswerTypeWhois AnswerType = "whois" AnswerTypeResolve AnswerType = "resolve" AnswerTypeCert AnswerType = "cert" AnswerTypeHeaders AnswerType = "headers" AnswerTypeASN AnswerType = "asn" AnswerTypeSubnet AnswerType = "subnet" // Content lookup AnswerTypeWiki AnswerType = "wiki" AnswerTypeDict AnswerType = "dict" AnswerTypeThesaurus AnswerType = "thesaurus" AnswerTypePkg AnswerType = "pkg" AnswerTypeCVE AnswerType = "cve" AnswerTypeRFC AnswerType = "rfc" // Directory search AnswerTypeDirectory AnswerType = "directory" // Encoding/formatting AnswerTypeHTML AnswerType = "html" AnswerTypeUnicode AnswerType = "unicode" AnswerTypeEmoji AnswerType = "emoji" AnswerTypeEscape AnswerType = "escape" AnswerTypeJSON AnswerType = "json" AnswerTypeYAML AnswerType = "yaml" // Utilities AnswerTypeHTTP AnswerType = "http" AnswerTypePort AnswerType = "port" AnswerTypeCron AnswerType = "cron" AnswerTypeChmod AnswerType = "chmod" AnswerTypeRegex AnswerType = "regex" AnswerTypeJWT AnswerType = "jwt" AnswerTypeTimestamp AnswerType = "timestamp" // URL tools AnswerTypeRobots AnswerType = "robots" AnswerTypeSitemap AnswerType = "sitemap" AnswerTypeTech AnswerType = "tech" AnswerTypeFeed AnswerType = "feed" AnswerTypeExpand AnswerType = "expand" AnswerTypeSafe AnswerType = "safe" AnswerTypeCache AnswerType = "cache" // Text tools AnswerTypeCase AnswerType = "case" AnswerTypeSlug AnswerType = "slug" AnswerTypeLorem AnswerType = "lorem" AnswerTypeWord AnswerType = "word" AnswerTypeBeautify AnswerType = "beautify" AnswerTypeDiff AnswerType = "diff" // Reference AnswerTypeUserAgent AnswerType = "useragent" AnswerTypeMIME AnswerType = "mime" AnswerTypeLicense AnswerType = "license" AnswerTypeCountry AnswerType = "country" AnswerTypeSlang AnswerType = "slang" AnswerTypeRules AnswerType = "rules" // Generators AnswerTypeASCII AnswerType = "ascii" AnswerTypeQR AnswerType = "qr" )
Direct answer types - these are full-page results, not widgets
type BeautifyHandler ¶
type BeautifyHandler struct{}
BeautifyHandler handles beautify:{code} queries
func NewBeautifyHandler ¶
func NewBeautifyHandler() *BeautifyHandler
NewBeautifyHandler creates a new code beautifier handler
func (*BeautifyHandler) Type ¶
func (h *BeautifyHandler) Type() AnswerType
type CVEHandler ¶
type CVEHandler struct {
// contains filtered or unexported fields
}
CVEHandler handles cve:{id} queries
func (*CVEHandler) Type ¶
func (h *CVEHandler) Type() AnswerType
type CacheHandler ¶
type CacheHandler struct {
// contains filtered or unexported fields
}
CacheHandler handles cache:{url} queries (web archive lookup)
func NewCacheHandler ¶
func NewCacheHandler() *CacheHandler
NewCacheHandler creates a new web cache/archive handler
func (*CacheHandler) Type ¶
func (h *CacheHandler) Type() AnswerType
type CaseHandler ¶
type CaseHandler struct{}
CaseHandler handles case:{text} queries
func NewCaseHandler ¶
func NewCaseHandler() *CaseHandler
NewCaseHandler creates a new case converter handler
func (*CaseHandler) Type ¶
func (h *CaseHandler) Type() AnswerType
type CertHandler ¶
type CertHandler struct {
// contains filtered or unexported fields
}
CertHandler handles cert:{domain} queries
func NewCertHandler ¶
func NewCertHandler() *CertHandler
NewCertHandler creates a new certificate handler
func (*CertHandler) Type ¶
func (h *CertHandler) Type() AnswerType
type CheatHandler ¶
type CheatHandler struct {
// contains filtered or unexported fields
}
CheatHandler handles cheat:{command} queries
func NewCheatHandler ¶
func NewCheatHandler() *CheatHandler
NewCheatHandler creates a new cheat.sh handler
func (*CheatHandler) Type ¶
func (h *CheatHandler) Type() AnswerType
type ChmodHandler ¶
type ChmodHandler struct{}
ChmodHandler handles chmod:{permissions} queries
func NewChmodHandler ¶
func NewChmodHandler() *ChmodHandler
NewChmodHandler creates a new chmod handler
func (*ChmodHandler) Type ¶
func (h *ChmodHandler) Type() AnswerType
type CountryHandler ¶
type CountryHandler struct {
// contains filtered or unexported fields
}
CountryHandler handles country:{code} queries
func NewCountryHandler ¶
func NewCountryHandler() *CountryHandler
NewCountryHandler creates a new country handler
func (*CountryHandler) Type ¶
func (h *CountryHandler) Type() AnswerType
type CronHandler ¶
type CronHandler struct{}
CronHandler handles cron:{expression} queries
func (*CronHandler) Type ¶
func (h *CronHandler) Type() AnswerType
type DNSHandler ¶
type DNSHandler struct {
// contains filtered or unexported fields
}
DNSHandler handles dns:{domain} queries
func (*DNSHandler) Type ¶
func (h *DNSHandler) Type() AnswerType
type DictHandler ¶
type DictHandler struct {
// contains filtered or unexported fields
}
DictHandler handles dict:{word} queries
func NewDictHandler ¶
func NewDictHandler() *DictHandler
NewDictHandler creates a new dictionary handler
func (*DictHandler) Type ¶
func (h *DictHandler) Type() AnswerType
type DiffHandler ¶
type DiffHandler struct{}
DiffHandler handles diff:{texts} queries
func (*DiffHandler) Type ¶
func (h *DiffHandler) Type() AnswerType
type DirectoryHandler ¶
type DirectoryHandler struct {
// contains filtered or unexported fields
}
DirectoryHandler handles directory:{term} queries (open directory search)
func NewDirectoryHandler ¶
func NewDirectoryHandler() *DirectoryHandler
NewDirectoryHandler creates a new directory search handler
func (*DirectoryHandler) Type ¶
func (h *DirectoryHandler) Type() AnswerType
type EmojiHandler ¶
type EmojiHandler struct{}
EmojiHandler handles emoji:{name} queries
func NewEmojiHandler ¶
func NewEmojiHandler() *EmojiHandler
NewEmojiHandler creates a new emoji handler
func (*EmojiHandler) Type ¶
func (h *EmojiHandler) Type() AnswerType
type EscapeHandler ¶
type EscapeHandler struct{}
EscapeHandler handles escape:{text} queries
func NewEscapeHandler ¶
func NewEscapeHandler() *EscapeHandler
NewEscapeHandler creates a new escape handler
func (*EscapeHandler) Type ¶
func (h *EscapeHandler) Type() AnswerType
type ExpandHandler ¶
type ExpandHandler struct {
// contains filtered or unexported fields
}
ExpandHandler handles expand:{url} queries (URL expander)
func NewExpandHandler ¶
func NewExpandHandler() *ExpandHandler
NewExpandHandler creates a new URL expander handler
func (*ExpandHandler) Type ¶
func (h *ExpandHandler) Type() AnswerType
type FeedHandler ¶
type FeedHandler struct {
// contains filtered or unexported fields
}
FeedHandler handles feed:{domain} queries (RSS/Atom discovery)
func NewFeedHandler ¶
func NewFeedHandler() *FeedHandler
NewFeedHandler creates a new feed discovery handler
func (*FeedHandler) Type ¶
func (h *FeedHandler) Type() AnswerType
type HTMLHandler ¶
type HTMLHandler struct{}
HTMLHandler handles html:{text} queries
func NewHTMLHandler ¶
func NewHTMLHandler() *HTMLHandler
NewHTMLHandler creates a new HTML encoding handler
func (*HTMLHandler) Type ¶
func (h *HTMLHandler) Type() AnswerType
type HTTPHandler ¶
type HTTPHandler struct{}
HTTPHandler handles http:{code} queries
func NewHTTPHandler ¶
func NewHTTPHandler() *HTTPHandler
NewHTTPHandler creates a new HTTP status code handler
func (*HTTPHandler) Type ¶
func (h *HTTPHandler) Type() AnswerType
type Handler ¶
type Handler interface {
// Type returns the answer type this handler provides
Type() AnswerType
// Handle processes the term and returns a direct answer
Handle(ctx context.Context, term string) (*Answer, error)
}
Handler interface for direct answer handlers
type HeadersHandler ¶
type HeadersHandler struct {
// contains filtered or unexported fields
}
HeadersHandler handles headers:{url} queries
func NewHeadersHandler ¶
func NewHeadersHandler() *HeadersHandler
NewHeadersHandler creates a new HTTP headers handler
func (*HeadersHandler) Type ¶
func (h *HeadersHandler) Type() AnswerType
type JSONHandler ¶
type JSONHandler struct{}
JSONHandler handles json:{data} queries
func (*JSONHandler) Type ¶
func (h *JSONHandler) Type() AnswerType
type JWTHandler ¶
type JWTHandler struct{}
JWTHandler handles jwt:{token} queries
func (*JWTHandler) Type ¶
func (h *JWTHandler) Type() AnswerType
type LicenseHandler ¶
type LicenseHandler struct {
// contains filtered or unexported fields
}
LicenseHandler handles license:{name} queries
func NewLicenseHandler ¶
func NewLicenseHandler() *LicenseHandler
NewLicenseHandler creates a new license handler
func (*LicenseHandler) Type ¶
func (h *LicenseHandler) Type() AnswerType
type LoremHandler ¶
type LoremHandler struct{}
LoremHandler handles lorem:{count} queries
func NewLoremHandler ¶
func NewLoremHandler() *LoremHandler
NewLoremHandler creates a new lorem ipsum generator handler
func (*LoremHandler) Type ¶
func (h *LoremHandler) Type() AnswerType
type MIMEHandler ¶
type MIMEHandler struct{}
MIMEHandler handles mime:{type} queries
func NewMIMEHandler ¶
func NewMIMEHandler() *MIMEHandler
NewMIMEHandler creates a new MIME type handler
func (*MIMEHandler) Type ¶
func (h *MIMEHandler) Type() AnswerType
type ManHandler ¶
type ManHandler struct {
// contains filtered or unexported fields
}
ManHandler handles man:{page} queries
func (*ManHandler) Type ¶
func (h *ManHandler) Type() AnswerType
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages all direct answer handlers
func (*Manager) GetHandler ¶
func (m *Manager) GetHandler(answerType AnswerType) (Handler, bool)
GetHandler returns the handler for a specific type
func (*Manager) GetHandlerTypes ¶
func (m *Manager) GetHandlerTypes() []AnswerType
GetHandlerTypes returns all registered handler types
func (*Manager) IsDirectAnswer ¶
IsDirectAnswer checks if query is a direct answer query
func (*Manager) Parse ¶
func (m *Manager) Parse(query string) (AnswerType, string)
Parse checks if query matches direct answer syntax and returns type and term Returns empty strings if not a direct answer query
func (*Manager) ProcessType ¶
func (m *Manager) ProcessType(ctx context.Context, answerType AnswerType, term string) (*Answer, error)
ProcessType handles a specific direct answer type
type PkgHandler ¶
type PkgHandler struct {
// contains filtered or unexported fields
}
PkgHandler handles pkg:{name} queries
func (*PkgHandler) Type ¶
func (h *PkgHandler) Type() AnswerType
type PortHandler ¶
type PortHandler struct{}
PortHandler handles port:{number} queries
func (*PortHandler) Type ¶
func (h *PortHandler) Type() AnswerType
type QRHandler ¶
type QRHandler struct{}
QRHandler handles qr:{text} queries
func (*QRHandler) Type ¶
func (h *QRHandler) Type() AnswerType
type RFCHandler ¶
type RFCHandler struct {
// contains filtered or unexported fields
}
RFCHandler handles rfc:{number} queries
func (*RFCHandler) Type ¶
func (h *RFCHandler) Type() AnswerType
type RegexHandler ¶
type RegexHandler struct{}
RegexHandler handles regex:{pattern} queries
func NewRegexHandler ¶
func NewRegexHandler() *RegexHandler
NewRegexHandler creates a new regex handler
func (*RegexHandler) Type ¶
func (h *RegexHandler) Type() AnswerType
type ResolveHandler ¶
type ResolveHandler struct {
// contains filtered or unexported fields
}
ResolveHandler handles resolve:{hostname} queries
func NewResolveHandler ¶
func NewResolveHandler() *ResolveHandler
NewResolveHandler creates a new resolve handler
func (*ResolveHandler) Type ¶
func (h *ResolveHandler) Type() AnswerType
type RobotsHandler ¶
type RobotsHandler struct {
// contains filtered or unexported fields
}
RobotsHandler handles robots:{domain} queries
func NewRobotsHandler ¶
func NewRobotsHandler() *RobotsHandler
NewRobotsHandler creates a new robots.txt handler
func (*RobotsHandler) Type ¶
func (h *RobotsHandler) Type() AnswerType
type RulesHandler ¶
type RulesHandler struct{}
RulesHandler handles rules:{query} queries Easter egg: Rules of the Internet
func NewRulesHandler ¶
func NewRulesHandler() *RulesHandler
NewRulesHandler creates a new rules handler
func (*RulesHandler) Type ¶
func (h *RulesHandler) Type() AnswerType
type SafeHandler ¶
type SafeHandler struct {
// contains filtered or unexported fields
}
SafeHandler handles safe:{url} queries (URL safety check)
func NewSafeHandler ¶
func NewSafeHandler() *SafeHandler
NewSafeHandler creates a new URL safety handler
func (*SafeHandler) Type ¶
func (h *SafeHandler) Type() AnswerType
type SitemapHandler ¶
type SitemapHandler struct {
// contains filtered or unexported fields
}
SitemapHandler handles sitemap:{domain} queries
func NewSitemapHandler ¶
func NewSitemapHandler() *SitemapHandler
NewSitemapHandler creates a new sitemap handler
func (*SitemapHandler) Type ¶
func (h *SitemapHandler) Type() AnswerType
type SlangHandler ¶
type SlangHandler struct {
// contains filtered or unexported fields
}
SlangHandler handles slang:{term} queries Uses Urban Dictionary API for definitions
func NewSlangHandler ¶
func NewSlangHandler() *SlangHandler
NewSlangHandler creates a new slang handler
func (*SlangHandler) Type ¶
func (h *SlangHandler) Type() AnswerType
type SlugHandler ¶
type SlugHandler struct{}
SlugHandler handles slug:{text} queries
func NewSlugHandler ¶
func NewSlugHandler() *SlugHandler
NewSlugHandler creates a new slug generator handler
func (*SlugHandler) Type ¶
func (h *SlugHandler) Type() AnswerType
type SubnetHandler ¶
type SubnetHandler struct{}
SubnetHandler handles subnet:{cidr} queries
func NewSubnetHandler ¶
func NewSubnetHandler() *SubnetHandler
NewSubnetHandler creates a new subnet calculator handler
func (*SubnetHandler) Type ¶
func (h *SubnetHandler) Type() AnswerType
type TLDRHandler ¶
type TLDRHandler struct {
// contains filtered or unexported fields
}
TLDRHandler handles tldr:{command} queries
func (*TLDRHandler) Type ¶
func (h *TLDRHandler) Type() AnswerType
type TechHandler ¶
type TechHandler struct {
// contains filtered or unexported fields
}
TechHandler handles tech:{domain} queries (technology detection)
func NewTechHandler ¶
func NewTechHandler() *TechHandler
NewTechHandler creates a new technology detection handler
func (*TechHandler) Type ¶
func (h *TechHandler) Type() AnswerType
type ThesaurusHandler ¶
type ThesaurusHandler struct {
// contains filtered or unexported fields
}
ThesaurusHandler handles thesaurus:{word} queries
func NewThesaurusHandler ¶
func NewThesaurusHandler() *ThesaurusHandler
NewThesaurusHandler creates a new thesaurus handler
func (*ThesaurusHandler) Type ¶
func (h *ThesaurusHandler) Type() AnswerType
type TimestampHandler ¶
type TimestampHandler struct{}
TimestampHandler handles timestamp:{value} queries
func NewTimestampHandler ¶
func NewTimestampHandler() *TimestampHandler
NewTimestampHandler creates a new timestamp handler
func (*TimestampHandler) Type ¶
func (h *TimestampHandler) Type() AnswerType
type UnicodeHandler ¶
type UnicodeHandler struct{}
UnicodeHandler handles unicode:{char} queries
func NewUnicodeHandler ¶
func NewUnicodeHandler() *UnicodeHandler
NewUnicodeHandler creates a new Unicode handler
func (*UnicodeHandler) Type ¶
func (h *UnicodeHandler) Type() AnswerType
type UserAgentHandler ¶
type UserAgentHandler struct{}
UserAgentHandler handles useragent:{string} queries
func NewUserAgentHandler ¶
func NewUserAgentHandler() *UserAgentHandler
NewUserAgentHandler creates a new user agent parser handler
func (*UserAgentHandler) Type ¶
func (h *UserAgentHandler) Type() AnswerType
type WhoisHandler ¶
type WhoisHandler struct {
// contains filtered or unexported fields
}
WhoisHandler handles whois:{domain} queries
func NewWhoisHandler ¶
func NewWhoisHandler() *WhoisHandler
NewWhoisHandler creates a new WHOIS handler
func (*WhoisHandler) Type ¶
func (h *WhoisHandler) Type() AnswerType
type WikiHandler ¶
type WikiHandler struct {
// contains filtered or unexported fields
}
WikiHandler handles wiki:{topic} queries
func NewWikiHandler ¶
func NewWikiHandler() *WikiHandler
NewWikiHandler creates a new Wikipedia handler
func (*WikiHandler) Type ¶
func (h *WikiHandler) Type() AnswerType
type WordHandler ¶
type WordHandler struct{}
WordHandler handles word:{text} queries (text statistics)
func NewWordHandler ¶
func NewWordHandler() *WordHandler
NewWordHandler creates a new word/text statistics handler
func (*WordHandler) Type ¶
func (h *WordHandler) Type() AnswerType
type YAMLHandler ¶
type YAMLHandler struct{}
YAMLHandler handles yaml:{data} queries
func (*YAMLHandler) Type ¶
func (h *YAMLHandler) Type() AnswerType