Skip to content

Commit

Permalink
feat: Support VMess-Websocket (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bpazy authored Oct 20, 2022
1 parent 2e670ab commit 63afa9e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
30 changes: 22 additions & 8 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,11 @@ func getOutBounds(links []*Link) []*xray.OutBound {
var outbounds []*xray.OutBound
for i, link := range links {
outbounds = append(outbounds, &xray.OutBound{
Tag: "outbound" + strconv.Itoa(i), // 应该测速后选择最合适的设置 tag 为 proxy
Protocol: getOutboundProtocol(link),
Comment: getOutboundComment(link),
Settings: getOutboundSettings(link),
StreamSettings: &xray.StreamSettings{
Network: "tcp",
Security: getOutboundStreamSettingsSecurity(link),
},
Tag: "outbound" + strconv.Itoa(i), // 应该测速后选择最合适的设置 tag 为 proxy
Protocol: getOutboundProtocol(link),
Comment: getOutboundComment(link),
Settings: getOutboundSettings(link),
StreamSettings: getOutboundStreamSettings(link),
Mux: &xray.Mux{
Enabled: false,
Concurrency: -1,
Expand All @@ -436,6 +433,23 @@ func getOutBounds(links []*Link) []*xray.OutBound {
return outbounds
}

func getOutboundStreamSettings(link *Link) *xray.StreamSettings {
if link.SsCfg != nil || link.TrojanCfg != nil {
return &xray.StreamSettings{
Network: "tcp",
Security: getOutboundStreamSettingsSecurity(link),
}
}
if link.VmessCfg != nil {
return &xray.StreamSettings{
Network: link.VmessCfg.Net,
WsSettings: nil,
}
}
// TODO error handle
panic(fmt.Sprintf("Not supported protocol: %+v", link))
}

func getOutboundStreamSettingsSecurity(link *Link) string {
if link.SsCfg != nil {
return ""
Expand Down
5 changes: 3 additions & 2 deletions xray/vmess.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ type AddressPort interface {
}

type StreamSettings struct {
Network string `json:"network"`
Security string `json:"security"`
Network string `json:"network"`
Security string `json:"security"`
WsSettings interface{} `json:"wsSettings"`
}

type Mux struct {
Expand Down

0 comments on commit 63afa9e

Please sign in to comment.