summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvuko <vuko@hackerspace.pl>2021-01-04 11:07:18 +0100
committervuko <vuko@hackerspace.pl>2021-01-04 11:08:44 +0100
commit74a4a02ada1c3a9a4fde40cd12ced1351824e84d (patch)
tree408f12bf0d39ea6708efbf83e708e6b0eae4119d
parent8c3a6834707634e227e517b131291539ace0b750 (diff)
downloadcheckinator-74a4a02ada1c3a9a4fde40cd12ced1351824e84d.tar.gz
checkinator-74a4a02ada1c3a9a4fde40cd12ced1351824e84d.tar.bz2
checkinator-74a4a02ada1c3a9a4fde40cd12ced1351824e84d.zip
add ip addres and hostname to get-clients api
-rw-r--r--at/cmd.py4
-rw-r--r--at/tracker.py4
2 files changed, 5 insertions, 3 deletions
diff --git a/at/cmd.py b/at/cmd.py
index c3707ff..1cd534e 100644
--- a/at/cmd.py
+++ b/at/cmd.py
@@ -26,11 +26,11 @@ def format_mac(raw: bytes) -> str:
def tracker_list():
parser = argparse.ArgumentParser()
- parser.add_argument("address", default='unix:///tmp/checkinator.sock', nargs='?', help="leases file")
+ parser.add_argument("address", default='unix:///tmp/checkinator.sock', nargs='?', help="tracker grpc address")
parser.add_argument("--timeout", type=int, default=None, help="timeout in minutes")
args = parser.parse_args()
with grpc.insecure_channel(args.address) as channel:
stub = DhcpTrackerStub(channel)
response = stub.GetClients(ClientsRequest())
for client in response.clients:
- print(format_mac(client.hw_address), client.last_seen )
+ print(format_mac(client.hw_address), client.last_seen, client.ip_address, client.client_hostname )
diff --git a/at/tracker.py b/at/tracker.py
index 01fa05b..efecbdd 100644
--- a/at/tracker.py
+++ b/at/tracker.py
@@ -16,7 +16,9 @@ parser.add_argument("config", type=Path, help="input file")
def lease_to_client(lease: DhcpLease) -> DhcpClient:
return DhcpClient(
hw_address = bytes.fromhex(lease.hwaddr.replace(':', '')),
- last_seen = datetime.fromtimestamp(lease.atime).isoformat(),
+ last_seen = datetime.utcfromtimestamp(lease.atime).isoformat(),
+ client_hostname = lease.name,
+ ip_address = lease.ip
)
class DhcpTrackerServicer(DhcpTrackerServicer):