Skip to content

Commit

Permalink
Fixed wrong usage of IpNetwork in api
Browse files Browse the repository at this point in the history
  • Loading branch information
gammelalf committed Apr 2, 2024
1 parent b71fcb2 commit 57222d9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion kraken/src/api/handler/data_export/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl From<Host> for AggregatedHost {

Self {
uuid,
ip_addr,
ip_addr: ip_addr.ip(),
os_type,
response_time,
certainty,
Expand Down
3 changes: 1 addition & 2 deletions kraken/src/api/handler/data_export/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::net::IpAddr;

use chrono::DateTime;
use chrono::Utc;
use ipnetwork::IpNetwork;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
Expand Down Expand Up @@ -43,7 +42,7 @@ pub struct AggregatedHost {
pub uuid: Uuid,

/// The IP address of the host.
pub ip_addr: IpNetwork, // TODO: this is wrong, should be IpAddr
pub ip_addr: IpAddr,

/// The type of OS of this host
pub os_type: OsType,
Expand Down
3 changes: 2 additions & 1 deletion kraken/src/api/handler/services/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use actix_web::web::Json;
use actix_web::web::Path;
use actix_web::HttpResponse;
use futures::TryStreamExt;
use ipnetwork::IpNetwork;
use rorm::and;
use rorm::conditions::DynamicCollection;
use rorm::db::sql::value::Value;
Expand Down Expand Up @@ -373,7 +374,7 @@ pub async fn create_service(
workspace,
user,
name,
host,
IpNetwork::from(host),
port.zip(protocols),
certainty,
)
Expand Down
3 changes: 1 addition & 2 deletions kraken/src/api/handler/services/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::net::IpAddr;

use chrono::DateTime;
use chrono::Utc;
use ipnetwork::IpNetwork;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
Expand All @@ -28,7 +27,7 @@ pub struct CreateServiceRequest {
pub certainty: ManualServiceCertainty,

/// The ip address the service runs on
pub host: IpNetwork, // TODO: this is wrong, should be IpAddr
pub host: IpAddr,

/// An optional port the service runs on
///
Expand Down

0 comments on commit 57222d9

Please sign in to comment.