Publish metadata from kubernetes plugin (#2829)

* Publish metadata from kubernetes plugin

* stickler fix

* Add a couple tests

* Add metadata section to README

* Update plugin/kubernetes/README.md

Co-Authored-By: Chris O'Haver <cohaver@infoblox.com>

* Address nit
This commit is contained in:
John Belamaric
2019-06-09 00:10:57 -07:00
committed by Miek Gieben
parent a1c97f82a6
commit ffcd2f61cf
6 changed files with 218 additions and 6 deletions

View File

@@ -10,7 +10,8 @@ import (
// remote will always be 10.240.0.1 and port 40212. The local address is always 127.0.0.1 and
// port 53.
type ResponseWriter struct {
TCP bool // if TCP is true we return an TCP connection instead of an UDP one.
TCP bool // if TCP is true we return an TCP connection instead of an UDP one.
RemoteIP string
}
// LocalAddr returns the local address, 127.0.0.1:53 (UDP, TCP if t.TCP is true).
@@ -23,9 +24,13 @@ func (t *ResponseWriter) LocalAddr() net.Addr {
return &net.UDPAddr{IP: ip, Port: port, Zone: ""}
}
// RemoteAddr returns the remote address, always 10.240.0.1:40212 (UDP, TCP is t.TCP is true).
// RemoteAddr returns the remote address, defaults to 10.240.0.1:40212 (UDP, TCP is t.TCP is true).
func (t *ResponseWriter) RemoteAddr() net.Addr {
ip := net.ParseIP("10.240.0.1")
remoteIP := "10.240.0.1"
if t.RemoteIP != "" {
remoteIP = t.RemoteIP
}
ip := net.ParseIP(remoteIP)
port := 40212
if t.TCP {
return &net.TCPAddr{IP: ip, Port: port, Zone: ""}