transocks/original_dst_stub.go

17 lines
507 B
Go
Raw Permalink Normal View History

2016-03-04 07:54:59 +06:00
// +build !linux
package transocks
import "net"
// GetOriginalDST retrieves the original destination address from
// NATed connection. Currently, only Linux iptables using DNAT/REDIRECT
// is supported. For other operating systems, this will just return
// conn.LocalAddr().
//
// Note that this function only works when nf_conntrack_ipv4 and/or
// nf_conntrack_ipv6 is loaded in the kernel.
func GetOriginalDST(conn *net.TCPConn) (*net.TCPAddr, error) {
return conn.LocalAddr().(*net.TCPAddr), nil
}