diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 4e5dfdf27..1eafde81e 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -70,6 +70,10 @@ "ImportPath": "github.com/jbenet/go-base58", "Rev": "568a28d73fd97651d3442392036a658b6976eed5" }, + { + "ImportPath": "github.com/jbenet/go-is-domain", + "Rev": "93b717f2ae17838a265e30277275ee99ee7198d6" + }, { "ImportPath": "github.com/jbenet/go-msgio", "Rev": "c9069ab79c95aa0686347b516972c7329c4391f2" diff --git a/Godeps/_workspace/src/github.com/jbenet/go-is-domain/LICENSE b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/LICENSE new file mode 100644 index 000000000..c7386b3c9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Juan Batiz-Benet + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/jbenet/go-is-domain/README.md b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/README.md new file mode 100644 index 000000000..21af7b395 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/README.md @@ -0,0 +1,23 @@ +# go-is-domain + +This package is dedicated to [@whyrusleeping](https://github.com/whyrusleeping). + +Docs: https://godoc.org/github.com/jbenet/go-is-domain + + +Check whether something is a domain. + + +```Go + +import ( + isd "github.com/jbenet/go-is-domain" +) + +isd.IsDomain("foo.com") // true +isd.IsDomain("foo.bar.com.") // true +isd.IsDomain("foo.bar.baz") // false + +``` + +MIT Licensed diff --git a/Godeps/_workspace/src/github.com/jbenet/go-is-domain/doc.go b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/doc.go new file mode 100644 index 000000000..db6855c4a --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/doc.go @@ -0,0 +1,13 @@ +/* +Package isdomain package allows users to check whether strings represent domain names. + + import ( + isd "github.com/jbenet/go-is-domain" + ) + + isd.IsDomain("foo.com") // true + isd.IsDomain("foo.bar.com.") // true + isd.IsDomain("foo.bar.baz") // false + +*/ +package isdomain diff --git a/Godeps/_workspace/src/github.com/jbenet/go-is-domain/domainre.go b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/domainre.go new file mode 100644 index 000000000..3b915f8e8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/domainre.go @@ -0,0 +1,12 @@ +package isdomain + +import "regexp" + +// DomainRegexpStr is a regular expression string to validate domains. +const DomainRegexpStr = "^([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}$" + +var domainRegexp *regexp.Regexp + +func init() { + domainRegexp = regexp.MustCompile(DomainRegexpStr) +} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-is-domain/is_domain.go b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/is_domain.go new file mode 100644 index 000000000..7591c7dc4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/is_domain.go @@ -0,0 +1,44 @@ +package isdomain + +import "strings" + +// IsICANNTLD returns whether the given string is a TLD (Top Level Domain), +// according to ICANN. Well, really according to the TLDs listed in this +// package. +func IsICANNTLD(s string) bool { + s = strings.ToUpper(s) + _, found := TLDs[s] + return found +} + +// IsExtendedTLD returns whether the given string is a TLD (Top Level Domain), +// extended with a few other "TLDs": .bit, .onion +func IsExtendedTLD(s string) bool { + s = strings.ToUpper(s) + _, found := ExtendedTLDs[s] + return found +} + +// IsTLD returns whether the given string is a TLD (according to ICANN, or +// in the set of ExtendedTLDs listed in this package. +func IsTLD(s string) bool { + return IsICANNTLD(s) || IsExtendedTLD(s) +} + +// IsDomain returns whether given string is a domain. +// It first checks the TLD, and then uses a regular expression. +func IsDomain(s string) bool { + if strings.HasSuffix(s, ".") { + s = s[:len(s)-1] + } + + split := strings.Split(s, ".") + tld := split[len(split)-1] + + if !IsTLD(tld) { + return false + } + + s = strings.ToLower(s) + return domainRegexp.MatchString(s) +} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-is-domain/is_domain_test.go b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/is_domain_test.go new file mode 100644 index 000000000..6bd224ef4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/is_domain_test.go @@ -0,0 +1,29 @@ +package isdomain + +import "testing" + +func TestBasic(t *testing.T) { + cases := map[string]bool{ + "foo.bar.baz.com": true, + "foo.bar.baz": false, + "foo.bar.baz.com.": true, + "com": false, // yeah yeah... + ".": false, // yeah yeah... + "..": false, + ".foo.com.": false, + ".foo.com": false, + "fo o.com": false, + "example.com": true, + "fjdoisajfdiosafdsa8fd8saf8dsa8fdsafdsa-fd-sa-fd-saf-dsa.org": true, + "fjdoisajfdiosafdsa8fd8saf8dsa8fdsafdsa-fd-sa-fd-saf-dsa.bit": true, + "fjdoisajfdiosafdsa8fd8saf8dsa8fdsafdsa-fd-sa-fd-saf-dsa.onion": true, + "a.b.c.d.e.f.g.h.i.j.k.l.museum": true, + "a.b.c.d.e.f.g.h.i.j.k.l": false, + } + + for d, ok := range cases { + if IsDomain(d) != ok { + t.Errorf("Misclassification: %v should be %v", d, ok) + } + } +} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-is-domain/tlds-alpha-by-domain.txt b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/tlds-alpha-by-domain.txt new file mode 100644 index 000000000..521f80e7a --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/tlds-alpha-by-domain.txt @@ -0,0 +1,727 @@ +# from http://data.iana.org/TLD/tlds-alpha-by-domain.txt +# Version 2014100300, Last Updated Fri Oct 3 07:07:01 2014 UTC +AC +ACADEMY +ACCOUNTANTS +ACTIVE +ACTOR +AD +AE +AERO +AF +AG +AGENCY +AI +AIRFORCE +AL +ALLFINANZ +AM +AN +AO +AQ +AR +ARCHI +ARMY +ARPA +AS +ASIA +ASSOCIATES +AT +ATTORNEY +AU +AUCTION +AUDIO +AUTOS +AW +AX +AXA +AZ +BA +BAR +BARGAINS +BAYERN +BB +BD +BE +BEER +BERLIN +BEST +BF +BG +BH +BI +BID +BIKE +BIO +BIZ +BJ +BLACK +BLACKFRIDAY +BLUE +BM +BMW +BN +BNPPARIBAS +BO +BOO +BOUTIQUE +BR +BRUSSELS +BS +BT +BUDAPEST +BUILD +BUILDERS +BUSINESS +BUZZ +BV +BW +BY +BZ +BZH +CA +CAB +CAL +CAMERA +CAMP +CANCERRESEARCH +CAPETOWN +CAPITAL +CARAVAN +CARDS +CARE +CAREER +CAREERS +CASA +CASH +CAT +CATERING +CC +CD +CENTER +CEO +CERN +CF +CG +CH +CHANNEL +CHEAP +CHRISTMAS +CHROME +CHURCH +CI +CITIC +CITY +CK +CL +CLAIMS +CLEANING +CLICK +CLINIC +CLOTHING +CLUB +CM +CN +CO +CODES +COFFEE +COLLEGE +COLOGNE +COM +COMMUNITY +COMPANY +COMPUTER +CONDOS +CONSTRUCTION +CONSULTING +CONTRACTORS +COOKING +COOL +COOP +COUNTRY +CR +CREDIT +CREDITCARD +CRUISES +CU +CUISINELLA +CV +CW +CX +CY +CYMRU +CZ +DAD +DANCE +DATING +DAY +DE +DEALS +DEGREE +DEMOCRAT +DENTAL +DENTIST +DESI +DIAMONDS +DIET +DIGITAL +DIRECT +DIRECTORY +DISCOUNT +DJ +DK +DM +DNP +DO +DOMAINS +DURBAN +DVAG +DZ +EAT +EC +EDU +EDUCATION +EE +EG +EMAIL +ENGINEER +ENGINEERING +ENTERPRISES +EQUIPMENT +ER +ES +ESQ +ESTATE +ET +EU +EUS +EVENTS +EXCHANGE +EXPERT +EXPOSED +FAIL +FARM +FEEDBACK +FI +FINANCE +FINANCIAL +FISH +FISHING +FITNESS +FJ +FK +FLIGHTS +FLORIST +FLY +FM +FO +FOO +FORSALE +FOUNDATION +FR +FRL +FROGANS +FUND +FURNITURE +FUTBOL +GA +GAL +GALLERY +GB +GBIZ +GD +GE +GENT +GF +GG +GH +GI +GIFT +GIFTS +GIVES +GL +GLASS +GLE +GLOBAL +GLOBO +GM +GMAIL +GMO +GMX +GN +GOOGLE +GOP +GOV +GP +GQ +GR +GRAPHICS +GRATIS +GREEN +GRIPE +GS +GT +GU +GUIDE +GUITARS +GURU +GW +GY +HAMBURG +HAUS +HEALTHCARE +HELP +HERE +HIPHOP +HIV +HK +HM +HN +HOLDINGS +HOLIDAY +HOMES +HORSE +HOST +HOSTING +HOUSE +HOW +HR +HT +HU +IBM +ID +IE +IL +IM +IMMO +IMMOBILIEN +IN +INDUSTRIES +INFO +ING +INK +INSTITUTE +INSURE +INT +INTERNATIONAL +INVESTMENTS +IO +IQ +IR +IS +IT +JE +JETZT +JM +JO +JOBS +JOBURG +JP +JUEGOS +KAUFEN +KE +KG +KH +KI +KIM +KITCHEN +KIWI +KM +KN +KOELN +KP +KR +KRD +KRED +KW +KY +KZ +LA +LACAIXA +LAND +LAWYER +LB +LC +LEASE +LGBT +LI +LIFE +LIGHTING +LIMITED +LIMO +LINK +LK +LOANS +LONDON +LOTTO +LR +LS +LT +LTDA +LU +LUXE +LUXURY +LV +LY +MA +MAISON +MANAGEMENT +MANGO +MARKET +MARKETING +MC +MD +ME +MEDIA +MEET +MELBOURNE +MEME +MENU +MG +MH +MIAMI +MIL +MINI +MK +ML +MM +MN +MO +MOBI +MODA +MOE +MONASH +MORTGAGE +MOSCOW +MOTORCYCLES +MOV +MP +MQ +MR +MS +MT +MU +MUSEUM +MV +MW +MX +MY +MZ +NA +NAGOYA +NAME +NAVY +NC +NE +NET +NETWORK +NEUSTAR +NEW +NEXUS +NF +NG +NGO +NHK +NI +NINJA +NL +NO +NP +NR +NRA +NRW +NU +NYC +NZ +OKINAWA +OM +ONG +ONL +OOO +ORG +ORGANIC +OTSUKA +OVH +PA +PARIS +PARTNERS +PARTS +PE +PF +PG +PH +PHARMACY +PHOTO +PHOTOGRAPHY +PHOTOS +PHYSIO +PICS +PICTURES +PINK +PIZZA +PK +PL +PLACE +PLUMBING +PM +PN +POHL +POST +PR +PRAXI +PRESS +PRO +PROD +PRODUCTIONS +PROF +PROPERTIES +PROPERTY +PS +PT +PUB +PW +PY +QA +QPON +QUEBEC +RE +REALTOR +RECIPES +RED +REHAB +REISE +REISEN +REN +RENTALS +REPAIR +REPORT +REPUBLICAN +REST +RESTAURANT +REVIEWS +RICH +RIO +RO +ROCKS +RODEO +RS +RSVP +RU +RUHR +RW +RYUKYU +SA +SAARLAND +SARL +SB +SC +SCA +SCB +SCHMIDT +SCHULE +SCOT +SD +SE +SERVICES +SEXY +SG +SH +SHIKSHA +SHOES +SI +SINGLES +SJ +SK +SL +SM +SN +SO +SOCIAL +SOFTWARE +SOHU +SOLAR +SOLUTIONS +SOY +SPACE +SPIEGEL +SR +ST +SU +SUPPLIES +SUPPLY +SUPPORT +SURF +SURGERY +SUZUKI +SV +SX +SY +SYSTEMS +SZ +TATAR +TATTOO +TAX +TC +TD +TECHNOLOGY +TEL +TF +TG +TH +TIENDA +TIPS +TIROL +TJ +TK +TL +TM +TN +TO +TODAY +TOKYO +TOOLS +TOP +TOWN +TOYS +TP +TR +TRADE +TRAINING +TRAVEL +TT +TUI +TV +TW +TZ +UA +UG +UK +UNIVERSITY +UNO +UOL +US +UY +UZ +VA +VACATIONS +VC +VE +VEGAS +VENTURES +VERSICHERUNG +VET +VG +VI +VIAJES +VILLAS +VISION +VLAANDEREN +VN +VODKA +VOTE +VOTING +VOTO +VOYAGE +VU +WALES +WANG +WATCH +WEBCAM +WEBSITE +WED +WF +WHOSWHO +WIEN +WIKI +WILLIAMHILL +WME +WORK +WORKS +WORLD +WS +WTC +WTF +XN--1QQW23A +XN--3BST00M +XN--3DS443G +XN--3E0B707E +XN--45BRJ9C +XN--4GBRIM +XN--55QW42G +XN--55QX5D +XN--6FRZ82G +XN--6QQ986B3XL +XN--80ADXHKS +XN--80AO21A +XN--80ASEHDB +XN--80ASWG +XN--90A3AC +XN--C1AVG +XN--CG4BKI +XN--CLCHC0EA0B2G2A9GCD +XN--CZR694B +XN--CZRU2D +XN--D1ACJ3B +XN--FIQ228C5HS +XN--FIQ64B +XN--FIQS8S +XN--FIQZ9S +XN--FPCRJ9C3D +XN--FZC2C9E2C +XN--GECRJ9C +XN--H2BRJ9C +XN--I1B6B1A6A2E +XN--IO0A7I +XN--J1AMH +XN--J6W193G +XN--KPRW13D +XN--KPRY57D +XN--KPUT3I +XN--L1ACC +XN--LGBBAT1AD8J +XN--MGB9AWBF +XN--MGBA3A4F16A +XN--MGBAAM7A8H +XN--MGBAB2BD +XN--MGBAYH7GPA +XN--MGBBH1A71E +XN--MGBC0A9AZCG +XN--MGBERP4A5D4AR +XN--MGBX4CD0AB +XN--NGBC5AZD +XN--NQV7F +XN--NQV7FS00EMA +XN--O3CW4H +XN--OGBPF8FL +XN--P1ACF +XN--P1AI +XN--PGBS0DH +XN--Q9JYB4C +XN--RHQV96G +XN--S9BRJ9C +XN--SES554G +XN--UNUP4Y +XN--VERMGENSBERATER-CTB +XN--VERMGENSBERATUNG-PWB +XN--VHQUV +XN--WGBH1C +XN--WGBL6A +XN--XHQ521B +XN--XKC2AL3HYE2A +XN--XKC2DL3A5EE0H +XN--YFRO4I67O +XN--YGBI2AMMX +XN--ZFR164B +XXX +XYZ +YACHTS +YANDEX +YE +YOKOHAMA +YOUTUBE +YT +ZA +ZIP +ZM +ZONE +ZW diff --git a/Godeps/_workspace/src/github.com/jbenet/go-is-domain/tlds.go b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/tlds.go new file mode 100644 index 000000000..c4969dbc2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-is-domain/tlds.go @@ -0,0 +1,737 @@ +package isdomain + +// TLDs is a set of TLDs, according to ICANN in 2014. +var TLDs = map[string]bool{ + "AC": true, + "ACADEMY": true, + "ACCOUNTANTS": true, + "ACTIVE": true, + "ACTOR": true, + "AD": true, + "AE": true, + "AERO": true, + "AF": true, + "AG": true, + "AGENCY": true, + "AI": true, + "AIRFORCE": true, + "AL": true, + "ALLFINANZ": true, + "AM": true, + "AN": true, + "AO": true, + "AQ": true, + "AR": true, + "ARCHI": true, + "ARMY": true, + "ARPA": true, + "AS": true, + "ASIA": true, + "ASSOCIATES": true, + "AT": true, + "ATTORNEY": true, + "AU": true, + "AUCTION": true, + "AUDIO": true, + "AUTOS": true, + "AW": true, + "AX": true, + "AXA": true, + "AZ": true, + "BA": true, + "BAR": true, + "BARGAINS": true, + "BAYERN": true, + "BB": true, + "BD": true, + "BE": true, + "BEER": true, + "BERLIN": true, + "BEST": true, + "BF": true, + "BG": true, + "BH": true, + "BI": true, + "BID": true, + "BIKE": true, + "BIO": true, + "BIZ": true, + "BJ": true, + "BLACK": true, + "BLACKFRIDAY": true, + "BLUE": true, + "BM": true, + "BMW": true, + "BN": true, + "BNPPARIBAS": true, + "BO": true, + "BOO": true, + "BOUTIQUE": true, + "BR": true, + "BRUSSELS": true, + "BS": true, + "BT": true, + "BUDAPEST": true, + "BUILD": true, + "BUILDERS": true, + "BUSINESS": true, + "BUZZ": true, + "BV": true, + "BW": true, + "BY": true, + "BZ": true, + "BZH": true, + "CA": true, + "CAB": true, + "CAL": true, + "CAMERA": true, + "CAMP": true, + "CANCERRESEARCH": true, + "CAPETOWN": true, + "CAPITAL": true, + "CARAVAN": true, + "CARDS": true, + "CARE": true, + "CAREER": true, + "CAREERS": true, + "CASA": true, + "CASH": true, + "CAT": true, + "CATERING": true, + "CC": true, + "CD": true, + "CENTER": true, + "CEO": true, + "CERN": true, + "CF": true, + "CG": true, + "CH": true, + "CHANNEL": true, + "CHEAP": true, + "CHRISTMAS": true, + "CHROME": true, + "CHURCH": true, + "CI": true, + "CITIC": true, + "CITY": true, + "CK": true, + "CL": true, + "CLAIMS": true, + "CLEANING": true, + "CLICK": true, + "CLINIC": true, + "CLOTHING": true, + "CLUB": true, + "CM": true, + "CN": true, + "CO": true, + "CODES": true, + "COFFEE": true, + "COLLEGE": true, + "COLOGNE": true, + "COM": true, + "COMMUNITY": true, + "COMPANY": true, + "COMPUTER": true, + "CONDOS": true, + "CONSTRUCTION": true, + "CONSULTING": true, + "CONTRACTORS": true, + "COOKING": true, + "COOL": true, + "COOP": true, + "COUNTRY": true, + "CR": true, + "CREDIT": true, + "CREDITCARD": true, + "CRUISES": true, + "CU": true, + "CUISINELLA": true, + "CV": true, + "CW": true, + "CX": true, + "CY": true, + "CYMRU": true, + "CZ": true, + "DAD": true, + "DANCE": true, + "DATING": true, + "DAY": true, + "DE": true, + "DEALS": true, + "DEGREE": true, + "DEMOCRAT": true, + "DENTAL": true, + "DENTIST": true, + "DESI": true, + "DIAMONDS": true, + "DIET": true, + "DIGITAL": true, + "DIRECT": true, + "DIRECTORY": true, + "DISCOUNT": true, + "DJ": true, + "DK": true, + "DM": true, + "DNP": true, + "DO": true, + "DOMAINS": true, + "DURBAN": true, + "DVAG": true, + "DZ": true, + "EAT": true, + "EC": true, + "EDU": true, + "EDUCATION": true, + "EE": true, + "EG": true, + "EMAIL": true, + "ENGINEER": true, + "ENGINEERING": true, + "ENTERPRISES": true, + "EQUIPMENT": true, + "ER": true, + "ES": true, + "ESQ": true, + "ESTATE": true, + "ET": true, + "EU": true, + "EUS": true, + "EVENTS": true, + "EXCHANGE": true, + "EXPERT": true, + "EXPOSED": true, + "FAIL": true, + "FARM": true, + "FEEDBACK": true, + "FI": true, + "FINANCE": true, + "FINANCIAL": true, + "FISH": true, + "FISHING": true, + "FITNESS": true, + "FJ": true, + "FK": true, + "FLIGHTS": true, + "FLORIST": true, + "FLY": true, + "FM": true, + "FO": true, + "FOO": true, + "FORSALE": true, + "FOUNDATION": true, + "FR": true, + "FRL": true, + "FROGANS": true, + "FUND": true, + "FURNITURE": true, + "FUTBOL": true, + "GA": true, + "GAL": true, + "GALLERY": true, + "GB": true, + "GBIZ": true, + "GD": true, + "GE": true, + "GENT": true, + "GF": true, + "GG": true, + "GH": true, + "GI": true, + "GIFT": true, + "GIFTS": true, + "GIVES": true, + "GL": true, + "GLASS": true, + "GLE": true, + "GLOBAL": true, + "GLOBO": true, + "GM": true, + "GMAIL": true, + "GMO": true, + "GMX": true, + "GN": true, + "GOOGLE": true, + "GOP": true, + "GOV": true, + "GP": true, + "GQ": true, + "GR": true, + "GRAPHICS": true, + "GRATIS": true, + "GREEN": true, + "GRIPE": true, + "GS": true, + "GT": true, + "GU": true, + "GUIDE": true, + "GUITARS": true, + "GURU": true, + "GW": true, + "GY": true, + "HAMBURG": true, + "HAUS": true, + "HEALTHCARE": true, + "HELP": true, + "HERE": true, + "HIPHOP": true, + "HIV": true, + "HK": true, + "HM": true, + "HN": true, + "HOLDINGS": true, + "HOLIDAY": true, + "HOMES": true, + "HORSE": true, + "HOST": true, + "HOSTING": true, + "HOUSE": true, + "HOW": true, + "HR": true, + "HT": true, + "HU": true, + "IBM": true, + "ID": true, + "IE": true, + "IL": true, + "IM": true, + "IMMO": true, + "IMMOBILIEN": true, + "IN": true, + "INDUSTRIES": true, + "INFO": true, + "ING": true, + "INK": true, + "INSTITUTE": true, + "INSURE": true, + "INT": true, + "INTERNATIONAL": true, + "INVESTMENTS": true, + "IO": true, + "IQ": true, + "IR": true, + "IS": true, + "IT": true, + "JE": true, + "JETZT": true, + "JM": true, + "JO": true, + "JOBS": true, + "JOBURG": true, + "JP": true, + "JUEGOS": true, + "KAUFEN": true, + "KE": true, + "KG": true, + "KH": true, + "KI": true, + "KIM": true, + "KITCHEN": true, + "KIWI": true, + "KM": true, + "KN": true, + "KOELN": true, + "KP": true, + "KR": true, + "KRD": true, + "KRED": true, + "KW": true, + "KY": true, + "KZ": true, + "LA": true, + "LACAIXA": true, + "LAND": true, + "LAWYER": true, + "LB": true, + "LC": true, + "LEASE": true, + "LGBT": true, + "LI": true, + "LIFE": true, + "LIGHTING": true, + "LIMITED": true, + "LIMO": true, + "LINK": true, + "LK": true, + "LOANS": true, + "LONDON": true, + "LOTTO": true, + "LR": true, + "LS": true, + "LT": true, + "LTDA": true, + "LU": true, + "LUXE": true, + "LUXURY": true, + "LV": true, + "LY": true, + "MA": true, + "MAISON": true, + "MANAGEMENT": true, + "MANGO": true, + "MARKET": true, + "MARKETING": true, + "MC": true, + "MD": true, + "ME": true, + "MEDIA": true, + "MEET": true, + "MELBOURNE": true, + "MEME": true, + "MENU": true, + "MG": true, + "MH": true, + "MIAMI": true, + "MIL": true, + "MINI": true, + "MK": true, + "ML": true, + "MM": true, + "MN": true, + "MO": true, + "MOBI": true, + "MODA": true, + "MOE": true, + "MONASH": true, + "MORTGAGE": true, + "MOSCOW": true, + "MOTORCYCLES": true, + "MOV": true, + "MP": true, + "MQ": true, + "MR": true, + "MS": true, + "MT": true, + "MU": true, + "MUSEUM": true, + "MV": true, + "MW": true, + "MX": true, + "MY": true, + "MZ": true, + "NA": true, + "NAGOYA": true, + "NAME": true, + "NAVY": true, + "NC": true, + "NE": true, + "NET": true, + "NETWORK": true, + "NEUSTAR": true, + "NEW": true, + "NEXUS": true, + "NF": true, + "NG": true, + "NGO": true, + "NHK": true, + "NI": true, + "NINJA": true, + "NL": true, + "NO": true, + "NP": true, + "NR": true, + "NRA": true, + "NRW": true, + "NU": true, + "NYC": true, + "NZ": true, + "OKINAWA": true, + "OM": true, + "ONG": true, + "ONL": true, + "OOO": true, + "ORG": true, + "ORGANIC": true, + "OTSUKA": true, + "OVH": true, + "PA": true, + "PARIS": true, + "PARTNERS": true, + "PARTS": true, + "PE": true, + "PF": true, + "PG": true, + "PH": true, + "PHARMACY": true, + "PHOTO": true, + "PHOTOGRAPHY": true, + "PHOTOS": true, + "PHYSIO": true, + "PICS": true, + "PICTURES": true, + "PINK": true, + "PIZZA": true, + "PK": true, + "PL": true, + "PLACE": true, + "PLUMBING": true, + "PM": true, + "PN": true, + "POHL": true, + "POST": true, + "PR": true, + "PRAXI": true, + "PRESS": true, + "PRO": true, + "PROD": true, + "PRODUCTIONS": true, + "PROF": true, + "PROPERTIES": true, + "PROPERTY": true, + "PS": true, + "PT": true, + "PUB": true, + "PW": true, + "PY": true, + "QA": true, + "QPON": true, + "QUEBEC": true, + "RE": true, + "REALTOR": true, + "RECIPES": true, + "RED": true, + "REHAB": true, + "REISE": true, + "REISEN": true, + "REN": true, + "RENTALS": true, + "REPAIR": true, + "REPORT": true, + "REPUBLICAN": true, + "REST": true, + "RESTAURANT": true, + "REVIEWS": true, + "RICH": true, + "RIO": true, + "RO": true, + "ROCKS": true, + "RODEO": true, + "RS": true, + "RSVP": true, + "RU": true, + "RUHR": true, + "RW": true, + "RYUKYU": true, + "SA": true, + "SAARLAND": true, + "SARL": true, + "SB": true, + "SC": true, + "SCA": true, + "SCB": true, + "SCHMIDT": true, + "SCHULE": true, + "SCOT": true, + "SD": true, + "SE": true, + "SERVICES": true, + "SEXY": true, + "SG": true, + "SH": true, + "SHIKSHA": true, + "SHOES": true, + "SI": true, + "SINGLES": true, + "SJ": true, + "SK": true, + "SL": true, + "SM": true, + "SN": true, + "SO": true, + "SOCIAL": true, + "SOFTWARE": true, + "SOHU": true, + "SOLAR": true, + "SOLUTIONS": true, + "SOY": true, + "SPACE": true, + "SPIEGEL": true, + "SR": true, + "ST": true, + "SU": true, + "SUPPLIES": true, + "SUPPLY": true, + "SUPPORT": true, + "SURF": true, + "SURGERY": true, + "SUZUKI": true, + "SV": true, + "SX": true, + "SY": true, + "SYSTEMS": true, + "SZ": true, + "TATAR": true, + "TATTOO": true, + "TAX": true, + "TC": true, + "TD": true, + "TECHNOLOGY": true, + "TEL": true, + "TF": true, + "TG": true, + "TH": true, + "TIENDA": true, + "TIPS": true, + "TIROL": true, + "TJ": true, + "TK": true, + "TL": true, + "TM": true, + "TN": true, + "TO": true, + "TODAY": true, + "TOKYO": true, + "TOOLS": true, + "TOP": true, + "TOWN": true, + "TOYS": true, + "TP": true, + "TR": true, + "TRADE": true, + "TRAINING": true, + "TRAVEL": true, + "TT": true, + "TUI": true, + "TV": true, + "TW": true, + "TZ": true, + "UA": true, + "UG": true, + "UK": true, + "UNIVERSITY": true, + "UNO": true, + "UOL": true, + "US": true, + "UY": true, + "UZ": true, + "VA": true, + "VACATIONS": true, + "VC": true, + "VE": true, + "VEGAS": true, + "VENTURES": true, + "VERSICHERUNG": true, + "VET": true, + "VG": true, + "VI": true, + "VIAJES": true, + "VILLAS": true, + "VISION": true, + "VLAANDEREN": true, + "VN": true, + "VODKA": true, + "VOTE": true, + "VOTING": true, + "VOTO": true, + "VOYAGE": true, + "VU": true, + "WALES": true, + "WANG": true, + "WATCH": true, + "WEBCAM": true, + "WEBSITE": true, + "WED": true, + "WF": true, + "WHOSWHO": true, + "WIEN": true, + "WIKI": true, + "WILLIAMHILL": true, + "WME": true, + "WORK": true, + "WORKS": true, + "WORLD": true, + "WS": true, + "WTC": true, + "WTF": true, + "XN--1QQW23A": true, + "XN--3BST00M": true, + "XN--3DS443G": true, + "XN--3E0B707E": true, + "XN--45BRJ9C": true, + "XN--4GBRIM": true, + "XN--55QW42G": true, + "XN--55QX5D": true, + "XN--6FRZ82G": true, + "XN--6QQ986B3XL": true, + "XN--80ADXHKS": true, + "XN--80AO21A": true, + "XN--80ASEHDB": true, + "XN--80ASWG": true, + "XN--90A3AC": true, + "XN--C1AVG": true, + "XN--CG4BKI": true, + "XN--CLCHC0EA0B2G2A9GCD": true, + "XN--CZR694B": true, + "XN--CZRU2D": true, + "XN--D1ACJ3B": true, + "XN--FIQ228C5HS": true, + "XN--FIQ64B": true, + "XN--FIQS8S": true, + "XN--FIQZ9S": true, + "XN--FPCRJ9C3D": true, + "XN--FZC2C9E2C": true, + "XN--GECRJ9C": true, + "XN--H2BRJ9C": true, + "XN--I1B6B1A6A2E": true, + "XN--IO0A7I": true, + "XN--J1AMH": true, + "XN--J6W193G": true, + "XN--KPRW13D": true, + "XN--KPRY57D": true, + "XN--KPUT3I": true, + "XN--L1ACC": true, + "XN--LGBBAT1AD8J": true, + "XN--MGB9AWBF": true, + "XN--MGBA3A4F16A": true, + "XN--MGBAAM7A8H": true, + "XN--MGBAB2BD": true, + "XN--MGBAYH7GPA": true, + "XN--MGBBH1A71E": true, + "XN--MGBC0A9AZCG": true, + "XN--MGBERP4A5D4AR": true, + "XN--MGBX4CD0AB": true, + "XN--NGBC5AZD": true, + "XN--NQV7F": true, + "XN--NQV7FS00EMA": true, + "XN--O3CW4H": true, + "XN--OGBPF8FL": true, + "XN--P1ACF": true, + "XN--P1AI": true, + "XN--PGBS0DH": true, + "XN--Q9JYB4C": true, + "XN--RHQV96G": true, + "XN--S9BRJ9C": true, + "XN--SES554G": true, + "XN--UNUP4Y": true, + "XN--VERMGENSBERATER-CTB": true, + "XN--VERMGENSBERATUNG-PWB": true, + "XN--VHQUV": true, + "XN--WGBH1C": true, + "XN--WGBL6A": true, + "XN--XHQ521B": true, + "XN--XKC2AL3HYE2A": true, + "XN--XKC2DL3A5EE0H": true, + "XN--YFRO4I67O": true, + "XN--YGBI2AMMX": true, + "XN--ZFR164B": true, + "XXX": true, + "XYZ": true, + "YACHTS": true, + "YANDEX": true, + "YE": true, + "YOKOHAMA": true, + "YOUTUBE": true, + "YT": true, + "ZA": true, + "ZIP": true, + "ZM": true, + "ZONE": true, + "ZW": true, +} + +// ExtendedTLDs is a set of additional "TLDs", allowing decentralized name +// systems, like TOR and Namecoin. +var ExtendedTLDs = map[string]bool{ + "BIT": true, + "ONION": true, +} diff --git a/crypto/key.go b/crypto/key.go index 4f702479a..8fcc13e7d 100644 --- a/crypto/key.go +++ b/crypto/key.go @@ -3,6 +3,7 @@ package crypto import ( "bytes" "errors" + "fmt" "crypto/elliptic" "crypto/hmac" @@ -12,7 +13,6 @@ import ( "crypto/sha256" "crypto/sha512" "hash" - "math/big" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto" @@ -96,25 +96,16 @@ func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error) { return nil, nil, err } - var pubKey bytes.Buffer - pubKey.Write(x.Bytes()) - pubKey.Write(y.Bytes()) + pubKey := elliptic.Marshal(curve, x, y) + u.PErr("GenerateEKeyPair %d\n", len(pubKey)) done := func(theirPub []byte) ([]byte, error) { // Verify and unpack node's public key. - curveSize := curve.Params().BitSize - - if len(theirPub) != (curveSize / 4) { - return nil, errors.New("Malformed public key.") + x, y := elliptic.Unmarshal(curve, theirPub) + if x == nil { + return nil, fmt.Errorf("Malformed public key: %d %v", len(theirPub), theirPub) } - bound := (curveSize / 8) - x := big.NewInt(0) - y := big.NewInt(0) - - x.SetBytes(theirPub[0:bound]) - y.SetBytes(theirPub[bound : bound*2]) - if !curve.IsOnCurve(x, y) { return nil, errors.New("Invalid public key.") } @@ -125,7 +116,7 @@ func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error) { return secret.Bytes(), nil } - return pubKey.Bytes(), done, nil + return pubKey, done, nil } // Generates a set of keys for each party by stretching the shared key. diff --git a/crypto/spipe/handshake.go b/crypto/spipe/handshake.go index f42f13aaa..a29d3c1d2 100644 --- a/crypto/spipe/handshake.go +++ b/crypto/spipe/handshake.go @@ -119,7 +119,7 @@ func (s *SecurePipe) handshake() error { } // u.POut("Selected %s %s %s\n", exchange, cipherType, hashType) - epubkey, done, err := ci.GenerateEKeyPair(exchange) // Generate EphemeralPubKey + epubkey, genSharedKey, err := ci.GenerateEKeyPair(exchange) // Generate EphemeralPubKey var handshake bytes.Buffer // Gather corpus to sign. handshake.Write(encoded) @@ -173,7 +173,7 @@ func (s *SecurePipe) handshake() error { return errors.New("Bad signature!") } - secret, err := done(exchangeResp.GetEpubkey()) + secret, err := genSharedKey(exchangeResp.GetEpubkey()) if err != nil { return err } diff --git a/importer/format/data.pb.go b/importer/format/data.pb.go index 9b8589d33..ffc942296 100644 --- a/importer/format/data.pb.go +++ b/importer/format/data.pb.go @@ -13,7 +13,7 @@ It has these top-level messages: */ package format -import proto "code.google.com/p/goprotobuf/proto" +import proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto" import math "math" // Reference imports to suppress errors if they are not otherwise used. diff --git a/namesys/dns.go b/namesys/dns.go index e9c4097d8..8dda6cb51 100644 --- a/namesys/dns.go +++ b/namesys/dns.go @@ -6,7 +6,7 @@ import ( b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" u "github.com/jbenet/go-ipfs/util" - isd "github.com/jbenet/go-is-domain" + isd "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain" ) // DNSResolver implements a Resolver on DNS domains diff --git a/util/util.go b/util/util.go index 39b635fdb..1e51064ed 100644 --- a/util/util.go +++ b/util/util.go @@ -122,11 +122,9 @@ func SetupLogging() { */ logging.SetFormatter(logging.MustStringFormatter(LogFormat)) - /* - for _, n := range loggers { - logging.SetLevel(logging.ERROR, n) - } - */ + for _, n := range loggers { + logging.SetLevel(logging.ERROR, n) + } } // Logger retrieves a particular logger + initializes it at a particular level