Chore: unified naming "skip-cert-verify"
This commit is contained in:
parent
d2174149c1
commit
ce7cb138d4
3 changed files with 54 additions and 49 deletions
|
@ -28,18 +28,18 @@ func (ss *Socks5Adapter) Conn() net.Conn {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Socks5 struct {
|
type Socks5 struct {
|
||||||
addr string
|
addr string
|
||||||
name string
|
name string
|
||||||
tls bool
|
tls bool
|
||||||
sni bool
|
skipCertVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Socks5Option struct {
|
type Socks5Option struct {
|
||||||
Name string `proxy:"name"`
|
Name string `proxy:"name"`
|
||||||
Server string `proxy:"server"`
|
Server string `proxy:"server"`
|
||||||
Port int `proxy:"port"`
|
Port int `proxy:"port"`
|
||||||
TLS bool `proxy:"tls"`
|
TLS bool `proxy:"tls,omitempty"`
|
||||||
SNI bool `proxy:"sni"`
|
SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *Socks5) Name() string {
|
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 {
|
if err == nil && ss.tls {
|
||||||
tlsConfig := tls.Config{
|
tlsConfig := tls.Config{
|
||||||
InsecureSkipVerify: ss.sni,
|
InsecureSkipVerify: ss.skipCertVerify,
|
||||||
MaxVersion: tls.VersionTLS12,
|
MaxVersion: tls.VersionTLS12,
|
||||||
}
|
}
|
||||||
c = tls.Client(c, &tlsConfig)
|
c = tls.Client(c, &tlsConfig)
|
||||||
|
@ -104,9 +104,9 @@ func (ss *Socks5) shakeHand(metadata *C.Metadata, rw io.ReadWriter) error {
|
||||||
|
|
||||||
func NewSocks5(option Socks5Option) *Socks5 {
|
func NewSocks5(option Socks5Option) *Socks5 {
|
||||||
return &Socks5{
|
return &Socks5{
|
||||||
addr: fmt.Sprintf("%s:%d", option.Server, option.Port),
|
addr: fmt.Sprintf("%s:%d", option.Server, option.Port),
|
||||||
name: option.Name,
|
name: option.Name,
|
||||||
tls: option.TLS,
|
tls: option.TLS,
|
||||||
sni: option.SNI,
|
skipCertVerify: option.SkipCertVerify,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,15 +31,16 @@ type Vmess struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type VmessOption struct {
|
type VmessOption struct {
|
||||||
Name string `proxy:"name"`
|
Name string `proxy:"name"`
|
||||||
Server string `proxy:"server"`
|
Server string `proxy:"server"`
|
||||||
Port int `proxy:"port"`
|
Port int `proxy:"port"`
|
||||||
UUID string `proxy:"uuid"`
|
UUID string `proxy:"uuid"`
|
||||||
AlterID int `proxy:"alterId"`
|
AlterID int `proxy:"alterId"`
|
||||||
Cipher string `proxy:"cipher"`
|
Cipher string `proxy:"cipher"`
|
||||||
TLS bool `proxy:"tls,omitempty"`
|
TLS bool `proxy:"tls,omitempty"`
|
||||||
Network string `proxy:"network,omitempty"`
|
Network string `proxy:"network,omitempty"`
|
||||||
WSPath string `proxy:"ws-path,omitempty"`
|
WSPath string `proxy:"ws-path,omitempty"`
|
||||||
|
SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *Vmess) Name() string {
|
func (ss *Vmess) Name() string {
|
||||||
|
@ -63,13 +64,14 @@ func (ss *Vmess) Generator(metadata *C.Metadata) (adapter C.ProxyAdapter, err er
|
||||||
func NewVmess(option VmessOption) (*Vmess, error) {
|
func NewVmess(option VmessOption) (*Vmess, error) {
|
||||||
security := strings.ToLower(option.Cipher)
|
security := strings.ToLower(option.Cipher)
|
||||||
client, err := vmess.NewClient(vmess.Config{
|
client, err := vmess.NewClient(vmess.Config{
|
||||||
UUID: option.UUID,
|
UUID: option.UUID,
|
||||||
AlterID: uint16(option.AlterID),
|
AlterID: uint16(option.AlterID),
|
||||||
Security: security,
|
Security: security,
|
||||||
TLS: option.TLS,
|
TLS: option.TLS,
|
||||||
Host: fmt.Sprintf("%s:%d", option.Server, option.Port),
|
Host: fmt.Sprintf("%s:%d", option.Server, option.Port),
|
||||||
NetWork: option.Network,
|
NetWork: option.Network,
|
||||||
WebSocketPath: option.WSPath,
|
WebSocketPath: option.WSPath,
|
||||||
|
SkipCertVerify: option.SkipCertVerify,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -39,10 +39,6 @@ var CipherMapping = map[string]byte{
|
||||||
"chacha20-poly1305": SecurityCHACHA20POLY1305,
|
"chacha20-poly1305": SecurityCHACHA20POLY1305,
|
||||||
}
|
}
|
||||||
|
|
||||||
var tlsConfig = &tls.Config{
|
|
||||||
InsecureSkipVerify: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Command types
|
// Command types
|
||||||
const (
|
const (
|
||||||
CommandTCP byte = 1
|
CommandTCP byte = 1
|
||||||
|
@ -65,24 +61,26 @@ type DstAddr struct {
|
||||||
|
|
||||||
// Client is vmess connection generator
|
// Client is vmess connection generator
|
||||||
type Client struct {
|
type Client struct {
|
||||||
user []*ID
|
user []*ID
|
||||||
uuid *uuid.UUID
|
uuid *uuid.UUID
|
||||||
security Security
|
security Security
|
||||||
tls bool
|
tls bool
|
||||||
host string
|
host string
|
||||||
websocket bool
|
websocket bool
|
||||||
websocketPath string
|
websocketPath string
|
||||||
|
skipCertVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config of vmess
|
// Config of vmess
|
||||||
type Config struct {
|
type Config struct {
|
||||||
UUID string
|
UUID string
|
||||||
AlterID uint16
|
AlterID uint16
|
||||||
Security string
|
Security string
|
||||||
TLS bool
|
TLS bool
|
||||||
Host string
|
Host string
|
||||||
NetWork string
|
NetWork string
|
||||||
WebSocketPath string
|
WebSocketPath string
|
||||||
|
SkipCertVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// New return a Conn with net.Conn and DstAddr
|
// 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"
|
scheme := "ws"
|
||||||
if c.tls {
|
if c.tls {
|
||||||
scheme = "wss"
|
scheme = "wss"
|
||||||
|
dialer.TLSClientConfig = &tls.Config{
|
||||||
|
InsecureSkipVerify: c.skipCertVerify,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
host, port, err := net.SplitHostPort(c.host)
|
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())
|
conn = newWebsocketConn(wsConn, conn.RemoteAddr())
|
||||||
} else if c.tls {
|
} 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
|
return newConn(conn, c.user[r], dst, c.security), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue