Add contact info on session info pop-up
This commit is contained in:
parent
1b175b81e9
commit
da4cc4995f
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -395,8 +395,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "async-psec"
|
||||
version = "0.1.0"
|
||||
source = "git+https://forge.chapril.org/hardcoresushi/async-psec#9d2713aea1e982d7c0f10a466268f623a87ec5d9"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58ab60657d7b3949c3bdb06570fc4855a4e83dbe6c9da73902c67355dd8f37a8"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"async-trait",
|
||||
|
@ -3,12 +3,13 @@ name = "aira"
|
||||
version = "0.0.2"
|
||||
authors = ["Hardcore Sushi <hardcore.sushi@disroot.org>"]
|
||||
edition = "2018"
|
||||
exclude = ["src/frontend"]
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8"
|
||||
rand-7 = { package = "rand", version = "0.7.3" }
|
||||
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros", "net", "io-util"] }
|
||||
async-psec = { version = "0.1", git = "https://forge.chapril.org/hardcoresushi/async-psec", features = ["split"] }
|
||||
async-psec = { version = "0.2", features = ["split"] }
|
||||
lazy_static = "1.4"
|
||||
socket2 = "0.4"
|
||||
rusqlite = { version = "0.25.1", features = ["bundled"] }
|
||||
|
@ -194,12 +194,19 @@ label {
|
||||
#session_info .name button::after {
|
||||
content: url("/static/imgs/icons/refresh");
|
||||
}
|
||||
#session_info p:first-of-type, #session_info pre {
|
||||
display: inline-block;
|
||||
#session_info .session_field {
|
||||
display: flex;
|
||||
gap: .3em;
|
||||
}
|
||||
#session_info p, #session_info pre {
|
||||
#session_info .session_field p {
|
||||
margin-top: 0;
|
||||
}
|
||||
#session_info .session_field p:first-child {
|
||||
color: #34db4a;
|
||||
}
|
||||
#session_info .session_field p:last-child {
|
||||
font-weight: bold;
|
||||
}
|
||||
.button_row {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
|
@ -771,6 +771,17 @@ function beautifyFingerprint(f) {
|
||||
}
|
||||
return f;
|
||||
}
|
||||
function generateSessionField(name, value) {
|
||||
let div = document.createElement("div");
|
||||
div.classList.add("session_field");
|
||||
let pName = document.createElement("p");
|
||||
pName.textContent = name+':';
|
||||
div.appendChild(pName);
|
||||
let pValue = document.createElement("p");
|
||||
pValue.textContent = value;
|
||||
div.appendChild(pValue);
|
||||
return div;
|
||||
}
|
||||
function showSessionInfoPopup() {
|
||||
let session = sessionsData.get(currentSessionId);
|
||||
if (typeof session !== "undefined") {
|
||||
@ -790,25 +801,29 @@ function showSessionInfoPopup() {
|
||||
nameDiv.appendChild(button);
|
||||
}
|
||||
mainDiv.appendChild(nameDiv);
|
||||
let pFingerprint = document.createElement("p");
|
||||
pFingerprint.textContent = "Fingerprint:";
|
||||
mainDiv.appendChild(pFingerprint);
|
||||
let pre = document.createElement("pre");
|
||||
pre.textContent = ' '+beautifyFingerprint(session.fingerprint);
|
||||
mainDiv.appendChild(pre);
|
||||
if (session.isOnline) {
|
||||
let pIp = document.createElement("p");
|
||||
pIp.textContent = "IP: "+session.ip;
|
||||
mainDiv.appendChild(pIp);
|
||||
let pConnection = document.createElement("p");
|
||||
pConnection.textContent = "Connection: ";
|
||||
mainDiv.appendChild(generateSessionField("Peer IP", session.ip));
|
||||
let connection;
|
||||
if (session.outgoing) {
|
||||
pConnection.textContent += "outgoing";
|
||||
connection = generateSessionField("Connection", "outgoing");
|
||||
} else {
|
||||
pConnection.textContent += "incomming";
|
||||
connection = generateSessionField("Connection", "incoming");
|
||||
}
|
||||
mainDiv.appendChild(pConnection);
|
||||
mainDiv.appendChild(connection);
|
||||
}
|
||||
if (session.isContact) {
|
||||
mainDiv.appendChild(generateSessionField("Is contact", "yes"));
|
||||
let isVerified;
|
||||
if (session.isVerified) {
|
||||
isVerified = generateSessionField("Is verified", "yes");
|
||||
} else {
|
||||
isVerified = generateSessionField("Is verified", "no");
|
||||
}
|
||||
mainDiv.appendChild(isVerified);
|
||||
} else {
|
||||
mainDiv.appendChild(generateSessionField("Is contact", "no"));
|
||||
}
|
||||
mainDiv.appendChild(generateSessionField("Fingerprint", beautifyFingerprint(session.fingerprint)));
|
||||
showPopup(mainDiv);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ impl SessionManager {
|
||||
|
||||
pub async fn connect_to(session_manager: Arc<SessionManager>, ip: IpAddr) -> io::Result<()> {
|
||||
let stream = TcpStream::connect(SocketAddr::new(ip, constants::PORT)).await?;
|
||||
SessionManager::handle_new_session(session_manager, Session::new(stream), true);
|
||||
SessionManager::handle_new_session(session_manager, Session::from(stream), true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ impl SessionManager {
|
||||
}
|
||||
};
|
||||
if let Some(mut session) = session {
|
||||
let ip = session.get_addr().unwrap().ip();
|
||||
let ip = session.peer_addr().unwrap().ip();
|
||||
let mut is_contact = false;
|
||||
let session_data = {
|
||||
let mut sessions = session_manager.sessions.write().unwrap();
|
||||
@ -531,7 +531,7 @@ impl SessionManager {
|
||||
client = server_v4.accept() => client,
|
||||
_ = receiver.recv() => break
|
||||
}).unwrap();
|
||||
SessionManager::handle_new_session(session_manager.clone(), Session::new(stream), false);
|
||||
SessionManager::handle_new_session(session_manager.clone(), Session::from(stream), false);
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user