feat: Support insecure gRPC

This commit is contained in:
gVisor bot 2023-05-13 09:38:14 +08:00
parent fe51e95d88
commit 90bf28cb89
3 changed files with 29 additions and 25 deletions

View File

@ -596,15 +596,19 @@ func NewVless(option VlessOption) (*Vless, error) {
Host: v.option.ServerName, Host: v.option.ServerName,
ClientFingerprint: v.option.ClientFingerprint, ClientFingerprint: v.option.ClientFingerprint,
} }
tlsConfig := tlsC.GetGlobalTLSConfig(&tls.Config{ if option.ServerName == "" {
InsecureSkipVerify: v.option.SkipCertVerify, gunConfig.Host = v.addr
ServerName: v.option.ServerName, }
}) var tlsConfig *tls.Config
if option.TLS {
if v.option.ServerName == "" { tlsConfig = tlsC.GetGlobalTLSConfig(&tls.Config{
host, _, _ := net.SplitHostPort(v.addr) InsecureSkipVerify: v.option.SkipCertVerify,
tlsConfig.ServerName = host ServerName: v.option.ServerName,
gunConfig.Host = host })
if option.ServerName == "" {
host, _, _ := net.SplitHostPort(v.addr)
tlsConfig.ServerName = host
}
} }
v.gunTLSConfig = tlsConfig v.gunTLSConfig = tlsConfig

View File

@ -413,13 +413,6 @@ func NewVmess(option VmessOption) (*Vmess, error) {
option.PacketAddr = false option.PacketAddr = false
} }
switch option.Network {
case "h2", "grpc":
if !option.TLS {
option.TLS = true
}
}
v := &Vmess{ v := &Vmess{
Base: &Base{ Base: &Base{
name: option.Name, name: option.Name,
@ -464,15 +457,19 @@ func NewVmess(option VmessOption) (*Vmess, error) {
Host: v.option.ServerName, Host: v.option.ServerName,
ClientFingerprint: v.option.ClientFingerprint, ClientFingerprint: v.option.ClientFingerprint,
} }
tlsConfig := &tls.Config{ if option.ServerName == "" {
InsecureSkipVerify: v.option.SkipCertVerify, gunConfig.Host = v.addr
ServerName: v.option.ServerName,
} }
var tlsConfig *tls.Config
if v.option.ServerName == "" { if option.TLS {
host, _, _ := net.SplitHostPort(v.addr) tlsConfig = tlsC.GetGlobalTLSConfig(&tls.Config{
tlsConfig.ServerName = host InsecureSkipVerify: v.option.SkipCertVerify,
gunConfig.Host = host ServerName: v.option.ServerName,
})
if option.ServerName == "" {
host, _, _ := net.SplitHostPort(v.addr)
tlsConfig.ServerName = host
}
} }
v.gunTLSConfig = tlsConfig v.gunTLSConfig = tlsConfig

View File

@ -199,9 +199,12 @@ func NewHTTP2Client(dialFn DialFn, tlsConfig *tls.Config, Fingerprint string, re
if err != nil { if err != nil {
return nil, err return nil, err
} }
wrap.remoteAddr = pconn.RemoteAddr() wrap.remoteAddr = pconn.RemoteAddr()
if tlsConfig == nil {
return pconn, nil
}
if len(Fingerprint) != 0 { if len(Fingerprint) != 0 {
if realityConfig == nil { if realityConfig == nil {
if fingerprint, exists := tlsC.GetFingerprint(Fingerprint); exists { if fingerprint, exists := tlsC.GetFingerprint(Fingerprint); exists {