zoro

package module
v0.0.0-...-3c35a94 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: GPL-3.0 Imports: 16 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

zoro

中文

zoro (mr2) can help you expose local server to external network. Support both TCP/UDP, of course support HTTP/HTTPS. Keep it simple, stupid.

❤️ A project by txthinking.com

Install via nami
nami install zoro
Install via brew
brew install zoro
Usage
NAME:
   zoro - Expose local TCP and UDP server to external network

USAGE:
   zoro [global options] command [command options] [arguments...]

COMMANDS:
   server       Run as server mode
   client       Run as client mode
   httpsserver  Run as https server mode
   httpsclient  Run as https client mode
   help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)

server and client

On remote server. Note that the firewall opens TCP and UDP on all relevant ports

$ zoro server --listen :9999 --password password

More parameters: $ zoro server --help

On local. Assume your remote zoro server is 1.2.3.4:9999, your local server is 127.0.0.1:8080, want the remote server to open port 8888

$ zoro client --server 1.2.3.4:9999 --password password --serverport 8888 --client 127.0.0.1:8080

More parameters: $ zoro client --help

Then access 1.2.3.4:8888 equals to access 127.0.0.1:8080

httpsserver and httpsclient

On remote server. Assume your domain is domain.com, cert of *.domain.com is ./domain_com_cert.pem and ./domain_com_cert_key.pem, want https listen on 443. Note that the firewall opens TCP on all relevant ports

$ zoro httpsserver --listen :9999 --password password --domain domain.com --cert ./domain_com_cert.pem --key ./domain_com_cert_key.pem --tlsport 443

More parameters: $ zoro httpsserver --help

On local. Assume your remote zoro httpsserver is 1.2.3.4:9999, your local HTTP 1.1 server is 127.0.0.1:8080, want the remote server to open subdomain hello

$ zoro httpsclient --server 1.2.3.4:9999 --password password --subdomain hello --client 127.0.0.1:8080

More parameters: $ zoro httpsclient --help

Then access https://hello.domain.com:443 equals to access http://127.0.0.1:8080

Example of server and client

Expose local HTTP server
$ zoro client --server 1.2.3.4:9999 --password password --serverport 8888 --client 127.0.0.1:8080

Then access 1.2.3.4:8888 equals to access 127.0.0.1:8080

Expose local SSH
$ zoro client --server 1.2.3.4:9999 --password password --serverport 8888 --client 127.0.0.1:22

Then access 1.2.3.4:8888 equals to access 127.0.0.1:22

$ ssh -oPort=8888 yourlocaluser@1.2.3.4
Expose local DNS server
$ zoro client --server 1.2.3.4:9999 --password password --serveport 8888 --client 127.0.0.1:53

Then access 1.2.3.4:8888 equals to access 127.0.0.1:53

$ dig github.com @1.2.3.4 -p 8888
Expose local directory via HTTP
$ zoro client --server 1.2.3.4:9999 --password password --serverport 8888 --dir /path/to/www --dirport 8080

Then access 1.2.3.4:8888 equals to access 127.0.0.1:8080, web root is /path/to/www

Expose any TCP/UDP service
...

About UDP

In some cases of multi-layer NAT, UDP may fail. I passed the test when I connected directly to the Wi-Fi provided by the ISP.

License

Licensed under The GPLv3 License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthZoro        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowZoro          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupZoro = fmt.Errorf("proto: unexpected end of group")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Server       string
	ServerPort   int64
	ServerDomain string
	ClientServer string
	TCPDeadline  int64
	TCPTimeout   int64
	UDPDeadline  int64
	UDPConn      *net.UDPConn
	Ckv          *crypto.KV
	TCPClient    *TCPClient
	UDPClient    *UDPClient
}

Client .

func NewClient

func NewClient(server, password string, serverPort int64, serverDomain, clientServer string, tcpTimeout, tcpDeadline, udpDeadline int64) *Client

NewClient .

func (*Client) ListenAndServe

func (c *Client) ListenAndServe() error

Run .

func (*Client) Shutdown

func (c *Client) Shutdown() error

Shutdown server.

type PingPong

type PingPong struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*PingPong) Descriptor

func (*PingPong) Descriptor() ([]byte, []int)

func (*PingPong) Marshal

func (m *PingPong) Marshal() (dAtA []byte, err error)

func (*PingPong) MarshalTo

func (m *PingPong) MarshalTo(dAtA []byte) (int, error)

func (*PingPong) MarshalToSizedBuffer

func (m *PingPong) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PingPong) ProtoMessage

func (*PingPong) ProtoMessage()

func (*PingPong) Reset

func (m *PingPong) Reset()

func (*PingPong) Size

func (m *PingPong) Size() (n int)

func (*PingPong) String

func (m *PingPong) String() string

func (*PingPong) Unmarshal

func (m *PingPong) Unmarshal(dAtA []byte) error

func (*PingPong) XXX_DiscardUnknown

func (m *PingPong) XXX_DiscardUnknown()

func (*PingPong) XXX_Marshal

func (m *PingPong) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PingPong) XXX_Merge

func (m *PingPong) XXX_Merge(src proto.Message)

func (*PingPong) XXX_Size

func (m *PingPong) XXX_Size() int

func (*PingPong) XXX_Unmarshal

func (m *PingPong) XXX_Unmarshal(b []byte) error

type Server

type Server struct {
	TCPAddr   *net.TCPAddr
	UDPAddr   *net.UDPAddr
	TCPListen *net.TCPListener
	UDPConn   *net.UDPConn
	Cache     *cache.Cache
	Ckv       *crypto.KV
	PortCkv   map[int64]*crypto.KV
}

Server .

func NewServer

func NewServer(addr, password string, portPassword []string) (*Server, error)

NewServer .

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe .

func (*Server) RunTCPServer

func (s *Server) RunTCPServer() error

RunTCPServer

func (*Server) RunUDPServer

func (s *Server) RunUDPServer() error

RunUDPServer

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown server.

func (*Server) TCPHandle

func (s *Server) TCPHandle(c *net.TCPConn) error

TCPHandle

func (*Server) UDPHandle

func (s *Server) UDPHandle(addr *net.UDPAddr, b []byte) error

UDPHandle

type TCPClient

type TCPClient struct {
	Client  *Client
	TCPConn *net.TCPConn
	Cache   *cache.Cache
	Done    chan byte
	Data    chan []byte
	Error   chan error
}

TCPClient .

func NewTCPClient

func NewTCPClient(c *Client) (*TCPClient, error)

NewTCPClient .

func (*TCPClient) Ping

func (c *TCPClient) Ping()

Ping server .

func (*TCPClient) Read

func (c *TCPClient) Read()

Read data from server.

func (*TCPClient) Run

func (c *TCPClient) Run() error

Run .

func (*TCPClient) Stop

func (c *TCPClient) Stop()

Stop .

type TCPHello

type TCPHello struct {
	Port                 int64    `protobuf:"varint,1,opt,name=Port,proto3" json:"Port,omitempty"`
	TCPTimeout           int64    `protobuf:"varint,2,opt,name=TCPTimeout,proto3" json:"TCPTimeout,omitempty"`
	TCPDeadline          int64    `protobuf:"varint,3,opt,name=TCPDeadline,proto3" json:"TCPDeadline,omitempty"`
	Key                  string   `protobuf:"bytes,4,opt,name=Key,proto3" json:"Key,omitempty"`
	Domain               string   `protobuf:"bytes,5,opt,name=Domain,proto3" json:"Domain,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*TCPHello) Descriptor

func (*TCPHello) Descriptor() ([]byte, []int)

func (*TCPHello) GetDomain

func (m *TCPHello) GetDomain() string

func (*TCPHello) GetKey

func (m *TCPHello) GetKey() string

func (*TCPHello) GetPort

func (m *TCPHello) GetPort() int64

func (*TCPHello) GetTCPDeadline

func (m *TCPHello) GetTCPDeadline() int64

func (*TCPHello) GetTCPTimeout

func (m *TCPHello) GetTCPTimeout() int64

func (*TCPHello) Marshal

func (m *TCPHello) Marshal() (dAtA []byte, err error)

func (*TCPHello) MarshalTo

func (m *TCPHello) MarshalTo(dAtA []byte) (int, error)

func (*TCPHello) MarshalToSizedBuffer

func (m *TCPHello) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*TCPHello) ProtoMessage

func (*TCPHello) ProtoMessage()

func (*TCPHello) Reset

func (m *TCPHello) Reset()

func (*TCPHello) Size

func (m *TCPHello) Size() (n int)

func (*TCPHello) String

func (m *TCPHello) String() string

func (*TCPHello) Unmarshal

func (m *TCPHello) Unmarshal(dAtA []byte) error

func (*TCPHello) XXX_DiscardUnknown

func (m *TCPHello) XXX_DiscardUnknown()

func (*TCPHello) XXX_Marshal

func (m *TCPHello) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TCPHello) XXX_Merge

func (m *TCPHello) XXX_Merge(src proto.Message)

func (*TCPHello) XXX_Size

func (m *TCPHello) XXX_Size() int

func (*TCPHello) XXX_Unmarshal

func (m *TCPHello) XXX_Unmarshal(b []byte) error

type TCPPacket

type TCPPacket struct {
	Address              string   `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address,omitempty"`
	Data                 []byte   `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*TCPPacket) Descriptor

func (*TCPPacket) Descriptor() ([]byte, []int)

func (*TCPPacket) GetAddress

func (m *TCPPacket) GetAddress() string

func (*TCPPacket) GetData

func (m *TCPPacket) GetData() []byte

func (*TCPPacket) Marshal

func (m *TCPPacket) Marshal() (dAtA []byte, err error)

func (*TCPPacket) MarshalTo

func (m *TCPPacket) MarshalTo(dAtA []byte) (int, error)

func (*TCPPacket) MarshalToSizedBuffer

func (m *TCPPacket) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*TCPPacket) ProtoMessage

func (*TCPPacket) ProtoMessage()

func (*TCPPacket) Reset

func (m *TCPPacket) Reset()

func (*TCPPacket) Size

func (m *TCPPacket) Size() (n int)

func (*TCPPacket) String

func (m *TCPPacket) String() string

func (*TCPPacket) Unmarshal

func (m *TCPPacket) Unmarshal(dAtA []byte) error

func (*TCPPacket) XXX_DiscardUnknown

func (m *TCPPacket) XXX_DiscardUnknown()

func (*TCPPacket) XXX_Marshal

func (m *TCPPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TCPPacket) XXX_Merge

func (m *TCPPacket) XXX_Merge(src proto.Message)

func (*TCPPacket) XXX_Size

func (m *TCPPacket) XXX_Size() int

func (*TCPPacket) XXX_Unmarshal

func (m *TCPPacket) XXX_Unmarshal(b []byte) error

type TCPServer

type TCPServer struct {
	Server      *Server
	Cache       *cache.Cache
	TCPConn     *net.TCPConn
	TCPListen   *net.TCPListener
	TCPTimeout  int64
	TCPDeadline int64
	Done        chan byte
	Data        chan []byte
	Error       chan error
}

TCPServer .

func NewTCPServer

func NewTCPServer(s *Server, c *net.TCPConn) (*TCPServer, error)

NewTCPServer. Some cases return nil, nil

func (*TCPServer) Accept

func (s *TCPServer) Accept()

Accept consumer.

func (*TCPServer) ListenAndServe

func (s *TCPServer) ListenAndServe() error

ListenAndServe .

func (*TCPServer) Read

func (s *TCPServer) Read()

Read data from client.

func (*TCPServer) Shutdown

func (s *TCPServer) Shutdown()

Shutdown .

type UDPClient

type UDPClient struct {
	Client  *Client
	UDPConn *net.UDPConn
	Cache   *cache.Cache
	Done    chan byte
	Data    chan []byte
	Error   chan error
}

UDPClient .

func NewUDPClient

func NewUDPClient(c *Client) (*UDPClient, error)

NewUDPClient .

func (*UDPClient) Ping

func (c *UDPClient) Ping()

Ping server .

func (*UDPClient) Read

func (c *UDPClient) Read()

Read data from server.

func (*UDPClient) Run

func (c *UDPClient) Run() error

Run .

func (*UDPClient) Stop

func (c *UDPClient) Stop()

Stop .

type UDPPacket

type UDPPacket struct {
	Port                 int64    `protobuf:"varint,1,opt,name=Port,proto3" json:"Port,omitempty"`
	Address              string   `protobuf:"bytes,2,opt,name=Address,proto3" json:"Address,omitempty"`
	Data                 []byte   `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
	Key                  string   `protobuf:"bytes,4,opt,name=Key,proto3" json:"Key,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UDPPacket) Descriptor

func (*UDPPacket) Descriptor() ([]byte, []int)

func (*UDPPacket) GetAddress

func (m *UDPPacket) GetAddress() string

func (*UDPPacket) GetData

func (m *UDPPacket) GetData() []byte

func (*UDPPacket) GetKey

func (m *UDPPacket) GetKey() string

func (*UDPPacket) GetPort

func (m *UDPPacket) GetPort() int64

func (*UDPPacket) Marshal

func (m *UDPPacket) Marshal() (dAtA []byte, err error)

func (*UDPPacket) MarshalTo

func (m *UDPPacket) MarshalTo(dAtA []byte) (int, error)

func (*UDPPacket) MarshalToSizedBuffer

func (m *UDPPacket) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*UDPPacket) ProtoMessage

func (*UDPPacket) ProtoMessage()

func (*UDPPacket) Reset

func (m *UDPPacket) Reset()

func (*UDPPacket) Size

func (m *UDPPacket) Size() (n int)

func (*UDPPacket) String

func (m *UDPPacket) String() string

func (*UDPPacket) Unmarshal

func (m *UDPPacket) Unmarshal(dAtA []byte) error

func (*UDPPacket) XXX_DiscardUnknown

func (m *UDPPacket) XXX_DiscardUnknown()

func (*UDPPacket) XXX_Marshal

func (m *UDPPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UDPPacket) XXX_Merge

func (m *UDPPacket) XXX_Merge(src proto.Message)

func (*UDPPacket) XXX_Size

func (m *UDPPacket) XXX_Size() int

func (*UDPPacket) XXX_Unmarshal

func (m *UDPPacket) XXX_Unmarshal(b []byte) error

type UDPServer

type UDPServer struct {
	Server  *Server
	UDPConn *net.UDPConn
	Addr    *net.UDPAddr
}

UDPServer .

func NewUDPServer

func NewUDPServer(s *Server, p *UDPPacket, addr *net.UDPAddr) (*UDPServer, error)

NewUDPServer .

func (*UDPServer) HandlePacket

func (s *UDPServer) HandlePacket(p *UDPPacket) error

HandlePacket sends data to consumer.

func (*UDPServer) ListenAndServe

func (s *UDPServer) ListenAndServe() error

ListenAndServe .

func (*UDPServer) Shutdown

func (s *UDPServer) Shutdown()

Shutdown .

Directories

Path Synopsis
cli
zoro command

Jump to

Keyboard shortcuts

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