List of usage examples for org.apache.commons.net.whois WhoisClient DEFAULT_HOST
String DEFAULT_HOST
To view the source code for org.apache.commons.net.whois WhoisClient DEFAULT_HOST.
Click Source Link
From source file:examples.unix.fwhois.java
public static void main(String[] args) { int index;//from ww w .j a v a 2s. c om String handle, host; InetAddress address = null; WhoisClient whois; if (args.length != 1) { System.err.println("usage: fwhois handle[@<server>]"); System.exit(1); } index = args[0].lastIndexOf("@"); whois = new WhoisClient(); // We want to timeout if a response takes longer than 60 seconds whois.setDefaultTimeout(60000); if (index == -1) { handle = args[0]; host = WhoisClient.DEFAULT_HOST; } else { handle = args[0].substring(0, index); host = args[0].substring(index + 1); } try { address = InetAddress.getByName(host); System.out.println("[" + address.getHostName() + "]"); } catch (UnknownHostException e) { System.err.println("Error unknown host: " + e.getMessage()); System.exit(1); } try { whois.connect(address); System.out.print(whois.query(handle)); whois.disconnect(); } catch (IOException e) { System.err.println("Error I/O exception: " + e.getMessage()); System.exit(1); } }
From source file:examples.fwhois.java
public static final void main(String[] args) { int index;/*w w w . jav a2 s . c om*/ String handle, host; InetAddress address = null; WhoisClient whois; if (args.length != 1) { System.err.println("usage: fwhois handle[@<server>]"); System.exit(1); } index = args[0].lastIndexOf("@"); whois = new WhoisClient(); // We want to timeout if a response takes longer than 60 seconds whois.setDefaultTimeout(60000); if (index == -1) { handle = args[0]; host = WhoisClient.DEFAULT_HOST; } else { handle = args[0].substring(0, index); host = args[0].substring(index + 1); } try { address = InetAddress.getByName(host); } catch (UnknownHostException e) { System.err.println("Error unknown host: " + e.getMessage()); System.exit(1); } System.out.println("[" + address.getHostName() + "]"); try { whois.connect(address); System.out.print(whois.query(handle)); whois.disconnect(); } catch (IOException e) { System.err.println("Error I/O exception: " + e.getMessage()); System.exit(1); } }
From source file:com.thunder.network.WhoisCommand.java
@Override public void runCommand(final String host, final OnPartialResultListener listener) { new Thread(new Runnable() { @Override//w w w .j a v a 2s . co m public void run() { StringBuilder result = new StringBuilder(""); WhoisClient whois = new WhoisClient(); try { whois.connect(WhoisClient.DEFAULT_HOST); String whoisData1 = whois.query("=" + host); result.append(whoisData1); listener.onPartialResult(result.toString()); listener.onFinish(); whois.disconnect(); } catch (IOException e) { e.printStackTrace(); listener.onError(e); } } }).start(); }
From source file:com.ecrimebureau.Web.Entity.WhoisS.java
public String getWhois(String domainName) { StringBuilder result = new StringBuilder(""); WhoisClient whois = new WhoisClient(); try {//w ww . ja va2 s .co m whois.connect(WhoisClient.DEFAULT_HOST); // whois =google.com String whoisData1 = whois.query("=" + domainName); // append first result result.append(whoisData1); whois.disconnect(); // get the google.com whois server - whois.markmonitor.com String whoisServerUrl = getWhoisServer(whoisData1); if (!whoisServerUrl.equals("")) { // whois -h whois.markmonitor.com google.com String whoisData2 = queryWithWhoisServer(domainName, whoisServerUrl); // append 2nd result result.append(whoisData2); } } catch (SocketException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return result.toString(); }
From source file:com.vish.phishDetect.Web_Utilities.java
public static int domainAge(String domainName) { StringBuilder whoisResult = new StringBuilder(""); WhoisClient crunchifyWhois = new WhoisClient(); try {/*from www. j av a2 s .com*/ // The WhoisClient class implements the client side of the Internet // Whois Protocol defined in RFC 954. To query a host you create a // WhoisClient instance, connect to the host, query the host, and // finally disconnect from the host. If the whois service you want // to query is on a non-standard port, connect to the host at that // port. crunchifyWhois.connect(WhoisClient.DEFAULT_HOST); String whoisData = crunchifyWhois.query("=" + domainName); whoisResult.append(whoisData); crunchifyWhois.disconnect(); } catch (SocketException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } String patternString1 = "No\\smatch\\sfor"; Pattern pattern = Pattern.compile(patternString1); Matcher matcher = pattern.matcher(whoisResult); if (!matcher.find()) { System.out.println(domainName + "\n" + whoisResult); } return 0;//whoisResult.toString(); }
From source file:com.k42b3.aletheia.protocol.whois.WhoisProtocol.java
public void run() { try {/* www. j av a 2 s . co m*/ String tld = getTld(request.getUrl()); String server; if (list.containsKey(tld)) { server = list.get(tld); } else { server = WhoisClient.DEFAULT_HOST; } // connect whois.connect(server); /*whois.addProtocolCommandListener(new ProtocolCommandListener(){ public void protocolCommandSent(ProtocolCommandEvent e) { //stringRequest+= e.getCommand() + "\n"; } public void protocolReplyReceived(ProtocolCommandEvent e) { //stringResponse+= e.getCommand() + "\n"; } });*/ // send query String response = whois.query(request.getUrl().getHost()); // create response this.request.setContent(stringRequest); this.response = new Response(response); // call callback callback.onResponse(this.request, this.response); } catch (Exception e) { Aletheia.handleException(e); } finally { // disconnect try { whois.disconnect(); } catch (IOException e) { Aletheia.handleException(e); } } }
From source file:org.apache.common.net.examples.unix.fwhois.java
public static final void main(String[] args) { int index;//from w w w. ja va 2s . c om String handle, host; InetAddress address = null; WhoisClient whois; if (args.length != 1) { System.err.println("usage: fwhois handle[@<server>]"); System.exit(1); } index = args[0].lastIndexOf("@"); whois = new WhoisClient(); // We want to timeout if a response takes longer than 60 seconds whois.setDefaultTimeout(60000); if (index == -1) { handle = args[0]; host = WhoisClient.DEFAULT_HOST; } else { handle = args[0].substring(0, index); host = args[0].substring(index + 1); } try { address = InetAddress.getByName(host); System.out.println("[" + address.getHostName() + "]"); } catch (UnknownHostException e) { System.err.println("Error unknown host: " + e.getMessage()); System.exit(1); } try { whois.connect(address); System.out.print(whois.query(handle)); whois.disconnect(); } catch (IOException e) { System.err.println("Error I/O exception: " + e.getMessage()); System.exit(1); } }
From source file:org.apache.commons.net.examples.unix.fwhois.java
public static void main(String[] args) { int index;// w ww. ja v a2 s. c om String handle, host; InetAddress address = null; WhoisClient whois; if (args.length != 1) { System.err.println("usage: fwhois handle[@<server>]"); System.exit(1); } index = args[0].lastIndexOf('@'); whois = new WhoisClient(); // We want to timeout if a response takes longer than 60 seconds whois.setDefaultTimeout(60000); if (index == -1) { handle = args[0]; host = WhoisClient.DEFAULT_HOST; } else { handle = args[0].substring(0, index); host = args[0].substring(index + 1); } try { address = InetAddress.getByName(host); System.out.println("[" + address.getHostName() + "]"); } catch (UnknownHostException e) { System.err.println("Error unknown host: " + e.getMessage()); System.exit(1); } try { whois.connect(address); System.out.print(whois.query(handle)); whois.disconnect(); } catch (IOException e) { System.err.println("Error I/O exception: " + e.getMessage()); System.exit(1); } }