Commit fa51a0e2 authored by Mateus Goto's avatar Mateus Goto

[Fixed] minors issues

parent a36406ed
from Utility.IPFinder import IPFinder import sys
sys.path.insert(0, "..")
from NHR9400series.NHR9410 import NHR9410 from NHR9400series.NHR9410 import NHR9410
from NHR9400series.NHR9430 import NHR9430 from NHR9400series.NHR9430 import NHR9430
from Utility.IPFinder import IPFinder
class controlInterface: class controlInterface:
def __init__(self): def __init__(self):
self.__listIp = IPFinder.getList() self.__listIp = []
self.__listUsedIp = [] self.__listUsedIp = []
self.__nhr9410 = [] self.__nhr9410 = []
self.__nhr9430 = [] self.__nhr9430 = []
#refresh the list of ip #refresh the list of ip
def refresh(self): def refresh(self):
self.__listIp = IPFinder.getList() ipfinder = IPFinder()
self.__listIp = ipfinder.getList()
for ip in self.__listUsedIp: for ip in self.__listUsedIp:
self.__listIp.remove(ip) self.__listIp.remove(ip)
#create a NHR9410 object #create a NHR9410 object
def newNhr9410(self): def newNhr9410(self):
new = NHR9410 new = NHR9410()
new.__init__() new.__init__()
new.locateIp(self.__listIp) new.locateIp(self.__listIp)
print(self.getListIp())
usedIp = new.getIp() usedIp = new.getIp()
self.__listIp.remove(usedIp) self.__listIp.remove(usedIp)
self.__listUsedIp.append(usedIp) self.__listUsedIp.append(usedIp)
...@@ -27,7 +34,7 @@ class controlInterface: ...@@ -27,7 +34,7 @@ class controlInterface:
#create a NHR9430 object #create a NHR9430 object
def newNhr9430(self): def newNhr9430(self):
new = NHR9430 new = NHR9430()
new.__init__() new.__init__()
new.locateIp(self.__listIp) new.locateIp(self.__listIp)
usedIp = new.getIp() usedIp = new.getIp()
...@@ -41,3 +48,5 @@ class controlInterface: ...@@ -41,3 +48,5 @@ class controlInterface:
def getNhr9430(self): def getNhr9430(self):
return self.__nhr9430 return self.__nhr9430
def getListIp(self):
return self.__listIp
import socket import socket
from threading import local
from scapy.all import ARP, Ether, srp from scapy.all import ARP, Ether, srp
...@@ -25,6 +24,8 @@ class IPFinder: ...@@ -25,6 +24,8 @@ class IPFinder:
clients = [] clients = []
for sent, received in result: for sent, received in result:
clients.append({"ip": received.psrc}) clients.append({"ip": received.psrc})
print(clients)
self.__clients = clients self.__clients = clients
def deteleIp(self, ip): def deteleIp(self, ip):
......
from Control_Interface.controlInterface import controlInterface from Control_Interface.controlInterface import controlInterface
from Utility.IPFinder import IPFinder
interface = controlInterface()
interface = controlInterface ips = []
ips = IPFinder().getList()
print(ips)
interface.newNhr9410() interface.newNhr9410()
interface.newNhr9430() interface.newNhr9430()
#interface.newNhr9430() #interface.newNhr9430()
nhr10 = [] nhr10 = []
print(nhr10)
nhr30 = [] nhr30 = []
nhr10 = interface.getNhr9410() nhr10 = interface.getNhr9410()
nhr30 = interface.getNhr9430() nhr30 = interface.getNhr9430()
......
(packet, timeout=3,retry = 1, verbose = 0)[0]
\ No newline at end of file
...@@ -10,7 +10,7 @@ def getAllIp(): ...@@ -10,7 +10,7 @@ def getAllIp():
s.connect(("10.255.255.255",1)) s.connect(("10.255.255.255",1))
local_ip = s.getsockname()[0] local_ip = s.getsockname()[0]
print(local_ip) print(local_ip)
local_ip = local_ip[:-3] + "1/24" local_ip = local_ip[:-2] + "1/24"
print(local_ip) print(local_ip)
print(type(local_ip)) print(type(local_ip))
arp = ARP(pdst=local_ip) arp = ARP(pdst=local_ip)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment