2010-12-12 5 views
2

私は小さなドメインチェッカーを開発していると私は.SEを動作させることはできません。SEO:.SEドメインで動作するwhoisサーバですか?

public string Lookup(string domain, RecordType recordType, SeoToolsSettings.Tld tld) 
{ 
    TcpClient tcp = new TcpClient(); 
    tcp.Connect(tld.WhoIsServer, 43); 
    string strDomain = recordType.ToString() + " " + domain + "\r\n"; 
    byte[] bytDomain = Encoding.ASCII.GetBytes(strDomain.ToCharArray()); 
    Stream s = tcp.GetStream(); 
    s.Write(bytDomain, 0, strDomain.Length); 
    StreamReader sr = new StreamReader(tcp.GetStream(), Encoding.ASCII); 
    string strLine = ""; 
    StringBuilder builder = new StringBuilder(); 
    while (null != (strLine = sr.ReadLine())) 
    { 
     builder.AppendLine(strLine); 
    } 
    tcp.Close(); 
    if (tld.WhoIsDelayMs > 0) System.Threading.Thread.Sleep(tld.WhoIsDelayMs); 
    return builder.ToString(); 
} 

私はWHOISサーバ私は保つwhois.nic-se.seとwhois.iis.seプットを試してみました取得:

# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation). 
# All rights reserved. 

# The information obtained through searches, or otherwise, is protected 
# by the Swedish Copyright Act (1960:729) and international conventions. 
# It is also subject to database protection according to the Swedish 
# Copyright Act. 

# Any use of this material to target advertising or 
# similar activities is forbidden and will be prosecuted. 
# If any of the information below is transferred to a third 
# party, it must be done in its entirety. This server must 
# not be used as a backend for a search engine. 

# Result of search for registered domain names under 
# the .SE top level domain. 

# The data is in the UTF-8 character set and the result is 
# printed with eight bits. 

"domain google.se" not found. 

編集:

を私は他の結果とUTF8に変更しようとしました。

私はsysinternalsからwhoisを使用しようとすると、正しい結果が得られますが、SE.whois-servers.netを使用しなくても自分のコードでは得られません。私のMac上でwhois google.seを行うとき

/ニールス

+0

はあなたのコードの作業を行いますwhois serと一緒に他のTLDのためのvers? –

+0

私はWin7でSysinternals 'whois google.se'を使って適切な出力を得ています。 –

+0

はい、私のコードは他のTLDでうまく動作します。 .comドメインにwhois.internic.netを使用していますが、これは問題なく動作します。 –

答えて

1

私はついにそれを解決しました。 Wiresharkの使い方

、私はSysinternalsのWHOISは、 "DOMAIN" の部分を追加していないことを見た:

文字列strDomain = recordType.ToString()+ "" +ドメイン+ "\ rを\ n" は、

(recordType.ToString == "DOMAIN")。

私がそれを取り除いたとき、それは機能しました!

1

うーん、私は次を得る:

# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation). 
# All rights reserved. 

# The information obtained through searches, or otherwise, is protected 
# by the Swedish Copyright Act (1960:729) and international conventions. 
# It is also subject to database protection according to the Swedish 
# Copyright Act. 

# Any use of this material to target advertising or 
# similar activities is forbidden and will be prosecuted. 
# If any of the information below is transferred to a third 
# party, it must be done in its entirety. This server must 
# not be used as a backend for a search engine. 

# Result of search for registered domain names under 
# the .SE top level domain. 

# The data is in the UTF-8 character set and the result is 
# printed with eight bits. 

state:   active 
domain:   google.se 
holder:   googoo5855-00001 
admin-c:   - 
tech-c:   - 
billing-c:  - 
created:   2008-10-20 
modified:   2010-09-18 
expires:   2011-10-20 
transferred:  2009-03-06 
nserver:   ns1.google.com 
nserver:   ns2.google.com 
nserver:   ns3.google.com 
nserver:   ns4.google.com 
dnssec:   unsigned delegation 
status:   ok 
registrar:  MarkMonitor Inc 

は、だから、おそらくあなたのコードです。おそらくUTF8のような非ASCIIエンコーディングでリクエストを行う必要がありますか?

+0

Hmmm ...他のエンコーディングを使用しようとします...しかし、それはあなたがマック上で使用するwhoisサーバーを見て可能ですか? whoisサーバwhois.internic.netを使って.comドメインのために働いていることに注意してください。 –

+0

UTF8に変更するとうまくいきませんでした。 –

1

あなたのコード理由ではないに見もせず:あなただけがRIPEたい場合

http://balexandre.com/verifyDomain.aspx @

これはpar.se

IP Found: 
- 193.13.249.142 

Host name: 
- parweb1.par.se 
Aliases: 
none 
IP address list: 
- 193.13.249.142 

のために、あなたを与えるだろうIPのの情報また


ボタンイベント

protected void btnCheck_Click(object sender, EventArgs e) 
{ 
    DomainCheck domain = new DomainCheck(); 
    string ip = domain.GetIPFromDomain(txtDomain.Text.Trim()); 

    litResponse.Text = String.Format(
          "IP{0} Found:<br/> - <strong>{1}</strong><br/>{2}", 
          ip.Contains(",") ? "'s" : "", 
          ip.Replace(",", "<br/> - "), domain.VerifyIP(ip)); 
} 

DomainCheckコードは

{テストするには、ip}テスト

http://balexandre.com/iplookup.aspx?ip=のための私のページを使用することができます。

public class DomainCheck 
{ 
    public DomainCheck() { } 

    public string VerifyIP(string ipAddress) 
    { 
     if (String.IsNullOrEmpty(ipAddress)) 
      return "IP Address is invalid!"; 

     string r = ""; 

     if (ipAddress.Contains(",")) 
     { 
      foreach (string ip in ipAddress.Split(',')) 
       r += String.Format("<br/><br/>#### <em>Checking {0}</em>{1}", ip, CheckIPAddress(ip)); 
     } 
     else 
      r += CheckIPAddress(ipAddress); 

     return r; 
    } 
    public string GetIPFromDomain(string hostname) 
    { 
     string r = ""; 
     IPAddress[] addresslist = Dns.GetHostAddresses(hostname); 

     foreach (IPAddress theaddress in addresslist) 
     { 
      r += String.Format("{0},", theaddress.ToString()); 
     } 
     return String.IsNullOrEmpty(r) ? null : r.TrimEnd(','); 
    } 

    private string CheckIPAddress(string ipAddress) 
    { 
     string r = ""; 
     try 
     { 
      IPAddress hostIPAddress = IPAddress.Parse(ipAddress); 
      IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress); 
      // Get the IP address list that resolves to the host names contained in 
      // the Alias property. 
      IPAddress[] address = hostInfo.AddressList; 
      // Get the alias names of the addresses in the IP address list. 
      String[] alias = hostInfo.Aliases; 
      r += String.Format(
        "<br/>Host name: <br/>- <strong>{0}</strong><br/>Aliases: ", 
        hostInfo.HostName); 

      if (alias.Length == 0) 
       r += "<br/><em>none</em>"; 
      else 
       for (int index = 0; index < alias.Length; index++) 
        r += String.Format("<br/>- <strong>{0}</strong>", alias[index]); 

      r += "<br/>IP address list: "; 
      if (address.Length == 0) 
       r += "<br/><em>none</em>"; 
      else 
       for (int index = 0; index < address.Length; index++) 
        r += String.Format("<br/>- <strong>{0}</strong>", address[index]); 
     } 
     catch (SocketException e) 
     { 
      r = String.Format(
        "SocketException caught!!!<br/>Source : {0}<br/>Message : {1}", 
        e.Source, e.Message); 
     } 
     catch (FormatException e) 
     { 
      r = String.Format(
        "FormatException caught!!!<br/>Source : {0}<br/>Message : {1}", 
        e.Source, e.Message); 
     } 
     catch (ArgumentNullException e) 
     { 
      r = String.Format(
        "ArgumentNullException caught!!!<br/>Source : {0}<br/>Message : {1}", 
        e.Source, e.Message); 
     } 
     catch (Exception e) 
     { 
      r = String.Format(
        "Exception caught!!!<br/>Source : {0}<br/>Message : {1}", 
        e.Source, e.Message); 
     } 
     return r; 
    } 
}