forked from LittleChest/dns-packet
unify variable name in examples
This commit is contained in:
parent
93b8c3c03b
commit
9446241c41
@ -15,7 +15,7 @@ function getRandomInt (min, max) {
|
|||||||
return Math.floor(Math.random() * (max - min + 1)) + min
|
return Math.floor(Math.random() * (max - min + 1)) + min
|
||||||
}
|
}
|
||||||
|
|
||||||
const encodeddnsPacket = dnsPacket.encode({
|
const buf = dnsPacket.encode({
|
||||||
type: 'query',
|
type: 'query',
|
||||||
id: getRandomInt(1, 65534),
|
id: getRandomInt(1, 65534),
|
||||||
flags: dnsPacket.RECURSION_DESIRED,
|
flags: dnsPacket.RECURSION_DESIRED,
|
||||||
@ -32,7 +32,7 @@ const options = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/dns-udpwireformat',
|
'Content-Type': 'application/dns-udpwireformat',
|
||||||
'Content-Length': Buffer.byteLength(encodeddnsPacket)
|
'Content-Length': Buffer.byteLength(buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,5 +48,5 @@ const request = https.request(options, (response) => {
|
|||||||
request.on('error', (e) => {
|
request.on('error', (e) => {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
})
|
})
|
||||||
request.write(encodeddnsPacket)
|
request.write(buf)
|
||||||
request.end()
|
request.end()
|
||||||
|
|||||||
@ -10,7 +10,7 @@ function getRandomInt (min, max) {
|
|||||||
return Math.floor(Math.random() * (max - min + 1)) + min
|
return Math.floor(Math.random() * (max - min + 1)) + min
|
||||||
}
|
}
|
||||||
|
|
||||||
const encodedPacket = dnsPacket.streamEncode({
|
const buf = dnsPacket.streamEncode({
|
||||||
type: 'query',
|
type: 'query',
|
||||||
id: getRandomInt(1, 65534),
|
id: getRandomInt(1, 65534),
|
||||||
flags: dnsPacket.RECURSION_DESIRED,
|
flags: dnsPacket.RECURSION_DESIRED,
|
||||||
@ -23,7 +23,7 @@ const encodedPacket = dnsPacket.streamEncode({
|
|||||||
const client = new net.Socket()
|
const client = new net.Socket()
|
||||||
client.connect(53, '8.8.8.8', function () {
|
client.connect(53, '8.8.8.8', function () {
|
||||||
console.log('Connected')
|
console.log('Connected')
|
||||||
client.write(encodedPacket)
|
client.write(buf)
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('data', function (data) {
|
client.on('data', function (data) {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ function getRandomInt (min, max) {
|
|||||||
return Math.floor(Math.random() * (max - min + 1)) + min
|
return Math.floor(Math.random() * (max - min + 1)) + min
|
||||||
}
|
}
|
||||||
|
|
||||||
const encodedPacket = dnsPacket.streamEncode({
|
const buf = dnsPacket.streamEncode({
|
||||||
type: 'query',
|
type: 'query',
|
||||||
id: getRandomInt(1, 65534),
|
id: getRandomInt(1, 65534),
|
||||||
flags: dnsPacket.RECURSION_DESIRED,
|
flags: dnsPacket.RECURSION_DESIRED,
|
||||||
@ -32,7 +32,7 @@ const options = {
|
|||||||
|
|
||||||
const client = tls.connect(options, () => {
|
const client = tls.connect(options, () => {
|
||||||
console.log('client connected')
|
console.log('client connected')
|
||||||
client.write(encodedPacket)
|
client.write(buf)
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('data', function (data) {
|
client.on('data', function (data) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user