tproxy

package
v0.0.0-...-84c9acc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2018 License: GPL-3.0 Imports: 5 Imported by: 0

README

透传用户IP手册

说明:

通过Linux的TPROXY功能,可以实现源站服务程序可以看见客户端真实IP,实现该功能需要linux操作系统和程序都要满足一定的条件.

环境要求:

源站必须是运行在Linux上面的服务程序,同时Linux需要满足下面条件:

1.Linux内核版本 >= 2.6.28

2.判断系统是否支持TPROXY,执行:

grep TPROXY /boot/config-`uname -r`

如果输出有下面的结果说明支持.

CONFIG_NETFILTER_XT_TARGET_TPROXY=m

部署步骤:

1.在源站的linux系统里面每次开机启动都要用root权限执行tproxy环境设置脚本:tproxy_setup.sh

2.在源站的linux系统里面使用root权限执行代理proxy

参数 -tproxy 是开启代理的tproxy功能.

./proxy -tproxy

2.源站的程序监听的地址IP需要使用:127.0.1.1

比如源站以前监听的地址是: 0.0.0.0:8800 , 现在需要修改为:127.0.1.1:8800

3.转发规则里面源站地址必须是对应的,比如上面的:127.0.1.1:8800

Documentation

Overview

Package tproxy provides the TCPDial and TCPListen tproxy equivalent of the net package Dial and Listen with tproxy support for linux ONLY.

Index

Constants

View Source
const IP_ORIGADDRS = 20

Variables

View Source
var Debug = false

Debug outs the library in Debug mode

Functions

func IPTcpAddrToUnixSocksAddr

func IPTcpAddrToUnixSocksAddr(addr string) (sa unix.Sockaddr, err error)

IPTcpAddrToUnixSocksAddr returns Sockaddr for specified TCP addr.

func IPv6UdpAddrToUnixSocksAddr

func IPv6UdpAddrToUnixSocksAddr(addr string) (sa unix.Sockaddr, err error)

IPv6UdpAddrToUnixSocksAddr returns Sockaddr for specified IPv6 addr.

func TCPDial

func TCPDial(localAddr, remoteAddr string, timeout time.Duration) (conn net.Conn, err error)

TCPDial is a special tcp connection which binds a non local address as the source. Except then the option to bind to a specific local address which the machine doesn't posses it is exactly like any other net.Conn connection. It is advised to use port numbered 0 in the localAddr and leave the kernel to choose which Local port to use in order to avoid errors and binding conflicts.

func TCPListen

func TCPListen(listenAddr string) (listener net.Listener, err error)

TCPListen is listening for incoming IP packets which are being intercepted. In conflict to regular Listen mehtod the socket destination and source addresses are of the intercepted connection. Else then that it works exactly like net package net.Listen.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL