Skip to content

Instantly share code, notes, and snippets.

View jeremiehuchet's full-sized avatar

Jérémie Huchet jeremiehuchet

View GitHub Profile
@jeremiehuchet
jeremiehuchet / get_original_dst.go
Created September 22, 2017 15:27 — forked from fangdingjun/get_original_dst.go
golang: get the original destination for the socket when redirect by linux iptables
// get the original destination for the socket when redirect by linux iptables
// refer to https://raw.githubusercontent.com/missdeer/avege/master/src/inbound/redir/redir_iptables.go
//
const (
SO_ORIGINAL_DST = 80
IP6T_SO_ORIGINAL_DST = 80
)
func getOriginalDst(clientConn *net.TCPConn) (rawaddr []byte, host string, newTCPConn *net.TCPConn, err error) {
if clientConn == nil {