Skip to content

Commit

Permalink
Fork. Fix network by socket. Fix irnic. Rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
mort3za committed Jul 10, 2016
0 parents commit f1e525c
Show file tree
Hide file tree
Showing 31 changed files with 1,293 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
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.
43 changes: 43 additions & 0 deletions lib/whois/answer.coffee
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
57 changes: 57 additions & 0 deletions lib/whois/answer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions lib/whois/client.coffee
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
29 changes: 29 additions & 0 deletions lib/whois/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f1e525c

Please sign in to comment.