Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Fix: IP Address Validation #4

Merged
merged 4 commits into from Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config.yml
Expand Up @@ -16,6 +16,6 @@ message: #Optional during receive
file: #Optional during receive
- "./dev_build.sh"
debug: 1 #Compulsory. 0 is for off and 1 and above for on
blacklists:
- 127.0.0.1
- 34.138.139.178
# blacklists:
# - 127.0.0.1
# - 34.138.139.178
4 changes: 2 additions & 2 deletions npm/package.json
@@ -1,13 +1,13 @@
{
"name": "@onboardbase/secure-share",
"version": "0.1.1",
"version": "0.1.2",
"description": "Share anything with teammates across machines via CLI",
"scripts": {
"test": "jest",
"postinstall": "node ./install.js"
},
"bin": {
"share": "run.js"
"scs": "run.js"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion share/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "scs"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
default-run = "scs"
description = "Open source p2p share for devs to share anything with teammates across machines securely."
Expand Down
2 changes: 1 addition & 1 deletion share/src/main.rs
Expand Up @@ -14,7 +14,7 @@ mod network;
#[derive(Parser, Debug)]
#[command(name = "scs")]
#[command(author = "Onboardbase. <onboardbase.com>")]
#[command(version = "0.1.1")]
#[command(version = "0.1.2")]
#[command(about = "Share anything with teammates across machines via CLI.", long_about = None)]
pub struct Cli {
/// Separated list of secrets to share. Key-Value pair is seperated by a comma. "my_key,my_value"
Expand Down
13 changes: 11 additions & 2 deletions share/src/network/hole_puncher.rs
Expand Up @@ -141,6 +141,7 @@
}
}
let mut connection_deets = ConnectionDetails::new();

block_on(async {
loop {
match swarm.next().await.unwrap() {
Expand All @@ -167,19 +168,27 @@
// println!("deetttss {:#?}", connection_id);
error!("This IP address is present in your blacklist.");
swarm.close_connection(connection_id);
exit(1);

Check warning on line 171 in share/src/network/hole_puncher.rs

View check run for this annotation

Codecov / codecov/patch

share/src/network/hole_puncher.rs#L171

Added line #L171 was not covered by tests
}

if !is_ip_whitelisted(&event, &config) {
error!("This IP address is not present in your whitleist.");

Check warning on line 175 in share/src/network/hole_puncher.rs

View check run for this annotation

Codecov / codecov/patch

share/src/network/hole_puncher.rs#L175

Added line #L175 was not covered by tests
swarm.close_connection(connection_id);
exit(1);

Check warning on line 177 in share/src/network/hole_puncher.rs

View check run for this annotation

Codecov / codecov/patch

share/src/network/hole_puncher.rs#L177

Added line #L177 was not covered by tests
}
}
SwarmEvent::Behaviour(Event::Ping(_)) => {}
SwarmEvent::IncomingConnection { connection_id, .. } => {
connection_deets.save_id(connection_id);
debug!("INCOMING CONNECTION: {:?}", connection_id);

Check warning on line 182 in share/src/network/hole_puncher.rs

View check run for this annotation

Codecov / codecov/patch

share/src/network/hole_puncher.rs#L182

Added line #L182 was not covered by tests
}
SwarmEvent::ConnectionEstablished {
peer_id, endpoint, ..
peer_id,
endpoint,
connection_id,
..

Check warning on line 188 in share/src/network/hole_puncher.rs

View check run for this annotation

Codecov / codecov/patch

share/src/network/hole_puncher.rs#L185-L188

Added lines #L185 - L188 were not covered by tests
} => {
connection_deets.save_id(connection_id);

Check warning on line 191 in share/src/network/hole_puncher.rs

View check run for this annotation

Codecov / codecov/patch

share/src/network/hole_puncher.rs#L190-L191

Added lines #L190 - L191 were not covered by tests
let addr = endpoint.get_remote_address();
info!("Established connection to {peer_id} via {addr}");

Expand Down