forked from NationTech/harmony
		
	feat: support new configurable field in dhcp config: filename64
This commit is contained in:
		
							parent
							
								
									7af83910ef
								
							
						
					
					
						commit
						8118df85ee
					
				| @ -124,6 +124,9 @@ impl DhcpServer for DummyInfra { | |||||||
|     async fn set_filename(&self, _filename: &str) -> Result<(), ExecutorError> { |     async fn set_filename(&self, _filename: &str) -> Result<(), ExecutorError> { | ||||||
|         unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) |         unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) | ||||||
|     } |     } | ||||||
|  |     async fn set_filename64(&self, _filename: &str) -> Result<(), ExecutorError> { | ||||||
|  |         unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) | ||||||
|  |     } | ||||||
|     fn get_ip(&self) -> IpAddress { |     fn get_ip(&self) -> IpAddress { | ||||||
|         unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) |         unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -49,6 +49,7 @@ pub trait DhcpServer: Send + Sync { | |||||||
|     async fn set_next_server(&self, ip: IpAddress) -> Result<(), ExecutorError>; |     async fn set_next_server(&self, ip: IpAddress) -> Result<(), ExecutorError>; | ||||||
|     async fn set_boot_filename(&self, boot_filename: &str) -> Result<(), ExecutorError>; |     async fn set_boot_filename(&self, boot_filename: &str) -> Result<(), ExecutorError>; | ||||||
|     async fn set_filename(&self, filename: &str) -> Result<(), ExecutorError>; |     async fn set_filename(&self, filename: &str) -> Result<(), ExecutorError>; | ||||||
|  |     async fn set_filename64(&self, filename64: &str) -> Result<(), ExecutorError>; | ||||||
|     fn get_ip(&self) -> IpAddress; |     fn get_ip(&self) -> IpAddress; | ||||||
|     fn get_host(&self) -> LogicalHost; |     fn get_host(&self) -> LogicalHost; | ||||||
|     async fn commit_config(&self) -> Result<(), ExecutorError>; |     async fn commit_config(&self) -> Result<(), ExecutorError>; | ||||||
|  | |||||||
| @ -79,4 +79,14 @@ impl DhcpServer for OPNSenseFirewall { | |||||||
| 
 | 
 | ||||||
|         Ok(()) |         Ok(()) | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     async fn set_filename64(&self, filename: &str) -> Result<(), ExecutorError> { | ||||||
|  |         { | ||||||
|  |             let mut writable_opnsense = self.opnsense_config.write().await; | ||||||
|  |             writable_opnsense.dhcp().set_filename64(filename); | ||||||
|  |             debug!("OPNsense dhcp server set filename {filename}"); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         Ok(()) | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -19,6 +19,7 @@ pub struct DhcpScore { | |||||||
|     pub next_server: Option<IpAddress>, |     pub next_server: Option<IpAddress>, | ||||||
|     pub boot_filename: Option<String>, |     pub boot_filename: Option<String>, | ||||||
|     pub filename: Option<String>, |     pub filename: Option<String>, | ||||||
|  |     pub filename64: Option<String>, | ||||||
|     pub filename_ipxe: Option<String>, |     pub filename_ipxe: Option<String>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -139,9 +140,22 @@ impl DhcpInterpret { | |||||||
|             None => Outcome::noop(), |             None => Outcome::noop(), | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|  |         let filename64_outcome = match &self.score.filename64 { | ||||||
|  |             Some(filename64) => { | ||||||
|  |                 let dhcp_server = Arc::new(topology.dhcp_server.clone()); | ||||||
|  |                 dhcp_server.set_filename64(&filename64).await?; | ||||||
|  |                 Outcome::new( | ||||||
|  |                     InterpretStatus::SUCCESS, | ||||||
|  |                     format!("Dhcp Interpret Set filename64 to {filename64}"), | ||||||
|  |                 ) | ||||||
|  |             } | ||||||
|  |             None => Outcome::noop(), | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|         if next_server_outcome.status == InterpretStatus::NOOP |         if next_server_outcome.status == InterpretStatus::NOOP | ||||||
|             && boot_filename_outcome.status == InterpretStatus::NOOP |             && boot_filename_outcome.status == InterpretStatus::NOOP | ||||||
|             && filename_outcome.status == InterpretStatus::NOOP |             && filename_outcome.status == InterpretStatus::NOOP | ||||||
|  |             && filename64_outcome.status == InterpretStatus::NOOP | ||||||
|         { |         { | ||||||
|             return Ok(Outcome::noop()); |             return Ok(Outcome::noop()); | ||||||
|         } |         } | ||||||
| @ -149,8 +163,8 @@ impl DhcpInterpret { | |||||||
|         Ok(Outcome::new( |         Ok(Outcome::new( | ||||||
|             InterpretStatus::SUCCESS, |             InterpretStatus::SUCCESS, | ||||||
|             format!( |             format!( | ||||||
|                 "Dhcp Interpret Set next boot to [{:?}], boot_filename to [{:?}], filename to [{:?}]", |                 "Dhcp Interpret Set next boot to [{:?}], boot_filename to [{:?}], filename to [{:?}], filename64 to [{:?}]", | ||||||
|                 self.score.boot_filename, self.score.boot_filename, self.score.filename |                 self.score.boot_filename, self.score.boot_filename, self.score.filename, self.score.filename64 | ||||||
|             ), |             ), | ||||||
|         )) |         )) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -41,8 +41,9 @@ impl OKDBootstrapDhcpScore { | |||||||
|                 // router address, this is leaking implementation details
 |                 // router address, this is leaking implementation details
 | ||||||
|                 Some(topology.router.get_gateway()), |                 Some(topology.router.get_gateway()), | ||||||
|                 Some("bootx64.efi".to_string()), |                 Some("bootx64.efi".to_string()), | ||||||
|                 Some(format!("{}:8080/boot.ipxe", topology.router.get_gateway())), |  | ||||||
|                 Some("undionly.kpxe".to_string()), |                 Some("undionly.kpxe".to_string()), | ||||||
|  |                 Some("ipxe.efi".to_string()), | ||||||
|  |                 Some(format!("{}:8080/boot.ipxe", topology.router.get_gateway())), | ||||||
|             ), |             ), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -35,6 +35,7 @@ impl OKDDhcpScore { | |||||||
|                 boot_filename: None, |                 boot_filename: None, | ||||||
|                 filename_ipxe: Some(format!("{}:8080/boot.ipxe", topology.router.get_gateway())), |                 filename_ipxe: Some(format!("{}:8080/boot.ipxe", topology.router.get_gateway())), | ||||||
|                 filename: Some("undionly.kpxe".to_string()), |                 filename: Some("undionly.kpxe".to_string()), | ||||||
|  |                 filename64: Some("ipxe.efi".to_string()), | ||||||
|             }, |             }, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user