/// When --core is used, this option will allow clients to connect to the public interface too. Otherwise, by default, they cannot.
#[arg(long, requires("core"))]
pubcore_with_clients: bool,
/// Quick config to forward all requests to another BROKER. format is "[DOMAIN/IP:PORT]@PEERID". An IPv6 should be encased in square brackets [IPv6] and the whole option should be between double quotes. Port defaults to 80 for IPs and 443 for domains
/// Quick config to forward all requests to another BROKER. format is "[DOMAIN/IP:PORT]@PEERID". An IPv6 should be encased in square brackets [IPv6] and the whole option should be between double quotes. Port defaults to 80 for IPs and 443 for domains
#[arg(
#[arg(
short,
short,
@ -67,6 +71,10 @@ pub(crate) struct Cli {
)]
)]
pubpublic: Option<String>,
pubpublic: Option<String>,
/// When --public is used, this option will disallow clients to connect to the public interface too. Otherwise, by default, they can. Should be used in combination with a --domain option
/// Quick config to listen for clients and core brokers on PRIVATE_INTERFACE, behind a DMZ or port forwarding of a public dynamic IP. PORTs defaults to 80
/// Quick config to listen for clients and core brokers on PRIVATE_INTERFACE, behind a DMZ or port forwarding of a public dynamic IP. PORTs defaults to 80
log_err!("The same private interface is already forwarding with a different setting, probably because of a --public option conflicting with a --dynamic option. Changing the port on one of the interfaces can help. cannot start");
log_err!("The same private interface is already forwarding with a different setting, probably because of a --public option conflicting with a --dynamic option. Changing the port on one of the interfaces can help. cannot start");
returnErr(());
returnErr(());
}
}
r.accept_forward_for=
panic!("this should never happen. --dynamic created after a --private");
log_err!("The same private interface is already forwarding with a different setting, probably because of a --public or --dynamic option conflicting with the --domain-private option. Changing the port on one of the interfaces can help. cannot start");
log_err!("The same private interface is already forwarding with a different setting, probably because of a --public or --dynamic option conflicting with the --domain-private option. Changing the port on one of the interfaces can help. cannot start");
returnErr(());
returnErr(());
}
}
r.accept_forward_for=res;
panic!(
"this should never happen. --domain-private created after a --private"
log_debug!("accepted private PUBLIC_STATIC or PUBLIC_DYN with direct {} with refuse_clients {}",listener.config.accept_direct,listener.config.refuse_clients);
log_err!("There isn't any overlay_config that should run as core or server. Check your config. cannot start");
log_err!("There isn't any overlay_config that should run as core or server. Check your config. cannot start");
returnErr(());
returnErr(());
}
}
letlisteners: HashSet<String>=HashSet::new();
ifrun_core&&!run_server{
log_warn!("There isn't any overlay_config that should run as server. This is a misconfiguration as a core server that cannot receive client connections is useless");
}
letmutlisteners: HashSet<String>=HashSet::new();
forlistenerin&config.listeners{
forlistenerin&config.listeners{
letmutid=listener.interface_name.clone();
letid: String=listener.to_string();
id.push('@');
if!listeners.insert(id.clone()){
id.push_str(&listener.port.to_string());
iflisteners.contains(&id){
log_err!(
log_err!(
"The listener {} is defined twice. Check your config file. cannot start",
"The listener {} is defined twice. Check your config file. cannot start",
"You have disabled accepting connections from clients on {}. This is unusual as --domain and --domain-private listeners are meant to answer to clients only. This will activate the relay_websocket on this listener. Is it really intended?",
log_err!(
listener.interface_name
"cannot bind to {} with addresses {} : {}",
);
interface.name,
}
ips_string,
e.to_string()
letlistener_id: String=listener.to_string();
)
letlistener_info=ListenerInfo{
})?;
config: listener,
log_info!("Listening on {} {}",interface.name,ips_string);
log_warn!("There isn't any listener that accept clients. This is a misconfiguration as a core server that cannot receive client connections is useless");
}
// saving the infos in the broker. This needs to happen before we start listening, as new incoming connections can happen anytime after that.
// and we need those infos for permission checking.
/// names of interfaces can be retrieved with the --list-interfaces option
pubinterface_name: String,
/// optional number of seconds for an interval of periodic refresh
/// of the actual IP(s) of the interface. Used for dynamic IP interfaces (DHCP)
pubinterface_refresh: u32,
// if to bind to the ipv6 address of the interface
pubipv6: bool,
/// local port to listen on
pubport: u16,
// will answer a probe coming from private LAN and if is_private, with its own peerId, so that guests on the network will be able to connect.
pubdiscoverable: bool,
/// Answers to connection requests originating from a direct client, without X-Forwarded-For headers
/// Can be used in combination with a accept_forward_for config, when a local daemon is behind a proxy, and also serves as broker for local apps/webbrowsers
pubaccept_direct: bool,
/// X-Forwarded-For config. only valid if IP/interface is localhost or private
pubaccept_forward_for: AcceptForwardForV0,
// impl fn is_private()
// returns false if public IP in interface, or if PublicDyn, PublicStatic
// if the ip is local or private, and the forwarding is not PublicDyn nor PublicStatic, (if is_private) then the app is served on HTTP get of /
// an interface with no accept_forward_for and no accept_direct, is de facto, disabled
_=>panic!("cannot call get_domain if AcceptForwardForV0 is not a domain"),
});
//let mut url = "https://".to_string();
//url.push_str(domain);
domain
}
}
#[cfg(not(target_arch = "wasm32"))]
/// DaemonConfig Listener Version 0
#[derive(Clone, Debug, Serialize, Deserialize)]
pubstructListenerV0{
/// local interface name to bind to
/// names of interfaces can be retrieved with the --list-interfaces option
pubinterface_name: String,
pubif_type: InterfaceType,
/// optional number of seconds for an interval of periodic refresh
/// of the actual IP(s) of the interface. Used for dynamic IP interfaces (DHCP)
pubinterface_refresh: u32,
// if to bind to the ipv6 address of the interface
pubipv6: bool,
/// local port to listen on
pubport: u16,
/// 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
pubserve_app: bool,
/// default to false. Set to true by --core (use --core-and-clients to override to false). only useful for a public IP listener, if the clients should use another listener like --domain or --domain-private.
/// do not set it on a --domain or --domain-private, as this will enable the relay_websocket feature, which should not be used except by app.nextgraph.one
pubrefuse_clients: bool,
// will answer a probe coming from private LAN and if is_private, with its own peerId, so that guests on the network will be able to connect.
pubdiscoverable: bool,
/// Answers to connection requests originating from a direct client, without X-Forwarded-For headers
/// Can be used in combination with a accept_forward_for config, when a local daemon is behind a proxy, and also serves as broker for local apps/webbrowsers
pubaccept_direct: bool,
/// X-Forwarded-For config. only valid if IP/interface is localhost or private
pubaccept_forward_for: AcceptForwardForV0,
// impl fn is_private()
// returns false if public IP in interface, or if PublicDyn, PublicStatic
// if the ip is local or private, and the forwarding is not PublicDyn nor PublicStatic, (if is_private) then the app is served on HTTP get of /
// an interface with no accept_forward_for and no accept_direct, is de facto, disabled