Skip to content

Commit

Permalink
Add support for -o to specify the origin for zone files that contain …
Browse files Browse the repository at this point in the history
…relative domains but lack an $ORIGIN directive. (fixes #14)
  • Loading branch information
ximon18 committed Nov 5, 2024
1 parent dc9f3ab commit b6a853a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/commands/signzone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pub struct SignZone {
#[arg(short = 'b', default_value_t = false)]
diagnostic_comments: bool,

/// Origin for the zone (for zonefiles with relative names and no $ORIGIN)
#[arg(short = 'o')]
origin: Option<Name<Bytes>>,

/// The zonefile to sign
#[arg(value_name = "zonefile")]
zonefile_path: PathBuf,
Expand Down Expand Up @@ -229,7 +233,10 @@ impl SignZone {

fn load_zone(&self) -> Result<SortedRecords<StoredName, StoredRecordData>, Error> {
let mut zone_file = File::open(self.zonefile_path.as_path())?;
let reader = inplace::Zonefile::load(&mut zone_file).unwrap();
let mut reader = inplace::Zonefile::load(&mut zone_file).unwrap();
if let Some(origin) = &self.origin {
reader.set_origin(origin.to_owned());
}
let mut records = SortedRecords::new();
for entry in reader {
let Ok(entry) = entry else {
Expand Down

0 comments on commit b6a853a

Please sign in to comment.