mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 03:52:17 +03:00
ip addresses formatted
This commit is contained in:
parent
114a44c223
commit
1979d4815e
1 changed files with 23 additions and 12 deletions
|
@ -12,6 +12,7 @@ import psutil
|
|||
from uuid import getnode as get_mac
|
||||
|
||||
from base.Scope import Scope
|
||||
from base.system.system import System
|
||||
from base.messaging.AnonymousMessager import AnonymousMessager
|
||||
|
||||
|
||||
|
@ -96,9 +97,11 @@ class Registration():
|
|||
self.logger.debug('[Registration] Registration parameters were created')
|
||||
|
||||
def get_registration_params(self):
|
||||
|
||||
print(System.Hardware.Network.ip_addresses())
|
||||
params = {
|
||||
'ipAddresses': str(self.get_ip_address()),
|
||||
'macAddresses': str(':'.join(("%012X" % get_mac())[i:i + 2] for i in range(0, 12, 2))),
|
||||
'ipAddresses': self.get_ip_address(),
|
||||
'macAddresses': System.Hardware.mac_address(),
|
||||
'hostname': str(socket.gethostname()),
|
||||
'system': str(platform.system()),
|
||||
'node': str(platform.node()),
|
||||
|
@ -113,6 +116,13 @@ class Registration():
|
|||
|
||||
return json.dumps(params)
|
||||
|
||||
def get_ip_address(self):
|
||||
arr = []
|
||||
for ip in System.Hardware.Network.ip_addresses():
|
||||
if ip is not 'localhost' and ip is not '127.0.0.1':
|
||||
arr.append(ip)
|
||||
return str(arr).replace('[','').replace(']','')
|
||||
|
||||
def get_disks(self):
|
||||
disk_info = []
|
||||
for _disk in psutil.disk_partitions():
|
||||
|
@ -146,11 +156,12 @@ class Registration():
|
|||
def generate_password(self):
|
||||
return uuid.uuid4()
|
||||
|
||||
"""
|
||||
def get_ip_address(self):
|
||||
f = os.popen('ifconfig eth0 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')
|
||||
return f.read()
|
||||
|
||||
"""
|
||||
|
||||
#TODO disabled because of netifaces dependency
|
||||
def get_ipAddresses(self):
|
||||
self.logger.debug('[Registration] looking for network interfaces')
|
||||
|
|
Loading…
Reference in a new issue