session

package
Version: v1.1.72 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSessionsCtl

func InitSessionsCtl()

Types

type HttpProxy

type HttpProxy struct {
	Domain           string
	RunId            string
	RemoteIP         string
	RemotePort       int
	UserName         string
	Password         string
	IfHttps          bool
	Description      string
	RemotePortStatus bool
}

服务结构

func (*HttpProxy) UpdateRemotePortStatus

func (hp *HttpProxy) UpdateRemotePortStatus()

type Session

type Session struct {
	Id             string
	OS             string
	ARCH           string
	Version        string
	Conn           *net.Conn
	GatewaySession *yamux.Session
	WorkConn       chan net.Conn
}

func (*Session) GetNewWorkConn

func (sess *Session) GetNewWorkConn() (net.Conn, error)

func (*Session) GetStream

func (sess *Session) GetStream() (*yamux.Stream, error)

func (*Session) RequestNewWorkConn

func (sess *Session) RequestNewWorkConn() error

func (*Session) Task

func (sess *Session) Task()

:TODO 存活检测

type SessionsManager

type SessionsManager struct {
	Session      map[string]*Session
	HttpProxyMap map[string]*HttpProxy
	RedisPool    *redis.Pool
}
var SessionsCtl SessionsManager

func (*SessionsManager) AddHttpProxy

func (sm *SessionsManager) AddHttpProxy(httpProxy *HttpProxy) error

func (*SessionsManager) CheckRedisKeyExit

func (sess *SessionsManager) CheckRedisKeyExit(key string) (bool, error)

func (*SessionsManager) CheckRemoteStatus

func (sm *SessionsManager) CheckRemoteStatus(targetType, runId, remoteIp string, remotePort int) (bool, error)

检查远端网关口的可用性,可用true

func (*SessionsManager) ConnectToSSH

func (sm *SessionsManager) ConnectToSSH(runId, remoteIP string, remotePort int, userName, passWord string) (stream *yamux.Stream, err error)

func (*SessionsManager) ConnectToSerialPort

func (sm *SessionsManager) ConnectToSerialPort(runId string, msgsd *models.ConnectSerialPort) (*yamux.Stream, error)

Connect to Serial Port

func (*SessionsManager) ConnectToTapTun

func (sm *SessionsManager) ConnectToTapTun(runId string) (*yamux.Stream, error)

func (*SessionsManager) ConnectToTcp

func (sm *SessionsManager) ConnectToTcp(runId, remoteIp string, remotePort int) (*yamux.Stream, error)

Connect to tcp

func (*SessionsManager) ConnectToTls

func (sm *SessionsManager) ConnectToTls(runId, remoteIp string, remotePort int) (*yamux.Stream, error)

func (*SessionsManager) ConnectToUdp

func (sm *SessionsManager) ConnectToUdp(runId, remoteIp string, remotePort int) (*yamux.Stream, error)

Connect to udp

func (*SessionsManager) ConnectToWs

func (sm *SessionsManager) ConnectToWs(runId, targetUrl, protocol, origin string) (*yamux.Stream, error)

func (*SessionsManager) CreateOneHTTP

func (sm *SessionsManager) CreateOneHTTP(ctx context.Context, in *pb.HTTPConfig) (*pb.HTTPConfig, error)

grpc

func (*SessionsManager) DelHttpProxy

func (sm *SessionsManager) DelHttpProxy(domain string)

func (*SessionsManager) DelRedisByKey

func (sess *SessionsManager) DelRedisByKey(key string) error

func (*SessionsManager) DelSession

func (sess *SessionsManager) DelSession(id string)

func (*SessionsManager) DeleteOneHTTP

func (sm *SessionsManager) DeleteOneHTTP(ctx context.Context, in *pb.HTTPConfig) (*pb.Empty, error)

func (*SessionsManager) GetAllHTTP

func (sm *SessionsManager) GetAllHTTP(ctx context.Context, in *pb.Device) (*pb.HTTPList, error)

func (*SessionsManager) GetAllHttpProxy

func (sm *SessionsManager) GetAllHttpProxy() map[string]*HttpProxy

func (*SessionsManager) GetAllRedisKey

func (sess *SessionsManager) GetAllRedisKey() ([]string, error)

func (*SessionsManager) GetNewWorkConnByID

func (sess *SessionsManager) GetNewWorkConnByID(id string) (net.Conn, error)

func (*SessionsManager) GetOneHTTP

func (sm *SessionsManager) GetOneHTTP(ctx context.Context, in *pb.HTTPConfig) (*pb.HTTPConfig, error)

func (*SessionsManager) GetOneHttpProxy

func (sm *SessionsManager) GetOneHttpProxy(domain string) (*HttpProxy, error)

TODO 根据配置文件确定从内存获取映射表还是redis

func (*SessionsManager) GetRedisConn

func (sess *SessionsManager) GetRedisConn() (redis.Conn, error)

Redis Method

func (*SessionsManager) GetRedisValueByKey

func (sess *SessionsManager) GetRedisValueByKey(key string) (interface{}, error)

func (*SessionsManager) GetRedisValueByKeyToBool

func (sess *SessionsManager) GetRedisValueByKeyToBool(key string) (bool, error)

func (*SessionsManager) GetRedisValueByKeyToBytes

func (sess *SessionsManager) GetRedisValueByKeyToBytes(key string) ([]byte, error)

func (*SessionsManager) GetRedisValueByKeyToInt

func (sess *SessionsManager) GetRedisValueByKeyToInt(key string) (int, error)

func (*SessionsManager) GetRedisValueByKeyToString

func (sess *SessionsManager) GetRedisValueByKeyToString(key string) (string, error)

func (*SessionsManager) GetSessionByID

func (sess *SessionsManager) GetSessionByID(id string) (*Session, error)

func (*SessionsManager) GetStreamByID

func (sess *SessionsManager) GetStreamByID(id string) (*yamux.Stream, error)

func (*SessionsManager) ListenMulticastUDP

func (sm *SessionsManager) ListenMulticastUDP(runId, ip string, port uint) (*yamux.Stream, error)

func (SessionsManager) RunKCP

func (sess SessionsManager) RunKCP()

func (SessionsManager) RunTCP

func (sess SessionsManager) RunTCP()

func (SessionsManager) RunTLS

func (sess SessionsManager) RunTLS()

func (*SessionsManager) ServeHTTP

func (sm *SessionsManager) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*SessionsManager) SetRedisKeyValue

func (sess *SessionsManager) SetRedisKeyValue(key string, value interface{}) error

func (*SessionsManager) SetSession

func (sess *SessionsManager) SetSession(id string, session *Session)

func (SessionsManager) StartHttpListenAndServ

func (sess SessionsManager) StartHttpListenAndServ()

http(s)代理端口监听

func (*SessionsManager) StartgRpcListenAndServ

func (sm *SessionsManager) StartgRpcListenAndServ()

func (*SessionsManager) UpdateAllHttpRemotePortStatus

func (sm *SessionsManager) UpdateAllHttpRemotePortStatus()

func (*SessionsManager) UpdateHttpProxyByMap

func (sm *SessionsManager) UpdateHttpProxyByMap(HttpProxyMap map[string]*HttpProxy)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to