proxy.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. // Package proxy contains all proxies used by Xray.
  2. //
  3. // To implement an inbound or outbound proxy, one needs to do the following:
  4. // 1. Implement the interface(s) below.
  5. // 2. Register a config creator through common.RegisterConfig.
  6. package proxy
  7. import (
  8. "bytes"
  9. "context"
  10. "crypto/rand"
  11. "io"
  12. "math/big"
  13. "runtime"
  14. "strconv"
  15. "time"
  16. "github.com/pires/go-proxyproto"
  17. "github.com/xtls/xray-core/app/dispatcher"
  18. "github.com/xtls/xray-core/common/buf"
  19. "github.com/xtls/xray-core/common/errors"
  20. "github.com/xtls/xray-core/common/net"
  21. "github.com/xtls/xray-core/common/protocol"
  22. "github.com/xtls/xray-core/common/session"
  23. "github.com/xtls/xray-core/common/signal"
  24. "github.com/xtls/xray-core/features/routing"
  25. "github.com/xtls/xray-core/features/stats"
  26. "github.com/xtls/xray-core/transport"
  27. "github.com/xtls/xray-core/transport/internet"
  28. "github.com/xtls/xray-core/transport/internet/reality"
  29. "github.com/xtls/xray-core/transport/internet/stat"
  30. "github.com/xtls/xray-core/transport/internet/tls"
  31. )
  32. var (
  33. Tls13SupportedVersions = []byte{0x00, 0x2b, 0x00, 0x02, 0x03, 0x04}
  34. TlsClientHandShakeStart = []byte{0x16, 0x03}
  35. TlsServerHandShakeStart = []byte{0x16, 0x03, 0x03}
  36. TlsApplicationDataStart = []byte{0x17, 0x03, 0x03}
  37. Tls13CipherSuiteDic = map[uint16]string{
  38. 0x1301: "TLS_AES_128_GCM_SHA256",
  39. 0x1302: "TLS_AES_256_GCM_SHA384",
  40. 0x1303: "TLS_CHACHA20_POLY1305_SHA256",
  41. 0x1304: "TLS_AES_128_CCM_SHA256",
  42. 0x1305: "TLS_AES_128_CCM_8_SHA256",
  43. }
  44. )
  45. const (
  46. TlsHandshakeTypeClientHello byte = 0x01
  47. TlsHandshakeTypeServerHello byte = 0x02
  48. CommandPaddingContinue byte = 0x00
  49. CommandPaddingEnd byte = 0x01
  50. CommandPaddingDirect byte = 0x02
  51. )
  52. // An Inbound processes inbound connections.
  53. type Inbound interface {
  54. // Network returns a list of networks that this inbound supports. Connections with not-supported networks will not be passed into Process().
  55. Network() []net.Network
  56. // Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound.
  57. Process(context.Context, net.Network, stat.Connection, routing.Dispatcher) error
  58. }
  59. // An Outbound process outbound connections.
  60. type Outbound interface {
  61. // Process processes the given connection. The given dialer may be used to dial a system outbound connection.
  62. Process(context.Context, *transport.Link, internet.Dialer) error
  63. }
  64. // UserManager is the interface for Inbounds and Outbounds that can manage their users.
  65. type UserManager interface {
  66. // AddUser adds a new user.
  67. AddUser(context.Context, *protocol.MemoryUser) error
  68. // RemoveUser removes a user by email.
  69. RemoveUser(context.Context, string) error
  70. }
  71. type GetInbound interface {
  72. GetInbound() Inbound
  73. }
  74. type GetOutbound interface {
  75. GetOutbound() Outbound
  76. }
  77. // TrafficState is used to track uplink and downlink of one connection
  78. // It is used by XTLS to determine if switch to raw copy mode, It is used by Vision to calculate padding
  79. type TrafficState struct {
  80. UserUUID []byte
  81. NumberOfPacketToFilter int
  82. EnableXtls bool
  83. IsTLS12orAbove bool
  84. IsTLS bool
  85. Cipher uint16
  86. RemainingServerHello int32
  87. // reader link state
  88. WithinPaddingBuffers bool
  89. ReaderSwitchToDirectCopy bool
  90. RemainingCommand int32
  91. RemainingContent int32
  92. RemainingPadding int32
  93. CurrentCommand int
  94. // write link state
  95. IsPadding bool
  96. WriterSwitchToDirectCopy bool
  97. }
  98. func NewTrafficState(userUUID []byte) *TrafficState {
  99. return &TrafficState{
  100. UserUUID: userUUID,
  101. NumberOfPacketToFilter: 8,
  102. EnableXtls: false,
  103. IsTLS12orAbove: false,
  104. IsTLS: false,
  105. Cipher: 0,
  106. RemainingServerHello: -1,
  107. WithinPaddingBuffers: true,
  108. ReaderSwitchToDirectCopy: false,
  109. RemainingCommand: -1,
  110. RemainingContent: -1,
  111. RemainingPadding: -1,
  112. CurrentCommand: 0,
  113. IsPadding: true,
  114. WriterSwitchToDirectCopy: false,
  115. }
  116. }
  117. // VisionReader is used to read xtls vision protocol
  118. // Note Vision probably only make sense as the inner most layer of reader, since it need assess traffic state from origin proxy traffic
  119. type VisionReader struct {
  120. buf.Reader
  121. trafficState *TrafficState
  122. ctx context.Context
  123. }
  124. func NewVisionReader(reader buf.Reader, state *TrafficState, context context.Context) *VisionReader {
  125. return &VisionReader{
  126. Reader: reader,
  127. trafficState: state,
  128. ctx: context,
  129. }
  130. }
  131. func (w *VisionReader) ReadMultiBuffer() (buf.MultiBuffer, error) {
  132. buffer, err := w.Reader.ReadMultiBuffer()
  133. if !buffer.IsEmpty() {
  134. if w.trafficState.WithinPaddingBuffers || w.trafficState.NumberOfPacketToFilter > 0 {
  135. mb2 := make(buf.MultiBuffer, 0, len(buffer))
  136. for _, b := range buffer {
  137. newbuffer := XtlsUnpadding(b, w.trafficState, w.ctx)
  138. if newbuffer.Len() > 0 {
  139. mb2 = append(mb2, newbuffer)
  140. }
  141. }
  142. buffer = mb2
  143. if w.trafficState.RemainingContent > 0 || w.trafficState.RemainingPadding > 0 || w.trafficState.CurrentCommand == 0 {
  144. w.trafficState.WithinPaddingBuffers = true
  145. } else if w.trafficState.CurrentCommand == 1 {
  146. w.trafficState.WithinPaddingBuffers = false
  147. } else if w.trafficState.CurrentCommand == 2 {
  148. w.trafficState.WithinPaddingBuffers = false
  149. w.trafficState.ReaderSwitchToDirectCopy = true
  150. } else {
  151. newError("XtlsRead unknown command ", w.trafficState.CurrentCommand, buffer.Len()).WriteToLog(session.ExportIDToError(w.ctx))
  152. }
  153. }
  154. if w.trafficState.NumberOfPacketToFilter > 0 {
  155. XtlsFilterTls(buffer, w.trafficState, w.ctx)
  156. }
  157. }
  158. return buffer, err
  159. }
  160. // VisionWriter is used to write xtls vision protocol
  161. // Note Vision probably only make sense as the inner most layer of writer, since it need assess traffic state from origin proxy traffic
  162. type VisionWriter struct {
  163. buf.Writer
  164. trafficState *TrafficState
  165. ctx context.Context
  166. writeOnceUserUUID []byte
  167. }
  168. func NewVisionWriter(writer buf.Writer, state *TrafficState, context context.Context) *VisionWriter {
  169. w := make([]byte, len(state.UserUUID))
  170. copy(w, state.UserUUID)
  171. return &VisionWriter{
  172. Writer: writer,
  173. trafficState: state,
  174. ctx: context,
  175. writeOnceUserUUID: w,
  176. }
  177. }
  178. func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
  179. if w.trafficState.NumberOfPacketToFilter > 0 {
  180. XtlsFilterTls(mb, w.trafficState, w.ctx)
  181. }
  182. if w.trafficState.IsPadding {
  183. if len(mb) == 1 && mb[0] == nil {
  184. mb[0] = XtlsPadding(nil, CommandPaddingContinue, &w.writeOnceUserUUID, true, w.ctx) // we do a long padding to hide vless header
  185. return w.Writer.WriteMultiBuffer(mb)
  186. }
  187. mb = ReshapeMultiBuffer(w.ctx, mb)
  188. longPadding := w.trafficState.IsTLS
  189. for i, b := range mb {
  190. if w.trafficState.IsTLS && b.Len() >= 6 && bytes.Equal(TlsApplicationDataStart, b.BytesTo(3)) {
  191. if w.trafficState.EnableXtls {
  192. w.trafficState.WriterSwitchToDirectCopy = true
  193. }
  194. var command byte = CommandPaddingContinue
  195. if i == len(mb) - 1 {
  196. command = CommandPaddingEnd
  197. if w.trafficState.EnableXtls {
  198. command = CommandPaddingDirect
  199. }
  200. }
  201. mb[i] = XtlsPadding(b, command, &w.writeOnceUserUUID, true, w.ctx)
  202. w.trafficState.IsPadding = false // padding going to end
  203. longPadding = false
  204. continue
  205. } else if !w.trafficState.IsTLS12orAbove && w.trafficState.NumberOfPacketToFilter <= 1 { // For compatibility with earlier vision receiver, we finish padding 1 packet early
  206. w.trafficState.IsPadding = false
  207. mb[i] = XtlsPadding(b, CommandPaddingEnd, &w.writeOnceUserUUID, longPadding, w.ctx)
  208. break
  209. }
  210. var command byte = CommandPaddingContinue
  211. if i == len(mb) - 1 && !w.trafficState.IsPadding {
  212. command = CommandPaddingEnd
  213. if w.trafficState.EnableXtls {
  214. command = CommandPaddingDirect
  215. }
  216. }
  217. mb[i] = XtlsPadding(b, command, &w.writeOnceUserUUID, longPadding, w.ctx)
  218. }
  219. }
  220. return w.Writer.WriteMultiBuffer(mb)
  221. }
  222. // ReshapeMultiBuffer prepare multi buffer for padding stucture (max 21 bytes)
  223. func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBuffer {
  224. needReshape := 0
  225. for _, b := range buffer {
  226. if b.Len() >= buf.Size-21 {
  227. needReshape += 1
  228. }
  229. }
  230. if needReshape == 0 {
  231. return buffer
  232. }
  233. mb2 := make(buf.MultiBuffer, 0, len(buffer)+needReshape)
  234. toPrint := ""
  235. for i, buffer1 := range buffer {
  236. if buffer1.Len() >= buf.Size-21 {
  237. index := int32(bytes.LastIndex(buffer1.Bytes(), TlsApplicationDataStart))
  238. if index < 21 || index > buf.Size-21 {
  239. index = buf.Size / 2
  240. }
  241. buffer2 := buf.New()
  242. buffer2.Write(buffer1.BytesFrom(index))
  243. buffer1.Resize(0, index)
  244. mb2 = append(mb2, buffer1, buffer2)
  245. toPrint += " " + strconv.Itoa(int(buffer1.Len())) + " " + strconv.Itoa(int(buffer2.Len()))
  246. } else {
  247. mb2 = append(mb2, buffer1)
  248. toPrint += " " + strconv.Itoa(int(buffer1.Len()))
  249. }
  250. buffer[i] = nil
  251. }
  252. buffer = buffer[:0]
  253. newError("ReshapeMultiBuffer ", toPrint).WriteToLog(session.ExportIDToError(ctx))
  254. return mb2
  255. }
  256. // XtlsPadding add padding to eliminate length siganature during tls handshake
  257. func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool, ctx context.Context) *buf.Buffer {
  258. var contentLen int32 = 0
  259. var paddingLen int32 = 0
  260. if b != nil {
  261. contentLen = b.Len()
  262. }
  263. if contentLen < 900 && longPadding {
  264. l, err := rand.Int(rand.Reader, big.NewInt(500))
  265. if err != nil {
  266. newError("failed to generate padding").Base(err).WriteToLog(session.ExportIDToError(ctx))
  267. }
  268. paddingLen = int32(l.Int64()) + 900 - contentLen
  269. } else {
  270. l, err := rand.Int(rand.Reader, big.NewInt(256))
  271. if err != nil {
  272. newError("failed to generate padding").Base(err).WriteToLog(session.ExportIDToError(ctx))
  273. }
  274. paddingLen = int32(l.Int64())
  275. }
  276. if paddingLen > buf.Size-21-contentLen {
  277. paddingLen = buf.Size - 21 - contentLen
  278. }
  279. newbuffer := buf.New()
  280. if userUUID != nil {
  281. newbuffer.Write(*userUUID)
  282. *userUUID = nil
  283. }
  284. newbuffer.Write([]byte{command, byte(contentLen >> 8), byte(contentLen), byte(paddingLen >> 8), byte(paddingLen)})
  285. if b != nil {
  286. newbuffer.Write(b.Bytes())
  287. b.Release()
  288. b = nil
  289. }
  290. newbuffer.Extend(paddingLen)
  291. newError("XtlsPadding ", contentLen, " ", paddingLen, " ", command).WriteToLog(session.ExportIDToError(ctx))
  292. return newbuffer
  293. }
  294. // XtlsUnpadding remove padding and parse command
  295. func XtlsUnpadding(b *buf.Buffer, s *TrafficState, ctx context.Context) *buf.Buffer {
  296. if s.RemainingCommand == -1 && s.RemainingContent == -1 && s.RemainingPadding == -1 { // inital state
  297. if b.Len() >= 21 && bytes.Equal(s.UserUUID, b.BytesTo(16)) {
  298. b.Advance(16)
  299. s.RemainingCommand = 5
  300. } else {
  301. return b
  302. }
  303. }
  304. newbuffer := buf.New()
  305. for b.Len() > 0 {
  306. if s.RemainingCommand > 0 {
  307. data, err := b.ReadByte()
  308. if err != nil {
  309. return newbuffer
  310. }
  311. switch s.RemainingCommand {
  312. case 5:
  313. s.CurrentCommand = int(data)
  314. case 4:
  315. s.RemainingContent = int32(data)<<8
  316. case 3:
  317. s.RemainingContent = s.RemainingContent | int32(data)
  318. case 2:
  319. s.RemainingPadding = int32(data)<<8
  320. case 1:
  321. s.RemainingPadding = s.RemainingPadding | int32(data)
  322. newError("Xtls Unpadding new block, content ", s.RemainingContent, " padding ", s.RemainingPadding, " command ", s.CurrentCommand).WriteToLog(session.ExportIDToError(ctx))
  323. }
  324. s.RemainingCommand--
  325. } else if s.RemainingContent > 0 {
  326. len := s.RemainingContent
  327. if b.Len() < len {
  328. len = b.Len()
  329. }
  330. data, err := b.ReadBytes(len)
  331. if err != nil {
  332. return newbuffer
  333. }
  334. newbuffer.Write(data)
  335. s.RemainingContent -= len
  336. } else { // remainingPadding > 0
  337. len := s.RemainingPadding
  338. if b.Len() < len {
  339. len = b.Len()
  340. }
  341. b.Advance(len)
  342. s.RemainingPadding -= len
  343. }
  344. if s.RemainingCommand <= 0 && s.RemainingContent <= 0 && s.RemainingPadding <= 0 { // this block done
  345. if s.CurrentCommand == 0 {
  346. s.RemainingCommand = 5
  347. } else {
  348. s.RemainingCommand = -1 // set to initial state
  349. s.RemainingContent = -1
  350. s.RemainingPadding = -1
  351. if b.Len() > 0 { // shouldn't happen
  352. newbuffer.Write(b.Bytes())
  353. }
  354. break
  355. }
  356. }
  357. }
  358. b.Release()
  359. b = nil
  360. return newbuffer
  361. }
  362. // XtlsFilterTls filter and recognize tls 1.3 and other info
  363. func XtlsFilterTls(buffer buf.MultiBuffer, trafficState *TrafficState, ctx context.Context) {
  364. for _, b := range buffer {
  365. if b == nil {
  366. continue
  367. }
  368. trafficState.NumberOfPacketToFilter--
  369. if b.Len() >= 6 {
  370. startsBytes := b.BytesTo(6)
  371. if bytes.Equal(TlsServerHandShakeStart, startsBytes[:3]) && startsBytes[5] == TlsHandshakeTypeServerHello {
  372. trafficState.RemainingServerHello = (int32(startsBytes[3])<<8 | int32(startsBytes[4])) + 5
  373. trafficState.IsTLS12orAbove = true
  374. trafficState.IsTLS = true
  375. if b.Len() >= 79 && trafficState.RemainingServerHello >= 79 {
  376. sessionIdLen := int32(b.Byte(43))
  377. cipherSuite := b.BytesRange(43+sessionIdLen+1, 43+sessionIdLen+3)
  378. trafficState.Cipher = uint16(cipherSuite[0])<<8 | uint16(cipherSuite[1])
  379. } else {
  380. newError("XtlsFilterTls short server hello, tls 1.2 or older? ", b.Len(), " ", trafficState.RemainingServerHello).WriteToLog(session.ExportIDToError(ctx))
  381. }
  382. } else if bytes.Equal(TlsClientHandShakeStart, startsBytes[:2]) && startsBytes[5] == TlsHandshakeTypeClientHello {
  383. trafficState.IsTLS = true
  384. newError("XtlsFilterTls found tls client hello! ", buffer.Len()).WriteToLog(session.ExportIDToError(ctx))
  385. }
  386. }
  387. if trafficState.RemainingServerHello > 0 {
  388. end := trafficState.RemainingServerHello
  389. if end > b.Len() {
  390. end = b.Len()
  391. }
  392. trafficState.RemainingServerHello -= b.Len()
  393. if bytes.Contains(b.BytesTo(end), Tls13SupportedVersions) {
  394. v, ok := Tls13CipherSuiteDic[trafficState.Cipher]
  395. if !ok {
  396. v = "Old cipher: " + strconv.FormatUint(uint64(trafficState.Cipher), 16)
  397. } else if v != "TLS_AES_128_CCM_8_SHA256" {
  398. trafficState.EnableXtls = true
  399. }
  400. newError("XtlsFilterTls found tls 1.3! ", b.Len(), " ", v).WriteToLog(session.ExportIDToError(ctx))
  401. trafficState.NumberOfPacketToFilter = 0
  402. return
  403. } else if trafficState.RemainingServerHello <= 0 {
  404. newError("XtlsFilterTls found tls 1.2! ", b.Len()).WriteToLog(session.ExportIDToError(ctx))
  405. trafficState.NumberOfPacketToFilter = 0
  406. return
  407. }
  408. newError("XtlsFilterTls inconclusive server hello ", b.Len(), " ", trafficState.RemainingServerHello).WriteToLog(session.ExportIDToError(ctx))
  409. }
  410. if trafficState.NumberOfPacketToFilter <= 0 {
  411. newError("XtlsFilterTls stop filtering", buffer.Len()).WriteToLog(session.ExportIDToError(ctx))
  412. }
  413. }
  414. }
  415. // UnwrapRawConn support unwrap stats, tls, utls, reality and proxyproto conn and get raw tcp conn from it
  416. func UnwrapRawConn(conn net.Conn) (net.Conn, stats.Counter, stats.Counter) {
  417. var readCounter, writerCounter stats.Counter
  418. if conn != nil {
  419. statConn, ok := conn.(*stat.CounterConnection)
  420. if ok {
  421. conn = statConn.Connection
  422. readCounter = statConn.ReadCounter
  423. writerCounter = statConn.WriteCounter
  424. }
  425. if xc, ok := conn.(*tls.Conn); ok {
  426. conn = xc.NetConn()
  427. } else if utlsConn, ok := conn.(*tls.UConn); ok {
  428. conn = utlsConn.NetConn()
  429. } else if realityConn, ok := conn.(*reality.Conn); ok {
  430. conn = realityConn.NetConn()
  431. } else if realityUConn, ok := conn.(*reality.UConn); ok {
  432. conn = realityUConn.NetConn()
  433. }
  434. if pc, ok := conn.(*proxyproto.Conn); ok {
  435. conn = pc.Raw()
  436. // 8192 > 4096, there is no need to process pc's bufReader
  437. }
  438. }
  439. return conn, readCounter, writerCounter
  440. }
  441. // CopyRawConnIfExist use the most efficient copy method.
  442. // - If caller don't want to turn on splice, do not pass in both reader conn and writer conn
  443. // - writer are from *transport.Link
  444. func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net.Conn, writer buf.Writer, timer signal.ActivityUpdater) error {
  445. readerConn, readCounter, _ := UnwrapRawConn(readerConn)
  446. writerConn, _, writeCounter := UnwrapRawConn(writerConn)
  447. reader := buf.NewReader(readerConn)
  448. if runtime.GOOS != "linux" && runtime.GOOS != "android" {
  449. return readV(ctx, reader, writer, timer, readCounter)
  450. }
  451. tc, ok := writerConn.(*net.TCPConn)
  452. if !ok || readerConn == nil || writerConn == nil {
  453. return readV(ctx, reader, writer, timer, readCounter)
  454. }
  455. inbound := session.InboundFromContext(ctx)
  456. if inbound == nil || inbound.CanSpliceCopy == 3 {
  457. return readV(ctx, reader, writer, timer, readCounter)
  458. }
  459. outbounds := session.OutboundsFromContext(ctx)
  460. if len(outbounds) == 0 {
  461. return readV(ctx, reader, writer, timer, readCounter)
  462. }
  463. for _, ob := range outbounds {
  464. if ob.CanSpliceCopy == 3 {
  465. return readV(ctx, reader, writer, timer, readCounter)
  466. }
  467. }
  468. for {
  469. inbound := session.InboundFromContext(ctx)
  470. outbounds := session.OutboundsFromContext(ctx)
  471. var splice = inbound.CanSpliceCopy == 1
  472. for _, ob := range outbounds {
  473. if ob.CanSpliceCopy != 1 {
  474. splice = false
  475. }
  476. }
  477. if splice {
  478. newError("CopyRawConn splice").WriteToLog(session.ExportIDToError(ctx))
  479. statWriter, _ := writer.(*dispatcher.SizeStatWriter)
  480. //runtime.Gosched() // necessary
  481. time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice
  482. w, err := tc.ReadFrom(readerConn)
  483. if readCounter != nil {
  484. readCounter.Add(w) // outbound stats
  485. }
  486. if writeCounter != nil {
  487. writeCounter.Add(w) // inbound stats
  488. }
  489. if statWriter != nil {
  490. statWriter.Counter.Add(w) // user stats
  491. }
  492. if err != nil && errors.Cause(err) != io.EOF {
  493. return err
  494. }
  495. return nil
  496. }
  497. buffer, err := reader.ReadMultiBuffer()
  498. if !buffer.IsEmpty() {
  499. if readCounter != nil {
  500. readCounter.Add(int64(buffer.Len()))
  501. }
  502. timer.Update()
  503. if werr := writer.WriteMultiBuffer(buffer); werr != nil {
  504. return werr
  505. }
  506. }
  507. if err != nil {
  508. return err
  509. }
  510. }
  511. }
  512. func readV(ctx context.Context, reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, readCounter stats.Counter) error {
  513. newError("CopyRawConn readv").WriteToLog(session.ExportIDToError(ctx))
  514. if err := buf.Copy(reader, writer, buf.UpdateActivity(timer), buf.AddToStatCounter(readCounter)); err != nil {
  515. return newError("failed to process response").Base(err)
  516. }
  517. return nil
  518. }