diff options
author | 2018-02-05 22:00:47 +0000 | |
---|---|---|
committer | 2018-02-05 22:00:47 +0000 | |
commit | 5b844b5017f004fffa83157041e8ffd3ac085c92 (patch) | |
tree | cbf86bb06cd42f720037a0e473ce2d1cba4036af /plugin/forward/protocol.go | |
parent | fb1cafe5fa54935361a5cc9a7e3308a738225126 (diff) | |
download | coredns-5b844b5017f004fffa83157041e8ffd3ac085c92.tar.gz coredns-5b844b5017f004fffa83157041e8ffd3ac085c92.tar.zst coredns-5b844b5017f004fffa83157041e8ffd3ac085c92.zip |
plugin/forward: add it (#1447)
* plugin/forward: add it
This moves coredns/forward into CoreDNS. Fixes as a few bugs, adds a
policy option and more tests to the plugin.
Update the documentation, test IPv6 address and add persistent tests.
* Always use random policy when spraying
* include scrub fix here as well
* use correct var name
* Code review
* go vet
* Move logging to metrcs
* Small readme updates
* Fix readme
Diffstat (limited to 'plugin/forward/protocol.go')
-rw-r--r-- | plugin/forward/protocol.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/plugin/forward/protocol.go b/plugin/forward/protocol.go new file mode 100644 index 000000000..338b60116 --- /dev/null +++ b/plugin/forward/protocol.go @@ -0,0 +1,30 @@ +package forward + +// Copied from coredns/core/dnsserver/address.go + +import ( + "strings" +) + +// protocol returns the protocol of the string s. The second string returns s +// with the prefix chopped off. +func protocol(s string) (int, string) { + switch { + case strings.HasPrefix(s, _tls+"://"): + return TLS, s[len(_tls)+3:] + case strings.HasPrefix(s, _dns+"://"): + return DNS, s[len(_dns)+3:] + } + return DNS, s +} + +// Supported protocols. +const ( + DNS = iota + 1 + TLS +) + +const ( + _dns = "dns" + _tls = "tls" +) |