transproxy

package module
v0.0.0-...-a40f8c7 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2017 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

transproxy

transparent proxy to cccccros the GFW, cooperate with iptables; also see redsocks: https://github.com/darkk/redsocks

thanks the proxy library from here: https://github.com/phuslu/goproxy/tree/master/httpproxy/proxy

  1. compile

    go get -u github.com/xiqingping/transproxy/...
    
  2. config the iptables

    # create TRANSPROXYD chain
    iptables -t nat -N TRANSPROXYD
    
    # packets from nobody(transproxyd run as nobody) do not redirect
    iptables -t nat -A TRANSPROXYD -p tcp -m owner --uid-owner nobody -j RETURN
    
    # packets to private net do not redirect
    iptables -t nat -A TRANSPROXYD -d 0.0.0.0/8 -j RETURN
    iptables -t nat -A TRANSPROXYD -d 10.0.0.0/8 -j RETURN
    iptables -t nat -A TRANSPROXYD -d 127.0.0.0/8 -j RETURN
    iptables -t nat -A TRANSPROXYD -d 169.254.0.0/16 -j RETURN
    iptables -t nat -A TRANSPROXYD -d 172.16.0.0/12 -j RETURN
    iptables -t nat -A TRANSPROXYD -d 192.168.0.0/16 -j RETURN
    iptables -t nat -A TRANSPROXYD -d 224.0.0.0/4 -j RETURN
    iptables -t nat -A TRANSPROXYD -d 240.0.0.0/4 -j RETURN
    
    # redirect all tcp packets to port 12345(transproxyd listen on this port)
    iptables -t nat -A TRANSPROXYD -p tcp -j REDIRECT --to-ports 12345
    
    # all output tcp packets jump to TRANSPROXYD chain
    iptables -t nat -A OUTPUT -p tcp  -j TRANSPROXYD
    
    
  3. Run the transproxyd, pls ref the config file under github.com/xiqingping/transproxy/transproxyd

    sudo transproxyd -config path/to/transproxyd.toml
    
    • Uid or Gid in the config must satify to iptables config iptables -t nat -A TRANSPROXYD -p tcp -m owner --uid-owner nobody -j RETURN
    • ListenAddr in the config must satify to iptables config iptables -t nat -A TRANSPROXYD -p tcp -j REDIRECT --to-ports 12345

Documentation

Index

Constants

View Source
const SO_ORIGINAL_DST = 80

Variables

This section is empty.

Functions

This section is empty.

Types

type BlackList

type BlackList struct {
	// contains filtered or unexported fields
}

BlackList black list of IP

func NewBlackList

func NewBlackList() *BlackList

NewBlackList create a black list

func (*BlackList) Add

func (bl *BlackList) Add(ip net.IP)

Add add a IP to the black list

func (*BlackList) Contains

func (bl *BlackList) Contains(ip net.IP) bool

Contains check if black list contains the specified IP

type SocketProxy

type SocketProxy struct {
	// contains filtered or unexported fields
}

func NewSocketProxy

func NewSocketProxy(conn *net.TCPConn, bl *BlackList, proxyDial proxy.Dialer, logger log.Logger) (sp *SocketProxy, err error)

func (*SocketProxy) Run

func (sp *SocketProxy) Run()

func (*SocketProxy) String

func (sp *SocketProxy) String() string

Directories

Path Synopsis
Package proxy provides support for a variety of protocols to proxy network data.
Package proxy provides support for a variety of protocols to proxy network data.

Jump to

Keyboard shortcuts

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