models

package
v0.0.0-...-0c2bc69 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success = iota
	NotExists
	InvalidPassword
	AlreadyInUse
	Unexpected
	Unsupported
)
View Source
const (
	ControlConn = iota
	WorkConn
)
View Source
const (
	Idle = iota
	Working
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientCtlReq

type ClientCtlReq struct {
	Type      int    `json:"Type"`
	Password  string `json:"Password"`
	ProxyName string `json:"ProxyName"`
}

type ClientCtlRes

type ClientCtlRes struct {
	GeneralRes
}

type GeneralRes

type GeneralRes struct {
	Code    int    `json:"Code"`
	Message string `json:"Message"`
}

type ProxyClient

type ProxyClient struct {
	// Actively connect to the public server, double forwarding
	// self (nat) -> server1 (public) && self (nat) -> server2 (nat)  => client <-> server1 <-> server2
	Name      string `yaml:"Name,omitempty"`
	Password  string `yaml:"Password,omitempty"`
	LocalHost string `yaml:"LocalHost,omitempty"`
	LocalPort int64  `yaml:"LocalPort,omitempty"`

	// Passive listening port, then actively forwarding to local server
	// client -> self (public) -> server (nat) => client <-> server
	PassiveMode bool   `yaml:"PassiveMode,omitempty"`
	BindAddr    string `yaml:"BindAddr,omitempty"`
	BindPort    int64  `yaml:"BindPort,omitempty"`
}

func (*ProxyClient) GetLocalConn

func (p *ProxyClient) GetLocalConn() (c *conn.Conn, err error)

func (*ProxyClient) GetRemoteConn

func (p *ProxyClient) GetRemoteConn(addr string, port int64) (c *conn.Conn, err error)

func (*ProxyClient) StartTunnel

func (p *ProxyClient) StartTunnel(serverAddr string, serverPort int64) (err error)

type ProxyServer

type ProxyServer struct {
	Name       string `yaml:"Name,omitempty"`
	Password   string `yaml:"Password,omitempty"`
	BindAddr   string `yaml:"BindAddr,omitempty"`
	ListenPort int64  `yaml:"ListenPort,omitempty"`

	Status       int64           `yaml:"-"`
	Listener     *conn.Listener  `yaml:"-"` // accept new connection from remote users
	CtlMsgChan   chan int64      `yaml:"-"` // every time accept a new user conn, put "1" to the channel
	CliConnChan  chan *conn.Conn `yaml:"-"` // get client conns from control goroutine
	UserConnList *list.List      `yaml:"-"` // store user conns
	Mutex        sync.Mutex      `yaml:"-"`
}

func (*ProxyServer) Close

func (p *ProxyServer) Close()

func (*ProxyServer) Init

func (p *ProxyServer) Init()

func (*ProxyServer) Lock

func (p *ProxyServer) Lock()

func (*ProxyServer) Start

func (p *ProxyServer) Start() (err error)

func (*ProxyServer) Unlock

func (p *ProxyServer) Unlock()

func (*ProxyServer) WaitUserConn

func (p *ProxyServer) WaitUserConn() (res int64)

type ServerCtlReq

type ServerCtlReq struct {
	Type int `json:"Type"`
}

Jump to

Keyboard shortcuts

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