[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Remove dead code



commit 6fc723f9fe3503acc3d48c9778d9c1dfd0793b64
Author: aagbsn <aagbsn@xxxxxxxx>
Date:   Sun Nov 2 21:08:43 2014 +0000

    Remove dead code
---
 ooni/utils/net.py |  124 -----------------------------------------------------
 1 file changed, 124 deletions(-)

diff --git a/ooni/utils/net.py b/ooni/utils/net.py
index fbd0fb5..2f1a2c6 100644
--- a/ooni/utils/net.py
+++ b/ooni/utils/net.py
@@ -37,18 +37,6 @@ userAgents = ("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko
               "Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)")
 
 
-class UnsupportedPlatform(Exception):
-    """Support for this platform is not currently available."""
-
-
-class IfaceError(Exception):
-    """Could not find default network interface."""
-
-
-class PermissionsError(SystemExit):
-    """This test requires admin or root privileges to run. Exiting..."""
-
-
 PLATFORMS = {'LINUX': sys.platform.startswith("linux"),
              'OPENBSD': sys.platform.startswith("openbsd"),
              'FREEBSD': sys.platform.startswith("freebsd"),
@@ -125,51 +113,6 @@ class ConnectAndCloseProtocol(protocol.Protocol):
     def connectionMade(self):
         self.transport.loseConnection()
 
-def getSystemResolver():
-    """
-    XXX implement a function that returns the resolver that is currently
-    default on the system.
-    """
-
-
-def getClientPlatform(platform_name=None):
-    for name, test in PLATFORMS.items():
-        if not platform_name or platform_name.upper() == name:
-            if test:
-                return name, test
-
-
-def getPosixIfaces():
-    from twisted.internet.test import _posixifaces
-
-    log.msg("Attempting to discover network interfaces...")
-    ifaces = _posixifaces._interfaces()
-    ifup = tryInterfaces(ifaces)
-    return ifup
-
-
-def getWindowsIfaces():
-    from twisted.internet.test import _win32ifaces
-
-    log.msg("Attempting to discover network interfaces...")
-    ifaces = _win32ifaces._interfaces()
-    ifup = tryInterfaces(ifaces)
-    return ifup
-
-
-def getIfaces(platform_name=None):
-    client, test = getClientPlatform(platform_name)
-    if client:
-        if client == ('LINUX' or 'DARWIN') or client[-3:] == 'BSD':
-            return getPosixIfaces()
-        elif client == 'WINDOWS':
-            return getWindowsIfaces()
-        ## XXX fixme figure out how to get iface for Solaris
-        else:
-            return None
-    else:
-        raise UnsupportedPlatform
-
 
 def randomFreePort(addr="127.0.0.1"):
     """
@@ -193,70 +136,3 @@ def randomFreePort(addr="127.0.0.1"):
             pass
         s.close()
     return port
-
-
-def checkInterfaces(ifaces=None, timeout=1):
-    """
-    @param ifaces:
-        A dictionary in the form of ifaces['if_name'] = 'if_addr'.
-    """
-    try:
-        from scapy.all import IP, ICMP
-        from scapy.all import sr1  ## we want this check to be blocking
-    except:
-        log.msg(("Scapy required: www.secdev.org/projects/scapy"))
-
-    ifup = {}
-    if not ifaces:
-        log.debug("checkInterfaces(): no interfaces specified!")
-        return None
-
-    for iface in ifaces:
-        for ifname, ifaddr in iface:
-            log.debug("checkInterfaces(): testing iface {} by pinging"
-                      + " local address {}".format(ifname, ifaddr))
-            try:
-                pkt = IP(dst=ifaddr) / ICMP()
-                ans, unans = sr1(pkt, iface=ifname, timeout=5, retry=3)
-            except Exception, e:
-                raise PermissionsError if e.find("Errno 1") else log.err(e)
-            else:
-                if ans.summary():
-                    log.debug("checkInterfaces(): got answer on interface %s"
-                              + ":\n%s".format(ifname, ans.summary()))
-                    ifup.update(ifname, ifaddr)
-                else:
-                    log.debug("Interface test packet was unanswered:\n%s"
-                              % unans.summary())
-    if len(ifup) > 0:
-        log.msg("Discovered working network interfaces: %s" % ifup)
-        return ifup
-    else:
-        raise IfaceError
-
-
-def getNonLoopbackIfaces(platform_name=None):
-    try:
-        ifaces = getIfaces(platform_name)
-    except UnsupportedPlatform, up:
-        log.err(up)
-
-    if not ifaces:
-        log.msg("Unable to discover network interfaces...")
-        return None
-    else:
-        found = [{i[0]: i[2]} for i in ifaces if i[0] != 'lo']
-        log.debug("getNonLoopbackIfaces: Found non-loopback interfaces: %s"
-                  % found)
-        try:
-            interfaces = checkInterfaces(found)
-        except IfaceError, ie:
-            log.err(ie)
-            return None
-        else:
-            return interfaces
-
-
-def getLocalAddress():
-    default_iface = getDefaultIface()
-    return default_iface.ipaddr



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits