From 70bbde046bd1fa81964766af622458af6bd939ca Mon Sep 17 00:00:00 2001 From: nils <48135649+Nilstrieb@users.noreply.github.com> Date: Tue, 11 May 2021 14:56:33 +0200 Subject: [PATCH 1/6] Create README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3463031 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# terminal-chat +Peer-to-peer DM Terminal chat + +## How to use it +Just start the program, then either (l)isten or (c)onnect, one person has to listen and then the other one has to connect to it. +The port is always 8080 for now, and the listeners ip address is shown for the listener, so it can easily be seen. +Then just write and the messages of the other person are shown in your terminal! From 9071bd370cf81aeaa9436aab9c0120916e159936 Mon Sep 17 00:00:00 2001 From: nils <48135649+Nilstrieb@users.noreply.github.com> Date: Tue, 11 May 2021 14:57:46 +0200 Subject: [PATCH 2/6] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3463031..ba49a81 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,7 @@ Peer-to-peer DM Terminal chat Just start the program, then either (l)isten or (c)onnect, one person has to listen and then the other one has to connect to it. The port is always 8080 for now, and the listeners ip address is shown for the listener, so it can easily be seen. Then just write and the messages of the other person are shown in your terminal! + +## Debugging +If it doesn't work, make sure that you connected to the correct ip address and port, and make sure that your firewall allows connections on port 8080 for this program. +If it still doesn't work open an issue. From fccb89b725555698e76a7ea120c3d8104cfa6805 Mon Sep 17 00:00:00 2001 From: Nilstrieb Date: Tue, 11 May 2021 15:09:21 +0200 Subject: [PATCH 3/6] better prints --- src/lib.rs | 4 +++- src/main.rs | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 330b026..650dd2a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ pub fn listen() -> StreamResult { println!("Listening on {}:8080", local_ipaddress::get().unwrap()); let listener = TcpListener::bind(("127.0.0.1", 8080))?; let stream = listener.incoming().next().unwrap()?; - println!("Connected. Waiting for response stream..."); + println!("Connected."); println!("other adress: {}", stream.peer_addr()?.ip()); Ok(stream) @@ -24,6 +24,7 @@ pub fn connect(address: String, port: String) -> StreamResult { let stream = TcpStream::connect((&*address, port))?; println!("Connected."); + println!("other adress: {}", stream.peer_addr()?.ip()); Ok(stream) } @@ -44,6 +45,7 @@ pub fn network_thread(mut stream: TcpStream, rx: Receiver) { } pub fn ui_thread(sx: Sender) { + println!("You can now write messages to your peer!"); loop { let input = input(); sx.send(input).expect("could not send value"); diff --git a/src/main.rs b/src/main.rs index fda4a66..b9114b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,9 +16,9 @@ fn main() { Version 0.1" ); - println!("Do you want to listen(l) or connect(c) to a listener?"); + println!("Do you want to (l)isten or (c)onnect to a listener?"); - let result = if input().contains("l") { + let result = if input() == "l" { listen() } else { println!("Address: (empty for default)"); @@ -36,8 +36,6 @@ Version 0.1" match result { Ok(s) => { - println!("Successful connection established."); - let (sx, rx): (Sender, Receiver) = mpsc::channel(); let net = thread::spawn(move || { From 9c3d94f581cec2872f0de161a2cbfc5c064c360b Mon Sep 17 00:00:00 2001 From: nils <48135649+Nilstrieb@users.noreply.github.com> Date: Mon, 5 Jul 2021 15:07:02 +0200 Subject: [PATCH 4/6] Update lib.rs --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 650dd2a..b188e3c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ type StreamResult = Result>; pub fn listen() -> StreamResult { println!("Listening on {}:8080", local_ipaddress::get().unwrap()); - let listener = TcpListener::bind(("127.0.0.1", 8080))?; + let listener = TcpListener::bind(("127.0.0.1", 80))?; let stream = listener.incoming().next().unwrap()?; println!("Connected."); println!("other adress: {}", stream.peer_addr()?.ip()); From d9a17a6464f7e5866e9866d8be75e7dae59f6986 Mon Sep 17 00:00:00 2001 From: nils <48135649+Nilstrieb@users.noreply.github.com> Date: Mon, 5 Jul 2021 15:10:56 +0200 Subject: [PATCH 5/6] Update lib.rs --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b188e3c..650dd2a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ type StreamResult = Result>; pub fn listen() -> StreamResult { println!("Listening on {}:8080", local_ipaddress::get().unwrap()); - let listener = TcpListener::bind(("127.0.0.1", 80))?; + let listener = TcpListener::bind(("127.0.0.1", 8080))?; let stream = listener.incoming().next().unwrap()?; println!("Connected."); println!("other adress: {}", stream.peer_addr()?.ip()); From 9cbbaca88abd4b73860ad8bc24763c7d34d79d6d Mon Sep 17 00:00:00 2001 From: nils <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 5 Feb 2022 18:30:46 +0100 Subject: [PATCH 6/6] fix listen bound ip --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 650dd2a..90297fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ type StreamResult = Result>; pub fn listen() -> StreamResult { println!("Listening on {}:8080", local_ipaddress::get().unwrap()); - let listener = TcpListener::bind(("127.0.0.1", 8080))?; + let listener = TcpListener::bind(("0.0.0.0", 8080))?; let stream = listener.incoming().next().unwrap()?; println!("Connected."); println!("other adress: {}", stream.peer_addr()?.ip());