tcpb

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 12 Imported by: 0

README

TCPB

TCP Bridge under HTTP protocol.

websocket tunnel side/client implmented with go websocket gorilla/websocket http connect/post tunnel server directly using envoy, only implmented tunnel client in my repo.

Usage

start up tcp server and envoy tunnel server side
docker-compose -f .docker/docker-compose.yml up -d
start tunnel client side
# tunnel remote tcp to local port 10001

# http post tunnel, using config in docker-compose.yaml: /etc/envoy/envoy_post.yaml
go run ./cmd/client/ --tunnel=http://127.0.0.1:10000 -port 10001 --method=POST

# http connect tunnel, using config in docker-compose.yaml: /etc/envoy/envoy_connect.yaml
# go run ./cmd/client/ --tunnel=http://127.0.0.1:10000 -port 10001
test with tcp client

test envoy encapsulate tcp server:

# type STOP to exist.
go run ./cmd/test-tool --addr 127.0.0.1:20000

test with tunnel client function:

# type STOP to exist.
go run ./cmd/test-tool --addr 127.0.0.1:10001

test websocket client/side:

# terminal 1
go run ./cmd/server/ -port 30000
# terminal 2
go run ./cmd/client/ --tunnel=ws://127.0.0.1:30000/127.0.0.1:20000 -port 10001
# terminal 3
go run ./cmd/test-tool --addr 127.0.0.1:10001

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	WSProxyGetter func(*http.Request) (*url.URL, error)
	HeartInterval time.Duration
}

Bridge implement data flow tunnel between tcp client/server with websocket.

func (*Bridge) TCP2Tunnel added in v0.8.0

func (b *Bridge) TCP2Tunnel(src net.Conn, proxyURL string) error

TCP2Tunnel tcp client -> tcp tunnel server(http/https/http2.0 or socket5).

func (*Bridge) TCP2WS

func (b *Bridge) TCP2WS(src net.Conn, wsURL string) error

TCP2WS tcp client -> websocket tunnel

func (*Bridge) WS2TCP

func (b *Bridge) WS2TCP(src *websocket.Conn, tcpAddress string) error

WS2TCP websocket tunnel -> tcp server

Directories

Path Synopsis
cmd
connect
Package connect implement proxy.Dialer(s) with http connect method.
Package connect implement proxy.Dialer(s) with http connect method.
post
Package post implement proxy.Dialer(s) with http post method.
Package post implement proxy.Dialer(s) with http post method.

Jump to

Keyboard shortcuts

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