Skip to content

Commit 6469650

Browse files
committed
fix dns early data problem
1 parent 4edb292 commit 6469650

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/server/connection.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,9 @@ impl Connection {
212212
if self.command == CONNECT {
213213
//if dns query is not done, cache data now
214214
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);
216216
self.closing = true;
217217
return;
218-
} else {
219-
buffer = &[];
220218
}
221219

222220
if self.target_addr.is_none() {
@@ -225,11 +223,9 @@ impl Connection {
225223
}
226224

227225
if self.try_setup_tcp_target(opts, poll) {
228-
buffer = self.data.as_slice();
229226
self.status = Status::TCPForward;
230-
} else {
231-
return;
232227
}
228+
return;
233229
} else {
234230
if self.try_setup_udp_target(opts, poll) {
235231
self.status = Status::UDPForward;
@@ -267,7 +263,11 @@ impl Connection {
267263
self.closing = true;
268264
return false;
269265
}
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+
}
271271
self.backend.replace(Box::new(backend));
272272
}
273273
Err(err) => {

0 commit comments

Comments
 (0)