mirror of
https://github.com/coredns/coredns.git
synced 2026-10-26 04:05:43 -04:00
core/dnsserver: preserve UDP packet destination addresses (#8644)
* core/dnsserver: preserve UDP packet destination addresses Signed-off-by: houyuwushang <180804215+houyuwushang@users.noreply.github.com> * test: modernize reverse UDP reply traversal Signed-off-by: houyuwushang <180804215+houyuwushang@users.noreply.github.com> * test: account for Unix IPv4 source-control capabilities Signed-off-by: houyuwushang <180804215+houyuwushang@users.noreply.github.com> --------- Signed-off-by: houyuwushang <180804215+houyuwushang@users.noreply.github.com>
This commit is contained in:
@@ -200,6 +200,15 @@ func (a *Addr) Unwrap() net.Addr {
|
||||
return a.r
|
||||
}
|
||||
|
||||
// LocalAddr returns the transport packet's destination when the underlying
|
||||
// address carries one. It is independent of the PROXY header's destination.
|
||||
func (a *Addr) LocalAddr() net.Addr {
|
||||
if packet, ok := a.u.(interface{ LocalAddr() net.Addr }); ok {
|
||||
return packet.LocalAddr()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// tlvsFor returns the header's raw TLVs when TLV capture is enabled, else nil.
|
||||
func (c *PacketConn) tlvsFor(header *proxyproto.Header) []byte {
|
||||
if !c.CaptureTLVs {
|
||||
|
||||
@@ -136,11 +136,16 @@ functions defined below.
|
||||
* `opcode() int`: query OPCODE
|
||||
* `port() string`: client's port
|
||||
* `proto() string`: protocol used (tcp or udp)
|
||||
* `server_ip() string`: server's IP address; for IPv6 addresses these are enclosed in brackets: `[::1]`
|
||||
* `server_ip() string`: server's destination IP address; IPv6 addresses have no brackets: `::1`
|
||||
* `server_port() string` : server's port
|
||||
* `size() int`: request size in bytes
|
||||
* `type() string`: type of the request (A, AAAA, TXT, ...)
|
||||
|
||||
For wildcard UDP listeners, `server_ip()` uses the destination address of the individual packet
|
||||
when the operating system supplies packet information. If that information is unavailable, including
|
||||
with custom packet listeners that do not expose it, the listening address is used instead.
|
||||
With *proxyproto*, this is the transport packet's destination, not the destination claimed in the PROXY header.
|
||||
|
||||
#### Utility Functions
|
||||
|
||||
* `incidr(ip string, cidr string) bool`: returns true if _ip_ is within _cidr_
|
||||
|
||||
Reference in New Issue
Block a user