Merge pull request #58 in DNS/adguard-dns from feature/348 to master

* commit '5533b434dac98ba610028ca98327992d18078da0':
  coredns plugin -- give out to browser last entries from querylog file, not first
  Update .gitignore to ignore non-gzipped querylog
  Makefile -- Fix bug introduced by 93c451cb0c
  coredns plugin -- Increase querylog given out to web UI from 1000 to 5000.
This commit is contained in:
Eugene Bujak 2018-10-10 00:35:58 +03:00
commit a54984f688
5 changed files with 7 additions and 10 deletions

4
.gitignore vendored
View File

@ -5,5 +5,5 @@
/coredns /coredns
/Corefile /Corefile
/dnsfilter.txt /dnsfilter.txt
/querylog.json.gz /querylog.json
/querylog.json.gz.1 /querylog.json.1

View File

@ -4,7 +4,7 @@ NATIVE_GOARCH = $(shell unset GOARCH; go env GOARCH)
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(patsubst %/,%,$(dir $(mkfile_path))) mkfile_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
GOPATH := $(mkfile_dir)/build/gopath GOPATH := $(mkfile_dir)/build/gopath
STATIC := build/static/bundle.css build/static/bundle.js build/static/index.html STATIC := build/static/index.html
.PHONY: all build clean .PHONY: all build clean
all: build all: build

View File

@ -255,7 +255,7 @@ class Logs extends Component {
const { queryLogEnabled } = dashboard; const { queryLogEnabled } = dashboard;
return ( return (
<Fragment> <Fragment>
<PageTitle title="Query Log" subtitle="Last 1000 DNS queries"> <PageTitle title="Query Log" subtitle="Last 5000 DNS queries">
<div className="page-title__actions"> <div className="page-title__actions">
{this.renderButtons(queryLogEnabled)} {this.renderButtons(queryLogEnabled)}
</div> </div>

View File

@ -24,7 +24,7 @@ const (
queryLogTimeLimit = time.Hour * 24 // how far in the past we care about querylogs queryLogTimeLimit = time.Hour * 24 // how far in the past we care about querylogs
queryLogRotationPeriod = time.Hour * 24 // rotate the log every 24 hours queryLogRotationPeriod = time.Hour * 24 // rotate the log every 24 hours
queryLogFileName = "querylog.json" // .gz added during compression queryLogFileName = "querylog.json" // .gz added during compression
queryLogCacheSize = 1000 // maximum API response for /querylog queryLogSize = 5000 // maximum API response for /querylog
queryLogCacheTime = time.Minute // if requested more often than this, give out cached response queryLogCacheTime = time.Minute // if requested more often than this, give out cached response
queryLogTopSize = 500 // Keep in memory only top N values queryLogTopSize = 500 // Keep in memory only top N values
queryLogAPIPort = "8618" // 8618 is sha512sum of "querylog" then each byte summed queryLogAPIPort = "8618" // 8618 is sha512sum of "querylog" then each byte summed
@ -116,8 +116,8 @@ func handleQueryLog(w http.ResponseWriter, r *http.Request) {
values = logBuffer values = logBuffer
logBufferLock.RUnlock() logBufferLock.RUnlock()
if len(values) < queryLogCacheSize { if len(values) < queryLogSize {
values = appendFromLogFile(values, queryLogCacheSize, queryLogTimeLimit) values = appendFromLogFile(values, queryLogSize, queryLogTimeLimit)
} }
queryLogLock.Lock() queryLogLock.Lock()
queryLogCache = values queryLogCache = values

View File

@ -250,9 +250,6 @@ func appendFromLogFile(values []logEntry, maxLen int, timeWindow time.Duration)
} }
needMore := func() bool { needMore := func() bool {
if len(a) >= maxLen {
return false
}
return true return true
} }