first commit

This commit is contained in:
monjack
2025-06-20 18:01:48 +08:00
commit 6daa6d65c1
24611 changed files with 2512443 additions and 0 deletions

21
app_vue/node_modules/dns-packet/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Mathias Buus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

402
app_vue/node_modules/dns-packet/README.md generated vendored Normal file
View File

@ -0,0 +1,402 @@
# dns-packet
[![](https://img.shields.io/npm/v/dns-packet.svg?style=flat)](https://www.npmjs.org/package/dns-packet) [![](https://img.shields.io/npm/dm/dns-packet.svg)](https://www.npmjs.org/package/dns-packet) [![](https://github.com/github/mafintosh/dns-packet/workflows/ci.yml/badge.svg)](https://github.com/github/mafintosh/dns-packet/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/mafintosh/dns-packet/badge.svg?branch=master)](https://coveralls.io/github/mafintosh/dns-packet?branch=master)
An [abstract-encoding](https://github.com/mafintosh/abstract-encoding) compliant module for encoding / decoding DNS packets. Lifted out of [multicast-dns](https://github.com/mafintosh/multicast-dns) as a separate module.
```
npm install dns-packet
```
## UDP Usage
``` js
const dnsPacket = require('dns-packet')
const dgram = require('dgram')
const socket = dgram.createSocket('udp4')
const buf = dnsPacket.encode({
type: 'query',
id: 1,
flags: dnsPacket.RECURSION_DESIRED,
questions: [{
type: 'A',
name: 'google.com'
}]
})
socket.on('message', message => {
console.log(dnsPacket.decode(message)) // prints out a response from google dns
})
socket.send(buf, 0, buf.length, 53, '8.8.8.8')
```
Also see [the UDP example](examples/udp.js).
## TCP, TLS, HTTPS
While DNS has traditionally been used over a datagram transport, it is increasingly being carried over TCP for larger responses commonly including DNSSEC responses and TLS or HTTPS for enhanced security. See below examples on how to use `dns-packet` to wrap DNS packets in these protocols:
- [TCP](examples/tcp.js)
- [DNS over TLS](examples/tls.js)
- [DNS over HTTPS](examples/doh.js)
## API
#### `var buf = packets.encode(packet, [buf], [offset])`
Encodes a DNS packet into a buffer containing a UDP payload.
#### `var packet = packets.decode(buf, [offset])`
Decode a DNS packet from a buffer containing a UDP payload.
#### `var buf = packets.streamEncode(packet, [buf], [offset])`
Encodes a DNS packet into a buffer containing a TCP payload.
#### `var packet = packets.streamDecode(buf, [offset])`
Decode a DNS packet from a buffer containing a TCP payload.
#### `var len = packets.encodingLength(packet)`
Returns how many bytes are needed to encode the DNS packet
## Packets
Packets look like this
``` js
{
type: 'query|response',
id: optionalIdNumber,
flags: optionalBitFlags,
questions: [...],
answers: [...],
additionals: [...],
authorities: [...]
}
```
The bit flags available are
``` js
packet.RECURSION_DESIRED
packet.RECURSION_AVAILABLE
packet.TRUNCATED_RESPONSE
packet.AUTHORITATIVE_ANSWER
packet.AUTHENTIC_DATA
packet.CHECKING_DISABLED
```
To use more than one flag bitwise-or them together
``` js
var flags = packet.RECURSION_DESIRED | packet.RECURSION_AVAILABLE
```
And to check for a flag use bitwise-and
``` js
var isRecursive = message.flags & packet.RECURSION_DESIRED
```
A question looks like this
``` js
{
type: 'A', // or SRV, AAAA, etc
class: 'IN', // one of IN, CS, CH, HS, ANY. Default: IN
name: 'google.com' // which record are you looking for
}
```
And an answer, additional, or authority looks like this
``` js
{
type: 'A', // or SRV, AAAA, etc
class: 'IN', // one of IN, CS, CH, HS
name: 'google.com', // which name is this record for
ttl: optionalTimeToLiveInSeconds,
(record specific data, see below)
}
```
## Supported record types
#### `A`
``` js
{
data: 'IPv4 address' // fx 127.0.0.1
}
```
#### `AAAA`
``` js
{
data: 'IPv6 address' // fx fe80::1
}
```
#### `CAA`
``` js
{
flags: 128, // octet
tag: 'issue|issuewild|iodef',
value: 'ca.example.net',
issuerCritical: false
}
```
#### `CNAME`
``` js
{
data: 'cname.to.another.record'
}
```
#### `DNAME`
``` js
{
data: 'dname.to.another.record'
}
```
#### `DNSKEY`
``` js
{
flags: 257, // 16 bits
algorithm: 1, // octet
key: Buffer
}
```
#### `DS`
``` js
{
keyTag: 12345,
algorithm: 8,
digestType: 1,
digest: Buffer
}
```
#### `HINFO`
``` js
{
data: {
cpu: 'cpu info',
os: 'os info'
}
}
```
#### `MX`
``` js
{
preference: 10,
exchange: 'mail.example.net'
}
```
#### `NAPTR`
``` js
{
data:
{
order: 100,
preference: 10,
flags: 's',
services: 'SIP+D2U',
regexp: '!^.*$!sip:customer-service@example.com!',
replacement: '_sip._udp.example.com'
}
}
```
#### `NS`
``` js
{
data: nameServer
}
```
#### `NSEC`
``` js
{
nextDomain: 'a.domain',
rrtypes: ['A', 'TXT', 'RRSIG']
}
```
#### `NSEC3`
``` js
{
algorithm: 1,
flags: 0,
iterations: 2,
salt: Buffer,
nextDomain: Buffer, // Hashed per RFC5155
rrtypes: ['A', 'TXT', 'RRSIG']
}
```
#### `NULL`
``` js
{
data: Buffer('any binary data')
}
```
#### `OPT`
[EDNS0](https://tools.ietf.org/html/rfc6891) options.
``` js
{
type: 'OPT',
name: '.',
udpPayloadSize: 4096,
flags: packet.DNSSEC_OK,
options: [{
// pass in any code/data for generic EDNS0 options
code: 12,
data: Buffer.alloc(31)
}, {
// Several EDNS0 options have enhanced support
code: 'PADDING',
length: 31,
}, {
code: 'CLIENT_SUBNET',
family: 2, // 1 for IPv4, 2 for IPv6
sourcePrefixLength: 64, // used to truncate IP address
scopePrefixLength: 0,
ip: 'fe80::',
}, {
code: 'TCP_KEEPALIVE',
timeout: 150 // increments of 100ms. This means 15s.
}, {
code: 'KEY_TAG',
tags: [1, 2, 3],
}]
}
```
The options `PADDING`, `CLIENT_SUBNET`, `TCP_KEEPALIVE` and `KEY_TAG` support enhanced de/encoding. See [optionscodes.js](https://github.com/mafintosh/dns-packet/blob/master/optioncodes.js) for all supported option codes. If the `data` property is present on a option, it takes precedence. On decoding, `data` will always be defined.
#### `PTR`
``` js
{
data: 'points.to.another.record'
}
```
#### `RP`
``` js
{
mbox: 'admin.example.com',
txt: 'txt.example.com'
}
```
#### `SSHFP`
``` js
{
algorithm: 1,
hash: 1,
fingerprint: 'A108C9F834354D5B37AF988141C9294822F5BC00'
}
````
#### `RRSIG`
``` js
{
typeCovered: 'A',
algorithm: 8,
labels: 1,
originalTTL: 3600,
expiration: timestamp,
inception: timestamp,
keyTag: 12345,
signersName: 'a.name',
signature: Buffer
}
```
#### `SOA`
``` js
{
data:
{
mname: domainName,
rname: mailbox,
serial: zoneSerial,
refresh: refreshInterval,
retry: retryInterval,
expire: expireInterval,
minimum: minimumTTL
}
}
```
#### `SRV`
``` js
{
data: {
port: servicePort,
target: serviceHostName,
priority: optionalServicePriority,
weight: optionalServiceWeight
}
}
```
#### `TLSA`
``` js
{
usage: 3,
selector: 1,
matchingType: 1,
certificate: Buffer
}
```
#### `TXT`
``` js
{
data: 'text' || Buffer || [ Buffer || 'text' ]
}
```
When encoding, scalar values are converted to an array and strings are converted to UTF-8 encoded Buffers. When decoding, the return value will always be an array of Buffer.
If you need another record type, open an issue and we'll try to add it.
## License
MIT

23
app_vue/node_modules/dns-packet/classes.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
'use strict'
exports.toString = function (klass) {
switch (klass) {
case 1: return 'IN'
case 2: return 'CS'
case 3: return 'CH'
case 4: return 'HS'
case 255: return 'ANY'
}
return 'UNKNOWN_' + klass
}
exports.toClass = function (name) {
switch (name.toUpperCase()) {
case 'IN': return 1
case 'CS': return 2
case 'CH': return 3
case 'HS': return 4
case 'ANY': return 255
}
return 0
}

1761
app_vue/node_modules/dns-packet/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

50
app_vue/node_modules/dns-packet/opcodes.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
'use strict'
/*
* Traditional DNS header OPCODEs (4-bits) defined by IANA in
* https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-5
*/
exports.toString = function (opcode) {
switch (opcode) {
case 0: return 'QUERY'
case 1: return 'IQUERY'
case 2: return 'STATUS'
case 3: return 'OPCODE_3'
case 4: return 'NOTIFY'
case 5: return 'UPDATE'
case 6: return 'OPCODE_6'
case 7: return 'OPCODE_7'
case 8: return 'OPCODE_8'
case 9: return 'OPCODE_9'
case 10: return 'OPCODE_10'
case 11: return 'OPCODE_11'
case 12: return 'OPCODE_12'
case 13: return 'OPCODE_13'
case 14: return 'OPCODE_14'
case 15: return 'OPCODE_15'
}
return 'OPCODE_' + opcode
}
exports.toOpcode = function (code) {
switch (code.toUpperCase()) {
case 'QUERY': return 0
case 'IQUERY': return 1
case 'STATUS': return 2
case 'OPCODE_3': return 3
case 'NOTIFY': return 4
case 'UPDATE': return 5
case 'OPCODE_6': return 6
case 'OPCODE_7': return 7
case 'OPCODE_8': return 8
case 'OPCODE_9': return 9
case 'OPCODE_10': return 10
case 'OPCODE_11': return 11
case 'OPCODE_12': return 12
case 'OPCODE_13': return 13
case 'OPCODE_14': return 14
case 'OPCODE_15': return 15
}
return 0
}

59
app_vue/node_modules/dns-packet/optioncodes.js generated vendored Normal file
View File

@ -0,0 +1,59 @@
'use strict'
exports.toString = function (type) {
switch (type) {
// list at
// https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-11
case 1: return 'LLQ'
case 2: return 'UL'
case 3: return 'NSID'
case 5: return 'DAU'
case 6: return 'DHU'
case 7: return 'N3U'
case 8: return 'CLIENT_SUBNET'
case 9: return 'EXPIRE'
case 10: return 'COOKIE'
case 11: return 'TCP_KEEPALIVE'
case 12: return 'PADDING'
case 13: return 'CHAIN'
case 14: return 'KEY_TAG'
case 26946: return 'DEVICEID'
}
if (type < 0) {
return null
}
return `OPTION_${type}`
}
exports.toCode = function (name) {
if (typeof name === 'number') {
return name
}
if (!name) {
return -1
}
switch (name.toUpperCase()) {
case 'OPTION_0': return 0
case 'LLQ': return 1
case 'UL': return 2
case 'NSID': return 3
case 'OPTION_4': return 4
case 'DAU': return 5
case 'DHU': return 6
case 'N3U': return 7
case 'CLIENT_SUBNET': return 8
case 'EXPIRE': return 9
case 'COOKIE': return 10
case 'TCP_KEEPALIVE': return 11
case 'PADDING': return 12
case 'CHAIN': return 13
case 'KEY_TAG': return 14
case 'DEVICEID': return 26946
case 'OPTION_65535': return 65535
}
const m = name.match(/_(\d+)$/)
if (m) {
return parseInt(m[1], 10)
}
return -1
}

47
app_vue/node_modules/dns-packet/package.json generated vendored Normal file
View File

@ -0,0 +1,47 @@
{
"name": "dns-packet",
"version": "5.6.1",
"description": "An abstract-encoding compliant module for encoding / decoding DNS packets",
"author": "Mathias Buus",
"license": "MIT",
"repository": "mafintosh/dns-packet",
"homepage": "https://github.com/mafintosh/dns-packet",
"engines": {
"node": ">=6"
},
"scripts": {
"clean": "rm -rf coverage .nyc_output/",
"lint": "eslint --color *.js examples/*.js",
"pretest": "npm run lint",
"test": "tape test.js",
"coverage": "nyc -r html npm test"
},
"dependencies": {
"@leichtgewicht/ip-codec": "^2.0.1"
},
"devDependencies": {
"eslint": "^5.14.1",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"tape": "^4.10.1"
},
"keywords": [
"dns",
"packet",
"encodings",
"encoding",
"encoder",
"abstract-encoding"
],
"files": [
"index.js",
"types.js",
"rcodes.js",
"opcodes.js",
"classes.js",
"optioncodes.js"
]
}

50
app_vue/node_modules/dns-packet/rcodes.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
'use strict'
/*
* Traditional DNS header RCODEs (4-bits) defined by IANA in
* https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml
*/
exports.toString = function (rcode) {
switch (rcode) {
case 0: return 'NOERROR'
case 1: return 'FORMERR'
case 2: return 'SERVFAIL'
case 3: return 'NXDOMAIN'
case 4: return 'NOTIMP'
case 5: return 'REFUSED'
case 6: return 'YXDOMAIN'
case 7: return 'YXRRSET'
case 8: return 'NXRRSET'
case 9: return 'NOTAUTH'
case 10: return 'NOTZONE'
case 11: return 'RCODE_11'
case 12: return 'RCODE_12'
case 13: return 'RCODE_13'
case 14: return 'RCODE_14'
case 15: return 'RCODE_15'
}
return 'RCODE_' + rcode
}
exports.toRcode = function (code) {
switch (code.toUpperCase()) {
case 'NOERROR': return 0
case 'FORMERR': return 1
case 'SERVFAIL': return 2
case 'NXDOMAIN': return 3
case 'NOTIMP': return 4
case 'REFUSED': return 5
case 'YXDOMAIN': return 6
case 'YXRRSET': return 7
case 'NXRRSET': return 8
case 'NOTAUTH': return 9
case 'NOTZONE': return 10
case 'RCODE_11': return 11
case 'RCODE_12': return 12
case 'RCODE_13': return 13
case 'RCODE_14': return 14
case 'RCODE_15': return 15
}
return 0
}

103
app_vue/node_modules/dns-packet/types.js generated vendored Normal file
View File

@ -0,0 +1,103 @@
'use strict'
exports.toString = function (type) {
switch (type) {
case 1: return 'A'
case 10: return 'NULL'
case 28: return 'AAAA'
case 18: return 'AFSDB'
case 42: return 'APL'
case 257: return 'CAA'
case 60: return 'CDNSKEY'
case 59: return 'CDS'
case 37: return 'CERT'
case 5: return 'CNAME'
case 49: return 'DHCID'
case 32769: return 'DLV'
case 39: return 'DNAME'
case 48: return 'DNSKEY'
case 43: return 'DS'
case 55: return 'HIP'
case 13: return 'HINFO'
case 45: return 'IPSECKEY'
case 25: return 'KEY'
case 36: return 'KX'
case 29: return 'LOC'
case 15: return 'MX'
case 35: return 'NAPTR'
case 2: return 'NS'
case 47: return 'NSEC'
case 50: return 'NSEC3'
case 51: return 'NSEC3PARAM'
case 12: return 'PTR'
case 46: return 'RRSIG'
case 17: return 'RP'
case 24: return 'SIG'
case 6: return 'SOA'
case 99: return 'SPF'
case 33: return 'SRV'
case 44: return 'SSHFP'
case 32768: return 'TA'
case 249: return 'TKEY'
case 52: return 'TLSA'
case 250: return 'TSIG'
case 16: return 'TXT'
case 252: return 'AXFR'
case 251: return 'IXFR'
case 41: return 'OPT'
case 255: return 'ANY'
}
return 'UNKNOWN_' + type
}
exports.toType = function (name) {
switch (name.toUpperCase()) {
case 'A': return 1
case 'NULL': return 10
case 'AAAA': return 28
case 'AFSDB': return 18
case 'APL': return 42
case 'CAA': return 257
case 'CDNSKEY': return 60
case 'CDS': return 59
case 'CERT': return 37
case 'CNAME': return 5
case 'DHCID': return 49
case 'DLV': return 32769
case 'DNAME': return 39
case 'DNSKEY': return 48
case 'DS': return 43
case 'HIP': return 55
case 'HINFO': return 13
case 'IPSECKEY': return 45
case 'KEY': return 25
case 'KX': return 36
case 'LOC': return 29
case 'MX': return 15
case 'NAPTR': return 35
case 'NS': return 2
case 'NSEC': return 47
case 'NSEC3': return 50
case 'NSEC3PARAM': return 51
case 'PTR': return 12
case 'RRSIG': return 46
case 'RP': return 17
case 'SIG': return 24
case 'SOA': return 6
case 'SPF': return 99
case 'SRV': return 33
case 'SSHFP': return 44
case 'TA': return 32768
case 'TKEY': return 249
case 'TLSA': return 52
case 'TSIG': return 250
case 'TXT': return 16
case 'AXFR': return 252
case 'IXFR': return 251
case 'OPT': return 41
case 'ANY': return 255
case '*': return 255
}
if (name.toUpperCase().startsWith('UNKNOWN_')) return parseInt(name.slice(8))
return 0
}