Commit graph

46 commits

Author SHA1 Message Date
Viktor
43fdf737d6
automaxprocs (#6948)
* Add automaxprocs for better multi processor support in containerized environments 

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* correct imports ordering

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* warning instead of fatal

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* fix imports ordering

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

---------

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>
2024-11-13 09:36:36 -08:00
Manuel Rüger
ebbbb453be
kubernetes: Add useragent (#6484)
In kubernetes' audit logs you'll see:

"userAgent":"coredns/v0.0.0 (linux/amd64) kubernetes/$Format"

This change adds a userAgent to the requests made by CoreDNS against the kubernetes API:

"userAgent":"CoreDNS/v1.11.1 git_commit:ae2bbc29be1aaae0b3ded5d188968a6c97bb3144 (linux/amd64/go1.22)"

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2024-08-26 16:45:39 -04:00
jdamick
24c64f97c9
Change the log flags to be a variable that can be set prior to calling Run (#6546)
Signed-off-by: Jeffrey Damick <jdamick@amazon.com>
Co-authored-by: Jeffrey Damick <jdamick@amazon.com>
2024-03-13 09:43:06 -04:00
David Hadas
280ef6f405
Move flags to coremain (#5865) 2023-01-23 04:27:18 -08:00
Ondřej Benkovský
257ca65a17
GO linting bump and removal of deprecated linters (#5624)
* bump golangci-lint with support of go 1.19

Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>

* remove deprecated usage of varcheck, deadcode, and structcheck

Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>

Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2022-09-19 05:53:43 -07:00
Yong Tang
c6709d930f
Fix security scans by cleaning up file path (#5185)
While performing security scans there were several
issue raised as G304 (CWE-22): Potential file inclusion via variable.
As some files path are taken from user input, it is possible the
filepath passed by user may have unintended effect if not properly formed.
This fix add Clean to remove the security warning and address some
potential issue.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2022-02-14 11:24:21 -05:00
Zou Nengren
5191959bd7
cleanup deprecated package io/ioutil (#4920)
Signed-off-by: zounengren <zouyee1989@gmail.com>
2021-10-13 09:30:31 +02:00
Miek Gieben
a9206996eb
core: flag blacklisting not needed anymore (#4420)
Automatically submitted.
2021-01-26 08:18:40 +00:00
Miek Gieben
b003d06003
For caddy v1 in our org (#4018)
* For caddy v1 in our org

This RP changes all imports for caddyserver/caddy to coredns/caddy. This
is the v1 code of caddy.

For the coredns/caddy repo the following changes have been made:

* anything not needed by us is deleted
* all `telemetry` stuff is deleted
* all its import paths are also changed to point to coredns/caddy
* the v1 branch has been moved to the master branch
* a v1.1.0 tag has been added to signal the latest release

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix imports

Signed-off-by: Miek Gieben <miek@miek.nl>

* Group coredns/caddy with out plugins

Signed-off-by: Miek Gieben <miek@miek.nl>

* remove this file

Signed-off-by: Miek Gieben <miek@miek.nl>

* Relax import ordering

github.com/coredns is now also a coredns dep, this makes
github.com/coredns/caddy fit more natural in the list.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix final import

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-24 18:14:41 +02:00
Anshul Sharma
c187d8fa01 Issue-3374 (#3383)
- Remove logo

Signed-off-by: Anshul Sharma <sharmaanshul2102@gmail.com>
2019-10-17 15:36:35 +01:00
Miek Gieben
dbd1c047cb
Run gostaticheck (#3325)
* Run gostaticheck

Run gostaticcheck on the codebase and fix almost all flagged items.

Only keep

* coremain/run.go:192:2: var appVersion is unused (U1000)
* plugin/chaos/setup.go:54:3: the surrounding loop is unconditionally terminated (SA4004)
* plugin/etcd/setup.go:103:3: the surrounding loop is unconditionally terminated (SA4004)
* plugin/pkg/replacer/replacer.go:274:13: argument should be pointer-like to avoid allocations (SA6002)
* plugin/route53/setup.go:124:28: session.New is deprecated: Use NewSession functions to create sessions instead. NewSession has the same functionality as New except an error can be returned when the func is called instead of waiting to receive an error until a request is made.  (SA1019)
* test/grpc_test.go:25:69: grpc.WithTimeout is deprecated: use DialContext and context.WithTimeout instead.  Will be supported throughout 1.x.  (SA1019)

The first one isn't true, as this is set via ldflags. The rest is
minor. The deprecation should be fixed at some point; I'll file some
issues.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Make sure to plug in the plugins

import the plugins, that file that did this was removed, put it in the
reload test as this requires an almost complete coredns server.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-01 07:41:29 +01:00
li mengyang
50bac4d3c3 fix: delete unused var and const (#3294)
Signed-off-by: hwdef <hwdef97@gmail.com>
2019-09-24 07:06:37 +01:00
Miek Gieben
c466003a94
startup: add logo (#3230)
* startup: add logo

As discussed in #3225, lets add a little logo. This PR incorperates this
in the startup text. It also removes the logging output as this outputs
identical lines of text, but for no clear reason. This means --quiet now
means "no output on startup at all".

Currently it looks like this:

~~~
.:1053
   ______                ____  _   _______
  / ____/___  ________  / __ \/ | / / ___/	CoreDNS-1.6.2
 / /   / __ \/ ___/ _ \/ / / /  |/ /\__ \ 	linux/amd64, go1.12.9,
/ /___/ /_/ / /  /  __/ /_/ / /|  /___/ /
\____/\____/_/   \___/_____/_/ |_//____/
~~~

We have 2 lines extra on the right if we need to print more (no ideas
come to mind currently).

Signed-off-by: Miek Gieben <miek@miek.nl>

* Add distinct marker for grep and cut purposes

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-30 15:12:17 +01:00
Miek Gieben
f5fe98395e
Remove -cpu flag (#2793)
The -cpu flag is a weird one (and copied originally from Caddy), it
basically sets GOMAXPROCS which can be *easily* done by just setting
that environment variable. Also with systemd and containerized env you
set this externally *anyway*, so there is little use to do this again in
the binary.

Also the option's help was confusing (i.e. percentage of what?). Remove
the option and supporting files.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-07-03 20:12:51 +01:00
Yong Tang
f8bba51f84
Update Caddy to 1.0.1, and update import path (#2961)
* Update Caddy to 1.0.1, and update import path

This fix updates caddy to 1.0.1 and also
updates the import path to github.com/caddyserver/caddy

This fix fixes 2959

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Also update plugin.cfg

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Update and bump zplugin.go

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-07-03 09:04:47 +08:00
Miek Gieben
58c703f5ef
Run gofmt -w -s on codebase (#2773)
This formats and simplifies all code by running gofmt -w -s on all Go
files.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-04-08 11:13:46 +01:00
Francois Tur
97e2a53a65 - remove caddy event, It is now triggered directly by Caddy in the Start function of the Instance (#2656) 2019-03-07 20:05:19 +00:00
Miek Gieben
9abbf4a4a0 map bool -> map struct{} (#2386)
This clear out the remaining map[x]bool usage and moves the bool to an
empty struct.

Two note worthy other changes:

* EnableChaos in the server is now also exported to make it show up in
  the documentation.
* The auto plugin is left as is, because there the boolean is
  explicitaly set to false to signal 'to-be-deleted' and the key is left
  as-is.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-10 02:17:15 -08:00
Miek Gieben
2456416444
logging: unify pkg/log and plugin/log (#2245)
Default to using pkg/log for all logging and use a fixed time prefix
which is RFC3339Millli (doesn't exist in time, so we just extended
RFC3339), i.e. Nano might be pushing it.

Logs go from:

2018/10/30 19:14:55 [INFO] CoreDNS-1.2.5
2018/10/30 19:14:55 [INFO] linux/amd64, go1.11,

to:

2018-10-30T19:10:07.547Z [INFO] CoreDNS-1.2.5
2018-10-30T19:10:07.547Z [INFO] linux/amd64, go1.11,

Which includes the timezone - which oddly the std log package doesn't
natively do.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-10-31 21:32:23 +00:00
Karsten Weiss
6d8a078704 Typo fixes (#2031) 2018-08-14 08:55:55 -07:00
Miek Gieben
41c724780f
remove deprecated code (#1888)
This removes:
* reverse plugin from plugin.cfg
* https_google option from proxy
* the -log flag
2018-06-20 11:35:07 +01:00
Miek Gieben
2758a756dd
Implement deprecation notice for 1.1.4 (#1833)
* Implement deprecation notice for 1.1.4

This still allows all the config to be parsed, but noops it:

* -log; always set the log to stdout; no matter what.
* https_google; removed from the proxy implementation.
* reverse plugin: set to deprecated.

* Whole of reverse can go

* Remove test for deprecated plugin
2018-05-24 14:30:01 +01:00
Silver
59dbcd32ea Signal handling breaks parent code (#1763) (#1764) 2018-05-03 08:57:38 +02:00
Miek Gieben
82d3195f2f
pkg/log usage in coremain as well (#1751) 2018-04-27 21:50:24 +01:00
Miek Gieben
455040c143
doc: some function/vars/const/package level updates (#1558)
* doc: some function/vars/const/package level updates

Various update that stood out while reading godoc.org for CoreDNS.

* Fix some misspellings as well
2018-02-23 15:02:05 +00:00
Miek Gieben
aeacbf6e24
move flag blacklisting to main (#1431)
* move flag blacklisting to main

Doing it in init() is the wrong place or something else changed. Doing
it in main() makes it easy to see *when* this happens.

* keep trapsignals
2018-01-25 21:40:40 +00:00
Tobias Schmidt
b707438534 Add coredns_build_info metric (#1418)
In order to track the rollout status of CoreDNS versions, add the common
build_info metric.
2018-01-23 20:10:55 +00:00
Ruslan Drozhdzh
d4bf076ccf Emit InstanceStartupEvent after starting server (#1410) 2018-01-21 19:28:21 +00:00
Yong Tang
9d87b953a0 Enhancement of external plugin enabling (#1392)
This fix is an enhancement of external plugin enabling.
Previously, it was already able to build a customerized
coredns with plugins enabled selectively, without changing
coredns source code. However, all default plugins are
actually bundled because of the import rule:
```
"github.com/coredns/coredns/coremain"
```

The issue is best described with the following:
```
root@localhost:/go/src/github.com/coredns/coredns/sample# cat sample.go
package main

import (
        _ "github.com/coredns/forward"

        "github.com/coredns/coredns/coremain"
        "github.com/coredns/coredns/core/dnsserver"
)

var directives = []string{
        "forward",
        "startup",
        "shutdown",
}

func init() {
        dnsserver.Directives = directives
}

func main() {
        coremain.Run()
}
root@localhost:/go/src/github.com/coredns/coredns/sample#
root@localhost:/go/src/github.com/coredns/coredns/sample# go build -v sample.go
root@localhost:/go/src/github.com/coredns/coredns/sample# ./sample -plugins
root@localhost:/go/src/github.com/coredns/coredns/sample# ./sample -plugins
Server types:
  dns

Caddyfile loaders:
  flag
  default

Other plugins:
  dns.auto
  dns.autopath
  dns.bind
  dns.cache
  dns.chaos
  dns.debug
  dns.dnssec
  dns.dnstap
  dns.erratic
  dns.errors
  dns.etcd
  dns.federation
  dns.file
  dns.forward
  dns.health
  dns.hosts
  dns.kubernetes
  dns.loadbalance
  dns.log
  dns.nsid
  dns.pprof
  dns.prometheus
  dns.proxy
  dns.reverse
  dns.rewrite
  dns.root
  dns.route53
  dns.secondary
  dns.template
....
```

This fix moves zplugins.go to a different package/directory so that
it is possible to "only import plugins as needed".

The following is the new output after this fix:
```
root@localhost:/go/src/github.com/coredns/coredns/sample# ./sample -plugins
Server types:
  dns

Caddyfile loaders:
  flag
  default

Other plugins:
  dns.forward
  dns.prometheus
  shutdown
  startup

root@localhost:/go/src/github.com/coredns/coredns/sample#
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-01-15 21:54:10 +00:00
Yong Tang
c0d435d4e8 Fix log output of the version string. (#910)
Split version string into two, before:
```
2017/08/12 19:43:08 [INFO] CoreDNS-010
linux/amd64, go1.8.3, a6d2d7b5
CoreDNS-010
linux/amd64, go1.8.3, a6d2d7b5
```
After:
```
root@9bd51ffc39aa:/go/src/github.com/coredns/coredns# ./coredns
.:53
2017/08/12 19:12:59 [INFO] CoreDNS-010
2017/08/12 19:12:59 [INFO] linux/amd64, go1.8, a6d2d7b
CoreDNS-010
linux/amd64, go1.8, a6d2d7b
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-12 20:59:28 +01:00
Yong Tang
a09f208c51 Add git commit to the version output. (#900)
Now the output would be:
```
 ./coredns -version
CoreDNS-010
linux/amd64, go1.8, 241e3db
```
In case the local file has been modified, then the output would be (with --dirty):
```
 ./coredns -version
CoreDNS-010
linux/amd64, go1.8, 241e3db-dirty
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-11 17:47:37 +01:00
Ning Xie
817f3960b8 fix hard code about server type (#759) 2017-06-28 02:05:54 -07:00
Miek Gieben
9e463e0bca core: errors on junk in the command line (#744)
We would silently ignore anything that we couldn't parse on the command
line, this change make this an error.

Fixes #743
2017-06-20 12:01:10 -07:00
Miek Gieben
0d72efbbf9 core: -log bolean flag to enable logging (#726)
* core: -log bolean flag to enable logging

Change to -log flag to a boolean that defaults false and when true
logs to stdout.

* And bool here
2017-06-09 14:09:16 +01:00
Miek Gieben
024f56682d middleware/chaos: fix version (#669)
* middleware/chaos: fix version

Move the version setting into a init function so it is done early. Then
tweak the setup code for chaos a bit to correctly pick this version up.
Add an integration test to pick this up in the toplevel test/ directory.

Fixes #667

* Update tests
2017-05-22 08:09:35 -04:00
Yong Tang
81af74aad0 Fix import path github.com/miekg/coredns -> github.com/coredns/coredns (#547)
This fix fixes import path from
`github.com/miekg/coredns`
->
`github.com/coredns/coredns`
2017-02-22 06:51:47 +00:00
Miek Gieben
da742ed596 core: remove unwanted flags (#410)
Remove unwanted flags (mostly from glog) and keep the ones we need.
2016-11-09 10:00:46 +00:00
Miek Gieben
9b5c9df321 Don't register quiet flag in register.go (#299)
This clashes to Caddy, which also has its own quiet flag. Move stuff
around a bit, also to prevent cyclic imports.
2016-09-25 18:42:08 +01:00
Miek Gieben
de0fa53379 Doc: add package docs (#296)
* Doc: add package docs

Add short package level docs to make godoc looks nicer.
Add some badges to the README.

* correct url
2016-09-25 08:39:20 +01:00
Miek Gieben
31851c6acd coredns: default Corefile (#265)
When no Corefile is given, default to loading the whoami middleware on
the default port (2053).  Also add back the -port flag that allows you
to override the default port.

Further cleanup the startup messages and use caddy's OnStartupComplete()
to blurp out which zones and ports we have.  These can be suppressed
with the -quiet flag.

Normal startup:

miek.nl.:1053
miek.nl2.:1053
example.org.:1054
2016/09/17 20:41:19 [INFO] CoreDNS-001 starting
CoreDNS-001 starting

with the -quiet flag:

2016/09/17 20:41:34 [INFO] CoreDNS-001 starting
2016-09-17 21:24:39 +01:00
Yong Tang
953cfc1de4 Remove lumberjack logger (#257)
* Removed lumberjack from coremain

As is mentioned in 251, this fix removed lumberjack from coremain.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Remove lumberjack from log middleware

As mentioned in 251, lumberjack is not suitable for applications like CoreDNS
so it is removed from the log middleware.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Update log/README.md as lumberjack has been removed

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Adjust default log output from `ioutil.Discard` to `os.Stdout`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-09-16 15:50:16 +01:00
Miek Gieben
2dd8a687b3 Startup notification (#250)
Stop the caddy message and start our own init notifications.
Log the version of CoreDNS when starting up.
Fix all middleware's setup functions so that return the error prefixed
with *which* middleware was failing; leads to better debuggable errors
when starting up.
2016-09-10 09:16:25 +01:00
Miek Gieben
3fab9b1bfa caddy.CaddyfileFromPipe requires server type
Change to be inline with latest caddy changes, caddy.CaddyfileFromPipe
requires servertype argument.

Fixes: #243
2016-09-06 08:31:51 +00:00
Miek Gieben
2eac03896b Use Corefile
Fix the code copied from Caddy to refer to Corefile and make 'coredns'
with flags pickup a local Corefile.

Also remove some references to Caddy in the docs and output of coredns.

Fixes #235
2016-08-29 14:39:24 +01:00
Miek Gieben
af6b3a6d02 Split out versions in version.go
The will prolly make automatic releases easier.
2016-08-24 21:43:47 +01:00
Miek Gieben
47f4e165a0 Fix main startup (#232)
Set version and name of the program. And then call coremain.Run().

The coremain split makes CoreDNS embeddable.

Also see #189 for an old PR.
2016-08-23 16:36:29 +01:00