Skip to content

Commit

Permalink
Merge pull request #87 from michal0000000/master
Browse files Browse the repository at this point in the history
add: SK support
  • Loading branch information
likexian authored Oct 18, 2024
2 parents e69af3e + b900b84 commit 95f6cb3
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 4 deletions.
8 changes: 4 additions & 4 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestParse(t *testing.T) {
if !assert.IsContains([]string{"", "at", "aq", "br", "ch", "de", "edu", "eu", "fr", "gov", "hk",
"hm", "int", "it", "jp", "kr", "kz", "mo", "nl", "nz", "pl", "pm", "re", "ro", "ru", "su", "tf", "ee",
"tk", "travel", "tv", "tw", "uk", "wf", "yt", "ir", "fi", "rs", "dk", "by", "ua",
"xn--mgba3a4f16a", "xn--p1ai", "se", "nu", "hu"}, extension) {
"xn--mgba3a4f16a", "xn--p1ai", "se", "sk", "nu", "hu"}, extension) {
assert.NotZero(t, whoisInfo.Domain.ID)
}

Expand All @@ -130,7 +130,7 @@ func TestParse(t *testing.T) {

if !assert.IsContains([]string{"aero", "ai", "at", "aq", "asia", "berlin", "biz", "br", "ch", "cn",
"co", "cymru", "de", "edu", "eu", "fr", "gov", "hk", "hm", "in", "int", "it", "jp", "kr",
"la", "london", "me", "mo", "museum", "name", "nl", "nz", "pm", "re", "ro", "ru", "sh",
"la", "london", "me", "mo", "museum", "name", "nl", "nz", "pm", "re", "ro", "ru", "sh", "sk",
"kz", "su", "tel", "ee", "tf", "tk", "travel", "tw", "uk", "us", "wales", "wf", "xxx",
"yt", "ir", "fi", "rs", "dk", "by", "ua", "xn--mgba3a4f16a", "xn--fiqs8s", "xn--p1ai",
"se", "nu", "hu"}, extension) {
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestParse(t *testing.T) {

if !assert.IsContains([]string{"", "ai", "at", "aq", "au", "br", "ca", "ch", "cn", "cx", "de",
"edu", "eu", "fr", "gov", "gs", "hk", "hm", "int", "it", "jp", "kr", "kz", "la", "mo", "nl",
"nz", "pl", "pm", "re", "ro", "ru", "su", "tf", "tk", "tw", "uk", "wf", "yt", "ir", "fi", "rs",
"nz", "pl", "pm", "re", "ro", "ru", "su", "sk", "tf", "tk", "tw", "uk", "wf", "yt", "ir", "fi", "rs",
"ee", "dk", "by", "ua", "xn--mgba3a4f16a", "xn--fiqs8s", "xn--p1ai", "se", "nu", "hu"}, extension) {
assert.NotZero(t, whoisInfo.Registrar.ID)
}
Expand All @@ -181,7 +181,7 @@ func TestParse(t *testing.T) {

if !assert.IsContains([]string{"", "aero", "ai", "at", "aq", "asia", "au", "br", "ch", "cn", "de",
"edu", "gov", "hk", "hm", "int", "jp", "kr", "kz", "la", "london", "love", "mo",
"museum", "name", "nl", "nz", "pl", "ru", "su", "tk", "top", "ir", "fi", "rs", "dk", "by", "ua",
"museum", "name", "nl", "nz", "pl", "ru", "sk", "su", "tk", "top", "ir", "fi", "rs", "dk", "by", "ua",
"xn--mgba3a4f16a", "xn--fiqs8s", "xn--p1ai", "se", "nu", "hu"}, extension) {
assert.NotZero(t, whoisInfo.Registrar.ReferralURL)
}
Expand Down
43 changes: 43 additions & 0 deletions prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ func Prepare(text, ext string) (string, bool) { //nolint:cyclop
return prepareUA(text), true
case "at":
return prepareAT(text), true
case "sk":
return prepareSK(text), true
default:
return text, false
}
Expand Down Expand Up @@ -1436,3 +1438,44 @@ func prepareAT(text string) string {

return result
}

// prepareSK do prepare the .sk domain
func prepareSK(text string) string {

tokens := map[string]string{
"Domain registrant": "Registrant",
"Authorised Registrar": "Registrar",
"Administrative Contact": "Administrative",
"Technical Contact": "Technical",
}

result := ""
prefix := ""

for _, v := range strings.Split(text, "\n") {

v = strings.TrimSpace(v)
v = strings.Replace(v, "\r", "", -1)

if v == "" {
continue
}

if strings.Contains(v, ":") {
vs := strings.SplitN(v, ":", 2)
value := strings.TrimSpace(vs[1])
token := strings.TrimSpace(vs[0])

if _, ok := tokens[token]; ok {
prefix = tokens[token]
prefix = fmt.Sprintf("%s ", prefix)
}

v = fmt.Sprintf("%s%s:%s", prefix, token, value)

}
result += "\n" + v
}

return result
}
5 changes: 5 additions & 0 deletions rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var (
"domain registered": "created_date",
"modified": "updated_date",
"changed": "updated_date",
"updated": "updated_date",
"update date": "updated_date",
"updated date": "updated_date",
"updated on": "updated_date",
Expand All @@ -98,6 +99,7 @@ var (
"expiry date": "expired_date",
"expiration time": "expired_date",
"renewal date": "expired_date",
"valid until": "expired_date",
"domain expire": "expired_date",
"domain expires": "expired_date",
"record expires on": "expired_date",
Expand All @@ -117,6 +119,7 @@ var (
"registrant nic hdl": "registrant_id",
"registrant nic handle": "registrant_id",
"registrant org id": "registrant_id",
"registrant domain registrant": "registrant_id",
"registrant name": "registrant_name",
"registrant person": "registrant_name",
"registrant contact": "registrant_name",
Expand Down Expand Up @@ -157,6 +160,7 @@ var (
"registrant contact postalcode": "registrant_postal_code",
"registrant contact postal code": "registrant_postal_code",
"registrant country": "registrant_country",
"registrant country code": "registrant_country",
"registrant country economy": "registrant_country",
"registrant contact country": "registrant_country",
"registrant phone": "registrant_phone",
Expand Down Expand Up @@ -185,5 +189,6 @@ var (
"registrant contact email": "registrant_email",
"registrant contact e mail": "registrant_email",
"registrant abuse contact email": "registrant_email",
"registrar authorised registrar": "registrar_id",
}
)
2 changes: 2 additions & 0 deletions testdata/noterror/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ If there is any problem, please feel free to open a new issue.
| .sexy | [line.sexy](sexy_line.sexy) | [line.sexy](sexy_line.sexy.json) ||
| .sh | [git.sh](sh_git.sh) | [git.sh](sh_git.sh.json) ||
| .sh | [google.sh](sh_google.sh) | [google.sh](sh_google.sh.json) ||
| .sk | [alza.sk](sk_alza.sk) | [alza.sk](sk_alza.sk.json) ||
| .sk | [google.sk](sk_google.sk) | [google.sk](sk_google.sk.json) ||
| .su | [git.su](su_git.su) | [git.su](su_git.su.json) ||
| .su | [google.su](su_google.su) | [google.su](su_google.su.json) ||
| .tel | [github.tel](tel_github.tel) | [github.tel](tel_github.tel.json) ||
Expand Down
56 changes: 56 additions & 0 deletions testdata/noterror/sk_alza.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Domain: alza.sk
Created: 2004-05-21
Valid Until: 2025-04-24
Updated: 2024-03-21
Domain Status: ok
Nameserver: beau.ns.cloudflare.com
Nameserver: gigi.ns.cloudflare.com

Domain registrant: A24C-154952
Name: Alza.cz a.s.
Organization: Alza.cz a.s.
Organization ID: 27082440
Street: Jankovcova 1522/53
City: Praha 7
Postal Code: 17000
Country Code: CZ
Authorised Registrar: ACTI-0024
Created: 2021-06-28
Updated: 2023-09-15

Registrar: ACTI-0024
Name: ACTIVE 24, s.r.o.
Organization: ACTIVE 24, s.r.o.
Organization ID: 25115804
Phone: +421.244460639
Email: [email protected]
Street: Sokolovska 394/17
City: Praha
Postal Code: 18600
Country Code: CZ
Created: 2017-09-14
Updated: 2024-10-10

Administrative Contact: A24C-154952
Name: Alza.cz a.s.
Organization: Alza.cz a.s.
Organization ID: 27082440
Street: Jankovcova 1522/53
City: Praha 7
Postal Code: 17000
Country Code: CZ
Created: 2021-06-28
Updated: 2023-09-15

Technical Contact: ACTI-0024
Name: ACTIVE 24, s.r.o.
Organization: ACTIVE 24, s.r.o.
Organization ID: 25115804
Phone: +421.244460639
Email: [email protected]
Street: Sokolovska 394/17
City: Praha
Postal Code: 18600
Country Code: CZ
Created: 2017-09-14
Updated: 2024-10-10
58 changes: 58 additions & 0 deletions testdata/noterror/sk_alza.sk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"domain": {
"domain": "alza.sk",
"punycode": "alza.sk",
"name": "alza",
"extension": "sk",
"status": [
"ok"
],
"name_servers": [
"beau.ns.cloudflare.com",
"gigi.ns.cloudflare.com"
],
"created_date": "2004-05-21",
"created_date_in_time": "2004-05-21T00:00:00Z",
"updated_date": "2024-03-21",
"updated_date_in_time": "2024-03-21T00:00:00Z",
"expiration_date": "2025-04-24",
"expiration_date_in_time": "2025-04-24T00:00:00Z"
},
"registrar": {
"name": "ACTIVE 24, s.r.o.",
"organization": "ACTIVE 24, s.r.o.",
"street": "Sokolovska 394/17",
"city": "Praha",
"postal_code": "18600",
"country": "CZ",
"phone": "+421.244460639",
"email": "[email protected]"
},
"registrant": {
"id": "A24C-154952",
"name": "Alza.cz a.s.",
"organization": "Alza.cz a.s.",
"street": "Jankovcova 1522/53",
"city": "Praha 7",
"postal_code": "17000",
"country": "CZ"
},
"administrative": {
"name": "Alza.cz a.s.",
"organization": "Alza.cz a.s.",
"street": "Jankovcova 1522/53",
"city": "Praha 7",
"postal_code": "17000",
"country": "CZ"
},
"technical": {
"name": "ACTIVE 24, s.r.o.",
"organization": "ACTIVE 24, s.r.o.",
"street": "Sokolovska 394/17",
"city": "Praha",
"postal_code": "18600",
"country": "CZ",
"phone": "+421.244460639",
"email": "[email protected]"
}
}
52 changes: 52 additions & 0 deletions testdata/noterror/sk_alza.sk.pre
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Domain:alza.sk
Created:2004-05-21
Valid Until:2025-04-24
Updated:2024-03-21
Domain Status:ok
Nameserver:beau.ns.cloudflare.com
Nameserver:gigi.ns.cloudflare.com
Registrant Domain registrant:A24C-154952
Registrant Name:Alza.cz a.s.
Registrant Organization:Alza.cz a.s.
Registrant Organization ID:27082440
Registrant Street:Jankovcova 1522/53
Registrant City:Praha 7
Registrant Postal Code:17000
Registrant Country Code:CZ
Registrar Authorised Registrar:ACTI-0024
Registrar Created:2021-06-28
Registrar Updated:2023-09-15
Registrar Registrar:ACTI-0024
Registrar Name:ACTIVE 24, s.r.o.
Registrar Organization:ACTIVE 24, s.r.o.
Registrar Organization ID:25115804
Registrar Phone:+421.244460639
Registrar Email:[email protected]
Registrar Street:Sokolovska 394/17
Registrar City:Praha
Registrar Postal Code:18600
Registrar Country Code:CZ
Registrar Created:2017-09-14
Registrar Updated:2024-10-10
Administrative Administrative Contact:A24C-154952
Administrative Name:Alza.cz a.s.
Administrative Organization:Alza.cz a.s.
Administrative Organization ID:27082440
Administrative Street:Jankovcova 1522/53
Administrative City:Praha 7
Administrative Postal Code:17000
Administrative Country Code:CZ
Administrative Created:2021-06-28
Administrative Updated:2023-09-15
Technical Technical Contact:ACTI-0024
Technical Name:ACTIVE 24, s.r.o.
Technical Organization:ACTIVE 24, s.r.o.
Technical Organization ID:25115804
Technical Phone:+421.244460639
Technical Email:[email protected]
Technical Street:Sokolovska 394/17
Technical City:Praha
Technical Postal Code:18600
Technical Country Code:CZ
Technical Created:2017-09-14
Technical Updated:2024-10-10
62 changes: 62 additions & 0 deletions testdata/noterror/sk_google.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Domain: google.sk
Created: 2003-07-24
Valid Until: 2025-07-24
Updated: 2024-06-22
Domain Status: clientTransferProhibited, clientUpdateProhibited, clientDeleteProhibited
Nameserver: ns1.google.com
Nameserver: ns2.google.com
Nameserver: ns3.google.com
Nameserver: ns4.google.com

Domain registrant: mmr-170347
Name: Domain Administrator
Organization: Google Ireland Holdings Unlimited Company
Organization ID: 369511
Phone: +353.14361000
Email: [email protected]
Street: 70 Sir John Rogerson's Quay
City: Dublin
Postal Code: 2
Country Code: IE
Authorised Registrar: MARK-0292
Created: 2019-06-07
Updated: 2019-06-07

Registrar: MARK-0292
Name: MarkMonitor International Limited
Organization: MarkMonitor International Limited
Organization ID: 4847541
Phone: +1.2083895740
Email: [email protected]
Street: 12 New Fetter Lane
City: London
Postal Code: EC4A 1JP
Country Code: UK
Created: 2018-06-27
Updated: 2024-09-30

Administrative Contact: mmr-170347
Name: Domain Administrator
Organization: Google Ireland Holdings Unlimited Company
Organization ID: 369511
Phone: +353.14361000
Email: [email protected]
Street: 70 Sir John Rogerson's Quay
City: Dublin
Postal Code: 2
Country Code: IE
Created: 2019-06-07
Updated: 2019-06-07

Technical Contact: mmr-170347
Name: Domain Administrator
Organization: Google Ireland Holdings Unlimited Company
Organization ID: 369511
Phone: +353.14361000
Email: [email protected]
Street: 70 Sir John Rogerson's Quay
City: Dublin
Postal Code: 2
Country Code: IE
Created: 2019-06-07
Updated: 2019-06-07
Loading

0 comments on commit 95f6cb3

Please sign in to comment.