Chore: unified naming "skip-cert-verify"

This commit is contained in:
gVisor bot 2018-10-29 20:16:43 +08:00
parent 06ff2c8ff9
commit 54f279c959
3 changed files with 54 additions and 49 deletions

View file

@ -31,15 +31,15 @@ type Socks5 struct {
addr string
name string
tls bool
sni bool
skipCertVerify bool
}
type Socks5Option struct {
Name string `proxy:"name"`
Server string `proxy:"server"`
Port int `proxy:"port"`
TLS bool `proxy:"tls"`
SNI bool `proxy:"sni"`
TLS bool `proxy:"tls,omitempty"`
SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"`
}
func (ss *Socks5) Name() string {
@ -55,7 +55,7 @@ func (ss *Socks5) Generator(metadata *C.Metadata) (adapter C.ProxyAdapter, err e
if err == nil && ss.tls {
tlsConfig := tls.Config{
InsecureSkipVerify: ss.sni,
InsecureSkipVerify: ss.skipCertVerify,
MaxVersion: tls.VersionTLS12,
}
c = tls.Client(c, &tlsConfig)
@ -107,6 +107,6 @@ func NewSocks5(option Socks5Option) *Socks5 {
addr: fmt.Sprintf("%s:%d", option.Server, option.Port),
name: option.Name,
tls: option.TLS,
sni: option.SNI,
skipCertVerify: option.SkipCertVerify,
}
}

View file

@ -40,6 +40,7 @@ type VmessOption struct {
TLS bool `proxy:"tls,omitempty"`
Network string `proxy:"network,omitempty"`
WSPath string `proxy:"ws-path,omitempty"`
SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"`
}
func (ss *Vmess) Name() string {
@ -70,6 +71,7 @@ func NewVmess(option VmessOption) (*Vmess, error) {
Host: fmt.Sprintf("%s:%d", option.Server, option.Port),
NetWork: option.Network,
WebSocketPath: option.WSPath,
SkipCertVerify: option.SkipCertVerify,
})
if err != nil {
return nil, err

View file

@ -39,10 +39,6 @@ var CipherMapping = map[string]byte{
"chacha20-poly1305": SecurityCHACHA20POLY1305,
}
var tlsConfig = &tls.Config{
InsecureSkipVerify: true,
}
// Command types
const (
CommandTCP byte = 1
@ -72,6 +68,7 @@ type Client struct {
host string
websocket bool
websocketPath string
skipCertVerify bool
}
// Config of vmess
@ -83,6 +80,7 @@ type Config struct {
Host string
NetWork string
WebSocketPath string
SkipCertVerify bool
}
// New return a Conn with net.Conn and DstAddr
@ -100,6 +98,9 @@ func (c *Client) New(conn net.Conn, dst *DstAddr) (net.Conn, error) {
scheme := "ws"
if c.tls {
scheme = "wss"
dialer.TLSClientConfig = &tls.Config{
InsecureSkipVerify: c.skipCertVerify,
}
}
host, port, err := net.SplitHostPort(c.host)
@ -125,7 +126,9 @@ func (c *Client) New(conn net.Conn, dst *DstAddr) (net.Conn, error) {
conn = newWebsocketConn(wsConn, conn.RemoteAddr())
} else if c.tls {
conn = tls.Client(conn, tlsConfig)
conn = tls.Client(conn, &tls.Config{
InsecureSkipVerify: c.skipCertVerify,
})
}
return newConn(conn, c.user[r], dst, c.security), nil
}