| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 | package internetimport (	"crypto/tls"	"net")type ConnectionHandler func(Connection)type Reusable interface {	Reusable() bool	SetReusable(reuse bool)}type StreamConnectionType intconst (	StreamConnectionTypeRawTCP    StreamConnectionType = 1	StreamConnectionTypeTCP       StreamConnectionType = 2	StreamConnectionTypeKCP       StreamConnectionType = 4	StreamConnectionTypeWebSocket StreamConnectionType = 8)type StreamSecurityType intconst (	StreamSecurityTypeNone StreamSecurityType = 0	StreamSecurityTypeTLS  StreamSecurityType = 1)var (	globalSessionCache = tls.NewLRUClientSessionCache(128))type TLSSettings struct {	AllowInsecure bool	Certs         []tls.Certificate}func (this *TLSSettings) GetTLSConfig() *tls.Config {	config := &tls.Config{		ClientSessionCache: globalSessionCache,	}	if this == nil {		return config	}	config.InsecureSkipVerify = this.AllowInsecure	config.Certificates = this.Certs	config.BuildNameToCertificate()	return config}type StreamSettings struct {	Type        StreamConnectionType	Security    StreamSecurityType	TLSSettings *TLSSettings}func (this *StreamSettings) IsCapableOf(streamType StreamConnectionType) bool {	return (this.Type & streamType) == streamType}type Connection interface {	net.Conn	Reusable}type SysFd interface {	SysFd() (int, error)}
 |