Exemple #1
0
 def _get_ip_addr(self):
     if not self._ip_addr:
         ifaces = platform.net_interfaces()
         try:
             self._ip_addr = [iface["ipv4"] for iface in ifaces if platform.is_private_ip(iface["ipv4"])][0]
         except IndexError:
             try:
                 self._ip_addr = [iface["ipv4"] for iface in ifaces if platform.is_public_ip(iface["ipv4"])][0]
             except IndexError:
                 pass
     return self._ip_addr
Exemple #2
0
 def _get_ip_addr(self):
     if not self._ip_addr:
         ifaces = platform.net_interfaces()
         try:
             self._ip_addr = [
                 iface['ipv4'] for iface in ifaces
                 if platform.is_private_ip(iface['ipv4'])
             ][0]
         except IndexError:
             try:
                 self._ip_addr = [
                     iface['ipv4'] for iface in ifaces
                     if platform.is_public_ip(iface['ipv4'])
                 ][0]
             except IndexError:
                 pass
     return self._ip_addr
Exemple #3
0
 def get_public_ip(self):
     if self._public_ip is None:
         ifaces = platform.net_interfaces()
         self._public_ip = ifaces[
             'eth0'] if 'eth1' in ifaces and 'eth0' in ifaces else ''
     return self._public_ip
Exemple #4
0
 def get_private_ip(self):
     if self._private_ip is None:
         ifaces = platform.net_interfaces()
         self._private_ip = ifaces['eth1' if 'eth1' in ifaces else 'eth0']
     return self._private_ip
Exemple #5
0
 def get_public_ip(self):
     if self._public_ip is None:
         ifaces = platform.net_interfaces()
         self._public_ip = ifaces['eth0'] if 'eth1' in ifaces and 'eth0' in ifaces else ''
     return self._public_ip
Exemple #6
0
 def get_private_ip(self):
     if self._private_ip is None:
         ifaces = platform.net_interfaces()
         self._private_ip = ifaces['eth1' if 'eth1' in ifaces else 'eth0']
     return self._private_ip