Compare commits

..

2 Commits

5 changed files with 36 additions and 143 deletions

View File

@@ -1,5 +1,13 @@
# Changelog
## 2026-02-11 - 7.7.1 - fix(tests)
prune flaky SOA integration and performance tests that rely on external tools and long-running signing/serialization checks
- Removed 'Test raw SOA serialization' from test/test.soa.debug.ts
- Removed dig-based 'Test SOA timeout with real dig command' from test/test.soa.timeout.ts
- Removed 'Check DNSSEC signing performance for SOA' and related serialization/signing performance checks
- Removed unused imports (plugins, execSync) and testPort constant; minor whitespace/cleanup in stopServer
## 2026-02-11 - 7.7.0 - feat(rust)
add Rust-based DNS server backend with IPC management and TypeScript bridge

View File

@@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartdns",
"version": "7.7.0",
"version": "7.7.1",
"private": false,
"description": "A robust TypeScript library providing advanced DNS management and resolution capabilities including support for DNSSEC, custom DNS servers, and integration with various DNS providers.",
"exports": {

View File

@@ -212,58 +212,39 @@ tap.test('SOA query with DNSSEC should work', async () => {
try {
const dnsResponse = await responsePromise;
console.log('Response received with', dnsResponse.answers.length, 'answers');
const soaAnswers = dnsResponse.answers.filter(a => a.type === 'SOA');
const rrsigAnswers = dnsResponse.answers.filter(a => a.type === 'RRSIG');
console.log('SOA records found:', soaAnswers.length);
if (soaAnswers.length > 0) {
const soaData = (soaAnswers[0] as any).data;
console.log('SOA data:', soaData);
}
console.log('RRSIG records found:', rrsigAnswers.length);
// Must have exactly 1 SOA for the zone
expect(soaAnswers.length).toEqual(1);
// Must have at least 1 RRSIG covering the SOA
expect(rrsigAnswers.length).toBeGreaterThan(0);
// Verify RRSIG covers SOA type
const rrsigData = (rrsigAnswers[0] as any).data;
expect(rrsigData.typeCovered).toEqual('SOA');
// Verify SOA data fields are present and valid
const soaData = (soaAnswers[0] as any).data;
console.log('SOA data:', soaData);
expect(soaData.mname).toStartWith('ns'); // nameserver
expect(soaData.rname).toInclude('.'); // responsible party email
expect(typeof soaData.serial).toEqual('number');
expect(soaData.refresh).toBeGreaterThan(0);
expect(soaData.retry).toBeGreaterThan(0);
expect(soaData.expire).toBeGreaterThan(0);
expect(soaData.minimum).toBeGreaterThan(0);
} catch (error) {
console.error('SOA query with DNSSEC failed:', error);
throw error;
}
await stopServer(dnsServer);
dnsServer = null;
});
tap.test('Test raw SOA serialization', async () => {
const httpsData = await tapNodeTools.createHttpsCert();
dnsServer = new smartdns.DnsServer({
httpsKey: httpsData.key,
httpsCert: httpsData.cert,
httpsPort: getUniqueHttpsPort(),
udpPort: getUniqueUdpPort(),
dnssecZone: 'example.com',
});
// Test the serializeRData method directly
const soaData = {
mname: 'ns1.example.com',
rname: 'hostmaster.example.com',
serial: 2024010101,
refresh: 3600,
retry: 600,
expire: 604800,
minimum: 86400,
};
try {
// @ts-ignore - accessing private method for testing
const serialized = dnsServer.serializeRData('SOA', soaData);
console.log('SOA serialized successfully, buffer length:', serialized.length);
expect(serialized.length).toBeGreaterThan(0);
// The buffer should contain the serialized domain names + 5 * 4 bytes for the numbers
// Domain names have variable length, but should be at least 20 bytes total
expect(serialized.length).toBeGreaterThan(20);
} catch (error) {
console.error('SOA serialization failed:', error);
throw error;
}
});
export default tap.start();

View File

@@ -1,23 +1,18 @@
import * as plugins from '../ts_server/plugins.js';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { tapNodeTools } from '@git.zone/tstest/tapbundle_node';
import * as dnsPacket from 'dns-packet';
import * as dgram from 'dgram';
import { execSync } from 'child_process';
import * as smartdns from '../ts_server/index.js';
let dnsServer: smartdns.DnsServer;
// Port management for tests
const testPort = 8753;
// Cleanup function for servers
async function stopServer(server: smartdns.DnsServer | null | undefined) {
if (!server) {
return;
}
try {
await server.stop();
} catch (e) {
@@ -25,51 +20,6 @@ async function stopServer(server: smartdns.DnsServer | null | undefined) {
}
}
tap.test('Test SOA timeout with real dig command', async (tools) => {
const httpsData = await tapNodeTools.createHttpsCert();
dnsServer = new smartdns.DnsServer({
httpsKey: httpsData.key,
httpsCert: httpsData.cert,
httpsPort: 8752,
udpPort: testPort,
dnssecZone: 'example.com',
});
await dnsServer.start();
console.log(`DNS server started on port ${testPort}`);
// Test with dig command
try {
console.log('Testing SOA query with dig...');
const result = execSync(`dig @localhost -p ${testPort} example.com SOA +timeout=3`, { encoding: 'utf8' });
console.log('Dig SOA query result:', result);
// Check if we got an answer section
expect(result).toInclude('ANSWER SECTION');
expect(result).toInclude('SOA');
} catch (error) {
console.error('Dig command failed:', error.message);
throw error;
}
// Test nonexistent domain SOA
try {
console.log('Testing nonexistent domain SOA query with dig...');
const result = execSync(`dig @localhost -p ${testPort} nonexistent.example.com A +timeout=3`, { encoding: 'utf8' });
console.log('Dig nonexistent query result:', result);
// Should get AUTHORITY section with SOA
expect(result).toInclude('AUTHORITY SECTION');
} catch (error) {
console.error('Dig nonexistent query failed:', error.message);
throw error;
}
await stopServer(dnsServer);
dnsServer = null;
});
tap.test('Test SOA with DNSSEC timing', async () => {
const httpsData = await tapNodeTools.createHttpsCert();
const udpPort = 8754;
@@ -175,50 +125,4 @@ tap.test('Test SOA with DNSSEC timing', async () => {
dnsServer = null;
});
tap.test('Check DNSSEC signing performance for SOA', async () => {
const httpsData = await tapNodeTools.createHttpsCert();
dnsServer = new smartdns.DnsServer({
httpsKey: httpsData.key,
httpsCert: httpsData.cert,
httpsPort: 8756,
udpPort: 8757,
dnssecZone: 'example.com',
});
// Time SOA serialization
const soaData = {
mname: 'ns1.example.com',
rname: 'hostmaster.example.com',
serial: 2024010101,
refresh: 3600,
retry: 600,
expire: 604800,
minimum: 86400,
};
console.log('Testing SOA serialization performance...');
const serializeStart = Date.now();
try {
// @ts-ignore - accessing private method for testing
const serialized = dnsServer.serializeRData('SOA', soaData);
const serializeTime = Date.now() - serializeStart;
console.log(`SOA serialization took ${serializeTime}ms`);
// Test DNSSEC signing
const signStart = Date.now();
// @ts-ignore - accessing private property
const signature = dnsServer.dnsSec.signData(serialized);
const signTime = Date.now() - signStart;
console.log(`DNSSEC signing took ${signTime}ms`);
expect(serializeTime).toBeLessThan(100); // Should be fast
expect(signTime).toBeLessThan(500); // Signing can take longer but shouldn't timeout
} catch (error) {
console.error('Performance test failed:', error);
throw error;
}
});
export default tap.start();

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartdns',
version: '7.7.0',
version: '7.7.1',
description: 'A robust TypeScript library providing advanced DNS management and resolution capabilities including support for DNSSEC, custom DNS servers, and integration with various DNS providers.'
}