Skip to content

Commit 6846768

Browse files
authored
Fix crash when zone specific config is missing (#11)
- Zone specific settings are optional, so check if it exists before accessing properties inside it
1 parent d4af26c commit 6846768

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
44

55
### Unreleased
66

7+
- fix: don't crash when zone settings is missing
8+
79
### [1.2.1] - 2024-08-22
810

911
- fix: don't make a set from a set (happened when periodic_checks < 5), #9

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ exports.checkZoneNegative = async function (zone, ip) {
344344
// IPv4-based DNSxLs MUST NOT contain an entry for 127.0.0.1.
345345

346346
// skip this test for DNS lists that don't follow the RFC
347-
if (this.cfg[zone].loopback_is_rejected) return true
347+
if (this.cfg[zone]?.loopback_is_rejected) return true
348348

349349
const query = ipQuery(ip, zone)
350350
try {
@@ -373,7 +373,7 @@ exports.check_zone = async function (zone) {
373373

374374
this.enable_zone(zone) // both tests passed
375375

376-
if (this.cfg[zone].ipv6 === true) {
376+
if (this.cfg[zone]?.ipv6 === true) {
377377
await this.checkZonePositive(zone, '::FFFF:7F00:2')
378378
await this.checkZoneNegative(zone, '::FFFF:7F00:1')
379379
}

0 commit comments

Comments
 (0)