o2o

package module
v1.0.2-0...-b4fc2ea Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 18 Imported by: 0

README

github.com/ohko/o2o Codacy Badge

TCP 隧道

将局域网任意IP的端口映射到公网服务器指定端口,隧道数据支持AES加密。

例如:将局域网192.168.1.240:5000映射到公网x.x.x.x:2399

User <-> Server <-> Client <-> LocalServer

Build

go build -mod=vendor -o server ./server
go build -mod=vendor -o client ./client
go build -mod=vendor -o forward ./forward

Server

# 开启2399等待Client连接、传送指令、隧道服务
./server -s :2399 -key=mykey

Client

# 连接服务器2399端口,传送指令
# 请求服务器开启2390端口,用于代理192.168.1.240的5000端口
./client -s x.x.x.x:2399 -key=mykey -p 0.0.0.0:2390:192.168.1.240:5000

指定服务转发

# 监听8080端口,将请求转发至ip.lyl.hk:80
./forward -p x.x.x.x:8080 -f ip.lyl.hk:80

Docker

# Server 开启2390-2399端口段
docker run --name=o2o -d --restart=always -p 2390-2399:2390-2399 ohko/o2o /server_linux -s :2399 -key=mykey

# Client 请求2390端口代理192.168.1.240的5000端口
docker run --name=o2o -d --restart=always ohko/o2o /client_linux -s x.x.x.x:2399 -p 0.0.0.0:2390:192.168.1.240:5000 -key=mykey

# Forward 监听8080端口,将请求转发至ip.lyl.hk:80
docker run --name=o2o -d --restart=always -p 8080:8080 ohko/o2o /forward_linux -p :8080 -f ip.lyl.hk:80

# 测试访问
curl http://x.x.x.x:2345
curl http://x.x.x.x:8080

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitCtrlC

func WaitCtrlC()

WaitCtrlC 捕捉Ctrl+C

Types

type Client

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

Client 客户端

func (*Client) OmsgClose

func (o *Client) OmsgClose()

OmsgClose ...

func (*Client) OmsgData

func (o *Client) OmsgData(cmd, ext uint16, data []byte)

OmsgData ...

func (*Client) OmsgError

func (o *Client) OmsgError(err error)

OmsgError ...

func (*Client) Reconnect

func (o *Client) Reconnect() error

Reconnect 重新连接服务器

func (*Client) Send

func (o *Client) Send(cmd, ext uint16, originData []byte) error

Send 原始数据加密后发送

func (*Client) Start

func (o *Client) Start(key, serverPort, proxyPort string, crc bool) error

Start 启动客户端

type Server

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

Server 服务端

func (*Server) OmsgClientClose

func (o *Server) OmsgClientClose(conn net.Conn)

OmsgClientClose ...

func (*Server) OmsgData

func (o *Server) OmsgData(conn net.Conn, cmd, ext uint16, data []byte)

OmsgData ...

func (*Server) OmsgError

func (o *Server) OmsgError(conn net.Conn, err error)

OmsgError ...

func (*Server) OmsgNewClient

func (o *Server) OmsgNewClient(conn net.Conn)

OmsgNewClient ...

func (*Server) Send

func (o *Server) Send(conn net.Conn, cmd, ext uint16, originData []byte) error

Send 原始数据加密后发送

func (*Server) Start

func (o *Server) Start(key, serverPort string, crc bool) error

Start 启动服务

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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