bridge

package module
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 2 Imported by: 1

README

Bridge

Bridge is a TCP proxy tool Support http(s)-connect socks4/4a/5/5h ssh proxycommand

Build Go Report Card GoDoc Docker Automated build GitHub license

Supported protocols

Example

Mapping example.org:80 TCP port to 8080 port of the local machines.

bridge -b :8080 -p example.org:80
# `curl -H 'Host: example.org' 127.0.0.1:8080` will return to the target page

Proxy that can go through various protocols.

bridge -b :8080 -p example.org:80 -p ssh://username:password@my_server:22
bridge -b :8080 -p example.org:80 -p ssh://username@my_server:22?identity_file=~/.ssh/id_rsa
bridge -b :8080 -p example.org:80 -p socks5://username:password@my_server:1080
bridge -b :8080 -p example.org:80 -p http://username:password@my_server:8080
bridge -b :8080 -p example.org:80 -p 'cmd:nc %h %p'
bridge -b :8080 -p example.org:80 -p 'cmd:ssh sshserver nc %h %p'

It can also go through multi-level proxy.

bridge -b :8080 -p example.org:80 -p http://username:password@my_server2:8080 -p http://username:password@my_server1:8080

Using proxy protocol(http/socks4/socks5) instead of direct TCP forwarding.

bridge -b :8080 -p -
bridge -b :8080 -p - -p http://username:password@my_server1:8080
# `http_proxy=http://127.0.0.1:8080 curl example.org` Will be the proxy

You can also use ssh to listen for port mapping from local port to server port,
due to the limitation of sshd, only 127.0.0.1 ports can be monitored.
if you want to provide external services,
you need to change the 'GatewayPorts no' in /etc/ssh/sshd_config to yes
and then reload sshd.

bridge -b :8080 -b ssh://username:password@my_server:22 -p 127.0.0.1:80

More of the time I'm acting as a ssh proxy.

# in ~/.ssh/config
ProxyCommand bridge -p %h:%p -p "ssh://username@my_server?identity_file=~/.ssh/id_rsa"

Usage

Usage: bridge [-d] \
	[-b=[[tcp://]bind_address]:bind_port \
	[-b=ssh://bridge_bind_address:bridge_bind_port [-b=(socks4://|socks4a://|socks5://|socks5h://|https://|http://|ssh://|cmd:)bridge_bind_address:bridge_bind_port ...]]] \ // 
	-p=([tcp://]proxy_address:proxy_port|-) \
	[-p=(socks4://|socks4a://|socks5://|socks5h://|https://|http://|ssh://|cmd:)bridge_proxy_address:bridge_proxy_port ...]
  -b, --bind strings    The first is the listening address, and then the proxy through which the listening address passes.
                        If it is not filled in, it is redirected to the pipeline.
                        only SSH and local support listening, so the last proxy must be ssh.
  -d, --debug           Output the communication data.
  -p, --proxy strings   The first is the dial-up address, followed by the proxy through which the dial-up address passes.

Install

go get -u -v github.com/wzshiming/bridge/cmd/bridge

or

Download releases

or

Docker image

License

Licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BridgeFunc

type BridgeFunc func(dialer Dialer, address string) (Dialer, error)

BridgeFunc type is an adapter for Bridger.

func (BridgeFunc) Bridge

func (b BridgeFunc) Bridge(dialer Dialer, address string) (Dialer, error)

Bridge calls b(dialer, address)

type Bridger

type Bridger interface {
	Bridge(dialer Dialer, address string) (Dialer, error)
}

Bridger contains options for crossing a bridge address.

type CommandDialFunc added in v0.2.0

type CommandDialFunc func(ctx context.Context, name string, args ...string) (net.Conn, error)

CommandDialFunc type is an adapter for Dialer with command.

func (CommandDialFunc) CommandDialContext added in v0.2.0

func (d CommandDialFunc) CommandDialContext(ctx context.Context, name string, args ...string) (net.Conn, error)

CommandDialContext calls d(ctx, name, args...)

type CommandDialer added in v0.2.0

type CommandDialer interface {
	CommandDialContext(ctx context.Context, name string, args ...string) (net.Conn, error)
}

CommandDialer contains options for connecting to an address with command.

type CommandListenConfig added in v0.6.8

type CommandListenConfig interface {
	CommandListen(ctx context.Context, name string, args ...string) (net.Listener, error)
}

CommandListenConfig contains options for listening to an address with command.

type CommandListenConfigFunc added in v0.6.8

type CommandListenConfigFunc func(ctx context.Context, name string, args ...string) (net.Listener, error)

CommandListenConfigFunc type is an adapter for ListenConfig with command.

func (CommandListenConfigFunc) CommandListen added in v0.6.8

func (l CommandListenConfigFunc) CommandListen(ctx context.Context, name string, args ...string) (net.Listener, error)

CommandListen calls b(ctx, network, address)

type DialFunc

type DialFunc func(ctx context.Context, network, address string) (net.Conn, error)

DialFunc type is an adapter for Dialer.

func (DialFunc) DialContext

func (d DialFunc) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext calls d(ctx, network, address)

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

Dialer contains options for connecting to an address.

type ListenConfig

type ListenConfig interface {
	Listen(ctx context.Context, network, address string) (net.Listener, error)
}

ListenConfig contains options for listening to an address.

type ListenConfigFunc

type ListenConfigFunc func(ctx context.Context, network, address string) (net.Listener, error)

ListenConfigFunc type is an adapter for ListenConfig.

func (ListenConfigFunc) Listen

func (l ListenConfigFunc) Listen(ctx context.Context, network, address string) (net.Listener, error)

Listen calls b(ctx, network, address)

Directories

Path Synopsis
cmd
internal
log
protocols
ssh
tls
ws

Jump to

Keyboard shortcuts

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