| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a1af6fc commit fa0457e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,6 +189,9 @@ exports.lookupService = function(host, port, callback) { | |||
| 189 | 189 | if (cares.isIP(host) === 0) | |
| 190 | 190 | throw new TypeError('host needs to be a valid IP address'); | |
| 191 | 191 | ||
| 192 | + if (typeof port !== 'number') | ||
| 193 | + throw new TypeError(`port argument must be a number, got "${port}"`); | ||
| 194 | + | ||
| 192 | 195 | callback = makeAsync(callback); | |
| 193 | 196 | ||
| 194 | 197 | var req = new GetNameInfoReqWrap(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -145,3 +145,19 @@ assert.doesNotThrow(function() { | |||
| 145 | 145 | hints: dns.ADDRCONFIG | dns.V4MAPPED | |
| 146 | 146 | }, noop); | |
| 147 | 147 | }); | |
| 148 | + | ||
| 149 | + assert.throws(function() { | ||
| 150 | + dns.lookupService('0.0.0.0'); | ||
| 151 | + }, /invalid arguments/); | ||
| 152 | + | ||
| 153 | + assert.throws(function() { | ||
| 154 | + dns.lookupService('fasdfdsaf', 0, noop); | ||
| 155 | + }, /host needs to be a valid IP address/); | ||
| 156 | + | ||
| 157 | + assert.throws(function() { | ||
| 158 | + dns.lookupService('0.0.0.0', '0', noop); | ||
| 159 | + }, /port argument must be a number, got "0"/); | ||
| 160 | + | ||
| 161 | + assert.doesNotThrow(function() { | ||
| 162 | + dns.lookupService('0.0.0.0', 0, noop); | ||
| 163 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments