summaryrefslogtreecommitdiffstats
path: root/Tools/world/world
blob: ac295cd62aa3e3239e0a4fd804234e88922bec94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#! /depot/sundry/plat/bin/python
#
# Note: you may have to edit the top line in this file.
#
# Usage: world addr1 [addr2 ...]
#
# $Id$

# This little perl program will take an internet address of the form
# foobar@some.place.domain and will print out where in the world that
# message originated from.  Its pretty dumb in that it just matches
# the `domain' part against a hard-coded list.  Also, I haven't
# checked the list for validity -- I picked it up from someplace. With
# the speed in which political boundaries are changing these days, no
# doubt there are some incorrect mappings.

import sys
prog = sys.argv[0]
del sys.argv[0]
if not sys.argv:
    print "No addresses provided.\nUsage:", prog, "addr1 [addr2 ...]\n"


# The mappings
nameorg = {
    "arpa": "Arpanet",
    "com": "commercial",
    "edu": "educational",
    "gov": "government",
    "mil": "military",
    "net": "networking",
    "org": "non-commercial",
    "int": "international"
    }


country = {
    "ag": "Antigua and Barbuda",
    "al": "Albania",
    "aq": "Antarctica",
    "ar": "Argentina",
    "at": "Austria",
    "au": "Australia",
    "bb": "Barbados",
    "be": "Belgium",
    "bg": "Bulgaria",
    "bo": "Bolivia",
    "br": "Brazil",
    "bs": "Bahamas",
    "bz": "Belize",
    "ca": "Canada",
    "ch": "Switzerland",
    "cl": "Chile",
    "cm": "Cameroon",
    "cn": "China",
    "co": "Colombia",
    "cr": "Costa Rica",
    "cy": "Cyprus",
    "cz": "Czech Republic",
    "de": "Germany",
    "dk": "Denmark",
    "dm": "Dominica",
    "do": "Dominican Republic",
    "ec": "Ecuador",
    "ee": "Estonia",
    "eg": "Egypt",
    "es": "Spain",
    "fi": "Finland",
    "fj": "Fiji",
    "fr": "France",
    "gb": "Great Britain",
    "gh": "Ghana",
    "gr": "Greece",
    "hk": "Hong Kong",
    "hr": "Croatia",
    "hu": "Hungary",
    "id": "Indonesia",
    "ie": "Ireland",
    "il": "Israel",
    "in": "India",
    "is": "Iceland",
    "it": "Italy",
    "jm": "Jamaica",
    "jp": "Japan",
    "km": "Comoros",
    "kn": "Saint Kitts and Nevis",
    "kr": "Republic of Korea",
    "kw": "Kuwait",
    "lc": "Saint Lucia",
    "li": "Liechtenstein",
    "lk": "Sri Lanka",
    "lu": "Luxembourg",
    "lv": "Latvia",
    "my": "Malaysia",
    "mx": "Mexico",
    "na": "Namibia",
    "ni": "Nicaragua",
    "nl": "Netherlands",
    "no": "Norway",
    "nz": "New Zealand",
    "pe": "Peru",
    "pg": "Papua New Guinea",
    "ph": "Philippines",
    "pl": "Poland",
    "pr": "Puerto Rico",
    "pt": "Portugal",
    "py": "Paraguay",
    "ro": "Romania",
    "se": "Sweden",
    "sg": "Singapore",
    "si": "Slovenia",
    "sk": "Slovakia",
    "sr": "Suriname",
    "su": "USSR",
    "tw": "Taiwan",
    "th": "Thailand",
    "tn": "Tunisia",
    "tr": "Turkey",
    "tt": "Trinidad and Tobago",
    "uk": "United Kingdom",
    "us": "United States",
    "uy": "Uruguay",
    "vc": "Saint Vincent and the Grenadines",
    "ve": "Venezuela",
    "vi": "Virgin Islands",
    "yu": "Yugoslavia",
    "za": "South Africa",
    "zw": "Zimbabwe"
    }

import string

while sys.argv:
    rawaddr = sys.argv[0]
    del sys.argv[0]

    components = string.splitfields(rawaddr, ".")
    addr = components[-1]

    if nameorg.has_key(addr):
	print addr, "is from a USA", nameorg[addr], "organization"
    elif country.has_key(addr):
	print addr, "originated from", country[addr]
    else:
	print "I have no idea where", addr, "came from!"