diff --git a/Whois.Tests/ParsingTests.cs b/Whois.Tests/ParsingTests.cs new file mode 100644 index 00000000..9a758470 --- /dev/null +++ b/Whois.Tests/ParsingTests.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Resources; +using NUnit.Framework; +using Tokens; +using Whois.Models; +using Whois.Visitors; + +namespace Whois +{ + [TestFixture] + public class ParsingTests + { + [Test] + public void TestParseSampleDomains() + { + var results = new List(); + + var sampleFileNames = Directory.EnumerateFiles(@"../../../Samples/Domains", "*.txt"); + + foreach (var sampleFileName in sampleFileNames) + { + var fullFileName = Path.Join(Directory.GetCurrentDirectory(), sampleFileName); + + var result = new SampleParseResult + { + Contents = File.ReadAllText(fullFileName), + FullFileName = fullFileName + }; + + results.Add(result); + } + + var visitor = new PatternExtractorVisitor(); + + foreach (var result in results) + { + result.ContentParsed = visitor.Parse(result.Contents); + } + + foreach (var result in results.Where(r => r.ContentParsed.Success == true).OrderBy(r => r.ContentParsed.BestMatch?.Tokens.Matches.Count)) + { + Console.WriteLine(result.DomainName); + } + } + + private class SampleParseResult + { + public string FullFileName { get; set; } + + public string DomainName + { + get + { + var fileName = Path.GetFileName(FullFileName); + + return Path + .GetFileNameWithoutExtension(fileName) + .ToLowerInvariant(); + } + } + + public string Contents { get; set; } + + public TokenMatcherResult ContentParsed { get; set; } + } + } +} diff --git a/Whois.Tests/Samples/Domains/025bbs.cn.txt b/Whois.Tests/Samples/Domains/025bbs.cn.txt new file mode 100644 index 00000000..1e28d2b3 --- /dev/null +++ b/Whois.Tests/Samples/Domains/025bbs.cn.txt @@ -0,0 +1,12 @@ +Domain Name: 025bbs.cn +ROID: 20180313s10001s99456578-cn +Domain Status: ok +Registrant ID: hc1250473063700 +Registrant: 南京越之彬网络科技有限公司 +Registrant Contact Email: email@qq.com +Sponsoring Registrar: 阿里云计算有限公司(万网) +Name Server: dns27.hichina.com +Name Server: dns28.hichina.com +Registration Time: 2018-03-13 21:45:16 +Expiration Time: 2021-03-13 21:45:16 +DNSSEC: unsigned \ No newline at end of file diff --git a/Whois.Tests/Samples/Domains/08.pl.txt b/Whois.Tests/Samples/Domains/08.pl.txt new file mode 100644 index 00000000..0cbe9dfe --- /dev/null +++ b/Whois.Tests/Samples/Domains/08.pl.txt @@ -0,0 +1,38 @@ +DOMAIN NAME: 08.pl + +registrant type: organization + +nameservers: dns111.ovh.net. + + ns111.ovh.net. + +created: 2004.02.07 06:45:12 + +last modified: 2019.02.01 18:05:52 + +renewal date: 2020.02.06 13:00:00 + +option created: 2017.01.20 04:34:55 + +option expiration date: 2020.01.20 04:34:55 + +dnssec: Signed + +DS: 46726 8 2 +F2A6D8AE119F40330E2C562813320D1AC008A14B65A9D8D1DB40D4AE214977FF + +REGISTRAR: + +OVH SAS + +2 Rue Kellermann + +59100 Roubaix + +Francja/France + ++48.717500200 + +https://www.ovh.pl/abuse/ + +WHOIS database responses and Registrant data available at: https://dns.pl/en/whois \ No newline at end of file diff --git a/Whois.Tests/Samples/Domains/_facebook.com.txt b/Whois.Tests/Samples/Domains/_facebook.com.txt deleted file mode 100644 index 83725ce4..00000000 --- a/Whois.Tests/Samples/Domains/_facebook.com.txt +++ /dev/null @@ -1,58 +0,0 @@ - Domain Name: FACEBOOK.COM - Registry Domain ID: 2320948_DOMAIN_COM-VRSN - Registrar WHOIS Server: whois.registrarsafe.com - Registrar URL: http://www.registrarsafe.com - Updated Date: 2018-07-23T18:17:13Z - Creation Date: 1997-03-29T05:00:00Z - Registry Expiry Date: 2028-03-30T04:00:00Z - Registrar: RegistrarSafe, LLC - Registrar IANA ID: 3237 - Registrar Abuse Contact Email: abusecomplaints@registrarsafe.com - Registrar Abuse Contact Phone: +1-650-308-7004 - Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited - Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited - Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited - Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited - Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited - Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited - Name Server: A.NS.FACEBOOK.COM - Name Server: B.NS.FACEBOOK.COM - DNSSEC: unsigned - URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/ ->>> Last update of whois database: 2018-10-31T15:28:46Z <<< - -For more information on Whois status codes, please visit https://icann.org/epp - -NOTICE: The expiration date displayed in this record is the date the -registrar's sponsorship of the domain name registration in the registry is -currently set to expire. This date does not necessarily reflect the expiration -date of the domain name registrant's agreement with the sponsoring -registrar. Users may consult the sponsoring registrar's Whois database to -view the registrar's reported date of expiration for this registration. - -TERMS OF USE: You are not authorized to access or query our Whois -database through the use of electronic processes that are high-volume and -automated except as reasonably necessary to register domain names or -modify existing registrations; the Data in VeriSign Global Registry -Services' ("VeriSign") Whois database is provided by VeriSign for -information purposes only, and to assist persons in obtaining information -about or related to a domain name registration record. VeriSign does not -guarantee its accuracy. By submitting a Whois query, you agree to abide -by the following terms of use: You agree that you may use this Data only -for lawful purposes and that under no circumstances will you use this Data -to: (1) allow, enable, or otherwise support the transmission of mass -unsolicited, commercial advertising or solicitations via e-mail, telephone, -or facsimile; or (2) enable high volume, automated, electronic processes -that apply to VeriSign (or its computer systems). The compilation, -repackaging, dissemination or other use of this Data is expressly -prohibited without the prior written consent of VeriSign. You agree not to -use electronic processes that are automated and high-volume to access or -query the Whois database except as reasonably necessary to register -domain names or modify existing registrations. VeriSign reserves the right -to restrict your access to the Whois database in its sole discretion to ensure -operational stability. VeriSign may restrict or terminate your access to the -Whois database for failure to abide by these terms of use. VeriSign -reserves the right to modify these terms at any time. - -The Registry database contains ONLY .COM, .NET, .EDU domains and -Registrars. diff --git a/Whois.Tests/Samples/Domains/amazon.co.jp.txt b/Whois.Tests/Samples/Domains/amazon.co.jp.txt index b956a853..858c4fae 100644 --- a/Whois.Tests/Samples/Domains/amazon.co.jp.txt +++ b/Whois.Tests/Samples/Domains/amazon.co.jp.txt @@ -3,22 +3,19 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] AMAZON.CO.JP -e. [そしきめい] あまぞん・いんく -f. [組織名] アマゾン・インク +Domain Information: +a. [Domain Name] AMAZON.CO.JP g. [Organization] Amazon, Inc. -k. [組織種別] 外国会社 l. [Organization Type] Foreign Company -m. [登録担当者] JC076JP -n. [技術連絡担当者] IK4644JP -p. [ネームサーバ] ns1.p31.dynect.net -p. [ネームサーバ] ns2.p31.dynect.net -p. [ネームサーバ] pdns1.ultradns.net -p. [ネームサーバ] pdns6.ultradns.co.uk -s. [署名鍵] -[状態] Connected (2018/11/30) -[登録年月日] 2002/11/21 -[接続年月日] 2002/11/21 -[最終更新] 2017/12/01 01:02:51 (JST) +m. [Administrative Contact] JC076JP +n. [Technical Contact] IK4644JP +p. [Name Server] ns1.p31.dynect.net +p. [Name Server] ns2.p31.dynect.net +p. [Name Server] pdns1.ultradns.net +p. [Name Server] pdns6.ultradns.co.uk +s. [Signing Key] +[State] Connected (2019/11/30) +[Registered Date] 2002/11/21 +[Connected Date] 2002/11/21 +[Last Update] 2018/12/01 01:01:57 (JST) diff --git a/Whois.Tests/Samples/Domains/ameblo.jp.txt b/Whois.Tests/Samples/Domains/ameblo.jp.txt index 184e7cd6..3b5d70fb 100644 --- a/Whois.Tests/Samples/Domains/ameblo.jp.txt +++ b/Whois.Tests/Samples/Domains/ameblo.jp.txt @@ -3,10 +3,9 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] +Domain Information: [Domain Name] AMEBLO.JP -[登録者名] 株式会社サイバーエージェント [Registrant] CyberAgent, Inc. [Name Server] a1-5.akam.net @@ -15,25 +14,20 @@ Domain Information: [ドメイン情報] [Name Server] a4-64.akam.net [Name Server] a6-65.akam.net [Name Server] a7-66.akam.net -[Signing Key] +[Signing Key] -[登録年月日] 2004/07/30 -[有効期限] 2019/07/31 -[状態] Active -[最終更新] 2018/08/01 01:05:09 (JST) +[Created on] 2004/07/30 +[Expires on] 2019/07/31 +[Status] Active +[Last Updated] 2018/08/01 01:05:09 (JST) -Contact Information: [公開連絡窓口] -[名前] 株式会社サイバーエージェント +Contact Information: [Name] CyberAgent, Inc. [Email] dns-ssl-info@cyberagent.co.jp -[Web Page] -[郵便番号] 150-0044 -[住所] 東京都渋谷区 - 円山町 19-1 - 渋谷プライムプラザ2F +[Web Page] +[Postal code] 150-0044 [Postal Address] Shibuya-ku 19-1 Maruyamacho Shibuya Prime Plaza 2F -[電話番号] 03-5459-6150 -[FAX番号] 03-5784-7070 - +[Phone] 03-5459-6150 +[Fax] 03-5784-7070 \ No newline at end of file diff --git a/Whois.Tests/Samples/Domains/apache.org.txt b/Whois.Tests/Samples/Domains/apache.org.txt index e69de29b..3544a1b2 100644 --- a/Whois.Tests/Samples/Domains/apache.org.txt +++ b/Whois.Tests/Samples/Domains/apache.org.txt @@ -0,0 +1,63 @@ +Domain name: apache.org +Registry Domain ID: D706686-LROR +Registrar WHOIS Server: whois.namecheap.com +Registrar URL: http://www.namecheap.com +Updated Date: 2018-09-25T13:18:21.00Z +Creation Date: 1995-04-11T04:00:00.00Z +Registrar Registration Expiration Date: 2022-04-12T04:00:00.00Z +Registrar: NAMECHEAP INC +Registrar IANA ID: 1068 +Registrar Abuse Contact Email: abuse@namecheap.com +Registrar Abuse Contact Phone: +1.6613102107 +Reseller: NAMECHEAP INC +Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited +Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited +Registry Registrant ID: +Registrant Name: Apache DNS +Registrant Organization: The Apache Software Foundation +Registrant Street: 401 Edgewater Place Suite 600 +Registrant City: Wakefield +Registrant State/Province: MA +Registrant Postal Code: 01880 +Registrant Country: US +Registrant Phone: +1.1234567890 +Registrant Phone Ext: +Registrant Fax: +1.7816238460 +Registrant Fax Ext: +Registrant Email: dns@apache.org +Registry Admin ID: +Admin Name: Apache DNS +Admin Organization: The Apache Software Foundation +Admin Street: 401 Edgewater Place Suite 600 +Admin City: Wakefield +Admin State/Province: MA +Admin Postal Code: 01880 +Admin Country: US +Admin Phone: +1.1234567890 +Admin Phone Ext: +Admin Fax: +1.7816238460 +Admin Fax Ext: +Admin Email: dns@apache.org +Registry Tech ID: +Tech Name: Apache DNS +Tech Organization: The Apache Software Foundation +Tech Street: 401 Edgewater Place Suite 600 +Tech City: Wakefield +Tech State/Province: MA +Tech Postal Code: 01880 +Tech Country: US +Tech Phone: +1.1234567890 +Tech Phone Ext: +Tech Fax: +1.7816238460 +Tech Fax Ext: +Tech Email: dns@apache.org +Name Server: ns2.surfnet.nl +Name Server: ns3.no-ip.com +Name Server: ns2.no-ip.com +Name Server: ns1.no-ip.com +Name Server: ns4.no-ip.com +DNSSEC: unsigned +URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ +>>> Last update of WHOIS database: 2019-05-25T07:08:56.94Z <<< + +For more information on Whois status codes, please visit https://icann.org/epp \ No newline at end of file diff --git a/Whois.Tests/Samples/Domains/bbb.org.txt b/Whois.Tests/Samples/Domains/bbb.org.txt deleted file mode 100644 index ec2ee5a5..00000000 --- a/Whois.Tests/Samples/Domains/bbb.org.txt +++ /dev/null @@ -1,12 +0,0 @@ - -No match for bbb.org. - -For more information on Whois status codes, please visit https://icann.org/epp - -Corporation Service Company(c) (CSC) The Trusted Partner of More than 50% of the 100 Best Global Brands. - -Contact us to learn more about our enterprise solutions for Global Domain Name Registration and Management, Trademark Research and Watching, Brand, Logo and Auction Monitoring, as well SSL Certificate Services and DNS Hosting. - -NOTICE: You are not authorized to access or query our WHOIS database through the use of high-volume, automated, electronic processes or for the purpose or purposes of using the data in any manner that violates these terms of use. The Data in the CSC WHOIS database is provided by CSC for information purposes only, and to assist persons in obtaining information about or related to a domain name registration record. CSC does not guarantee its accuracy. By submitting a WHOIS query, you agree to abide by the following terms of use: you agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via direct mail, e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to CSC (or its computer systems). CSC reserves the right to terminate your access to the WHOIS database in its sole discretion for any violations by you of these terms of use. CSC reserves the right to modify these terms at any time. - -Register your domain name at http://www.cscglobal.com diff --git a/Whois.Tests/Samples/Domains/biglobe.ne.jp.txt b/Whois.Tests/Samples/Domains/biglobe.ne.jp.txt index b3c715d3..eeb24734 100644 --- a/Whois.Tests/Samples/Domains/biglobe.ne.jp.txt +++ b/Whois.Tests/Samples/Domains/biglobe.ne.jp.txt @@ -3,20 +3,17 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] BIGLOBE.NE.JP -b. [ねっとわーくさーびすめい] びっぐろーぶさーびす -c. [ネットワークサービス名] BIGLOBEサービス +Domain Information: +a. [Domain Name] BIGLOBE.NE.JP d. [Network Service Name] BIGLOBE Services -k. [組織種別] ネットワークサービス l. [Organization Type] Network Service -m. [登録担当者] HT40618JP -n. [技術連絡担当者] HT40618JP -p. [ネームサーバ] ns02.mesh.ad.jp -p. [ネームサーバ] ns03.mesh.ad.jp -s. [署名鍵] -[状態] Connected (2018/12/31) -[登録年月日] 1996/12/17 -[接続年月日] 1997/01/07 -[最終更新] 2018/06/06 10:56:24 (JST) +m. [Administrative Contact] HT40618JP +n. [Technical Contact] HT40618JP +p. [Name Server] ns02.mesh.ad.jp +p. [Name Server] ns03.mesh.ad.jp +s. [Signing Key] +[State] Connected (2019/12/31) +[Registered Date] 1996/12/17 +[Connected Date] 1997/01/07 +[Last Update] 2019/01/01 01:02:11 (JST) diff --git a/Whois.Tests/Samples/Domains/geocities.jp.txt b/Whois.Tests/Samples/Domains/geocities.jp.txt index ed5091d6..c6bcf508 100644 --- a/Whois.Tests/Samples/Domains/geocities.jp.txt +++ b/Whois.Tests/Samples/Domains/geocities.jp.txt @@ -3,32 +3,29 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] +Domain Information: [Domain Name] GEOCITIES.JP -[登録者名] ヤフー株式会社 [Registrant] Yahoo Japan Corporation [Name Server] ns01.yahoo.co.jp [Name Server] ns02.yahoo.co.jp [Name Server] ns11.yahoo.co.jp [Name Server] ns12.yahoo.co.jp -[Signing Key] +[Signing Key] -[登録年月日] 2001/05/07 -[有効期限] 2019/05/31 -[状態] Active -[最終更新] 2018/06/01 01:05:08 (JST) +[Created on] 2001/05/07 +[Expires on] 2019/05/31 +[Status] Active +[Last Updated] 2018/06/01 01:05:08 (JST) -Contact Information: [公開連絡窓口] -[名前] ヤフー株式会社 +Contact Information: [Name] Yahoo Japan Corporation [Email] nic-admin@mail.yahoo.co.jp -[Web Page] -[郵便番号] 102-8282 -[住所] 東京都千代田区紀尾井町1番3号 +[Web Page] +[Postal code] 102-8282 [Postal Address] 1-3 Kioicho, Chiyoda-ku Tokyo 102-8282 Japan -[電話番号] 03-6898-8200 -[FAX番号] +[Phone] 03-6898-8200 +[Fax] diff --git a/Whois.Tests/Samples/Domains/goo.ne.jp.txt b/Whois.Tests/Samples/Domains/goo.ne.jp.txt index 0dd548a9..47ed84a8 100644 --- a/Whois.Tests/Samples/Domains/goo.ne.jp.txt +++ b/Whois.Tests/Samples/Domains/goo.ne.jp.txt @@ -3,25 +3,19 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] GOO.NE.JP -b. [ねっとわーくさーびすめい] つうしんによりあくせすされるでんしめでぃあ - じょうでのあらゆるじょうほうげんのいんでっくすさくせいおよびけんさく - ・こうこくさーびす -c. [ネットワークサービス名] 通信によりアクセスされる電子メディア上での - あらゆる情報源のインデックス作成及び検索・広告サービス +Domain Information: +a. [Domain Name] GOO.NE.JP d. [Network Service Name] GOO -k. [組織種別] ネットワークサービス l. [Organization Type] Network Service -m. [登録担当者] HS8389JP -n. [技術連絡担当者] SH820JP -p. [ネームサーバ] ns1.goo.ne.jp -p. [ネームサーバ] ns2.goo.ne.jp -p. [ネームサーバ] ns.intervia.ad.jp -p. [ネームサーバ] ns.via.or.jp -s. [署名鍵] -[状態] Connected (2019/06/30) -[登録年月日] 2004/06/15 -[接続年月日] 2004/06/15 -[最終更新] 2018/07/01 01:05:35 (JST) +m. [Administrative Contact] HS8389JP +n. [Technical Contact] SH820JP +p. [Name Server] ns1.goo.ne.jp +p. [Name Server] ns2.goo.ne.jp +p. [Name Server] ns.intervia.ad.jp +p. [Name Server] ns.via.or.jp +s. [Signing Key] +[State] Connected (2019/06/30) +[Registered Date] 2004/06/15 +[Connected Date] 2004/06/15 +[Last Update] 2018/07/01 01:05:35 (JST) diff --git a/Whois.Tests/Samples/Domains/google.co.jp.txt b/Whois.Tests/Samples/Domains/google.co.jp.txt index 27f09d9a..c9d10d98 100644 --- a/Whois.Tests/Samples/Domains/google.co.jp.txt +++ b/Whois.Tests/Samples/Domains/google.co.jp.txt @@ -3,22 +3,19 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] GOOGLE.CO.JP -e. [そしきめい] ぐーぐるかぶしきかいしゃ -f. [組織名] グーグル株式会社 +Domain Information: +a. [Domain Name] GOOGLE.CO.JP g. [Organization] Google Japan -k. [組織種別] 株式会社 l. [Organization Type] corporation -m. [登録担当者] DL152JP -n. [技術連絡担当者] TW124137JP -p. [ネームサーバ] ns1.google.com -p. [ネームサーバ] ns2.google.com -p. [ネームサーバ] ns3.google.com -p. [ネームサーバ] ns4.google.com -s. [署名鍵] -[状態] Connected (2019/03/31) -[登録年月日] 2001/03/22 -[接続年月日] 2001/03/22 -[最終更新] 2018/04/01 01:06:23 (JST) +m. [Administrative Contact] DL152JP +n. [Technical Contact] TW124137JP +p. [Name Server] ns1.google.com +p. [Name Server] ns2.google.com +p. [Name Server] ns3.google.com +p. [Name Server] ns4.google.com +s. [Signing Key] +[State] Connected (2020/03/31) +[Registered Date] 2001/03/22 +[Connected Date] 2001/03/22 +[Last Update] 2019/04/01 01:05:59 (JST) diff --git a/Whois.Tests/Samples/Domains/hatena.ne.jp.txt b/Whois.Tests/Samples/Domains/hatena.ne.jp.txt index a496f615..f7fa73e9 100644 --- a/Whois.Tests/Samples/Domains/hatena.ne.jp.txt +++ b/Whois.Tests/Samples/Domains/hatena.ne.jp.txt @@ -3,22 +3,19 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] HATENA.NE.JP -b. [ねっとわーくさーびすめい] はてな -c. [ネットワークサービス名] はてな +Domain Information: +a. [Domain Name] HATENA.NE.JP d. [Network Service Name] hatena -k. [組織種別] ネットワークサービス l. [Organization Type] Network Service -m. [登録担当者] YK52331JP -n. [技術連絡担当者] DT033JP -p. [ネームサーバ] ns-1239.awsdns-26.org -p. [ネームサーバ] ns-1574.awsdns-04.co.uk -p. [ネームサーバ] ns-451.awsdns-56.com -p. [ネームサーバ] ns-947.awsdns-54.net -s. [署名鍵] -[状態] Connected (2019/03/31) -[登録年月日] 2014/03/18 -[接続年月日] 2014/03/18 -[最終更新] 2018/06/25 11:55:26 (JST) +m. [Administrative Contact] YK52331JP +n. [Technical Contact] DT033JP +p. [Name Server] ns-1239.awsdns-26.org +p. [Name Server] ns-1574.awsdns-04.co.uk +p. [Name Server] ns-451.awsdns-56.com +p. [Name Server] ns-947.awsdns-54.net +s. [Signing Key] +[State] Connected (2020/03/31) +[Registered Date] 2014/03/18 +[Connected Date] 2014/03/18 +[Last Update] 2019/04/01 01:07:14 (JST) diff --git a/Whois.Tests/Samples/Domains/jugem.jp.txt b/Whois.Tests/Samples/Domains/jugem.jp.txt index 293ca58f..77d9546d 100644 --- a/Whois.Tests/Samples/Domains/jugem.jp.txt +++ b/Whois.Tests/Samples/Domains/jugem.jp.txt @@ -3,31 +3,27 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] +Domain Information: [Domain Name] JUGEM.JP -[登録者名] GMOペパボ株式会社 [Registrant] GMO Pepabo, Inc. [Name Server] dns0.jugem.jp [Name Server] dns1.jugem.jp -[Signing Key] +[Signing Key] -[登録年月日] 2004/06/28 -[有効期限] 2019/06/30 -[状態] Active -[最終更新] 2018/07/01 01:05:10 (JST) +[Created on] 2004/06/28 +[Expires on] 2019/06/30 +[Status] Active +[Last Updated] 2018/07/01 01:05:10 (JST) -Contact Information: [公開連絡窓口] -[名前] 佐藤 健太郎 +Contact Information: [Name] Kentaro Sato [Email] admin@muumuu-domain.com -[Web Page] -[郵便番号] 150-8512 -[住所] 東京都渋谷区 桜丘町26番1号 - セルリアンタワー +[Web Page] +[Postal code] 150-8512 [Postal Address] Cerulean Tower 26-1 Sakuragaoka-cho Shibuya-ku -[電話番号] 03-5456-2622 -[FAX番号] 03-5456-2633 +[Phone] 03-5456-2622 +[Fax] 03-5456-2633 diff --git a/Whois.Tests/Samples/Domains/miibeian.gov.cn.txt b/Whois.Tests/Samples/Domains/miibeian.gov.cn.txt deleted file mode 100644 index f2cd130f..00000000 --- a/Whois.Tests/Samples/Domains/miibeian.gov.cn.txt +++ /dev/null @@ -1 +0,0 @@ -the Domain Name you apply can not be registered online. Please consult your Domain Name registrar diff --git a/Whois.Tests/Samples/Domains/networkadvertising.org.txt b/Whois.Tests/Samples/Domains/networkadvertising.org.txt deleted file mode 100644 index 761d0214..00000000 --- a/Whois.Tests/Samples/Domains/networkadvertising.org.txt +++ /dev/null @@ -1 +0,0 @@ -Could not retrieve Whois data. diff --git a/Whois.Tests/Samples/Domains/npr.org.txt b/Whois.Tests/Samples/Domains/npr.org.txt deleted file mode 100644 index 761d0214..00000000 --- a/Whois.Tests/Samples/Domains/npr.org.txt +++ /dev/null @@ -1 +0,0 @@ -Could not retrieve Whois data. diff --git a/Whois.Tests/Samples/Domains/ocn.ne.jp.txt b/Whois.Tests/Samples/Domains/ocn.ne.jp.txt index 7e41f35a..1c03b038 100644 --- a/Whois.Tests/Samples/Domains/ocn.ne.jp.txt +++ b/Whois.Tests/Samples/Domains/ocn.ne.jp.txt @@ -3,21 +3,18 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] OCN.NE.JP -b. [ねっとわーくさーびすめい] おーぷんこんぴゅーたねっとわーく -c. [ネットワークサービス名] オープンコンピュータネットワーク +Domain Information: +a. [Domain Name] OCN.NE.JP d. [Network Service Name] Open Computer Network -k. [組織種別] ネットワークサービス l. [Organization Type] Network Service -m. [登録担当者] MO081JP -n. [技術連絡担当者] KK551JP -n. [技術連絡担当者] MO081JP -p. [ネームサーバ] ns1.ocn.ad.jp -p. [ネームサーバ] ns2.ocn.ad.jp -s. [署名鍵] -[状態] Connected (2018/11/30) -[登録年月日] 1996/11/19 -[接続年月日] 1996/12/02 -[最終更新] 2017/12/01 01:07:24 (JST) +m. [Administrative Contact] MO081JP +n. [Technical Contact] KK551JP +n. [Technical Contact] MO081JP +p. [Name Server] ns1.ocn.ad.jp +p. [Name Server] ns2.ocn.ad.jp +s. [Signing Key] +[State] Connected (2019/11/30) +[Registered Date] 1996/11/19 +[Connected Date] 1996/12/02 +[Last Update] 2018/12/01 01:05:33 (JST) diff --git a/Whois.Tests/Samples/Domains/pbs.org.txt b/Whois.Tests/Samples/Domains/pbs.org.txt deleted file mode 100644 index cf8e2faf..00000000 --- a/Whois.Tests/Samples/Domains/pbs.org.txt +++ /dev/null @@ -1,12 +0,0 @@ - -No match for pbs.org. - -For more information on Whois status codes, please visit https://icann.org/epp - -Corporation Service Company(c) (CSC) The Trusted Partner of More than 50% of the 100 Best Global Brands. - -Contact us to learn more about our enterprise solutions for Global Domain Name Registration and Management, Trademark Research and Watching, Brand, Logo and Auction Monitoring, as well SSL Certificate Services and DNS Hosting. - -NOTICE: You are not authorized to access or query our WHOIS database through the use of high-volume, automated, electronic processes or for the purpose or purposes of using the data in any manner that violates these terms of use. The Data in the CSC WHOIS database is provided by CSC for information purposes only, and to assist persons in obtaining information about or related to a domain name registration record. CSC does not guarantee its accuracy. By submitting a WHOIS query, you agree to abide by the following terms of use: you agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via direct mail, e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to CSC (or its computer systems). CSC reserves the right to terminate your access to the WHOIS database in its sole discretion for any violations by you of these terms of use. CSC reserves the right to modify these terms at any time. - -Register your domain name at http://www.cscglobal.com diff --git a/Whois.Tests/Samples/Domains/phoca.cz.txt b/Whois.Tests/Samples/Domains/phoca.cz.txt index 49688391..8fea4b5f 100644 --- a/Whois.Tests/Samples/Domains/phoca.cz.txt +++ b/Whois.Tests/Samples/Domains/phoca.cz.txt @@ -1 +1,79 @@ -Your connection limit exceeded. Please slow down and try again later. +% (c) 2006-2018 CZ.NIC, z.s.p.o. +% +% Intended use of supplied data and information +% +% Data contained in the domain name register, as well as information +% supplied through public information services of CZ.NIC association, +% are appointed only for purposes connected with Internet network +% administration and operation, or for the purpose of legal or other +% similar proceedings, in process as regards a matter connected +% particularly with holding and using a concrete domain name. +% +% Full text available at: +% http://www.nic.cz/page/306/intended-use-of-supplied-data-and-information/ +% +% See also a search service at http://www.nic.cz/whois/ +% +% +% Whoisd Server Version: 3.12.0 +% Timestamp: Mon May 27 13:24:05 2019 + +domain: phoca.cz +registrant: SB:SUB000029824-ZONER +admin-c: PER000029824-ZONER +nsset: NSS:SUB100000001-ZONER:553 +registrar: REG-ZONER +registered: 08.08.2007 07:15:00 +changed: 04.04.2012 04:37:56 +expire: 08.08.2019 + +contact: SB:SUB000029824-ZONER +name: Lenka Medunov +address: Bratrstva 38 +address: Znojmo +address: 66902 +address: CZ +registrar: REG-ZONER +created: 08.08.2007 06:55:00 +changed: 15.05.2018 21:32:00 + +contact: PER000029824-ZONER +name: Lenka Medunov +address: Bratrstva 38 +address: Znojmo +address: 66902 +address: CZ +registrar: REG-ZONER +created: 08.08.2007 06:15:00 +changed: 15.05.2018 21:32:00 + +nsset: NSS:SUB100000001-ZONER:553 +nserver: ns2.videon-znojmo.cz +nserver: ns1.videon-znojmo.cz +tech-c: SB:SUB100000001-ZONER +tech-c: PER000000001-ZONER +registrar: REG-ZONER +created: 01.10.2007 02:00:00 + +contact: SB:SUB100000001-ZONER +org: ZONER software a.s. +name: ZONER software a.s. +address: Nov sady 18 +address: Brno +address: 60200 +address: CZ +registrar: REG-ZONER +created: 10.08.2001 22:13:00 +changed: 15.05.2018 21:32:00 + +contact: PER000000001-ZONER +name: Petr Horinek +address: Nov sady 18 +address: Brno +address: 60200 +address: CZ +registrar: REG-ZONER +created: 10.08.2001 22:13:00 +changed: 15.05.2018 21:32:00 + + diff --git a/Whois.Tests/Samples/Domains/rakuten.co.jp.txt b/Whois.Tests/Samples/Domains/rakuten.co.jp.txt index 4b9359bb..18fdd4cd 100644 --- a/Whois.Tests/Samples/Domains/rakuten.co.jp.txt +++ b/Whois.Tests/Samples/Domains/rakuten.co.jp.txt @@ -3,22 +3,19 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] RAKUTEN.CO.JP -e. [そしきめい] らくてんかぶしきがいしゃ -f. [組織名] 楽天株式会社 +Domain Information: +a. [Domain Name] RAKUTEN.CO.JP g. [Organization] Rakuten, Inc. -k. [組織種別] 株式会社 l. [Organization Type] joint stock corporation -m. [登録担当者] MW16026JP -n. [技術連絡担当者] SN26755JP -p. [ネームサーバ] ns01.rakuten.co.jp -p. [ネームサーバ] ns02.rakuten.co.jp -p. [ネームサーバ] ns03.rakuten.co.jp -p. [ネームサーバ] ns04.rakuten.co.jp -s. [署名鍵] -[状態] Connected (2019/02/28) -[登録年月日] 1997/02/07 -[接続年月日] 1997/02/19 -[最終更新] 2018/10/30 16:10:03 (JST) +m. [Administrative Contact] MW16026JP +n. [Technical Contact] SN26755JP +p. [Name Server] ns01.rakuten.co.jp +p. [Name Server] ns02.rakuten.co.jp +p. [Name Server] ns03.rakuten.co.jp +p. [Name Server] ns04.rakuten.co.jp +s. [Signing Key] +[State] Connected (2020/02/29) +[Registered Date] 1997/02/07 +[Connected Date] 1997/02/19 +[Last Update] 2019/03/01 01:06:24 (JST) diff --git a/Whois.Tests/Samples/Domains/sakura.ne.jp.txt b/Whois.Tests/Samples/Domains/sakura.ne.jp.txt index cd79c6a7..9eeab725 100644 --- a/Whois.Tests/Samples/Domains/sakura.ne.jp.txt +++ b/Whois.Tests/Samples/Domains/sakura.ne.jp.txt @@ -3,21 +3,18 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] SAKURA.NE.JP -b. [ねっとわーくさーびすめい] さくらいんたーねっと -c. [ネットワークサービス名] さくらインターネット +Domain Information: +a. [Domain Name] SAKURA.NE.JP d. [Network Service Name] SAKURA Internet -k. [組織種別] ネットワークサービス l. [Organization Type] Network Service -m. [登録担当者] KT48024JP -n. [技術連絡担当者] TS22695JP -n. [技術連絡担当者] KW419JP -p. [ネームサーバ] ns1.dns.ne.jp -p. [ネームサーバ] ns2.dns.ne.jp -s. [署名鍵] -[状態] Connected (2019/07/31) -[登録年月日] 2017/07/21 -[接続年月日] 2017/07/21 -[最終更新] 2018/08/01 01:03:45 (JST) +m. [Administrative Contact] KT48024JP +n. [Technical Contact] TS22695JP +n. [Technical Contact] KW419JP +p. [Name Server] ns1.dns.ne.jp +p. [Name Server] ns2.dns.ne.jp +s. [Signing Key] +[State] Connected (2019/07/31) +[Registered Date] 2017/07/21 +[Connected Date] 2017/07/21 +[Last Update] 2018/08/01 01:03:45 (JST) diff --git a/Whois.Tests/Samples/Domains/t.co.txt b/Whois.Tests/Samples/Domains/t.co.txt deleted file mode 100644 index 76d78a66..00000000 --- a/Whois.Tests/Samples/Domains/t.co.txt +++ /dev/null @@ -1,12 +0,0 @@ - -No match for t.co. - -For more information on Whois status codes, please visit https://icann.org/epp - -Corporation Service Company(c) (CSC) The Trusted Partner of More than 50% of the 100 Best Global Brands. - -Contact us to learn more about our enterprise solutions for Global Domain Name Registration and Management, Trademark Research and Watching, Brand, Logo and Auction Monitoring, as well SSL Certificate Services and DNS Hosting. - -NOTICE: You are not authorized to access or query our WHOIS database through the use of high-volume, automated, electronic processes or for the purpose or purposes of using the data in any manner that violates these terms of use. The Data in the CSC WHOIS database is provided by CSC for information purposes only, and to assist persons in obtaining information about or related to a domain name registration record. CSC does not guarantee its accuracy. By submitting a WHOIS query, you agree to abide by the following terms of use: you agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via direct mail, e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to CSC (or its computer systems). CSC reserves the right to terminate your access to the WHOIS database in its sole discretion for any violations by you of these terms of use. CSC reserves the right to modify these terms at any time. - -Register your domain name at http://www.cscglobal.com diff --git a/Whois.Tests/Samples/Domains/un.org.txt b/Whois.Tests/Samples/Domains/un.org.txt deleted file mode 100644 index 761d0214..00000000 --- a/Whois.Tests/Samples/Domains/un.org.txt +++ /dev/null @@ -1 +0,0 @@ -Could not retrieve Whois data. diff --git a/Whois.Tests/Samples/Domains/yahoo.co.jp.txt b/Whois.Tests/Samples/Domains/yahoo.co.jp.txt index 7f4935e6..2da55683 100644 --- a/Whois.Tests/Samples/Domains/yahoo.co.jp.txt +++ b/Whois.Tests/Samples/Domains/yahoo.co.jp.txt @@ -3,22 +3,19 @@ [ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] [ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] -Domain Information: [ドメイン情報] -a. [ドメイン名] YAHOO.CO.JP -e. [そしきめい] やふーかぶしきがいしゃ -f. [組織名] ヤフー株式会社 +Domain Information: +a. [Domain Name] YAHOO.CO.JP g. [Organization] Yahoo Japan Corporation -k. [組織種別] 株式会社 l. [Organization Type] Corporation -m. [登録担当者] HA14103JP -n. [技術連絡担当者] KM43416JP -p. [ネームサーバ] ns01.yahoo.co.jp -p. [ネームサーバ] ns02.yahoo.co.jp -p. [ネームサーバ] ns11.yahoo.co.jp -p. [ネームサーバ] ns12.yahoo.co.jp -s. [署名鍵] -[状態] Connected (2018/11/30) -[登録年月日] 2000/11/17 -[接続年月日] 2000/11/17 -[最終更新] 2017/12/01 01:02:55 (JST) +m. [Administrative Contact] HA14103JP +n. [Technical Contact] KM43416JP +p. [Name Server] ns01.yahoo.co.jp +p. [Name Server] ns02.yahoo.co.jp +p. [Name Server] ns11.yahoo.co.jp +p. [Name Server] ns12.yahoo.co.jp +s. [Signing Key] +[State] Connected (2019/11/30) +[Registered Date] 2000/11/17 +[Connected Date] 2000/11/17 +[Last Update] 2018/12/01 01:02:00 (JST) diff --git a/Whois.Tests/Visitors/PatternExtractorVisitorTest.cs b/Whois.Tests/Visitors/PatternExtractorVisitorTest.cs index e619a756..8997461c 100644 --- a/Whois.Tests/Visitors/PatternExtractorVisitorTest.cs +++ b/Whois.Tests/Visitors/PatternExtractorVisitorTest.cs @@ -127,5 +127,174 @@ public void TestParseBrRecord() Assert.AreEqual("ns2.ultraprovedor.com.br", record.NameServers[1]); Assert.AreEqual("ns3.ultraprovedor.com.br", record.NameServers[2]); } + + [Test] + public void TestParseHiChinaRecord() + { + var sample = File.ReadAllText("..\\..\\..\\Samples\\Domains\\025bbs.cn.txt"); + + var state = new LookupState + { + Response = new WhoisResponse(sample), + Options = new WhoisOptions { ParseWhoisResponse = true } + }; + + visitor.Visit(state); + + var record = state.Response.ParsedResponse; + + Assert.AreEqual("025bbs.cn", record.DomainName); + Assert.AreEqual("20180313s10001s99456578-cn", record.RegistryDomainId); + Assert.AreEqual("阿里云计算有限公司(万网)", record.Registrar.Name); + Assert.AreEqual(new DateTime(2018, 3, 13, 21, 45, 16), record.Registered.Value.ToUniversalTime()); + Assert.AreEqual(new DateTime(2021, 3, 13, 21, 45, 16), record.Expiration.Value.ToUniversalTime()); + Assert.AreEqual("南京越之彬网络科技有限公司", record.Registrant.Name); + Assert.AreEqual("hc1250473063700", record.Registrant.RegistryId); + Assert.AreEqual("email@qq.com", record.Registrant.Email); + + Assert.AreEqual(2, record.NameServers.Count); + Assert.AreEqual("dns27.hichina.com", record.NameServers[0]); + Assert.AreEqual("dns28.hichina.com", record.NameServers[1]); + } + + [Test] + public void TestParsePlRecord() + { + var sample = File.ReadAllText("..\\..\\..\\Samples\\Domains\\08.pl.txt"); + + var state = new LookupState + { + Response = new WhoisResponse(sample), + Options = new WhoisOptions { ParseWhoisResponse = true } + }; + + visitor.Visit(state); + + var record = state.Response.ParsedResponse; + + Assert.AreEqual("08.pl", record.DomainName); + } + + [Test] + public void TestParseJpRecord() + { + var sample = File.ReadAllText("..\\..\\..\\Samples\\Domains\\amazon.co.jp.txt"); + + var state = new LookupState + { + Response = new WhoisResponse(sample), + Options = new WhoisOptions { ParseWhoisResponse = true } + }; + + visitor.Visit(state); + + var record = state.Response.ParsedResponse; + + Assert.AreEqual("amazon.co.jp", record.DomainName); + Assert.AreEqual("Amazon, Inc.", record.Registrant.Name); + Assert.AreEqual("JC076JP", record.AdminContact.Name); + Assert.AreEqual("IK4644JP", record.TechnicalContact.Name); + Assert.AreEqual(4, record.NameServers.Count); + Assert.AreEqual("ns1.p31.dynect.net", record.NameServers[0]); + Assert.AreEqual("ns2.p31.dynect.net", record.NameServers[1]); + Assert.AreEqual("pdns1.ultradns.net", record.NameServers[2]); + Assert.AreEqual("pdns6.ultradns.co.uk", record.NameServers[3]); + Assert.AreEqual(new DateTime(2002, 11, 21), record.Registered); + Assert.AreEqual(new DateTime(2018, 12, 01), record.Updated); + } + + [Test] + public void TestParseDeRecord() + { + var sample = File.ReadAllText("..\\..\\..\\Samples\\Domains\\amazon.de.txt"); + + var state = new LookupState + { + Response = new WhoisResponse(sample), + Options = new WhoisOptions { ParseWhoisResponse = true } + }; + + visitor.Visit(state); + + var record = state.Response.ParsedResponse; + + Assert.AreEqual("amazon.de", record.DomainName); + } + + [Test] + public void TestParseJpAltRecord() + { + var sample = File.ReadAllText("..\\..\\..\\Samples\\Domains\\ameblo.jp.txt"); + + var state = new LookupState + { + Response = new WhoisResponse(sample), + Options = new WhoisOptions { ParseWhoisResponse = true } + }; + + visitor.Visit(state); + + var record = state.Response.ParsedResponse; + + Assert.AreEqual("ameblo.jp", record.DomainName); + Assert.AreEqual("CyberAgent, Inc.", record.Registrant.Name); + Assert.AreEqual(6, record.NameServers.Count); + Assert.AreEqual("a1-5.akam.net", record.NameServers[0]); + Assert.AreEqual("a11-66.akam.net", record.NameServers[1]); + Assert.AreEqual("a20-67.akam.net", record.NameServers[2]); + Assert.AreEqual("a4-64.akam.net", record.NameServers[3]); + Assert.AreEqual("a6-65.akam.net", record.NameServers[4]); + Assert.AreEqual("a7-66.akam.net", record.NameServers[5]); + Assert.AreEqual(new DateTime(2004, 7, 30), record.Registered); + Assert.AreEqual(new DateTime(2019, 7, 31), record.Expiration); + Assert.AreEqual(new DateTime(2018, 8, 1), record.Updated); + Assert.AreEqual("CyberAgent, Inc.", record.AdminContact.Name); + Assert.AreEqual("dns-ssl-info@cyberagent.co.jp", record.AdminContact.Email); + Assert.AreEqual(3, record.AdminContact.Address.Count); + Assert.AreEqual("Shibuya-ku", record.AdminContact.Address[0]); + Assert.AreEqual("19-1 Maruyamacho", record.AdminContact.Address[1]); + Assert.AreEqual("Shibuya Prime Plaza 2F", record.AdminContact.Address[2]); + Assert.AreEqual("03-5459-6150", record.AdminContact.TelephoneNumber); + Assert.AreEqual("03-5784-7070", record.AdminContact.FaxNumber); + } + + [Test] + public void TestParseBeRecord() + { + var sample = File.ReadAllText("..\\..\\..\\Samples\\Domains\\youtu.be.txt"); + + var state = new LookupState + { + Response = new WhoisResponse(sample), + Options = new WhoisOptions { ParseWhoisResponse = true } + }; + + visitor.Visit(state); + + var record = state.Response.ParsedResponse; + + Assert.AreEqual("youtu.be", record.DomainName); + } + + [Test] + public void TestParseCzRecord() + { + var sample = File.ReadAllText("..\\..\\..\\Samples\\Domains\\phoca.cz.txt"); + + var result = visitor.Parse(sample); + + Assert.IsTrue(result.Success); + Assert.AreEqual("CZ.NIC", result.BestMatch.Template.Name); + + var record = result.BestMatch.Value; + + Assert.AreEqual("phoca.cz", record.DomainName); + + Assert.AreEqual("REG-ZONER", record.Registrar.Name); + + Assert.AreEqual(new DateTime(2007, 8, 8, 7, 15, 0), record.Registered); + Assert.AreEqual(new DateTime(2012, 4, 4, 4, 37, 56), record.Updated); + Assert.AreEqual(new DateTime(2019, 8, 8), record.Expiration); + } } } diff --git a/LICENSE.md b/Whois/LICENSE.txt similarity index 100% rename from LICENSE.md rename to Whois/LICENSE.txt diff --git a/Whois/Resources/Patterns/Domains/CzNic.txt b/Whois/Resources/Patterns/Domains/CzNic.txt new file mode 100644 index 00000000..74dba99a --- /dev/null +++ b/Whois/Resources/Patterns/Domains/CzNic.txt @@ -0,0 +1,13 @@ +--- +# +# CZ.NIC Template for .cz domains +# +name: CZ.NIC + +hint: supplied through public information services of CZ.NIC association +--- +domain: { DomainName : Required, EOL, IsDomainName, ToLower } +registrar: { Registrar.Name : Optional, EOL } +registered: { Registered : Optional, EOL, ToDateTimeUtc("dd.MM.yyyy HH:mm:ss") } +changed: { Updated : Optional, EOL, ToDateTimeUtc("dd.MM.yyyy HH:mm:ss") } +expire: { Expiration : Optional, EOL, ToDateTimeUtc("dd.MM.yyyy") } diff --git a/Whois/Resources/Patterns/Domains/DeNic.txt b/Whois/Resources/Patterns/Domains/DeNic.txt new file mode 100644 index 00000000..9475141e --- /dev/null +++ b/Whois/Resources/Patterns/Domains/DeNic.txt @@ -0,0 +1,7 @@ +--- +# +# DeNIC eG Template for .de domains +# +name: DeNIC +--- +Domain: {DomainName!$:IsDomainName, ToLower} \ No newline at end of file diff --git a/Whois/Resources/Patterns/Domains/DnsBe.txt b/Whois/Resources/Patterns/Domains/DnsBe.txt new file mode 100644 index 00000000..efaa02f4 --- /dev/null +++ b/Whois/Resources/Patterns/Domains/DnsBe.txt @@ -0,0 +1,58 @@ +--- +# +# DNS Belgium Template for .be domains +# +name: DNS Belgium + +hint: % .be Whois Server +--- +% .be Whois Server 6.1 +% +% The WHOIS service offered by DNS Belgium and the access to the records in the DNS Belgium +% WHOIS database are provided for information purposes only. It allows +% persons to check whether a specific domain name is still available or not +% and to obtain information related to the registration records of +% existing domain names. +% +% DNS Belgium cannot, under any circumstances, be held liable where the stored +% information would prove to be incomplete or inaccurate in any sense. +% +% By submitting a query you agree not to use the information made available +% to: +% - allow, enable or otherwise support the transmission of unsolicited, +% commercial advertising or other solicitations whether via email or otherwise; +% - target advertising in any possible way; +% - to cause nuisance in any possible way to the domain name holders by sending +% messages to them (whether by automated, electronic processes capable of +% enabling high volumes or other possible means). +% +% Without prejudice to the above, it is explicitly forbidden to extract, copy +% and/or use or re-utilise in any form and by any means (electronically or +% not) the whole or a quantitatively or qualitatively substantial part +% of the contents of the WHOIS database without prior and explicit permission +% by DNS Belgium, nor in any attempt thereof, to apply automated, electronic +% processes to DNS Belgium (or its systems). +% +% You agree that any reproduction and/or transmission of data for commercial +% purposes will always be considered as the extraction of a substantial +% part of the content of the WHOIS database. +% +% By submitting the query you agree to abide by this policy and accept that +% DNS Belgium can take measures to limit the use of its whois services in order to +% protect the privacy of its registrants or the integrity of the database. +% + +Domain: {DomainName!$:IsDomainName, ToLower} +Registered: {Registered?$:ToDateTime("ddd MMM d yyyy")} + +Registrar: + Name: {Registrar.Name?$} + Website: {Registrar.Url?$: IsUrl } + +Nameservers: + {NameServers$*: IsDomainName } + {NameServers$*: IsDomainName } + +Flags: + {DomainStatus*$} + {DomainStatus*$} \ No newline at end of file diff --git a/Whois/Resources/Patterns/Domains/DnsPl.txt b/Whois/Resources/Patterns/Domains/DnsPl.txt new file mode 100644 index 00000000..4f90f0de --- /dev/null +++ b/Whois/Resources/Patterns/Domains/DnsPl.txt @@ -0,0 +1,17 @@ +DOMAIN NAME: {DomainName$:ToLower()} + +registrant type: organization + +nameservers: {NameServers}. + + {NameServers*}. + +created: {Registered?$:ToDateTime("yyyy.MM.dd HH:mm:ss")} + +last modified: {Updated?$:ToDateTime("yyyy.MM.dd HH:mm:ss")} + +renewal date: {Expiration?$:ToDateTime("yyyy.MM.dd HH:mm:ss")} + +REGISTRAR: + +{Registrar.Name?$} diff --git a/Whois/Resources/Patterns/Domains/HiChina.txt b/Whois/Resources/Patterns/Domains/HiChina.txt new file mode 100644 index 00000000..d042dcdb --- /dev/null +++ b/Whois/Resources/Patterns/Domains/HiChina.txt @@ -0,0 +1,12 @@ +--- +OutOfOrder: true +--- +Domain Name: {DomainName$:ToLower()} +ROID: {RegistryDomainId$} +Registrant ID: {Registrant.RegistryId?$} +Registrant: {Registrant.Name?$} +Registrant Contact Email: {Registrant.Email?$} +Sponsoring Registrar: {Registrar.Name?$} +Name Server: {NameServers$*} +Registration Time: {Registered?$:ToDateTimeUtc("yyyy-MM-dd HH:mm:ss")} +Expiration Time: {Expiration?$:ToDateTimeUtc("yyyy-MM-dd HH:mm:ss")} \ No newline at end of file diff --git a/Whois/Resources/Patterns/Domains/Jprs.txt b/Whois/Resources/Patterns/Domains/Jprs.txt new file mode 100644 index 00000000..9ecfffdb --- /dev/null +++ b/Whois/Resources/Patterns/Domains/Jprs.txt @@ -0,0 +1,25 @@ +--- +# +# JPRS Template for .jp domains +# +name: JPRS + +hint: JPRS database provides information on network administration. + +outOfOrder: true +--- +[ JPRS database provides information on network administration. Its use is ] +[ restricted to network administration purposes. For further information, ] +[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] +[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] + +Domain Information: +a. [Domain Name] {DomainName!$:IsDomainName, ToLower()} +g. [Organization] {Registrant.Name?$} +m. [Administrative Contact] {AdminContact.Name?$} +n. [Technical Contact] {TechnicalContact.Name?$} +p. [Name Server] {NameServers$*} +[Registered Date] {Registered?$:ToDateTime("yyyy/MM/dd")} +[Connected Date] {Registered?$:ToDateTime("yyyy/MM/dd")} +[Last Update] {Updated?$:SubstringBefore(' '), ToDateTime("yyyy/MM/dd")} + diff --git a/Whois/Resources/Patterns/Domains/JprsAlt.txt b/Whois/Resources/Patterns/Domains/JprsAlt.txt new file mode 100644 index 00000000..9c2bc94a --- /dev/null +++ b/Whois/Resources/Patterns/Domains/JprsAlt.txt @@ -0,0 +1,31 @@ +--- +# +# Alternative JPRS Template for .jp domains +# +name: JPRS-Alt + +hint: JPRS database provides information on network administration. +--- +[ JPRS database provides information on network administration. Its use is ] +[ restricted to network administration purposes. For further information, ] +[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] +[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] + +Domain Information: +[Domain Name] {DomainName!$:IsDomainName, ToLower()} + +[Registrant] {Registrant.Name?$} + +[Name Server] {NameServers$*} + +[Created on] {Registered?$:ToDateTime("yyyy/MM/dd")} +[Expires on] {Expiration?$:ToDateTime("yyyy/MM/dd")} +[Last Updated] {Updated?$:SubstringBefore(' '), ToDateTime("yyyy/MM/dd")} + +Contact Information: +[Name] {AdminContact.Name?$} +[Email] {AdminContact.Email?$: IsEmail} +[Postal Address] {AdminContact.Address?$} + {AdminContact.Address?$*} +[Phone] {AdminContact.TelephoneNumber?$} +[Fax] {AdminContact.FaxNumber?$} \ No newline at end of file diff --git a/Whois/Servers/IanaServerLookup.cs b/Whois/Servers/IanaServerLookup.cs index bd2556a7..c855ad5d 100644 --- a/Whois/Servers/IanaServerLookup.cs +++ b/Whois/Servers/IanaServerLookup.cs @@ -28,7 +28,8 @@ public async Task LookupAsync(string tld) // Reflect the raw response onto a ParsedWhoisServer object var parsed = new Tokenizer() - .Parse(Embedded.Patterns.Servers.Iana, content); + .Tokenize(Embedded.Patterns.Servers.Iana, content) + .Value; var response = new WhoisServer(tld, parsed.Url); diff --git a/Whois/Visitors/DownloadVisitor.cs b/Whois/Visitors/DownloadVisitor.cs index 01caf983..c23e9bfd 100644 --- a/Whois/Visitors/DownloadVisitor.cs +++ b/Whois/Visitors/DownloadVisitor.cs @@ -14,9 +14,12 @@ public class DownloadVisitor : IWhoisVisitor public async Task Visit(LookupState state) { + var domainName = state.Domain; + if (domainName.EndsWith("jp")) domainName += "/e"; + using (var tcpReader = TcpReaderFactory.Create()) { - var response = await tcpReader.Read(state.WhoisServer.Url, 43, state.Domain, state.Options.DefaultEncoding); + var response = await tcpReader.Read(state.WhoisServer.Url, 43, domainName, state.Options.DefaultEncoding); state.Response = new WhoisResponse { diff --git a/Whois/Visitors/PatternExtractorVisitor.cs b/Whois/Visitors/PatternExtractorVisitor.cs index 02288b54..56837865 100644 --- a/Whois/Visitors/PatternExtractorVisitor.cs +++ b/Whois/Visitors/PatternExtractorVisitor.cs @@ -27,7 +27,7 @@ public PatternExtractorVisitor() Embedded.Patterns.Domains.ForEach((name, pattern) => { - matcher.AddPattern(pattern, name); + matcher.RegisterTemplate(pattern, name); }); } @@ -40,11 +40,14 @@ public Task Visit(LookupState state) try { - if (matcher.TryMatch(state.Response.Content, out var match)) + var matchResult = Parse(state.Response.Content); + var match = matchResult.BestMatch; + + if (match != null && match.Success) { - Log.Debug("Parsed WHOIS data using pattern {0} - {1} replacement(s) made.", match.Template.Name, match.Matches); + Log.Debug("Parsed WHOIS data using pattern {0} - {1} replacement(s) made.", match.Template.Name, match.Tokens.Matches.Count); - state.Response.ParsedResponse = match.Result; + state.Response.ParsedResponse = match.Value; } else { @@ -61,14 +64,19 @@ public Task Visit(LookupState state) return Task.FromResult(state); } + public TokenMatcherResult Parse(string whoisContent) + { + return matcher.Match(whoisContent); + } + public void AddPattern(string content, string name) { - matcher.AddPattern(content, name); + matcher.RegisterTemplate(content, name); } public void ClearPatterns() { - matcher.ClearPatterns(); + matcher.Templates.Clear(); } public void RegisterPatternValidator() where T : ITokenValidator diff --git a/Whois/Visitors/RedirectVisitor.cs b/Whois/Visitors/RedirectVisitor.cs index b847813f..e8335210 100644 --- a/Whois/Visitors/RedirectVisitor.cs +++ b/Whois/Visitors/RedirectVisitor.cs @@ -45,13 +45,16 @@ public bool IsARedirectRecord(WhoisResponse response, out WhoisRedirect redirect var pattern = Embedded.Patterns.Redirects.VerisignGrs; var tokenizer = new TokenMatcher(); - tokenizer.AddPattern(pattern, "verisign-grs.com"); + tokenizer.RegisterTemplate(pattern, "verisign-grs.com"); - if (tokenizer.TryMatch(response.Content, out var match)) + var matchResult = tokenizer.Match(response.Content); + var match = matchResult.BestMatch; + + if (match != null && match.Success) { - Log.Debug("Found redirect for {0} to {1}", response.Domain, match.Result.Url); + Log.Debug("Found redirect for {0} to {1}", response.Domain, match.Value.Url); - redirect = match.Result; + redirect = match.Value; if (string.IsNullOrEmpty(redirect.Url) == false) { diff --git a/Whois/Whois.csproj b/Whois/Whois.csproj index e4bc651a..b20d7703 100644 --- a/Whois/Whois.csproj +++ b/Whois/Whois.csproj @@ -2,19 +2,26 @@ netstandard2.0;net452 true - 2.0.1.0 + 2.0.2.0 Chris Wood flipbit.co.uk http://github.com/flipbit/whois - https://raw.github.com/flipbit/whois/master/LICENSE.md - whois - An Extensible WHOIS Library + whois lookup parsing + A .NET Framework 4.5.2 and Standard 2.0 WHOIS Lookup and Parsing Library Chris Wood 2019 Whois - + + + + + + + + + @@ -22,8 +29,16 @@ + + + + + + + + @@ -35,12 +50,21 @@ + all runtime; build; native; contentfiles; analyzers - + + + + + LICENSE.txt + + + + \ No newline at end of file