This commit is contained in:
Philipp Kunz 2016-11-15 22:40:40 +01:00
parent 04733a5f52
commit 700ab08315
11 changed files with 38 additions and 166 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
node_modules/ node_modules/
pages/ pages/
public/ public/
coverage/

File diff suppressed because one or more lines are too long

View File

@ -1,80 +0,0 @@
TN:
SF:/Users/philkunz/gitlab/pushrocks/dnsly/dist/index.js
FN:3,(anonymous_1)
FN:3,defineProperties
FN:3,(anonymous_3)
FN:5,_classCallCheck
FN:13,(anonymous_5)
FN:17,Dnsly
FN:30,getRecord
FN:37,(anonymous_8)
FN:51,close
FN:60,_setDnsProvider
FNF:10
FNH:10
FNDA:1,(anonymous_1)
FNDA:1,defineProperties
FNDA:1,(anonymous_3)
FNDA:2,_classCallCheck
FNDA:1,(anonymous_5)
FNDA:2,Dnsly
FNDA:3,getRecord
FNDA:3,(anonymous_8)
FNDA:2,close
FNDA:2,_setDnsProvider
DA:3,3
DA:5,2
DA:7,1
DA:8,1
DA:13,1
DA:17,1
DA:18,2
DA:20,2
DA:21,2
DA:28,1
DA:31,3
DA:32,3
DA:38,3
DA:39,0
DA:41,3
DA:43,3
DA:52,2
DA:61,2
DA:62,2
DA:63,2
DA:65,0
DA:70,1
DA:73,1
LF:23
LH:21
BRDA:3,1,0,3
BRDA:3,1,1,3
BRDA:3,2,0,3
BRDA:3,2,1,0
BRDA:3,3,0,1
BRDA:3,3,1,0
BRDA:3,4,0,0
BRDA:3,4,1,1
BRDA:5,5,0,0
BRDA:5,5,1,2
BRDA:38,6,0,0
BRDA:38,6,1,3
BRDA:61,7,0,2
BRDA:61,7,1,0
BRF:14
BRH:8
end_of_record
TN:
SF:/Users/philkunz/gitlab/pushrocks/dnsly/dist/dnsly.plugins.js
FNF:0
FNH:0
DA:3,1
DA:4,1
DA:5,1
DA:6,1
DA:7,1
LF:5
LH:5
BRF:0
BRH:0
end_of_record

View File

@ -1,4 +1,4 @@
import 'typings-global'; import 'typings-global';
import * as beautylog from 'beautylog'; import * as beautylog from 'beautylog';
declare let dnsSocket: any; import * as dns from 'dns';
export { beautylog, dnsSocket }; export { beautylog, dns };

View File

@ -2,6 +2,6 @@
require("typings-global"); require("typings-global");
const beautylog = require("beautylog"); const beautylog = require("beautylog");
exports.beautylog = beautylog; exports.beautylog = beautylog;
let dnsSocket = require('dns-socket'); const dns = require("dns");
exports.dnsSocket = dnsSocket; exports.dns = dns;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG5zbHkucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2Ruc2x5LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2Qix1Q0FBc0M7QUFJbEMsOEJBQVM7QUFIYixJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUE7QUFJakMsOEJBQVMifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG5zbHkucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2Ruc2x5LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2Qix1Q0FBc0M7QUFJbEMsOEJBQVM7QUFIYiwyQkFBMEI7QUFJdEIsa0JBQUcifQ==

5
dist/index.d.ts vendored
View File

@ -8,7 +8,6 @@ export declare type TDnsRecordType = 'A' | 'AAAA' | 'CNAME' | 'PTR' | 'MX' | 'NA
export declare class Dnsly { export declare class Dnsly {
dnsServerIp: string; dnsServerIp: string;
dnsServerPort: number; dnsServerPort: number;
dnsSocketInstance: any;
/** /**
* constructor for class dnsly * constructor for class dnsly
*/ */
@ -17,10 +16,6 @@ export declare class Dnsly {
* gets a record * gets a record
*/ */
getRecord(recordNameArg: string, recordTypeArg: TDnsRecordType): q.Promise<{}>; getRecord(recordNameArg: string, recordTypeArg: TDnsRecordType): q.Promise<{}>;
/**
* close the dnsly instance
*/
close(): void;
/** /**
* set the DNS provider * set the DNS provider
*/ */

19
dist/index.js vendored
View File

@ -10,32 +10,20 @@ class Dnsly {
*/ */
constructor(dnsProviderArg) { constructor(dnsProviderArg) {
this._setDnsProvider(dnsProviderArg); this._setDnsProvider(dnsProviderArg);
this.dnsSocketInstance = plugins.dnsSocket();
} }
/** /**
* gets a record * gets a record
*/ */
getRecord(recordNameArg, recordTypeArg) { getRecord(recordNameArg, recordTypeArg) {
let done = q.defer(); let done = q.defer();
this.dnsSocketInstance.query({ plugins.dns.resolve(recordNameArg, recordTypeArg, (err, addresses) => {
questions: [{
type: recordTypeArg,
name: recordNameArg
}]
}, this.dnsServerPort, this.dnsServerIp, (err, res) => {
if (err) { if (err) {
done.reject(err); done.reject(err);
} }
done.resolve(res); done.resolve(addresses);
}); });
return done.promise; return done.promise;
} }
/**
* close the dnsly instance
*/
close() {
this.dnsSocketInstance.destroy();
}
/** /**
* set the DNS provider * set the DNS provider
*/ */
@ -43,6 +31,7 @@ class Dnsly {
if (dnsProvider === 'google') { if (dnsProvider === 'google') {
this.dnsServerIp = '8.8.8.8'; this.dnsServerIp = '8.8.8.8';
this.dnsServerPort = 53; this.dnsServerPort = 53;
plugins.dns.setServers(['8.8.8.8', '8.8.4.4']);
} }
else { else {
throw new Error('unknown dns provider'); throw new Error('unknown dns provider');
@ -50,4 +39,4 @@ class Dnsly {
} }
} }
exports.Dnsly = Dnsly; exports.Dnsly = Dnsly;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsdUJBQXNCO0FBQ3RCLDJDQUEwQztBQWMxQzs7R0FFRztBQUNIO0lBS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7UUFDN0MsRUFBRSxDQUFDLENBQUMsV0FBVyxLQUFLLFFBQVEsQ0FBQyxDQUFDLENBQUM7WUFDM0IsSUFBSSxDQUFDLFdBQVcsR0FBRyxTQUFTLENBQUE7WUFDNUIsSUFBSSxDQUFDLGFBQWEsR0FBRyxFQUFFLENBQUE7WUFDdkIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsQ0FBQyxTQUFTLEVBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQTtRQUNqRCxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixNQUFNLElBQUksS0FBSyxDQUFDLHNCQUFzQixDQUFDLENBQUE7UUFDM0MsQ0FBQztJQUNMLENBQUM7Q0FDSjtBQXBDRCxzQkFvQ0MifQ==

View File

@ -8,7 +8,7 @@ describe('dnsly', function () {
testDnsly = new dnsly.Dnsly('google'); testDnsly = new dnsly.Dnsly('google');
should(testDnsly).be.instanceOf(dnsly.Dnsly); should(testDnsly).be.instanceOf(dnsly.Dnsly);
}); });
it('should, get a dns record for a domain when called quickly', function (done) { it('should, get a dns record for a domain', function (done) {
testDnsly.getRecord('google.com', 'A').then(res => { testDnsly.getRecord('google.com', 'A').then(res => {
console.log(res); console.log(res);
done(); done();
@ -17,33 +17,14 @@ describe('dnsly', function () {
done(err); done(err);
}); });
}); });
it('should, get a dns record for a domain when called with timeout', function (done) { it('should, get a mx record for a domain', function (done) {
setTimeout(() => { testDnsly.getRecord('google.com', 'MX').then(res => {
testDnsly.getRecord('google.com', 'A').then(res => { console.log(res);
console.log(res); done();
done(); }).catch(err => {
}).catch(err => { console.log(err);
console.log(err); done(err);
done(err); });
});
}, 1000);
});
it('should get a dns record for a domain when called with second instance and timeout', function (done) {
this.timeout(10000);
let testDnsly2 = new dnsly.Dnsly('google');
setTimeout(() => {
testDnsly2.getRecord('google.com', 'MX').then(res => {
console.log(res);
done();
testDnsly2.close();
}).catch(err => {
console.log(err);
done(err);
});
}, 5000);
});
it('should close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xDQUFDLENBQUE7SUFFRixFQUFFLENBQUMsc0NBQXNDLEVBQUUsVUFBVSxJQUFJO1FBQ3JELFNBQVMsQ0FBQyxTQUFTLENBQUMsWUFBWSxFQUFFLElBQUksQ0FBQyxDQUFDLElBQUksQ0FBQyxHQUFHO1lBQzVDLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7WUFDaEIsSUFBSSxFQUFFLENBQUE7UUFDVixDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsR0FBRztZQUNSLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7WUFDaEIsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQ2IsQ0FBQyxDQUFDLENBQUE7SUFFTixDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFBIn0=

View File

@ -22,7 +22,14 @@ describe('dnsly', function () {
}) })
it('should close the instance', function () { it('should, get a mx record for a domain', function (done) {
testDnsly.close() testDnsly.getRecord('google.com', 'MX').then(res => {
console.log(res)
done()
}).catch(err => {
console.log(err)
done(err)
})
}) })
}) })

View File

@ -1,8 +1,8 @@
import 'typings-global' import 'typings-global'
import * as beautylog from 'beautylog' import * as beautylog from 'beautylog'
let dnsSocket = require('dns-socket') import * as dns from 'dns'
export { export {
beautylog, beautylog,
dnsSocket dns
} }

View File

@ -19,13 +19,11 @@ export type TDnsRecordType = 'A'
export class Dnsly { export class Dnsly {
dnsServerIp: string dnsServerIp: string
dnsServerPort: number dnsServerPort: number
dnsSocketInstance
/** /**
* constructor for class dnsly * constructor for class dnsly
*/ */
constructor(dnsProviderArg: TDnsProvider) { constructor(dnsProviderArg: TDnsProvider) {
this._setDnsProvider(dnsProviderArg) this._setDnsProvider(dnsProviderArg)
this.dnsSocketInstance = plugins.dnsSocket()
} }
/** /**
@ -33,31 +31,15 @@ export class Dnsly {
*/ */
getRecord(recordNameArg: string, recordTypeArg: TDnsRecordType) { getRecord(recordNameArg: string, recordTypeArg: TDnsRecordType) {
let done = q.defer() let done = q.defer()
this.dnsSocketInstance.query( plugins.dns.resolve(recordNameArg,recordTypeArg, (err, addresses) => {
{ if (err) {
questions: [{ done.reject(err)
type: recordTypeArg, }
name: recordNameArg done.resolve(addresses)
}] })
},
this.dnsServerPort,
this.dnsServerIp,
(err, res) => {
if (err) {
done.reject(err)
}
done.resolve(res)
})
return done.promise return done.promise
} }
/**
* close the dnsly instance
*/
close() {
this.dnsSocketInstance.destroy()
}
/** /**
* set the DNS provider * set the DNS provider
*/ */
@ -65,6 +47,7 @@ export class Dnsly {
if (dnsProvider === 'google') { if (dnsProvider === 'google') {
this.dnsServerIp = '8.8.8.8' this.dnsServerIp = '8.8.8.8'
this.dnsServerPort = 53 this.dnsServerPort = 53
plugins.dns.setServers(['8.8.8.8','8.8.4.4'])
} else { } else {
throw new Error('unknown dns provider') throw new Error('unknown dns provider')
} }