added private_core option on listener

Niko PLP 1 month ago
parent 09fa6e4293
commit 68a4f1281e
  1. 20
      ng-sdk-js/src/lib.rs
  2. 1
      ngd/src/main.rs
  3. 9
      p2p-net/src/types.rs
  4. 2
      p2p-net/src/utils.rs

@ -57,8 +57,8 @@ pub async fn get_local_bootstrap(location: String, invite: JsValue) -> JsValue {
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub async fn decode_invitation(invite: String) -> JsValue {
let res = decode_invitation_string(invite);
pub async fn get_local_bootstrap_with_public(location: String, invite: JsValue) -> JsValue {
let res = retrieve_local_bootstrap(location, invite.as_string(), true).await;
if res.is_some() {
serde_wasm_bindgen::to_value(&res.unwrap()).unwrap()
} else {
@ -68,8 +68,8 @@ pub async fn decode_invitation(invite: String) -> JsValue {
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub async fn get_local_url(location: String) -> JsValue {
let res = retrieve_local_url(location).await;
pub async fn decode_invitation(invite: String) -> JsValue {
let res = decode_invitation_string(invite);
if res.is_some() {
serde_wasm_bindgen::to_value(&res.unwrap()).unwrap()
} else {
@ -79,10 +79,10 @@ pub async fn get_local_url(location: String) -> JsValue {
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub async fn get_ngone_url_of_invitation(invitation_string: String) -> JsValue {
let res = decode_invitation_string(invitation_string);
pub async fn get_local_url(location: String) -> JsValue {
let res = retrieve_local_url(location).await;
if res.is_some() {
serde_wasm_bindgen::to_value(&res.unwrap().get_urls()[0]).unwrap()
serde_wasm_bindgen::to_value(&res.unwrap()).unwrap()
} else {
JsValue::FALSE
}
@ -90,10 +90,10 @@ pub async fn get_ngone_url_of_invitation(invitation_string: String) -> JsValue {
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub async fn get_local_bootstrap_with_public(location: String, invite: JsValue) -> JsValue {
let res = retrieve_local_bootstrap(location, invite.as_string(), true).await;
pub async fn get_ngone_url_of_invitation(invitation_string: String) -> JsValue {
let res = decode_invitation_string(invitation_string);
if res.is_some() {
serde_wasm_bindgen::to_value(&res.unwrap()).unwrap()
serde_wasm_bindgen::to_value(&res.unwrap().get_urls()[0]).unwrap()
} else {
JsValue::FALSE
}

@ -688,6 +688,7 @@ async fn main_inner() -> Result<(), ()> {
ipv6: public_part.0.is_some(),
interface_refresh: 0,
port: private_part.1,
private_core: false,
discoverable: false,
refuse_clients: args.public_without_clients,
serve_app: false,

@ -951,6 +951,9 @@ pub struct ListenerV0 {
/// local port to listen on
pub port: u16,
/// force a private or localhost interface to be accepted as a core interface
pub private_core: bool,
/// should the server serve the app files in HTTP mode (not WS). this setting will be discarded and app will not be served anyway if remote IP is public or listener is public
pub serve_app: bool,
@ -998,6 +1001,7 @@ impl ListenerV0 {
interface_refresh: 0,
ipv6,
port,
private_core: false,
discoverable: false,
accept_direct: true,
refuse_clients: false,
@ -1013,7 +1017,10 @@ impl ListenerV0 {
AcceptForwardForV0::PublicDyn(_) => true,
AcceptForwardForV0::PublicDomain(_) | AcceptForwardForV0::PublicDomainPeer(_) => false,
AcceptForwardForV0::PrivateDomain(_) => false,
AcceptForwardForV0::No => self.if_type == InterfaceType::Public,
AcceptForwardForV0::No => {
self.if_type == InterfaceType::Public
|| (self.private_core && self.if_type != InterfaceType::Invalid)
}
}
}

@ -276,7 +276,7 @@ pub fn get_domain_without_port_443(domain: &str) -> &str {
}
pub fn is_public_ipv4(ip: &Ipv4Addr) -> bool {
// TODO, use core::net::Ipv6Addr.is_global when it will be stable
// TODO, use core::net::Ipv4Addr.is_global when it will be stable
return is_ipv4_global(ip);
}

Loading…
Cancel
Save