more capabilities

This commit is contained in:
John Smith 2023-07-03 15:56:13 -04:00
parent dfb4eefd92
commit ffc54f482e
17 changed files with 143 additions and 0 deletions

View File

@ -528,6 +528,12 @@ impl NetworkManager {
if will_validate_dial_info && !c.capabilities.disable.contains(&CAP_WILL_VALIDATE_DIAL_INFO) {
capabilities.push(CAP_WILL_VALIDATE_DIAL_INFO);
}
if !c.capabilities.disable.contains(&CAP_WILL_DHT) {
capabilities.push(CAP_WILL_DHT);
}
if !c.capabilities.disable.contains(&CAP_WILL_APPMESSAGE) {
capabilities.push(CAP_WILL_APPMESSAGE);
}
PublicInternetNodeStatus {
capabilities
@ -556,6 +562,12 @@ impl NetworkManager {
if will_validate_dial_info && !c.capabilities.disable.contains(&CAP_WILL_VALIDATE_DIAL_INFO) {
capabilities.push(CAP_WILL_VALIDATE_DIAL_INFO);
}
if !c.capabilities.disable.contains(&CAP_WILL_DHT) {
capabilities.push(CAP_WILL_DHT);
}
if !c.capabilities.disable.contains(&CAP_WILL_APPMESSAGE) {
capabilities.push(CAP_WILL_APPMESSAGE);
}
LocalNetworkNodeStatus {
capabilities
}

View File

@ -9,6 +9,8 @@ pub const CAP_WILL_TUNNEL: Capability = FourCC(*b"TUNL");
pub const CAP_WILL_SIGNAL: Capability = FourCC(*b"SGNL");
pub const CAP_WILL_RELAY: Capability = FourCC(*b"RLAY");
pub const CAP_WILL_VALIDATE_DIAL_INFO: Capability = FourCC(*b"DIAL");
pub const CAP_WILL_DHT: Capability = FourCC(*b"DHTV");
pub const CAP_WILL_APPMESSAGE: Capability = FourCC(*b"APPM");
pub const MAX_CAPABILITIES: usize = 64;
/// PublicInternet RoutingDomain Status

View File

@ -53,6 +53,14 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_APPMESSAGE) {
return Ok(NetworkResult::service_unavailable("appcall is disabled"));
}
}
// Get the question
let (op_id, _, _, kind) = msg.operation.clone().destructure();
let app_call_q = match kind {

View File

@ -24,6 +24,14 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_APPMESSAGE) {
return Ok(NetworkResult::service_unavailable("appmessage is disabled"));
}
}
// Get the statement
let (_, _, _, kind) = msg.operation.destructure();
let app_message = match kind {

View File

@ -6,6 +6,16 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_TUNNEL) {
return Ok(NetworkResult::service_unavailable(
"cancel tunnel is disabled",
));
}
}
Err(RPCError::unimplemented("process_cancel_tunnel_q"))
}
}

View File

@ -6,6 +6,15 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_TUNNEL) {
return Ok(NetworkResult::service_unavailable(
"complete tunnel is disabled",
));
}
}
Err(RPCError::unimplemented("process_complete_tunnel_q"))
}
}

View File

@ -6,6 +6,13 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_BLOCKSTORE) {
return Ok(NetworkResult::service_unavailable("find block is disabled"));
}
}
Err(RPCError::unimplemented("process_find_block_q"))
}
}

View File

@ -163,6 +163,13 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_DHT) {
return Ok(NetworkResult::service_unavailable("get value is disabled"));
}
}
// Ensure this never came over a private route, safety route is okay though
match &msg.header.detail {
RPCMessageHeaderDetail::Direct(_) | RPCMessageHeaderDetail::SafetyRouted(_) => {}

View File

@ -365,6 +365,19 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities
.disable
.contains(&CAP_WILL_ROUTE)
{
return Ok(NetworkResult::service_unavailable(
"route is disabled",
));
}
}
// Get header detail, must be direct and not inside a route itself
let detail = match msg.header.detail {
RPCMessageHeaderDetail::Direct(detail) => detail,

View File

@ -175,6 +175,13 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_DHT) {
return Ok(NetworkResult::service_unavailable("set value is disabled"));
}
}
// Ensure this never came over a private route, safety route is okay though
match &msg.header.detail {
RPCMessageHeaderDetail::Direct(_) | RPCMessageHeaderDetail::SafetyRouted(_) => {}

View File

@ -37,6 +37,14 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_SIGNAL) {
return Ok(NetworkResult::service_unavailable("signal is disabled"));
}
}
// Can't allow anything other than direct packets here, as handling reverse connections
// or anything like via signals over private routes would deanonymize the route
match &msg.header.detail {

View File

@ -6,6 +6,15 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_TUNNEL) {
return Ok(NetworkResult::service_unavailable(
"start tunnel is disabled",
));
}
}
Err(RPCError::unimplemented("process_start_tunnel_q"))
}
}

View File

@ -6,6 +6,15 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_BLOCKSTORE) {
return Ok(NetworkResult::service_unavailable(
"supply block is disabled",
));
}
}
Err(RPCError::unimplemented("process_supply_block_q"))
}
}

View File

@ -58,6 +58,19 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities
.disable
.contains(&CAP_WILL_VALIDATE_DIAL_INFO)
{
return Ok(NetworkResult::service_unavailable(
"validate dial info is disabled",
));
}
}
let detail = match msg.header.detail {
RPCMessageHeaderDetail::Direct(detail) => detail,
RPCMessageHeaderDetail::SafetyRouted(_) | RPCMessageHeaderDetail::PrivateRouted(_) => {

View File

@ -6,6 +6,15 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_DHT) {
return Ok(NetworkResult::service_unavailable(
"value changed is disabled",
));
}
}
Err(RPCError::unimplemented("process_value_changed"))
}
}

View File

@ -6,6 +6,16 @@ impl RPCProcessor {
&self,
msg: RPCMessage,
) -> Result<NetworkResult<()>, RPCError> {
// Ignore if disabled
{
let c = self.config.get();
if c.capabilities.disable.contains(&CAP_WILL_DHT) {
return Ok(NetworkResult::service_unavailable(
"watch value is disabled",
));
}
}
Err(RPCError::unimplemented("process_watch_value_q"))
}
}

View File

@ -58,6 +58,8 @@ class Capability(StrEnum):
CAP_WILL_SIGNAL = "SGNL"
CAP_WILL_RELAY = "RLAY"
CAP_WILL_VALIDATE_DIAL_INFO = "DIAL"
CAP_WILL_DHT = "DHTV"
CAP_WILL_APPMESSAGE = "APPM"
class Stability(StrEnum):