mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-18 09:02:45 +03:00
Add MTProxy, MASQUE, VPN, Link parser. Update AmneziaWG. Remove Tunneling
This commit is contained in:
49
parser/clash/vless.go
Normal file
49
parser/clash/vless.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package clash
|
||||
|
||||
import "github.com/sagernet/sing-box/option"
|
||||
|
||||
type VlessOption struct {
|
||||
DialerOptions `yaml:",inline"`
|
||||
ServerOptions `yaml:",inline"`
|
||||
*TLSOptions `yaml:",inline"`
|
||||
UUID string `yaml:"uuid"`
|
||||
Flow string `yaml:"flow,omitempty"`
|
||||
UDP bool `yaml:"udp,omitempty"`
|
||||
PacketAddr bool `yaml:"packet-addr,omitempty"`
|
||||
XUDP bool `yaml:"xudp,omitempty"`
|
||||
PacketEncoding string `yaml:"packet-encoding,omitempty"`
|
||||
Network string `yaml:"network,omitempty"`
|
||||
ServerName string `yaml:"servername,omitempty"`
|
||||
HTTPOpts HTTPOptions `yaml:"http-opts,omitempty"`
|
||||
HTTP2Opts HTTP2Options `yaml:"h2-opts,omitempty"`
|
||||
GrpcOpts GrpcOptions `yaml:"grpc-opts,omitempty"`
|
||||
WSOpts WSOptions `yaml:"ws-opts,omitempty"`
|
||||
MuxOpts *MuxOptions `yaml:"smux,omitempty"`
|
||||
}
|
||||
|
||||
func (v *VlessOption) Build() any {
|
||||
if v.TLSOptions != nil {
|
||||
v.SNI = v.ServerName
|
||||
}
|
||||
switch v.PacketEncoding {
|
||||
case "":
|
||||
if v.PacketAddr {
|
||||
v.PacketEncoding = "packetaddr"
|
||||
} else {
|
||||
v.PacketEncoding = "xudp"
|
||||
}
|
||||
case "packet":
|
||||
v.PacketEncoding = "packetaddr"
|
||||
}
|
||||
return &option.VLESSOutboundOptions{
|
||||
DialerOptions: v.DialerOptions.Build(),
|
||||
ServerOptions: v.ServerOptions.Build(),
|
||||
UUID: v.UUID,
|
||||
Flow: v.Flow,
|
||||
Network: clashNetworks(v.UDP),
|
||||
OutboundTLSOptionsContainer: clashTLSOptions(v.Server, v.TLSOptions),
|
||||
Multiplex: v.MuxOpts.Build(),
|
||||
Transport: clashTransport(v.Network, v.HTTPOpts, v.HTTP2Opts, v.GrpcOpts, v.WSOpts),
|
||||
PacketEncoding: &v.PacketEncoding,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user