Skip to content

Commit

Permalink
core: services: beacon: Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Aug 1, 2023
1 parent 9fd0fd5 commit 426810c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/services/beacon/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def get_phys(self) -> List[psutil._common.snicaddr]:

def get_ip_strs(self) -> List[str]:
"""
get ip as a string. this also translates 'ips[n]' to the n-th ip in that interface
gets a list of the interface IPs (IPv4 only) as a list of strings:
- if self.ip is "ips[*]", it returns all ips of that interface
- if self.ip is "ips[n]", it returns the n-th ip of that interface
- if self.ip is a single ipv4 (like "192.168.2.2"), it returns that ip as a string
- if self.ip is (mistakenly) an IPv6, it raises an InvalidIpAddress error
"""
address = str(self.ip)
# Check for 'ips[n]'
Expand Down Expand Up @@ -71,7 +75,7 @@ def get_ip_strs(self) -> List[str]:

def get_ips(self) -> List[bytes]:
"""
returns the ip as 4 bytes
returns a list of the interface IPs (IPv4 only) as a list of 4 bytes
"""
return [socket.inet_aton(ip) for ip in self.get_ip_strs()]

Expand Down

0 comments on commit 426810c

Please sign in to comment.