Feature: vmess add websocket support

This commit is contained in:
Dreamacro
2018-10-28 23:46:32 +08:00
parent bcba14e05e
commit d2174149c1
5 changed files with 180 additions and 20 deletions

View File

@ -38,6 +38,8 @@ type VmessOption struct {
AlterID int `proxy:"alterId"`
Cipher string `proxy:"cipher"`
TLS bool `proxy:"tls,omitempty"`
Network string `proxy:"network,omitempty"`
WSPath string `proxy:"ws-path,omitempty"`
}
func (ss *Vmess) Name() string {
@ -54,17 +56,20 @@ func (ss *Vmess) Generator(metadata *C.Metadata) (adapter C.ProxyAdapter, err er
return nil, fmt.Errorf("%s connect error", ss.server)
}
tcpKeepAlive(c)
c = ss.client.New(c, parseVmessAddr(metadata))
c, err = ss.client.New(c, parseVmessAddr(metadata))
return &VmessAdapter{conn: c}, err
}
func NewVmess(option VmessOption) (*Vmess, error) {
security := strings.ToLower(option.Cipher)
client, err := vmess.NewClient(vmess.Config{
UUID: option.UUID,
AlterID: uint16(option.AlterID),
Security: security,
TLS: option.TLS,
UUID: option.UUID,
AlterID: uint16(option.AlterID),
Security: security,
TLS: option.TLS,
Host: fmt.Sprintf("%s:%d", option.Server, option.Port),
NetWork: option.Network,
WebSocketPath: option.WSPath,
})
if err != nil {
return nil, err