A lot of DNS fixes.
This commit is contained in:
Generated
+1
-1
@@ -45,7 +45,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alfis"
|
name = "alfis"
|
||||||
version = "0.8.5"
|
version = "0.8.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"blakeout",
|
"blakeout",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alfis"
|
name = "alfis"
|
||||||
version = "0.8.5"
|
version = "0.8.6"
|
||||||
authors = ["Revertron <alfis@revertron.com>"]
|
authors = ["Revertron <alfis@revertron.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|||||||
+38
-48
@@ -76,7 +76,7 @@ impl BlockchainFilter {
|
|||||||
// Create DnsPacket
|
// Create DnsPacket
|
||||||
let mut packet = DnsPacket::new();
|
let mut packet = DnsPacket::new();
|
||||||
packet.header.authoritative_answer = true;
|
packet.header.authoritative_answer = true;
|
||||||
packet.header.rescode = ResultCode::NOERROR;
|
packet.header.rescode = ResultCode::NXDOMAIN;
|
||||||
packet.questions.push(DnsQuestion::new(String::from(qname), qtype));
|
packet.questions.push(DnsQuestion::new(String::from(qname), qtype));
|
||||||
let serial = self.context.lock().unwrap().chain.get_soa_serial();
|
let serial = self.context.lock().unwrap().chain.get_soa_serial();
|
||||||
BlockchainFilter::add_soa_record(zone, serial, &mut packet);
|
BlockchainFilter::add_soa_record(zone, serial, &mut packet);
|
||||||
@@ -198,9 +198,9 @@ impl DnsFilter for BlockchainFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut answers: Vec<DnsRecord> = Vec::new();
|
let mut answers: Vec<DnsRecord> = Vec::new();
|
||||||
let a_record = qtype == QueryType::A || qtype == QueryType::AAAA;
|
let mut cname: Option<DnsRecord> = None;
|
||||||
for mut record in data.records.iter_mut() {
|
for mut record in data.records.iter_mut() {
|
||||||
if record.get_querytype() == qtype || (a_record && record.get_querytype() == QueryType::CNAME) {
|
if record.get_querytype() == qtype || record.get_querytype() == QueryType::CNAME {
|
||||||
match &mut record {
|
match &mut record {
|
||||||
DnsRecord::A { domain, .. }
|
DnsRecord::A { domain, .. }
|
||||||
| DnsRecord::AAAA { domain, .. }
|
| DnsRecord::AAAA { domain, .. }
|
||||||
@@ -211,7 +211,7 @@ impl DnsFilter for BlockchainFilter {
|
|||||||
| DnsRecord::MX { domain, .. }
|
| DnsRecord::MX { domain, .. }
|
||||||
| DnsRecord::UNKNOWN { domain, .. }
|
| DnsRecord::UNKNOWN { domain, .. }
|
||||||
| DnsRecord::SOA { domain, .. }
|
| DnsRecord::SOA { domain, .. }
|
||||||
| DnsRecord::TXT { domain, .. } if domain == "@" => {
|
| DnsRecord::TXT { domain, .. } if (domain == "@" && subdomain.is_empty()) || domain == &subdomain => {
|
||||||
*domain = String::from(qname);
|
*domain = String::from(qname);
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
@@ -220,65 +220,55 @@ impl DnsFilter for BlockchainFilter {
|
|||||||
match record.get_domain() {
|
match record.get_domain() {
|
||||||
None => {}
|
None => {}
|
||||||
Some(domain) => {
|
Some(domain) => {
|
||||||
if domain == top_domain {
|
if domain == qname || domain == subdomain {
|
||||||
answers.push(record.clone());
|
if record.get_querytype() == QueryType::CNAME {
|
||||||
} else if domain == subdomain {
|
cname = Some(record.clone());
|
||||||
match &mut record {
|
} else {
|
||||||
DnsRecord::A { domain, .. }
|
answers.push(record.clone());
|
||||||
| DnsRecord::AAAA { domain, .. }
|
|
||||||
| DnsRecord::NS { domain, .. }
|
|
||||||
| DnsRecord::CNAME { domain, .. }
|
|
||||||
| DnsRecord::SRV { domain, .. }
|
|
||||||
| DnsRecord::TLSA { domain, .. }
|
|
||||||
| DnsRecord::MX { domain, .. }
|
|
||||||
| DnsRecord::UNKNOWN { domain, .. }
|
|
||||||
| DnsRecord::SOA { domain, .. }
|
|
||||||
| DnsRecord::TXT { domain, .. } => {
|
|
||||||
*domain = String::from(qname);
|
|
||||||
}
|
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
answers.push(record.clone());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if answers.is_empty() && cname.is_some() {
|
||||||
|
answers.push(cname.unwrap());
|
||||||
|
}
|
||||||
|
let mut domain_exists = !answers.is_empty();
|
||||||
if answers.is_empty() {
|
if answers.is_empty() {
|
||||||
// If there are no records found we search for *.domain.tld record
|
// If there are no records found we search for *.domain.tld record
|
||||||
for mut record in data.records {
|
for mut record in data.records {
|
||||||
if record.get_querytype() == qtype {
|
let record_domain = record.get_domain().unwrap_or(String::new());
|
||||||
match record.get_domain() {
|
if record.get_querytype() == qtype && record_domain == "*" {
|
||||||
None => {}
|
match &mut record {
|
||||||
Some(domain) => {
|
DnsRecord::A { domain, .. }
|
||||||
if domain == top_domain {
|
| DnsRecord::AAAA { domain, .. }
|
||||||
answers.push(record.clone());
|
| DnsRecord::NS { domain, .. }
|
||||||
} else if domain == "*" {
|
| DnsRecord::CNAME { domain, .. }
|
||||||
match &mut record {
|
| DnsRecord::SRV { domain, .. }
|
||||||
DnsRecord::A { domain, .. }
|
| DnsRecord::TLSA { domain, .. }
|
||||||
| DnsRecord::AAAA { domain, .. }
|
| DnsRecord::MX { domain, .. }
|
||||||
| DnsRecord::NS { domain, .. }
|
| DnsRecord::UNKNOWN { domain, .. }
|
||||||
| DnsRecord::CNAME { domain, .. }
|
| DnsRecord::SOA { domain, .. }
|
||||||
| DnsRecord::SRV { domain, .. }
|
| DnsRecord::TXT { domain, .. } => {
|
||||||
| DnsRecord::TLSA { domain, .. }
|
*domain = String::from(qname);
|
||||||
| DnsRecord::MX { domain, .. }
|
|
||||||
| DnsRecord::UNKNOWN { domain, .. }
|
|
||||||
| DnsRecord::SOA { domain, .. }
|
|
||||||
| DnsRecord::TXT { domain, .. } => {
|
|
||||||
*domain = String::from(qname);
|
|
||||||
}
|
|
||||||
_ => ()
|
|
||||||
}
|
|
||||||
answers.push(record.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
|
answers.push(record.clone());
|
||||||
|
}
|
||||||
|
if !domain_exists && (record_domain == subdomain || record_domain == "*") {
|
||||||
|
domain_exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//debug!("Answers: {:?}", &answers);
|
if let Some(mut packet) = self.create_packet(qname, qtype, zone, answers) {
|
||||||
return self.create_packet(qname, qtype, zone, answers);
|
if domain_exists && packet.answers.is_empty() {
|
||||||
|
packet.header.rescode = ResultCode::NOERROR;
|
||||||
|
}
|
||||||
|
return Some(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -297,7 +297,7 @@ impl Peers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If someone has less blocks (we mined a new block) we send a ping with our height
|
// If someone has fewer blocks (we mined a new block) we send a ping with our height
|
||||||
if self.need_behind_ping() {
|
if self.need_behind_ping() {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
match self.peers
|
match self.peers
|
||||||
|
|||||||
Reference in New Issue
Block a user