mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-04-08 23:06:01 -04:00
integrate tls settings in ws
This commit is contained in:
@@ -3,6 +3,7 @@ package tcp
|
||||
import (
|
||||
"net"
|
||||
|
||||
"crypto/tls"
|
||||
"v2ray.com/core/common/log"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/transport/internet"
|
||||
@@ -12,7 +13,7 @@ var (
|
||||
globalCache = NewConnectionCache()
|
||||
)
|
||||
|
||||
func Dial(src v2net.Address, dest v2net.Destination) (internet.Connection, error) {
|
||||
func Dial(src v2net.Address, dest v2net.Destination, options internet.DialerOptions) (internet.Connection, error) {
|
||||
log.Info("Dailing TCP to ", dest)
|
||||
if src == nil {
|
||||
src = v2net.AnyIP
|
||||
@@ -29,15 +30,23 @@ func Dial(src v2net.Address, dest v2net.Destination) (internet.Connection, error
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if options.Stream != nil && options.Stream.Security == internet.StreamSecurityTypeTLS {
|
||||
config := options.Stream.TLSSettings.GetTLSConfig()
|
||||
if dest.Address.Family().IsDomain() {
|
||||
config.ServerName = dest.Address.Domain()
|
||||
}
|
||||
conn = tls.Client(conn, config)
|
||||
}
|
||||
return NewConnection(id, conn, globalCache), nil
|
||||
}
|
||||
|
||||
func DialRaw(src v2net.Address, dest v2net.Destination) (internet.Connection, error) {
|
||||
func DialRaw(src v2net.Address, dest v2net.Destination, options internet.DialerOptions) (internet.Connection, error) {
|
||||
log.Info("Dailing Raw TCP to ", dest)
|
||||
conn, err := internet.DialToDest(src, dest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TODO: handle dialer options
|
||||
return &RawConnection{
|
||||
TCPConn: *conn.(*net.TCPConn),
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user