Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b56beb7
Add TCP support to DNS server and client
lohanidamodar Dec 30, 2025
771b57f
Fix codeql analysis
lohanidamodar Dec 30, 2025
e2072ce
Fix guard agains fread zero
lohanidamodar Dec 30, 2025
e2dfb60
Update src/DNS/Client.php
lohanidamodar Dec 30, 2025
52477c2
Fix socket errors
lohanidamodar Dec 30, 2025
ed48cd1
set socket non blocking
lohanidamodar Dec 31, 2025
6521de9
Fix: set max tcp clients limit
lohanidamodar Dec 31, 2025
8982341
make tcp secondary in swoole adapter
lohanidamodar Dec 31, 2025
8d658b0
max buffer and framesize for tcp
lohanidamodar Dec 31, 2025
76881ff
handle truncation
lohanidamodar Dec 31, 2025
ebdc963
truncation test
lohanidamodar Dec 31, 2025
32c096f
Fix param order
lohanidamodar Dec 31, 2025
aa96f07
fix truncation test
lohanidamodar Dec 31, 2025
de9a2d3
review improvements to truncation
lohanidamodar Dec 31, 2025
55871f3
Fix phpstan issues
lohanidamodar Dec 31, 2025
f74cf61
Fix codeql
lohanidamodar Dec 31, 2025
2ea924a
Fix phpstan level max
lohanidamodar Dec 31, 2025
cf1906c
phpstan max
lohanidamodar Dec 31, 2025
dc9c2fb
Enhance TCP support and implement RFC-compliant truncation in DNS mes…
lohanidamodar Feb 2, 2026
a03283f
remove phpunit
lohanidamodar Feb 2, 2026
47e9b49
Enhance DNS message handling with RFC compliance and add tests for po…
lohanidamodar Feb 2, 2026
3d3a764
update test and domain
lohanidamodar Feb 2, 2026
9d59eed
Refactor DNS Client tests to validate RRSet order using RFC 2181 comp…
lohanidamodar Feb 2, 2026
926e86d
Update TCP response handling to use maximum response size in packet p…
lohanidamodar Feb 2, 2026
1232d12
Implement multi-zone resolver for DNS server with localhost zone support
lohanidamodar Feb 2, 2026
8e4a930
Enhance TCP fallback test for large TXT records to ensure proper resp…
lohanidamodar Feb 2, 2026
8914fbe
Refactor Swoole adapter constructor to use protected properties for c…
lohanidamodar Feb 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .phpunit.result.cache

This file was deleted.

19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ $adapter = new Native('0.0.0.0', 5300);
$zone = new Zone(
name: 'example.test',
records: [
new Record(name: 'example.test', type: Record::TYPE_A, rdata: '127.0.0.1', ttl: 60),
new Record(name: 'example.test', type: Record::TYPE_A, rdata: '192.0.2.1', ttl: 60),
new Record(name: 'www.example.test', type: Record::TYPE_CNAME, rdata: 'example.test', ttl: 60),
new Record(name: 'example.test', type: Record::TYPE_TXT, rdata: '"demo record"', ttl: 60),
],
soa: new Record(
name: 'example.test',
type: Record::TYPE_SOA,
rdata: 'ns1.example.test hostmaster.example.test 1 7200 1800 1209600 3600',
ttl: 60
),
new Record(
name: 'example.test',
type: Record::TYPE_SOA,
rdata: 'ns1.example.test hostmaster.example.test 1 7200 1800 1209600 3600',
ttl: 60
),
]
);

$server = new Server($adapter, new Memory($zone));
Expand All @@ -55,7 +54,7 @@ $server->setDebug(true);
$server->start();
```

The server listens on UDP port `5300` and answers queries for `example.test` from the in-memory zone. Implement the [`Utopia\DNS\Resolver`](src/DNS/Resolver.php) interface to serve records from databases, APIs, or other stores.
The server listens on both UDP and TCP port `5300` (RFC 5966) and answers queries for `example.test` from the in-memory zone. Implement the [`Utopia\DNS\Resolver`](src/DNS/Resolver.php) interface to serve records from databases, APIs, or other stores.

## Resolvers
- `Memory`: authoritative resolver backed by a `Zone` object
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"format": "./vendor/bin/pint --config pint.json",
"format:check": "./vendor/bin/pint --test --config pint.json",
"analyze": "./vendor/bin/phpstan analyse --level 8 -c phpstan.neon src tests",
"analyze": "./vendor/bin/phpstan analyse --level max -c phpstan.neon src tests",
"test": "./vendor/bin/phpunit --configuration phpunit.xml"
},
"authors": [
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ services:
- dns
ports:
- '5300:5300/udp'
- '5300:5300/tcp'
networks:
dns:
4 changes: 2 additions & 2 deletions src/DNS/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ abstract public function onWorkerStart(callable $callback): void;
/**
* Packet handler
*
* @param callable(string $buffer, string $ip, int $port): string $callback
* @phpstan-param callable(string $buffer, string $ip, int $port):string $callback
* @param callable(string $buffer, string $ip, int $port, ?int $maxResponseSize): string $callback
* @phpstan-param callable(string $buffer, string $ip, int $port, ?int $maxResponseSize):string $callback
*/
abstract public function onPacket(callable $callback): void;

Expand Down
Loading