Example #1
0
 def get_iface(self):
     ifaces_list = []
     ifaces_tupel = netinfo.list_active_devs()
     for iface in ifaces_tupel:
         if not iface == 'lo':
             ifaces_list.append(iface)
     return ifaces_list[0]
Example #2
0
def getPublicIPs():
    ips = []

    interfaces = netinfo.list_active_devs()
    for interface in interfaces:
        if not interface.startswith('lo'):
            ip = netinfo.get_ip(interface)
            ips.append(ip)

    return ips
Example #3
0
    def fill_active_interfaces(self):
        ifaces_list = list()
        ifaces_tupel = netinfo.list_active_devs()
        for dev in ifaces_tupel:
            if not dev == 'lo':
                ifaces_list.append(dev)

        if len(ifaces_list) > 0:
            for iface in ifaces_list:
                self.comboIfaces.addItem(iface)
Example #4
0
 def run_send(self):
     while True:
         log.info("Broadcasting local repos")
         for repo in self.core.repos.values():
             for iface in netinfo.list_active_devs():
                 self.socket.sendto(
                     repo.encrypt(repo.uuid.decode("hex")),
                     (netinfo.get_broadcast(iface), 54545)
                 )
         sleep(15)  # low for debugging, probably want this higher
Example #5
0
def getPublicIPs():
    ips = []

    interfaces = netinfo.list_active_devs()
    for interface in interfaces:
        if not interface.startswith("lo"):
            ip = netinfo.get_ip(interface)
            ips.append(ip)

    return ips
Example #6
0
def getMyIP():

    # Change this to retrieve and
    # return the IP of the current system.
    # The IP address
    for dev in netinfo.list_active_devs():
        # The IP address of the interface
        addr = netinfo.get_ip(dev)
        # Get the IP address
        if not addr == "127.0.0.1":
            # Save the IP address and break
            return addr
Example #7
0
    def test_task_3(self):
        results = dict()
        threads = list()

        for iface in netinfo.list_active_devs():
            args = [DEST_IP, iface, PACKET_COUNT, results]
            threads.append(SniffSync(*args))
            args.pop()
            threads.append(Ping(*args))

        for t in threads:
            t.start()

        for t in threads:
            t.join()

        for k, v in results.iteritems():
            self.assertEqual(PACKET_COUNT, v)
def init_tv():
	global lan_ip
	global wan_ip
	global wlan_ip
	global tv_thread
	for dev in netinfo.list_active_devs():
		print dev
		if dev == 'eth0':
			lan_ip = netinfo.get_ip(dev)
			print 'get lan ip:',lan_ip
			print dev
			print netinfo.get_ip(dev)
		elif dev == 'wlan0':
			wlan_ip = netinfo.get_ip(dev)
			print wlan_ip
		elif dev == 'lo':
			print 'local ip'
		##todo wan ip
		elif dev == 'ppp0':
			wan_ip = netinfo.get_ip(dev)
	
	tv_thread.setDaemon(True)
	tv_thread.start()
Example #9
0
 def getSystemIfs():
     return netinfo.list_active_devs()
Example #10
0
#    www.sassan.me.uk
#    pypi.python.org/pypi/pynetinfo/

#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.

#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import netinfo
for dev in netinfo.list_active_devs():
    print "*********************************"
    print dev
    print "mac: " + netinfo.get_hwaddr(dev)
    print "ip: " + netinfo.get_ip(dev)
    print "netmask: " + netinfo.get_netmask(dev)
    print "broadcast: " + netinfo.get_broadcast(dev)
print "######################################"
for route in netinfo.get_routes():
    print route['dest'] + "/" + route['netmask'] + " -> " + route['gateway']

#netinfo.del_route("", "192.168.0.0", "164.11.222.253", "255.255.255.0");
Example #11
0
import netinfo
for dev in netinfo.list_active_devs():
	print "*********************************"
	print dev
	print "mac: "+netinfo.get_hwaddr(dev)
	print "ip: "+netinfo.get_ip(dev)
	print "netmask: "+netinfo.get_netmask(dev)
	print "broadcast: "+netinfo.get_broadcast(dev)
print "######################################"
for route in netinfo.get_routes():
    print route['dest']+"/"+route['netmask']+" -> "+route['gateway']


#netinfo.del_route("", "192.168.0.0", "164.11.222.253", "255.255.255.0");
Example #12
0
def first_eth_iface():
    for i in netinfo.list_active_devs():
        if re.match('^eth\w+$', i):
            return i
    raise Exception('No ethX interfaces found in the system!')
Example #13
0
def isMyAddr(addr):
    for devName in netinfo.list_active_devs():
        #print "Addr %s %s" % (netinfo.get_ip(devName),  addr)
        if cmp(netinfo.get_ip(devName),  addr) == 0:
            return True
    return False
Example #14
0
def get_local_ips():
    inetIPs = []
    for interface in netinfo.list_active_devs():
        ip = netinfo.get_ip(interface)
        inetIPs.append(ip)
    return inetIPs
Example #15
0
def getMyIP():
	for interface in netinfo.list_active_devs():
		if not interface.startswith('lo'):
			return netinfo.get_ip(interface)
Example #16
0
def get_ip():
    return tuple([info.get_ip(iface) for iface in info.list_active_devs()])