Branch 'v1.4' - server/mirrormanager
by Matt Domsch
server/mirrormanager/controllers.py | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
New commits:
commit f0356370962eaa9dd8bac33c4b8b1c747a577725
Author: Matt Domsch <Matt_Domsch(a)dell.com>
Date: Mon Jun 20 22:51:20 2011 -0500
controllers: add NetblockCountry simple interface
diff --git a/server/mirrormanager/controllers.py b/server/mirrormanager/controllers.py
index 66c6c5b..d0f2ffb 100644
--- a/server/mirrormanager/controllers.py
+++ b/server/mirrormanager/controllers.py
@@ -1205,6 +1205,33 @@ class LocationHostController(controllers.Controller, identity.SecureResource, co
raise redirect("/adminview")
+#########################################################3
+# NetblockCountry
+#########################################################3
+class NetblockCountryFields(widgets.WidgetsList):
+ netblock = widgets.TextField(validator=validators.All(validators.NotEmpty, validators.UnicodeString))
+ country = widgets.TextField(validator=validators.All(validators.NotEmpty, validators.UnicodeString))
+
+netblock_country_form = widgets.TableForm(fields=NetblockCountryFields(), submit_text="Create Netblock->Country mapping")
+
+class NetblockCountryController(SimpleDbObjectController):
+ page_title = "Netblock to Country mapping"
+ myClass = NetblockCountry
+ url_prefix="netblock_country"
+ form = netblock_country_form
+
+ @expose(template="mirrormanager.templates.boringform")
+ @validate(form=form)
+ @error_handler(SimpleDbObjectController.new)
+ def create(self, **kwargs):
+ SimpleDbObjectController.create(self, **kwargs)
+
+ @expose(template="mirrormanager.templates.boringform")
+ @validate(form=form)
+ @error_handler()
+ def update(self, obj, **kwargs):
+ return SimpleDbObjectController.update(self, obj, **kwargs)
+
class Root(controllers.RootController):
# reserved for other uses outside TG
12 years, 10 months
Branch 'v1.4' - mirrorlist-server/mirrorlist_server.py
by Matt Domsch
mirrorlist-server/mirrorlist_server.py | 84 +++++++++++++++++++--------------
1 file changed, 50 insertions(+), 34 deletions(-)
New commits:
commit c6d9928929852137fe2567e05c8da57fb8cde4e5
Author: Matt Domsch <Matt_Domsch(a)dell.com>
Date: Mon Jun 20 22:37:45 2011 -0500
mirrorlist_server: add netblock country cache lookup
diff --git a/mirrorlist-server/mirrorlist_server.py b/mirrorlist-server/mirrorlist_server.py
index fafe90a..cdc856d 100755
--- a/mirrorlist-server/mirrorlist_server.py
+++ b/mirrorlist-server/mirrorlist_server.py
@@ -65,6 +65,7 @@ asn_host_cache = {}
internet2_tree = radix.Radix()
global_tree = radix.Radix()
host_netblocks_tree = radix.Radix()
+netblock_country_tree = radix.Radix()
location_cache = {}
netblock_country_cache = {}
@@ -184,24 +185,26 @@ def metalink(cache, directory, file, hosts_and_urls):
doc += '</metalink>\n'
return ('metalink', 200, doc)
-def client_netblocks(ip):
- result = []
- try:
- clientIP = IP(ip)
- except:
- return result
-
+def tree_lookup(tree, clientIP):
# fast lookup in the tree; if present, find all the netblocks by deleting the found one and searching again
# this is safe w/o copying the tree again only because this is the only place the tree is used, and
# we'll get a new copy of the tree from our parent the next time it fork()s.
- node = host_netblocks_tree.search_best(clientIP.strNormal())
+ result = []
+ node = tree.search_best(clientIP.strNormal())
while node is not None:
result.extend(node.data['hosts'])
prefix = node.prefix
- host_netblocks_tree.delete(prefix)
- node = host_netblocks_tree.search_best(clientIP.strNormal())
+ tree.delete(prefix)
+ node = tree.search_best(clientIP.strNormal())
return result
+def client_netblocks(ip):
+ try:
+ clientIP = IP(ip)
+ except:
+ return []
+ result = tree_lookup(host_netblocks_tree, clientIP)
+
def trim_by_client_country(s, clientCountry):
if clientCountry is None:
return s
@@ -401,6 +404,36 @@ def trim_to_preferred_protocols(hosts_and_urls):
results.append((hostid, url))
return results
+def client_ip_to_country(client_ip):
+ clientCountry = None
+ try:
+ ip = IP(client_ip)
+ except:
+ return None
+
+ # lookup in the cache first
+ result = tree_lookup(netblock_country_tree, ip)
+ if len(result) > 0:
+ clientCountry = result[0]
+ return clientCountry
+
+ # attempt IPv6, then IPv6 6to4 as IPv4, then Teredo, then IPv4
+ try:
+ if ip.version() == 6:
+ if gipv6 is not None:
+ clientCountry = gipv6.country_code_by_addr_v6(ip.strNormal())
+ if clientCountry is None:
+ # Try the IPv6-to-IPv4 translation schemes
+ for scheme in (convert_6to4_v4, convert_teredo_v4):
+ result = scheme(ip)
+ if result is not None:
+ ip = result
+ break
+ if ip.version() == 4 and gipv4 is not None:
+ clientCountry = gipv4.country_code_by_addr(ip.strNormal())
+ except:
+ pass
+ return clientCountry
def do_mirrorlist(kwargs):
global debug
@@ -500,25 +533,7 @@ def do_mirrorlist(kwargs):
done = 1
client_ip = kwargs['client_ip']
- clientCountry = None
- # fixme!! lookup client in netblock_country_cache here first
- # attempt IPv6, then IPv6 6to4 as IPv4, then Teredo, then IPv4
- try:
- ip = IP(client_ip)
- if ip.version() == 6:
- if gipv6 is not None:
- clientCountry = gipv6.country_code_by_addr_v6(ip.strNormal())
- if clientCountry is None:
- # Try the IPv6-to-IPv4 translation schemes
- for scheme in (convert_6to4_v4, convert_teredo_v4):
- result = scheme(ip)
- if result is not None:
- ip = result
- break
- if ip.version() == 4 and gipv4 is not None:
- clientCountry = gipv4.country_code_by_addr(ip.strNormal())
- except:
- pass
+ clientCountry = client_ip_to_country(client_ip)
if clientCountry is None:
print_client_country = "N/A"
@@ -612,16 +627,14 @@ def do_mirrorlist(kwargs):
d = dict(message=header, resulttype='mirrorlist', returncode=200, results=host_url_list)
return d
-
-def setup_host_netblocks_tree():
+def setup_cache_tree(cache):
tree = radix.Radix()
- for k, v in host_netblock_cache.iteritems():
+ for k, v in cache.iteritems():
node = tree.add(k.strNormal())
node.data['hosts'] = v
return tree
def setup_netblocks(netblocks_file):
-
tree = radix.Radix()
if netblocks_file is not None:
try:
@@ -701,14 +714,17 @@ def read_caches():
global internet2_tree
global global_tree
global host_netblocks_tree
+ global netblock_country_tree
del internet2_tree
del global_tree
del host_netblocks_tree
+ del netblock_country_tree
internet2_tree = setup_netblocks(internet2_netblocks_file)
global_tree = setup_netblocks(global_netblocks_file)
- host_netblocks_tree = setup_host_netblocks_tree()
+ host_netblocks_tree = setup_cache_tree(host_netblock_cache)
+ netblock_country_tree = setup_cache_tree(netblock_country_cache)
def errordoc(metalink, message):
if metalink:
12 years, 10 months
Branch 'v1.4' - server/mirrormanager
by Matt Domsch
server/mirrormanager/templates/site.kid | 33 +++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
New commits:
commit b8374548fdef843e12b2b2140233589c5d90a329
Author: Matt Domsch <Matt_Domsch(a)dell.com>
Date: Thu Jun 16 15:33:53 2011 -0500
updated export compliance text from spot
diff --git a/server/mirrormanager/templates/site.kid b/server/mirrormanager/templates/site.kid
index ac50df6..4aafe56 100644
--- a/server/mirrormanager/templates/site.kid
+++ b/server/mirrormanager/templates/site.kid
@@ -31,23 +31,26 @@ License Agreement</a>.
</p>
<h2>Export Compliance</h2>
<p>
-Because Fedora software contains encryption technology, Fedora
-software and technical information is subject to the
-U.S. Export Administration Regulations and other U.S. and foreign law,
-and may not be exported or re-exported to certain countries (currently
-Cuba, Iran, Iraq, North Korea, Sudan and Syria) or to persons or
-entities prohibited from receiving U.S. exports (including those (a)
-on the Bureau of Industry and Security Denied Parties List or Entity
-List, (b) on the Office of Foreign Assets Control list of Specially
-Designated Nationals and Blocked Persons, and (c) involved with
-missile technology or nuclear, chemical or biological weapons). You
-may not download Fedora software or technical information if you are
-located in one of these countries, or otherwise affected by these
-restrictions. You may not provide Fedora software or technical
+By downloading Fedora software, you acknowledge that you understand
+all of the following: Fedora software and technical information may be
+subject to the U.S. Export Administration Regulations (the “EAR”) and
+other U.S. and foreign laws and may not be exported, re-exported or
+transferred (a) to any country listed in Country Group E:1 in
+Supplement No. 1 to part 740 of the EAR (currently, Cuba, Iran, North
+Korea, Sudan and Syria); (b) to any prohibited destination or to any end
+user who has been prohibited from participating in U.S. export
+transactions by any federal agency of the U.S. government; or (c) for
+use in connection with the design, development or production of
+nuclear, chemical or biological weapons, or rocket systems, space
+launch vehicles, or sounding rockets, or unmanned air vehicle
+systems. You may not download Fedora software or technical information
+if you are located in one of these countries or otherwise subject to
+these restrictions. You may not provide Fedora software or technical
information to individuals or entities located in one of these
-countries or otherwise affected by these restrictions. You are also
+countries or otherwise subject to these restrictions. You are also
responsible for compliance with foreign law requirements applicable to
-the import and use of Fedora software and technical information.
+the import, export and use of Fedora software and technical
+information.
</p>
${form(value=values, action=tg.url(action), disabled_fields=disabled_fields)}
12 years, 10 months