common

package
v0.0.0-...-b054e3c Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Version = 0.70

Variables

View Source
var Conn2Admin map[net.Conn]*AdminInfo
View Source
var Conn2ClientInfo map[net.Conn]*ClientInfo
View Source
var ServerName2Conn map[string]net.Conn

Functions

func DelAllCacheContainer

func DelAllCacheContainer()

func DelCacheContainer

func DelCacheContainer(key string)

func GetCacheContainer

func GetCacheContainer(key string) *cacheContainer

func GetClientInfoByConn

func GetClientInfoByConn(conn net.Conn, cb_ok func(*ClientInfo), cb_fail func())

func GetClientInfoByName

func GetClientInfoByName(ServerName string, cb_ok func(*ClientInfo), cb_fail func())

func GetId

func GetId(name string) string

func GetOnlineServiceNumByName

func GetOnlineServiceNumByName(userName string) int

func GetOnlineServiceNumByNameAndIP

func GetOnlineServiceNumByNameAndIP(userName, ip string) int

func GetServerInfoByConn

func GetServerInfoByConn(conn net.Conn, cb_ok func(*ClientInfo), cb_fail func())

func HashPasswd

func HashPasswd(pass string) string

func Id_test

func Id_test(name string)

func Md5

func Md5(msg string) string

func Read

func Read(conn net.Conn, callback ReadCallBack)

func RmId

func RmId(name, id string)

func Write

func Write(conn net.Conn, id string, action string, content string) error

func Xor

func Xor(s string) string

Types

type AdminInfo

type AdminInfo struct {
	Conn net.Conn
}

type ClientInfo

type ClientInfo struct {
	Conn       net.Conn
	ClientMap  map[net.Conn]*Session
	Id2Session map[string]*Session

	UserName  string
	ClientKey string

	ResponseTime int64

	Quit chan bool

	IsServer       bool
	ServerName     string // is serverName != "", this client is a server!
	Id2MakeSession map[string]*UDPMakeSession
}

func (*ClientInfo) AddClient

func (s *ClientInfo) AddClient(conn net.Conn, clientInfo ClientSetting)

func (*ClientInfo) DelClient

func (s *ClientInfo) DelClient(conn net.Conn) string

func (*ClientInfo) GetSession

func (s *ClientInfo) GetSession(conn net.Conn) *Session

func (*ClientInfo) Loop

func (s *ClientInfo) Loop()

type ClientSetting

type ClientSetting struct {
	AccessKey string
	ClientKey string

	Name       string
	ClientType string
	Version    float32
	Delay      int
	Mode       int
	PipeNum    int
	AesKey     string
}

type ReadCallBack

type ReadCallBack func(conn net.Conn, id string, action string, arg string)

type ReadUDPCallBack

type ReadUDPCallBack func(conn *net.UDPConn, addr *net.UDPAddr, id string, action string, arg string)

type Session

type Session struct {
	Id                string
	ClientA           net.Conn
	ClientB           net.Conn
	Status            string
	OverTime          int64
	Method            string
	Setting           ClientSetting
	MakeHoleResponseN int
	MakeHoleHasFail   bool
	Quit              chan bool
}

func (*Session) Down

func (session *Session) Down()

func (*Session) Loop

func (session *Session) Loop()

func (*Session) RestartSession

func (session *Session) RestartSession(ServerName string)

func (*Session) StartCSMode

func (session *Session) StartCSMode()

func (*Session) StartSession

func (session *Session) StartSession(n int, ServerName, sessionId string)

func (*Session) String

func (session *Session) String() string

type UDPMakeSession

type UDPMakeSession struct {
	Id         string
	CreateTime int64
	ClientA    net.Conn
	ClientB    net.Conn
	SessionId  string
	PipeType   string
	Status     string
	ServerName string
	Quit       chan bool
}

func (*UDPMakeSession) BeginMakeHole

func (udpsession *UDPMakeSession) BeginMakeHole(step int, content string)

func (*UDPMakeSession) Loop

func (udpsession *UDPMakeSession) Loop()

func (*UDPMakeSession) Remove

func (udpsession *UDPMakeSession) Remove(bTimeout bool)

Jump to

Keyboard shortcuts

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