mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-08 05:29:47 +00:00
add DnsConfig and ZoneConfig with proto definitions
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "common.proto";
|
||||
|
||||
package dns;
|
||||
|
||||
enum DnsConfigKind {
|
||||
LOCAL = 0;
|
||||
REMOTE = 1;
|
||||
}
|
||||
|
||||
message DnsConfigPb {
|
||||
DnsConfigKind kind = 1;
|
||||
repeated ZoneConfigPb zones = 2;
|
||||
string name = 3;
|
||||
string domain = 4;
|
||||
repeated common.SocketAddr addresses = 5;
|
||||
repeated string listeners = 6;
|
||||
}
|
||||
|
||||
message ZoneConfigPb {
|
||||
string origin = 1;
|
||||
uint32 ttl = 2;
|
||||
repeated string records = 3;
|
||||
repeated string forwarders = 4;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/dns.rs"));
|
||||
|
||||
impl Display for ZoneConfigPb {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
writeln!(f, "; EasyTier Magic DNS zone file")?;
|
||||
writeln!(f, "; https://github.com/easytier/easytier")?;
|
||||
|
||||
if !self.forwarders.is_empty() {
|
||||
writeln!(f, "; Forwarders:")?;
|
||||
for forwarder in &self.forwarders {
|
||||
writeln!(f, "; \t{}", forwarder)?;
|
||||
}
|
||||
}
|
||||
writeln!(f)?;
|
||||
|
||||
write!(f, "$ORIGIN {}", self.origin)?;
|
||||
if !self.origin.ends_with('.') {
|
||||
write!(f, ".")?;
|
||||
}
|
||||
writeln!(f)?;
|
||||
|
||||
writeln!(f, "$TTL {}", self.ttl)?;
|
||||
|
||||
writeln!(f)?;
|
||||
|
||||
for record in &self.records {
|
||||
writeln!(f, "{}", record)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ pub mod rpc_types;
|
||||
pub mod acl;
|
||||
pub mod api;
|
||||
pub mod common;
|
||||
#[cfg(feature = "magic-dns")]
|
||||
pub mod dns;
|
||||
pub mod error;
|
||||
#[cfg(feature = "magic-dns")]
|
||||
pub mod magic_dns;
|
||||
|
||||
Reference in New Issue
Block a user