Skip to content

Commit fbb7f73

Browse files
committed
Test connecting to 'localhost' on parent
1 parent e16707f commit fbb7f73

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
Connected to Google successfully!
2+
Connected to Google successfully!
3+
Connected to Google successfully!
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use std::net::{Ipv4Addr, TcpStream};
1+
use std::net::TcpStream;
22
use std::io::{Read, Write};
33

4-
fn main() {
4+
fn connect(host: &str, port: u16) {
5+
let remote = format!("{}:{}", host, port);
56
println!("# Running outgoing connection test");
6-
let mut socket = TcpStream::connect(format!("google.com:80")).unwrap();
7+
let mut socket = TcpStream::connect(remote).unwrap();
78
// `socket.local_addr()` may return the actual local IP address, not 127.0.0.1
89
assert!(socket.local_addr().unwrap().port() != 80);
9-
assert!(socket.peer_addr().unwrap().ip() != Ipv4Addr::new(127, 0, 0, 1));
10-
assert_eq!(socket.peer_addr().unwrap().port(), 80);
10+
assert_eq!(socket.peer_addr().unwrap().port(), port);
1111
socket.write(b"GET / HTTP/1.1\n\n").unwrap();
1212
socket.flush().unwrap();
1313
let mut page = [0; 4192];
@@ -20,3 +20,9 @@ fn main() {
2020
println!("Failed to read from connection, got: {}", page);
2121
}
2222
}
23+
24+
fn main() {
25+
connect("www.google.com", 80);
26+
connect("127.0.0.1", 3080);
27+
connect("localhost", 3080);
28+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -ex
2+
3+
function cleanup {
4+
killall socat
5+
}
6+
7+
trap cleanup err
8+
trap cleanup exit
9+
10+
socat -v TCP-LISTEN:3080,fork TCP:www.google.com:80

fortanix-vme/ci-common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function cargo_test {
126126
fi
127127

128128
if [ -f ./test_interaction.sh ]; then
129-
kill ${test_interaction}
129+
kill ${test_interaction} || true
130130
fi
131131

132132
popd

0 commit comments

Comments
 (0)