@@ -212,11 +212,9 @@ impl Connection {
212
212
if self . command == CONNECT {
213
213
//if dns query is not done, cache data now
214
214
if let Err ( err) = self . data . write ( buffer) {
215
- log:: warn!( "connection:{} cache data failed" , self . index) ;
215
+ log:: warn!( "connection:{} cache data failed {} " , self . index, err ) ;
216
216
self . closing = true ;
217
217
return ;
218
- } else {
219
- buffer = & [ ] ;
220
218
}
221
219
222
220
if self . target_addr . is_none ( ) {
@@ -225,11 +223,9 @@ impl Connection {
225
223
}
226
224
227
225
if self . try_setup_tcp_target ( opts, poll) {
228
- buffer = self . data . as_slice ( ) ;
229
226
self . status = Status :: TCPForward ;
230
- } else {
231
- return ;
232
227
}
228
+ return ;
233
229
} else {
234
230
if self . try_setup_udp_target ( opts, poll) {
235
231
self . status = Status :: UDPForward ;
@@ -267,7 +263,11 @@ impl Connection {
267
263
self . closing = true ;
268
264
return false ;
269
265
}
270
- let backend = TcpBackend :: new ( tcp_target, self . index , self . target_token ( ) , opts. tcp_idle_duration ) ;
266
+ let mut backend = TcpBackend :: new ( tcp_target, self . index , self . target_token ( ) , opts. tcp_idle_duration ) ;
267
+ if !self . data . is_empty ( ) {
268
+ backend. dispatch ( self . data . as_slice ( ) , opts) ;
269
+ self . data . clear ( ) ;
270
+ }
271
271
self . backend . replace ( Box :: new ( backend) ) ;
272
272
}
273
273
Err ( err) => {
0 commit comments