gstunnellib

package
v6.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

* *Open source agreement: * The project is based on the GPLv3 protocol. *

Index

Constants

View Source
const G_Deep_debug = gsbase.G_Deep_debug
View Source
const G_Info_protobuf bool = true
View Source
const G_RunTime_Debug = gsbase.G_RunTime_Debug
View Source
const G_Version string = gsbase.G_Version

Variables

View Source
var G_logger *log.Logger

Functions

func ChanClean added in v6.3.0

func ChanClean(c chan []byte)

func ChanClose added in v6.3.0

func ChanClose(c interface{})

func CheckError_test added in v6.3.0

func CheckError_test(inerr error, t *testing.T)
func CheckError_test_old(inerr error, t *testing.T) {
	if inerr != nil {
		_, file, line, ok := runtime.Caller(1)
		if !ok {
			file = "???"
			line = -1
		}
		finfo, _ := os.Stat(file)
		fileName := finfo.Name()
		t.Logf("%s:%d: ", fileName, line)

		panic(inerr)
		//t.Fatal(inerr)
	}
}
func CheckError_test_noExit_old(inerr error, t *testing.T) {
	if inerr != nil {
		_, file, line, ok := runtime.Caller(1)
		if !ok {
			file = "???"
			line = -1
		}
		finfo, _ := os.Stat(file)
		fileName := finfo.Name()
		errstr := fmt.Sprintf("%s:%d:Test error: %s", fileName, line, inerr)
		t.Logf(errstr)
		log.Println(errstr)
	}
}

func CheckError_test_noExit added in v6.3.0

func CheckError_test_noExit(inerr error, t *testing.T)

func Find0

func Find0(v1 []byte) (int, bool)

func GetGSPackSize added in v6.3.0

func GetGSPackSize(data []byte) uint16

func GetIP added in v6.3.0

func GetIP(conn net.Addr) string

func GetNetConnAddrString added in v6.3.0

func GetNetConnAddrString(str string, conn net.Conn) string

func GetNetLocalRDPort added in v6.3.0

func GetNetLocalRDPort() string

func GetRDKeyString96 added in v6.3.0

func GetRDKeyString96() string
func GetRDKeyString32() string {
	return gsrand.GetrandStringPlus(32)
}

func GetRDNetConn added in v6.3.0

func GetRDNetConn() (net.Conn, net.Conn)

func GetRDNetConnLiten added in v6.3.0

func GetRDNetConnLiten() (net.Conn, net.Conn, net.Listener)

func IsClosedPanic added in v6.3.0

func IsClosedPanic(conn net.Conn)

func IsErrorNetUsually added in v6.3.0

func IsErrorNetUsually(err error) bool

func IsNetConnClosed added in v6.3.0

func IsNetConnClosed(conn net.Conn) bool

func IsNetConnClosed_Read added in v6.3.0

func IsNetConnClosed_Read(conn net.Conn) bool

func IsOk_PackDataLen_panic added in v6.3.0

func IsOk_PackDataLen_panic(data []byte)

func NetConnWriteAll added in v6.3.0

func NetConnWriteAll(dst net.Conn, buf []byte) (int64, error)

func NewGSRSAPackNetImp added in v6.3.0

func NewGSRSAPackNetImp(key string, serverRSAKey, clientRSAKey *gsrsa.RSA) *gsRSAPackNetImp

func NewRSAPackImpWithGSTClient added in v6.3.0

func NewRSAPackImpWithGSTClient(key string, serverRSAKey, ClientRSAKey *gsrsa.RSA) *gsRSAPackImp

func NewRSAPackImpWithGSTServer added in v6.3.0

func NewRSAPackImpWithGSTServer(key string, serverRSAKey *gsrsa.RSA) *gsRSAPackImp

func Nullprint

func Nullprint(v ...interface{}) (int, error)

func Nullprintf

func Nullprintf(format string, a ...interface{}) (n int, err error)

func Panic_Recover_GSCtx added in v6.3.0

func Panic_Recover_GSCtx(inlog *log.Logger, gctx IGSContext)

func RunGRuntimeStatistics_print

func RunGRuntimeStatistics_print(inlog *log.Logger, inruntstats IRuntime_statistics)

func TcpDoKeepAlive added in v6.3.0

func TcpDoKeepAlive(conn net.Conn)

Types

type Conn added in v6.3.0

type Conn interface {
	Read(b []byte) (n int, err error)
	Write(b []byte) (n int, err error)
	Close() error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

type GSTNetConnDebug added in v6.3.0

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

func NewGSTNetConnDebug added in v6.3.0

func NewGSTNetConnDebug(conn net.Conn) *GSTNetConnDebug

func (*GSTNetConnDebug) Close added in v6.3.0

func (c *GSTNetConnDebug) Close() error

func (*GSTNetConnDebug) LocalAddr added in v6.3.0

func (c *GSTNetConnDebug) LocalAddr() net.Addr

func (*GSTNetConnDebug) Read added in v6.3.0

func (c *GSTNetConnDebug) Read(b []byte) (n int, err error)

func (*GSTNetConnDebug) RemoteAddr added in v6.3.0

func (c *GSTNetConnDebug) RemoteAddr() net.Addr

func (*GSTNetConnDebug) SetDeadline added in v6.3.0

func (c *GSTNetConnDebug) SetDeadline(t time.Time) error

func (*GSTNetConnDebug) SetReadDeadline added in v6.3.0

func (c *GSTNetConnDebug) SetReadDeadline(t time.Time) error

func (*GSTNetConnDebug) SetWriteDeadline added in v6.3.0

func (c *GSTNetConnDebug) SetWriteDeadline(t time.Time) error

func (*GSTNetConnDebug) Write added in v6.3.0

func (c *GSTNetConnDebug) Write(b []byte) (n int, err error)

type GsConfig

type GsConfig struct {
	Listen  string
	Servers []string
	Key     string

	RSAServerPrivate string
	RSAServerPublic  string

	Tmr_display_time   int
	Tmr_changekey_time int
	NetworkTimeout     int

	Debug    bool
	Mt_model bool
	WebUI    bool
}

func CreateGsconfig

func CreateGsconfig(confg string) *GsConfig

func (*GsConfig) GetRSAServer added in v6.3.0

func (c *GsConfig) GetRSAServer() *gsrsa.RSA

Deep copy, new obj.

func (*GsConfig) GetRSAServerPrivate added in v6.3.0

func (c *GsConfig) GetRSAServerPrivate() *rsa.PrivateKey

func (*GsConfig) GetRSAServerPublic added in v6.3.0

func (c *GsConfig) GetRSAServerPublic() *rsa.PublicKey

func (*GsConfig) GetServer_rand

func (c *GsConfig) GetServer_rand() string

func (*GsConfig) GetServers

func (c *GsConfig) GetServers() []string

type IGId added in v6.3.0

type IGId interface {
	GenerateId() uint64
	GetId() uint64
}

func NewGIdImp added in v6.3.0

func NewGIdImp() IGId

type IGSContext added in v6.3.0

type IGSContext interface {
	GetGsId() uint64
	GetGsStatus() IGsStatus
	Close()
}

func NewGSContextImp added in v6.3.0

func NewGSContextImp(gsid uint64, gsst IGsStatus) IGSContext

type IGSPack added in v6.3.0

type IGSPack interface {
	Packing([]byte) []byte
	Unpack([]byte) ([]byte, error)

	ChangeCryKey() []byte
	PackVersion() []byte
}

func NewGsPack

func NewGsPack(key string) IGSPack

type IGSPackNet added in v6.3.0

type IGSPackNet interface {
	IGSPack

	WriteEncryData([]byte) error
	GetDecryData() ([]byte, error)
	GetDecryDataFormBytes([]byte) ([]byte, error)

	GetGSPackSize(data []byte) uint16
}

net buffer encrypter decrypter pack unpack

func NewGsPackNet added in v6.3.0

func NewGsPackNet(key string) IGSPackNet

type IGSRSAPackNet added in v6.3.0

type IGSRSAPackNet interface {
	IGSPackNet

	ClientPublicKeyPack() []byte
	ChangeCryKeyFromGSTServer() ([]byte, string)
	ChangeCryKeyFromGSTClient() ([]byte, string)
	PackPOHello() []byte

	IsExistsClientKey() bool
	GetClientRSAKey() *gsrsa.RSA
	SetClientRSAKey(*gsrsa.RSA)
	GetServerRSAKey() *gsrsa.RSA
	UnpackEx([]byte) (*UnpackReV, error)
	UnpackOneGSTPackFromNetConn(src net.Conn, timeout time.Duration) (*UnpackReV, error)
}

func NewGSRSAPackNetImpWithGSTClient added in v6.3.0

func NewGSRSAPackNetImpWithGSTClient(key string, serverRSAKey, clientRSAKey *gsrsa.RSA) IGSRSAPackNet

func NewGSRSAPackNetImpWithGSTServer added in v6.3.0

func NewGSRSAPackNetImpWithGSTServer(key string, serverRSAKey *gsrsa.RSA) IGSRSAPackNet

type IGlobal_values added in v6.3.0

type IGlobal_values interface {
	GetDebug() bool
	SetDebug(bool)
}

func NewGlobalValuesImp added in v6.3.0

func NewGlobalValuesImp() IGlobal_values

type IGorou_status added in v6.3.0

type IGorou_status interface {
	IsOk() bool
	SetOk()
	SetClose()
}

func NewGorouStatus added in v6.3.0

func NewGorouStatus() IGorou_status

func NewGorouStatusNetConn added in v6.3.0

func NewGorouStatusNetConn(inconnList []net.Conn) IGorou_status

type IGsRSAPack added in v6.3.0

type IGsRSAPack interface {
	IGSPack
	ClientPublicKeyPack() []byte
	ChangeCryKeyFromGSTServer() ([]byte, string)
	ChangeCryKeyFromGSTClient() ([]byte, string)
	PackPOHello() []byte

	IsExistsClientKey() bool
	GetClientRSAKey() *gsrsa.RSA
	SetClientRSAKey(*gsrsa.RSA)
	GetServerRSAKey() *gsrsa.RSA
	UnpackEx([]byte) (*UnpackReV, error)
}

type IGsStatus added in v6.3.0

type IGsStatus interface {
	GetJson() []byte
	GetStatusData() *gsStatusData
	GetStatusConnList() IStatusConnList
}

func NewGsStatusImp added in v6.3.0

func NewGsStatusImp() IGsStatus

type INetTime added in v6.3.0

type INetTime interface {
	Add(time.Duration)
	PrintString() string
}

func NewNetTimeImp added in v6.3.0

func NewNetTimeImp() INetTime

func NewNetTimeImpName added in v6.3.0

func NewNetTimeImpName(name string) INetTime

type IRunTimeDebugInfo added in v6.3.0

type IRunTimeDebugInfo interface {
	AddPackingPackSizeList(string, int)
	WriteFile(FileName string)
}
var G_RunTimeDebugInfo1 IRunTimeDebugInfo

func NewRunTimeDebugInfo added in v6.3.0

func NewRunTimeDebugInfo() IRunTimeDebugInfo

type IRuntime_statistics added in v6.3.0

type IRuntime_statistics interface {
	//	AddTotalNetworkData(int)
	AddSrcTotalNetData_recv(int)
	AddSrcTotalNetData_send(int)
	AddServerTotalNetData_recv(int)
	AddServerTotalNetData_send(int)

	GetJson() ([]byte, error)
}

func NewRuntimeStatistics

func NewRuntimeStatistics() IRuntime_statistics

func NewRuntimeStatisticsNULL added in v6.3.0

func NewRuntimeStatisticsNULL() IRuntime_statistics

type IStatusConnList added in v6.3.0

type IStatusConnList interface {
	Add(id uint64, conn1, conn2 net.Conn)
	Delete(id uint64)
	HTMLString() string
	// contains filtered or unexported methods
}

type UnpackReV added in v6.3.0

type UnpackReV struct {
	OperType  uint32
	ClientKey *gsrsa.RSA
	GenData   []byte
	Version   string
	Key       []byte
}

func (*UnpackReV) IsChangeCryKey added in v6.3.0

func (u *UnpackReV) IsChangeCryKey() bool

func (*UnpackReV) IsChangeCryKeyFromGSTClient added in v6.3.0

func (u *UnpackReV) IsChangeCryKeyFromGSTClient() bool

func (*UnpackReV) IsChangeCryKeyFromGSTServer added in v6.3.0

func (u *UnpackReV) IsChangeCryKeyFromGSTServer() bool

func (*UnpackReV) IsClientPubKey added in v6.3.0

func (u *UnpackReV) IsClientPubKey() bool

func (*UnpackReV) IsPOGen added in v6.3.0

func (u *UnpackReV) IsPOGen() bool

func (*UnpackReV) IsPOHello added in v6.3.0

func (u *UnpackReV) IsPOHello() bool

func (*UnpackReV) IsPOVersion added in v6.3.0

func (u *UnpackReV) IsPOVersion() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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