Debian Codegraph @

proxy/vmess/outbound/outbound.go

raw symbols SCIP
1 // +build !confonly
2
3 package outboundscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/
4
5 //go:generate go run v2ray.com/core/common/errors/errorgen
6
7 import (
8 "contextscip-go gomod github.com/golang/go/src go1.15 context/"
9 "timescip-go gomod github.com/golang/go/src go1.15 time/"
10
11 "v2ray.com/corescip-go gomod v2ray.com/core . `v2ray.com/core`/"
12 "v2ray.com/core/commonscip-go gomod v2ray.com/core . `v2ray.com/core/common`/"
13 "v2ray.com/core/common/bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/"
14 "v2ray.com/core/common/netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/"
15 "v2ray.com/core/common/platformscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/"
16 "v2ray.com/core/common/protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/"
17 "v2ray.com/core/common/retryscip-go gomod v2ray.com/core . `v2ray.com/core/common/retry`/"
18 "v2ray.com/core/common/sessionscip-go gomod v2ray.com/core . `v2ray.com/core/common/session`/"
19 "v2ray.com/core/common/signalscip-go gomod v2ray.com/core . `v2ray.com/core/common/signal`/"
20 "v2ray.com/core/common/taskscip-go gomod v2ray.com/core . `v2ray.com/core/common/task`/"
21 "v2ray.com/core/features/policyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/"
22 "v2ray.com/core/proxy/vmessscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess`/"
23 "v2ray.com/core/proxy/vmess/encodingscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/"
24 "v2ray.com/core/transportscip-go gomod v2ray.com/core . `v2ray.com/core/transport`/"
25 "v2ray.com/core/transport/internetscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/"
26 )
27
28 // Handler is an outbound connection handler for VMess protocol.
29 type Handlerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler# struct {
30 serverListscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#serverList. *protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.ServerListscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerList#
31 serverPickerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#serverPicker. protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.ServerPickerscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerPicker#
32 policyManagerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#policyManager. policyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/.Managerscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Manager#
33 }
34
35 // New creates a new VMess outbound handler.
36 func Newscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/New().(ctx contextscip-go gomod github.com/golang/go/src go1.15 context/.Contextscip-go gomod github.com/golang/go/src go1.15 context/Context#, config *Configscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Config#) (*Handlerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#, error) {
37 serverList := protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.NewServerListscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/NewServerList().()
38 for _, rec := range config.Receiverscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Config#Receiver. {
39 s, err := protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.NewServerSpecFromPBscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/NewServerSpecFromPB().(rec)
40 if err != nil {
41 return nil, newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/newError().("failed to parse server spec").Basescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#Base().(err)
42 }
43 serverList.AddServerscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerList#AddServer().(s)
44 }
45
46 v := corescip-go gomod v2ray.com/core . `v2ray.com/core`/.MustFromContextscip-go gomod v2ray.com/core . `v2ray.com/core`/MustFromContext().(ctx)
47 handler := &Handlerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#{
48 serverListscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#serverList.: serverList,
49 serverPickerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#serverPicker.: protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.NewRoundRobinServerPickerscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/NewRoundRobinServerPicker().(serverList),
50 policyManagerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#policyManager.: v.GetFeaturescip-go gomod v2ray.com/core . `v2ray.com/core`/Instance#GetFeature().(policyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/.ManagerTypescip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/ManagerType().()).(policyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/.Managerscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Manager#),
51 }
52
53 return handler, nil
54 }
55
56 // Process implements proxy.Outbound.Process().
57 func (h *Handlerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#) Processscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#Process().(ctx contextscip-go gomod github.com/golang/go/src go1.15 context/.Contextscip-go gomod github.com/golang/go/src go1.15 context/Context#, link *transportscip-go gomod v2ray.com/core . `v2ray.com/core/transport`/.Linkscip-go gomod v2ray.com/core . `v2ray.com/core/transport`/Link#, dialer internetscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/.Dialerscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/Dialer#) error {
58 var rec *protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.ServerSpecscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerSpec#
59 var conn internetscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/.Connectionscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/Connection#
60
61 err := retryscip-go gomod v2ray.com/core . `v2ray.com/core/common/retry`/.ExponentialBackoffscip-go gomod v2ray.com/core . `v2ray.com/core/common/retry`/ExponentialBackoff().(5, 200).Onscip-go gomod v2ray.com/core . `v2ray.com/core/common/retry`/Strategy#On.(func() error {
62 rec = h.serverPickerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#serverPicker..PickServerscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerPicker#PickServer.()
63 rawConn, err := dialer.Dialscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/Dialer#Dial.(ctx, rec.Destinationscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerSpec#Destination().())
64 if err != nil {
65 return err
66 }
67 conn = rawConn
68
69 return nil
70 })
71 if err != nil {
72 return newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/newError().("failed to find an available destination").Basescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#Base().(err).AtWarningscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#AtWarning().()
73 }
74 defer conn.Closescip-go gomod github.com/golang/go/src go1.15 net/Conn#Close().()
75
76 outbound := sessionscip-go gomod v2ray.com/core . `v2ray.com/core/common/session`/.OutboundFromContextscip-go gomod v2ray.com/core . `v2ray.com/core/common/session`/OutboundFromContext().(ctx)
77 if outbound == nil || !outbound.Targetscip-go gomod v2ray.com/core . `v2ray.com/core/common/session`/Outbound#Target..IsValidscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Destination#IsValid().() {
78 return newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/newError().("target not specified").AtErrorscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#AtError().()
79 }
80
81 target := outbound.Targetscip-go gomod v2ray.com/core . `v2ray.com/core/common/session`/Outbound#Target.
82 newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/newError().("tunneling request to ", target, " via ", rec.Destinationscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerSpec#Destination().()).WriteToLogscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#WriteToLog().(sessionscip-go gomod v2ray.com/core . `v2ray.com/core/common/session`/.ExportIDToErrorscip-go gomod v2ray.com/core . `v2ray.com/core/common/session`/ExportIDToError().(ctx))
83
84 command := protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestCommandTCPscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestCommandTCP.
85 if target.Networkscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Destination#Network. == netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.Network_UDPscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Network_UDP. {
86 command = protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestCommandUDPscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestCommandUDP.
87 }
88 if target.Addressscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Destination#Address..Familyscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Address#Family.().IsDomainscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/AddressFamily#IsDomain().() && target.Addressscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Destination#Address..Domainscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Address#Domain.() == "v1.mux.cool" {
89 command = protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestCommandMuxscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestCommandMux.
90 }
91
92 user := rec.PickUserscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerSpec#PickUser().()
93 request := &protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestHeaderscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#{
94 Versionscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Version.: encodingscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/.Versionscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/Version.,
95 Userscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#User.: user,
96 Commandscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Command.: command,
97 Addressscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Address.: target.Addressscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Destination#Address.,
98 Portscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Port.: target.Portscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Destination#Port.,
99 Optionscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Option.: protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestOptionChunkStreamscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestOptionChunkStream.,
100 }
101
102 account := request.Userscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#User..Accountscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/MemoryUser#Account..(*vmessscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess`/.MemoryAccountscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess`/MemoryAccount#)
103 request.Securityscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Security. = account.Securityscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess`/MemoryAccount#Security.
104
105 if request.Securityscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Security. == protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.SecurityType_AES128_GCMscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/SecurityType_AES128_GCM. || request.Securityscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Security. == protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.SecurityType_NONEscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/SecurityType_NONE. || request.Securityscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Security. == protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.SecurityType_CHACHA20_POLY1305scip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/SecurityType_CHACHA20_POLY1305. {
106 request.Optionscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Option..Setscip-go gomod v2ray.com/core . `v2ray.com/core/common/bitmask`/Byte#Set().(protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestOptionChunkMaskingscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestOptionChunkMasking.)
107 }
108
109 if shouldEnablePaddingscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/shouldEnablePadding().(request.Securityscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Security.) && request.Optionscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Option..Hasscip-go gomod v2ray.com/core . `v2ray.com/core/common/bitmask`/Byte#Has().(protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestOptionChunkMaskingscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestOptionChunkMasking.) {
110 request.Optionscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Option..Setscip-go gomod v2ray.com/core . `v2ray.com/core/common/bitmask`/Byte#Set().(protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestOptionGlobalPaddingscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestOptionGlobalPadding.)
111 }
112
113 input := link.Readerscip-go gomod v2ray.com/core . `v2ray.com/core/transport`/Link#Reader.
114 output := link.Writerscip-go gomod v2ray.com/core . `v2ray.com/core/transport`/Link#Writer.
115
116 isAEAD := false
117 if !aeadDisabledscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/aeadDisabled. && len(account.AlterIDsscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess`/MemoryAccount#AlterIDs.) == 0 {
118 isAEAD = true
119 }
120
121 session := encodingscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/.NewClientSessionscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/NewClientSession().(ctx, isAEAD, protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.DefaultIDHashscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/DefaultIDHash().)
122 sessionPolicy := h.policyManagerscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#policyManager..ForLevelscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Manager#ForLevel.(request.Userscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#User..Levelscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/MemoryUser#Level.)
123
124 ctx, cancel := contextscip-go gomod github.com/golang/go/src go1.15 context/.WithCancelscip-go gomod github.com/golang/go/src go1.15 context/WithCancel().(ctx)
125 timer := signalscip-go gomod v2ray.com/core . `v2ray.com/core/common/signal`/.CancelAfterInactivityscip-go gomod v2ray.com/core . `v2ray.com/core/common/signal`/CancelAfterInactivity().(ctx, cancel, sessionPolicy.Timeoutsscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Session#Timeouts..ConnectionIdlescip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Timeout#ConnectionIdle.)
126
127 requestDone := func() error {
128 defer timer.SetTimeoutscip-go gomod v2ray.com/core . `v2ray.com/core/common/signal`/ActivityTimer#SetTimeout().(sessionPolicy.Timeoutsscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Session#Timeouts..DownlinkOnlyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Timeout#DownlinkOnly.)
129
130 writer := bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.NewBufferedWriterscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/NewBufferedWriter().(bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.NewWriterscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/NewWriter().(conn))
131 if err := session.EncodeRequestHeaderscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/ClientSession#EncodeRequestHeader().(request, writer); err != nil {
132 return newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/newError().("failed to encode request").Basescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#Base().(err).AtWarningscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#AtWarning().()
133 }
134
135 bodyWriter := session.EncodeRequestBodyscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/ClientSession#EncodeRequestBody().(request, writer)
136 if err := bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.CopyOnceTimeoutscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/CopyOnceTimeout().(input, bodyWriter, timescip-go gomod github.com/golang/go/src go1.15 time/.Millisecondscip-go gomod github.com/golang/go/src go1.15 time/Millisecond.*100); err != nil && err != bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.ErrNotTimeoutReaderscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/ErrNotTimeoutReader. && err != bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.ErrReadTimeoutscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/ErrReadTimeout. {
137 return newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/newError().("failed to write first payload").Basescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#Base().(err)
138 }
139
140 if err := writer.SetBufferedscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/BufferedWriter#SetBuffered().(false); err != nil {
141 return err
142 }
143
144 if err := bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.Copyscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/Copy().(input, bodyWriter, bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.UpdateActivityscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/UpdateActivity().(timer)); err != nil {
145 return err
146 }
147
148 if request.Optionscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestHeader#Option..Hasscip-go gomod v2ray.com/core . `v2ray.com/core/common/bitmask`/Byte#Has().(protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.RequestOptionChunkStreamscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/RequestOptionChunkStream.) {
149 if err := bodyWriter.WriteMultiBufferscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/Writer#WriteMultiBuffer.(bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.MultiBufferscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/MultiBuffer#{}); err != nil {
150 return err
151 }
152 }
153
154 return nil
155 }
156
157 responseDone := func() error {
158 defer timer.SetTimeoutscip-go gomod v2ray.com/core . `v2ray.com/core/common/signal`/ActivityTimer#SetTimeout().(sessionPolicy.Timeoutsscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Session#Timeouts..UplinkOnlyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Timeout#UplinkOnly.)
159
160 reader := &bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.BufferedReaderscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/BufferedReader#{Readerscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/BufferedReader#Reader.: bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.NewReaderscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/NewReader().(conn)}
161 header, err := session.DecodeResponseHeaderscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/ClientSession#DecodeResponseHeader().(reader)
162 if err != nil {
163 return newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/newError().("failed to read header").Basescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#Base().(err)
164 }
165 h.handleCommandscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Handler#handleCommand().(rec.Destinationscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ServerSpec#Destination().(), header.Commandscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/ResponseHeader#Command.)
166
167 bodyReader := session.DecodeResponseBodyscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/encoding`/ClientSession#DecodeResponseBody().(request, reader)
168
169 return bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.Copyscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/Copy().(bodyReader, output, bufscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/.UpdateActivityscip-go gomod v2ray.com/core . `v2ray.com/core/common/buf`/UpdateActivity().(timer))
170 }
171
172 var responseDonePost = taskscip-go gomod v2ray.com/core . `v2ray.com/core/common/task`/.OnSuccessscip-go gomod v2ray.com/core . `v2ray.com/core/common/task`/OnSuccess().(responseDone, taskscip-go gomod v2ray.com/core . `v2ray.com/core/common/task`/.Closescip-go gomod v2ray.com/core . `v2ray.com/core/common/task`/Close().(output))
173 if err := taskscip-go gomod v2ray.com/core . `v2ray.com/core/common/task`/.Runscip-go gomod v2ray.com/core . `v2ray.com/core/common/task`/Run().(ctx, requestDone, responseDonePost); err != nil {
174 return newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/newError().("connection ends").Basescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#Base().(err)
175 }
176
177 return nil
178 }
179
180 var (
181 enablePaddingscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/enablePadding. = false
182 aeadDisabledscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/aeadDisabled. = false
183 )
184
185 func shouldEnablePaddingscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/shouldEnablePadding().(s protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.SecurityTypescip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/SecurityType#) bool {
186 return enablePaddingscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/enablePadding. || s == protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.SecurityType_AES128_GCMscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/SecurityType_AES128_GCM. || s == protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.SecurityType_CHACHA20_POLY1305scip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/SecurityType_CHACHA20_POLY1305. || s == protocolscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/.SecurityType_AUTOscip-go gomod v2ray.com/core . `v2ray.com/core/common/protocol`/SecurityType_AUTO.
187 }
188
189 func initscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/init().() {
190 commonscip-go gomod v2ray.com/core . `v2ray.com/core/common`/.Mustscip-go gomod v2ray.com/core . `v2ray.com/core/common`/Must().(commonscip-go gomod v2ray.com/core . `v2ray.com/core/common`/.RegisterConfigscip-go gomod v2ray.com/core . `v2ray.com/core/common`/RegisterConfig().((*Configscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Config#)(nil), func(ctx contextscip-go gomod github.com/golang/go/src go1.15 context/.Contextscip-go gomod github.com/golang/go/src go1.15 context/Context#, config interface{}) (interface{}, error) {
191 return Newscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/New().(ctx, config.(*Configscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/Config#))
192 }))
193
194 const defaultFlagValue = "NOT_DEFINED_AT_ALL"
195
196 paddingValue := platformscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/.NewEnvFlagscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/NewEnvFlag().("v2ray.vmess.padding").GetValuescip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/EnvFlag#GetValue().(func() string { return defaultFlagValue })
197 if paddingValue != defaultFlagValue {
198 enablePaddingscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/enablePadding. = true
199 }
200
201 isAeadDisabled := platformscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/.NewEnvFlagscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/NewEnvFlag().("v2ray.vmess.aead.disabled").GetValuescip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/EnvFlag#GetValue().(func() string { return defaultFlagValue })
202 if isAeadDisabled == "true" {
203 aeadDisabledscip-go gomod v2ray.com/core . `v2ray.com/core/proxy/vmess/outbound`/aeadDisabled. = true
204 }
205 }