1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 09:56:18 -05:00
v2fly/transport/internet/connection.go

63 lines
1.1 KiB
Go
Raw Normal View History

2016-06-14 16:54:08 -04:00
package internet
import (
2016-07-10 09:27:58 -04:00
"crypto/tls"
2016-06-14 16:54:08 -04:00
"net"
)
type ConnectionHandler func(Connection)
type Reusable interface {
Reusable() bool
SetReusable(reuse bool)
}
type StreamConnectionType int
2016-07-10 09:27:58 -04:00
const (
2016-06-14 16:54:08 -04:00
StreamConnectionTypeRawTCP StreamConnectionType = 1
StreamConnectionTypeTCP StreamConnectionType = 2
StreamConnectionTypeKCP StreamConnectionType = 4
)
2016-07-10 09:27:58 -04:00
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
}
2016-06-14 16:54:08 -04:00
type StreamSettings struct {
2016-07-10 09:27:58 -04:00
Type StreamConnectionType
Security StreamSecurityType
TLSSettings *TLSSettings
2016-06-14 16:54:08 -04:00
}
func (this *StreamSettings) IsCapableOf(streamType StreamConnectionType) bool {
return (this.Type & streamType) == streamType
}
type Connection interface {
net.Conn
Reusable
}
2016-06-29 18:08:20 -04:00
type SysFd interface {
SysFd() (int, error)
}