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