1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-08 14:24:36 -04:00
v2fly/transport/internet/connection.go
2016-07-10 15:27:58 +02:00

63 lines
1.1 KiB
Go

package internet
import (
"crypto/tls"
"net"
)
type ConnectionHandler func(Connection)
type Reusable interface {
Reusable() bool
SetReusable(reuse bool)
}
type StreamConnectionType int
const (
StreamConnectionTypeRawTCP StreamConnectionType = 1
StreamConnectionTypeTCP StreamConnectionType = 2
StreamConnectionTypeKCP StreamConnectionType = 4
)
type StreamSecurityType int
const (
StreamSecurityTypeNone StreamSecurityType = 0
StreamSecurityTypeTLS StreamSecurityType = 1
)
type TLSSettings struct {
Certs []tls.Certificate
}
func (this *TLSSettings) GetTLSConfig() *tls.Config {
config := &tls.Config{
InsecureSkipVerify: true,
}
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)
}