mirror of https://github.com/0xERR0R/blocky.git
added/changed some comments
This commit is contained in:
parent
21f9b90841
commit
59c650ff6a
|
@ -213,6 +213,7 @@ Loop:
|
|||
return cache
|
||||
}
|
||||
|
||||
// Match matches passed domain name against cached list entries
|
||||
func (b *ListCache) Match(domain string, groupsToCheck []string) (found bool, group string) {
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
|
|
|
@ -67,7 +67,7 @@ type BlockingResolver struct {
|
|||
status *status
|
||||
}
|
||||
|
||||
// NewBlockingResolver retuns a new configured instance of the resolver
|
||||
// NewBlockingResolver returns a new configured instance of the resolver
|
||||
func NewBlockingResolver(cfg config.BlockingConfig) ChainedResolver {
|
||||
blockHandler := createBlockHandler(cfg)
|
||||
blacklistMatcher := lists.NewListCache(lists.BLACKLIST, cfg.BlackLists, cfg.RefreshPeriod)
|
||||
|
@ -95,7 +95,7 @@ func (r *BlockingResolver) RefreshLists() {
|
|||
r.whitelistMatcher.Refresh()
|
||||
}
|
||||
|
||||
// EnableBlocking enables the blocking agains the blacklists
|
||||
// EnableBlocking enables the blocking against the blacklists
|
||||
func (r *BlockingResolver) EnableBlocking() {
|
||||
s := r.status
|
||||
s.enableTimer.Stop()
|
||||
|
@ -226,7 +226,7 @@ func (r *BlockingResolver) handleBlacklist(groupsToCheck []string,
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
// Resolve checks the query agains the blacklist and delegates to next resolver if domain is not blocked
|
||||
// Resolve checks the query against the blacklist and delegates to next resolver if domain is not blocked
|
||||
func (r *BlockingResolver) Resolve(request *Request) (*Response, error) {
|
||||
logger := withPrefix(request.Log, "blacklist_resolver")
|
||||
groupsToCheck := r.groupsToCheckForClient(request)
|
||||
|
|
|
@ -12,7 +12,8 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// CachingResolver caches answers from dns queries with their TTL time, to avoid external resolver calls for recurrent queries
|
||||
// CachingResolver caches answers from dns queries with their TTL time,
|
||||
// to avoid external resolver calls for recurrent queries
|
||||
type CachingResolver struct {
|
||||
NextResolver
|
||||
minCacheTimeSec, maxCacheTimeSec int
|
||||
|
@ -123,9 +124,9 @@ func (r *CachingResolver) getTotalCacheEntryNumber() int {
|
|||
return count
|
||||
}
|
||||
|
||||
//nolint:gocognit,funlen
|
||||
// Resolve checks if the current query result is already in the cache and returns it
|
||||
// or delegates to the next resover
|
||||
// or delegates to the next resolver
|
||||
//nolint:gocognit,funlen
|
||||
func (r *CachingResolver) Resolve(request *Request) (response *Response, err error) {
|
||||
logger := withPrefix(request.Log, "caching_resolver")
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ func TestDOHUpstream(fn func(request *dns.Msg) (response *dns.Msg),
|
|||
return upstream
|
||||
}
|
||||
|
||||
// TestUDPUpstream creates a mock UDP upstream
|
||||
//nolint:funlen
|
||||
// TestUdpUpstream creates a mock UDP upstream
|
||||
func TestUDPUpstream(fn func(request *dns.Msg) (response *dns.Msg)) config.Upstream {
|
||||
a, err := net.ResolveUDPAddr("udp4", ":0")
|
||||
util.FatalOnError("can't resolve address: ", err)
|
||||
|
|
|
@ -60,7 +60,7 @@ func (r ParallelBestResolver) String() string {
|
|||
return fmt.Sprintf("parallel upstreams '%s'", strings.Join(result, "; "))
|
||||
}
|
||||
|
||||
// Resolver sends the query request to multiple upstream resolvers and returns the fastest result
|
||||
// Resolve sends the query request to multiple upstream resolvers and returns the fastest result
|
||||
func (r *ParallelBestResolver) Resolve(request *Request) (*Response, error) {
|
||||
logger := request.Log.WithField("prefix", "parallel_best_resolver")
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ type Resolver interface {
|
|||
type ChainedResolver interface {
|
||||
Resolver
|
||||
|
||||
// Next sets the next resulver
|
||||
// Next sets the next resolver
|
||||
Next(n Resolver)
|
||||
|
||||
// GetNext returns the next resolver
|
||||
|
@ -131,10 +131,12 @@ type NextResolver struct {
|
|||
next Resolver
|
||||
}
|
||||
|
||||
// Next sets the next resolver
|
||||
func (r *NextResolver) Next(n Resolver) {
|
||||
r.next = n
|
||||
}
|
||||
|
||||
// GetNext returns the next resolver
|
||||
func (r *NextResolver) GetNext() Resolver {
|
||||
return r.next
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package web
|
||||
|
||||
//IndexTmpl html template for the start page
|
||||
const IndexTmpl = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
|
Loading…
Reference in New Issue