diff --git a/Cargo.toml b/Cargo.toml
index 63d8f3d..feb3a01 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,6 +32,7 @@ uuid = {version = "0.8", features = ["v4"]}
webbrowser = "0.5.5"
libmdns = "0.6" #mDNS advertiser
multicast_dns = "0.5" #mDNS browser
+pnet_datalink = "0.27.2"
base64 = "0.13.0"
time = "0.2.25"
scrypt = "0.7.0"
diff --git a/src/frontend/imgs/icons/info.svg b/src/frontend/imgs/icons/info.svg
new file mode 100644
index 0000000..c5a70ec
--- /dev/null
+++ b/src/frontend/imgs/icons/info.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/frontend/index.css b/src/frontend/index.css
index 43a44d5..71c6c75 100644
--- a/src/frontend/index.css
+++ b/src/frontend/index.css
@@ -224,21 +224,35 @@ input[type="file"] {
background-color: var(--accent);
border-radius: 12px;
}
-#refresher {
- position: relative;
-}
-#refresher button {
- position: absolute;
- right: 10px;
- top: 15px;
- z-index: 1;
-}
#refresher button::after {
content: url("/static/imgs/icons/refresh");
}
#connect_box {
margin-bottom: 20px;
}
+#refresher, #connect_box>div {
+ position: relative;
+}
+#show_local_ips, #refresher button {
+ position: absolute;
+ right: 10px;
+ top: 15px;
+ z-index: 1;
+}
+#show_local_ips::after {
+ content: url("/static/imgs/icons/info/52585C");
+ background-color: unset;
+ padding: unset;
+ width: 38px;
+ height: 38px;
+}
+#show_local_ips:hover::after {
+ background-color: unset;
+ content: url("/static/imgs/icons/info/FF3C00");
+}
+ul.ips {
+ list-style-type: unset;
+}
#chat_header {
flex-direction: row;
align-items: center;
diff --git a/src/frontend/index.html b/src/frontend/index.html
index f99b06d..f6592f5 100644
--- a/src/frontend/index.html
+++ b/src/frontend/index.html
@@ -23,6 +23,9 @@
+
+
+
Add a new peer by IP:
diff --git a/src/frontend/index.js b/src/frontend/index.js
index 9763a40..8f831ce 100644
--- a/src/frontend/index.js
+++ b/src/frontend/index.js
@@ -3,6 +3,7 @@
let identityName = undefined;
let socket = null;
let notificationAllowed = false;
+let localIps = [];
let currentSessionId = -1;
let sessionsData = new Map();
let msgHistory = new Map();
@@ -30,6 +31,21 @@ ip_input.addEventListener("keyup", function(event) {
ip_input.value = "";
}
});
+document.getElementById("show_local_ips").onclick = function() {
+ let mainDiv = document.createElement("div");
+ let h2Title = document.createElement("h2");
+ h2Title.textContent = "Your IP addresses:";
+ mainDiv.appendChild(h2Title);
+ let ul = document.createElement("ul");
+ ul.classList.add("ips");
+ for (let i=0; i HttpResponse {
"download" => Some(include_str!("frontend/imgs/icons/download.svg")),
"cancel" => Some(include_str!("frontend/imgs/icons/cancel.svg")),
"refresh" => Some(include_str!("frontend/imgs/icons/refresh.svg")),
+ "info" => Some(include_str!("frontend/imgs/icons/info.svg")),
"delete_conversation" => Some(include_str!("frontend/imgs/icons/delete_conversation.svg")),
_ => None
} {
diff --git a/src/ui_interface.rs b/src/ui_interface.rs
index 90fec19..40956cb 100644
--- a/src/ui_interface.rs
+++ b/src/ui_interface.rs
@@ -3,7 +3,7 @@ use tungstenite::{WebSocket, protocol::Role, Message};
use crate::{protocol, session_manager::LargeFileDownload};
mod ui_messages {
- use std::{iter::FromIterator, net::IpAddr, str::from_utf8};
+ use std::{fmt::Display, iter::FromIterator, net::IpAddr, str::from_utf8};
use tungstenite::Message;
use uuid::Uuid;
use crate::{print_error, session_manager::{protocol, LargeFileDownload, FileState}, utils::to_uuid_bytes};
@@ -11,17 +11,22 @@ mod ui_messages {
const ON_NEW_MESSAGE: &str = "new_message";
const LOAD_SENT_MESSAGE: &str = "load_sent_msg";
- fn new_message(verb: &str, session_id: &usize, outgoing: bool, raw_message: &[u8]) -> Option {
+ fn new_message(command: &str, session_id: &usize, outgoing: bool, raw_message: &[u8]) -> Option {
match from_utf8(raw_message) {
- Ok(msg) => Some(Message::from(format!("{} {} {} {}", verb, session_id, outgoing, msg))),
+ Ok(msg) => Some(Message::from(format!("{} {} {} {}", command, session_id, outgoing, msg))),
Err(e) => {
print_error!(e);
None
}
}
}
- fn simple_event(verb: &str, session_id: &usize) -> Message {
- Message::from(format!("{} {}", verb, session_id))
+ fn simple_event(command: &str, session_id: &usize) -> Message {
+ Message::from(format!("{} {}", command, session_id))
+ }
+ fn data_list(command: &str, data: Vec) -> Message {
+ Message::from(command.to_owned()+&String::from_iter(data.into_iter().map(|i| {
+ format!(" {}", i)
+ })))
}
pub fn on_disconnected(session_id: &usize) -> Message {
@@ -91,9 +96,10 @@ mod ui_messages {
}
}
pub fn set_not_seen(session_ids: Vec) -> Message {
- Message::from("not_seen".to_owned()+&String::from_iter(session_ids.into_iter().map(|session_id| {
- format!(" {}", session_id)
- })))
+ data_list("not_seen", session_ids)
+ }
+ pub fn set_local_ips(ips: Vec) -> Message {
+ data_list("local_ips", ips)
}
pub fn on_name_told(session_id: &usize, name: &str) -> Message {
Message::from(format!("name_told {} {}", session_id, name))
@@ -183,6 +189,9 @@ impl UiConnection {
pub fn set_not_seen(&mut self, session_ids: Vec) {
self.write_message(ui_messages::set_not_seen(session_ids));
}
+ pub fn set_local_ips(&mut self, ips: Vec) {
+ self.write_message(ui_messages::set_local_ips(ips));
+ }
pub fn set_name(&mut self, new_name: &str) {
self.write_message(ui_messages::set_name(new_name));
}