forked from juliangiuca/whoisjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fork. Fix network by socket. Fix irnic. Rename.
- Loading branch information
0 parents
commit f1e525c
Showing
31 changed files
with
1,293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# WhoisJS | ||
|
||
A WHOIS module for Node.js written in CoffeeScript. WhoisJS is able to perform lookups on over 200 TLDs. | ||
|
||
This is a fork of https://github.com/juliangiuca/whoisjs with some fixes. | ||
Maybe some of TLDs need review, I just checked .com .org .ir .net, But other TLDs should work as well, If you see any issues send them here: https://github.com/mort3za/domaincheck/issues | ||
|
||
## Requirements | ||
This library has been tested with Node.JS 6.2.2 | ||
|
||
## How to Install | ||
$ npm install whoisjs | ||
|
||
## How to Use | ||
``` | ||
DomainCheck = require('domaincheck').whois | ||
who = new DomainCheck() | ||
domain = "wikipedia.org" | ||
who.query domain, (response) -> | ||
state = "available" if response.available() | ||
state = "unavailable" if response.unavailable() | ||
state = "timeout" if response.timeout() | ||
state = "error" if response.error() | ||
state ||= "unknown" | ||
callback(domain, state); | ||
``` | ||
|
||
## How to debug | ||
#### Show me the whois response already! | ||
From the above, `response.raw` contains the response data from the Whois server. console.log it, and see what's happening. | ||
|
||
The `lib/whois/server/adapters` files describe how the response is interpreted via the `positive()`, `negative()`, and `error()` functions. | ||
If you notice the responses aren't being registered correctly, please file and issue or send a pull request. | ||
|
||
## License | ||
WhoisJS is released under the MIT license. | ||
|
||
## Credit | ||
WhoisJS is inspired by [Ruby Whois](https://github.com/weppos/whois) | ||
|
||
## Author | ||
[Julian Giuca](mailto:[email protected]). | ||
|
||
## Maintainer | ||
[Morteza Ziaeemehr](mailto:[email protected]). | ||
|
||
Please feel free to contact me with any questions, tips, or suggestions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class Answer | ||
constructor: (negative_regex, positive_regex, error_regex) -> | ||
# console.log 'positive_regex', positive_regex | ||
# console.log 'negative_regex', negative_regex | ||
# console.log 'error_regex', error_regex | ||
this.nRegex = new RegExp(negative_regex, 'i') | ||
this.pRegex = new RegExp(positive_regex, 'i') | ||
this.eRegex = new RegExp(error_regex, 'i') | ||
this.raw = new Array | ||
|
||
isAvailable: -> | ||
result = false | ||
if this.raw | ||
if this.raw == "timeout" | ||
this.reason = "timeout" | ||
else if this.error() | ||
this.reason = "error" | ||
else if this.positive() | ||
this.reason = "Domain taken!" | ||
else | ||
result = !this.positive() and this.negative() | ||
|
||
return result | ||
|
||
available: -> | ||
!this.positive() and !this.error() and this.negative() | ||
|
||
unavailable: -> | ||
this.positive() and !this.negative() and !this.error() | ||
|
||
timeout: -> | ||
this.raw == "timeout" | ||
|
||
positive: -> | ||
!!this.raw.match(this.pRegex) | ||
|
||
negative: -> | ||
!!this.raw.match(this.nRegex) | ||
|
||
error: -> | ||
!!this.raw.match(this.eRegex) || this.raw == "error" | ||
|
||
exports.answer = Answer |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Client | ||
require("./definitions/tlds") | ||
|
||
lookup: (domain, callback, server) -> | ||
console.log 'Matched server:', server | ||
console.log 'domain', domain | ||
if not server | ||
callback({validation: false, message: 'Top Level Domain not supported.'}) | ||
else | ||
server = server[1] | ||
# console.log 'server:', server, server.lookup | ||
server.lookup domain, (response) -> | ||
# console.log response | ||
callback(response) | ||
|
||
exports.client = Client |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.