feat: assign mac / gateway
This commit is contained in:
25
src/router/mikrotik.rs
Normal file
25
src/router/mikrotik.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use std::net::IpAddr;
|
||||
use lnvps_db::VmIpAssignment;
|
||||
use rocket::async_trait;
|
||||
use crate::router::Router;
|
||||
|
||||
pub struct MikrotikRouter {
|
||||
url: String,
|
||||
token: String,
|
||||
}
|
||||
|
||||
impl MikrotikRouter {
|
||||
pub fn new(url: &str, token: &str) -> Self {
|
||||
Self {
|
||||
url: url.to_string(),
|
||||
token: token.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Router for MikrotikRouter {
|
||||
async fn add_arp_entry(&self, ip: IpAddr, mac: &[u8; 6], comment: Option<&str>) -> anyhow::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
18
src/router/mod.rs
Normal file
18
src/router/mod.rs
Normal file
@ -0,0 +1,18 @@
|
||||
use anyhow::Result;
|
||||
use rocket::async_trait;
|
||||
use std::net::IpAddr;
|
||||
|
||||
/// Router defines a network device used to access the hosts
|
||||
///
|
||||
/// In our infrastructure we use this to add static ARP entries on the router
|
||||
/// for every IP assignment, this way we don't need to have a ton of ARP requests on the
|
||||
/// VM network because of people doing IP scanning
|
||||
///
|
||||
/// It also prevents people from re-assigning their IP to another in the range,
|
||||
#[async_trait]
|
||||
pub trait Router {
|
||||
async fn add_arp_entry(&self, ip: IpAddr, mac: &[u8; 6], comment: Option<&str>) -> Result<()>;
|
||||
}
|
||||
|
||||
mod mikrotik;
|
||||
pub use mikrotik::*;
|
Reference in New Issue
Block a user