Skip to content

Commit

Permalink
feat: dns trace support (#105)
Browse files Browse the repository at this point in the history
* add: trace field to dns cmd schema

* add: trace field to demo page

* add: docs
  • Loading branch information
patrykcieszkowski authored May 9, 2022
1 parent 7ae6dfd commit e5826da
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/measurement/post-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ below is presented a schema containing all possible input values; some are gener
protocol?: string
type?: string
resolver?: string
trace?: boolean
}
port?: number
protocol?: string
Expand Down
14 changes: 14 additions & 0 deletions docs/measurement/schema/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,17 @@ resolver is the name or IP address of the name server to query. This can be an I
```json
"resolver": "1.1.1.1"
```
### trace

Toggle tracing of the delegation path from the root name servers for the name being looked up. It will follow referrals from the root servers, showing the answer from each server that was used to resolve the lookup.

**key**: `measurement.query.trace`

**required**: `false`

**rules**:
- typeof `boolean`

```json
"trace": true
```
108 changes: 108 additions & 0 deletions docs/measurement/schema/response.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,114 @@ the delay between sending the packet and getting the response.

### DNS

***warning!***: In case the measurement was requested with `toggle` enabled, the `Reasult.result` will be of type `Object[]`. This is because each trace path is returned individually by the probe.

example:
```json
{
"id": "tEaUg3vYnOu2exVC",
"type": "ping",
"status": "finished",
"createdAt": 1650384403719,
"updatedAt": 1650384404482,
"results": [
{
"probe": {
"continent": "AF",
"region": "southern africa",
"country": "ZA",
"state": null,
"city": "cape town",
"asn": 16509,
"longitude": 18.4232,
"latitude": -33.9258,
"network": "amazon.com inc."
},
"result": [
{
"time": 4,
"server": "127.0.0.53",
"answer": [
{
"domain": ".",
"type": "NS",
"ttl": "6593",
"class": "IN",
"value": "c.root-servers.net."
},
...
{
"domain": ".",
"type": "NS",
"ttl": "6593",
"class": "IN",
"value": "h.root-servers.net."
}
]
},
{
"time": 24,
"server": "d.root-servers.net",
"answer": [
{
"domain": "net.",
"type": "NS",
"ttl": "172800",
"class": "IN",
"value": "a.gtld-servers.net."
},
...
{
"domain": "net.",
"type": "RRSIG",
"ttl": "86400",
"class": "IN",
"value": "nStNJg=="
}
]
},
{
"time": 32,
"server": "c.gtld-servers.net",
"answer": [
{
"domain": "jsdelivr.net.",
"type": "NS",
"ttl": "172800",
"class": "IN",
"value": "dns1.p03.nsone.net."
},
...
{
"domain": "GBMGFDMMHIENHS2RNSDAQ541H88GB5IO.net.",
"type": "RRSIG",
"ttl": "86400",
"class": "IN",
"value": "NO9LoUolBGhvxHSQfhwCyAi0slPURsAkC4DBUS1WrpipCQ=="
}
]
},
{
"time": 28,
"server": "gns3.cloudns.net",
"answer": [
{
"domain": "cdn.jsdelivr.net.",
"type": "CNAME",
"ttl": "900",
"class": "IN",
"value": "jsdelivr.map.fastly.net."
}
]
}
],
"rawOutput": "; <<>> DiG 9.18.1-1ubuntu1-Ubuntu <<>> +trace +nocookie +tries +timeout cdn.jsdelivr.net\n;; global options: +cmd\n.\t\t\t6593\tIN\tNS\tj.root-servers.net.\n.\t\t\t6593\tIN\tNS\tc.root-servers.net.\n.\t\t\t6593\tIN\tNS\tg.root-servers.net.\n.\t\t\t6593\tIN\tNS\tb.root-servers.net.\n.\t\t\t6593\tIN\tNS\ti.root-servers.net.\n.\t\t\t6593\tIN\tNS\ta.root-servers.net.\n.\t\t\t6593\tIN\tNS\te.root-servers.net.\n.\t\t\t6593\tIN\tNS\tl.root-servers.net.\n.\t\t\t6593\tIN\tNS\tk.root-servers.net.\n.\t\t\t6593\tIN\tNS\tf.root-servers.net.\n.\t\t\t6593\tIN\tNS\tm.root-servers.net.\n.\t\t\t6593\tIN\tNS\td.root-servers.net.\n.\t\t\t6593\tIN\tNS\th.root-servers.net.\n;; Received 811 bytes from 127.0.0.53#53(127.0.0.53) in 4 ms\n\nnet.\t\t\t172800\tIN\tNS\ta.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\tb.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\tc.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\td.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\te.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\tf.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\tg.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\th.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\ti.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\tj.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\tk.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\tl.gtld-servers.net.\nnet.\t\t\t172800\tIN\tNS\tm.gtld-servers.net.\nnet.\t\t\t86400\tIN\tDS\t35886 8 2 7862B27F5F516EBE19680444D4CE5E762981931842C465F00236401D 8BD973EE\nnet.\t\t\t86400\tIN\tRRSIG\tDS 8 1 86400 20220509170000 20220426160000 47671 . IbbmgURsOFU02lEF33VZIt90+xd+DSAy6n+LowQlVMbxAxB6BsF5nNi1 n0Xsfixgxk06JOsQOLeMnTSX6xGZ5baCHa8pWGlS2CZ3wpmWt9Fg5Y/r Vqpneq9sBXuvcyLZ4OOzxqY8Xvqnj5EBqx2wegOxqOzbw4I2MLPeFWS4 hRvHcodnVkAHaWbDWLi3olY+8nIdWMLRdMxA1VkzliQn0MOPNn6mhKeG HTh3uOo7FSm+adbefRhC6X8QDoSFQ6VKYhd3mVJ7HGJ2JsvpVsJlG5Ff WNBztAw7W5Tg9aIVxPwfl3tNvlkpyvDqgurJLXVqmB7F+t3f3+8QKDMb nStNJg==\n;; Received 1173 bytes from 199.7.91.13#53(d.root-servers.net) in 24 ms\n\njsdelivr.net.\t\t172800\tIN\tNS\tdns1.p03.nsone.net.\njsdelivr.net.\t\t172800\tIN\tNS\tdns2.p03.nsone.net.\njsdelivr.net.\t\t172800\tIN\tNS\tdns3.p03.nsone.net.\njsdelivr.net.\t\t172800\tIN\tNS\tdns4.p03.nsone.net.\njsdelivr.net.\t\t172800\tIN\tNS\tgns1.cloudns.net.\njsdelivr.net.\t\t172800\tIN\tNS\tgns2.cloudns.net.\njsdelivr.net.\t\t172800\tIN\tNS\tgns3.cloudns.net.\njsdelivr.net.\t\t172800\tIN\tNS\tgns4.cloudns.net.\nA1RT98BS5QGC9NFI51S9HCI47ULJG6JH.net. 86400 IN NSEC3 1 1 0 - A1RTLNPGULOGN7B9A62SHJE1U3TTP8DR NS SOA RRSIG DNSKEY NSEC3PARAM\nA1RT98BS5QGC9NFI51S9HCI47ULJG6JH.net. 86400 IN RRSIG NSEC3 8 2 86400 20220503055829 20220426044829 45728 net. kqtegTsTwSJ9OJ/4UpoKnOzaSfaEaSxd03SERi2nhwhL1Dd/xjXF+Oy+ gB2NxI8IHBdT0Za1PadKRYefjjI+phvYB2Z2s7LqLE5iLju+2R6mVMQu TfkTO8GJWxBDMcXdcX2cjTxSan7y8m4kbzeGvqFHwiWtodDnT2lFQBvg QKqFhOv3D/NZtRua5mWeuy78rB3MIZQmGQ7rwapaz4h4eg==\nGBMGFDMMHIENHS2RNSDAQ541H88GB5IO.net. 86400 IN NSEC3 1 1 0 - GBMKRB78QIII3C3NIFGFSK27G1IBHMM0 NS DS RRSIG\nGBMGFDMMHIENHS2RNSDAQ541H88GB5IO.net. 86400 IN RRSIG NSEC3 8 2 86400 20220430055643 20220423044643 45728 net. JIFFMnHeaG97gcZYao5JGWkTJ4zGKDAKrfLOi9KrKVmBroFmnjfOytBo NgTxIl17GlLW2kaq1doKHpDHUu8y4u/56OdJmeBgL+OYqGbQjmICztpK dU+p9eoXUPLMkDFTqrwFhN1dm51Q9sle4MiDHMeLHBrs76jlpBcR+PQn NO9LoUolBGhvxHSQfhwCyAi0slPURsAkC4DBUS1WrpipCQ==\n;; Received 1116 bytes from 192.26.92.30#53(c.gtld-servers.net) in 32 ms\n\ncdn.jsdelivr.net.\t900\tIN\tCNAME\tjsdelivr.map.fastly.net.\n;; Received 79 bytes from 185.136.98.122#53(gns3.cloudns.net) in 28 ms\n"
}
}
]
}
```

#### server

**key**: `Result.result.server`
Expand Down
10 changes: 10 additions & 0 deletions public/measurements.vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ const app = () => ({
query.resolver = this.query.query.resolver;
}

if (this.query.query.trace) {
query.trace = !!this.query.query.trace;
}

if (Object.keys(query).length > 0) {
measurement.query = query;
}
Expand Down Expand Up @@ -250,6 +254,12 @@ const app = () => ({
</select>
</div>
</div>
<div v-if="query.type === 'dns'" class="form-group row">
<label for="query_dns_type" class="col-sm-2 col-form-label">trace</label>
<div class="col-sm-10">
<input type="checkbox" v-model="query.query.trace" >
</div>
</div>
<div v-if="query.type === 'dns'" class="form-group row">
<label for="query_dns_type" class="col-sm-2 col-form-label">dns type</label>
<div class="col-sm-10">
Expand Down
1 change: 1 addition & 0 deletions src/measurement/schema/command-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ export const dnsSchema = Joi.object({
resolver: Joi.string().ip().custom(joiMalwareValidateIp),
protocol: Joi.string().valid(...allowedProtocols).insensitive().default('UDP'),
port: Joi.number().default('53'),
trace: Joi.boolean().default(false),
}).default({}),
});
21 changes: 21 additions & 0 deletions test/tests/unit/measurement/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,26 @@ describe('command schema', () => {
expect(valid.error).to.exist;
});

it('should pass (trace enabled)', async () => {
const input = {
type: 'dns',
target: 'abc.com',
query: {
trace: true,
type: 'a',
protocol: 'tcp',
},
};

const valid = dnsSchema.validate(input);

expect(valid.error).to.not.exist;
expect(valid.value.type).to.equal('dns');
expect(valid.value.query.trace).to.equal(true);
expect(valid.value.query.protocol).to.equal('TCP');
expect(valid.value.query.type).to.equal('A');
});

it('should pass and correct values (incorrect caps)', async () => {
const input = {
type: 'DNS',
Expand All @@ -254,6 +274,7 @@ describe('command schema', () => {
target: 'abc.com',
query: {
type: 'A',
trace: false,
resolver: '1.1.1.1',
protocol: 'UDP',
port: 53,
Expand Down

0 comments on commit e5826da

Please sign in to comment.