mirror of
https://codeberg.org/prof_x_pvt_ltd/captive.whump.shanti-portal
synced 2024-08-14 22:46:42 +00:00
try to do a purge as well for old clients with no traffic.
This commit is contained in:
parent
2faac71fe5
commit
742cf01e86
1 changed files with 10 additions and 1 deletions
|
@ -107,6 +107,8 @@ if args.refresh:
|
|||
timeout=600
|
||||
)
|
||||
|
||||
current_date = datetime.now()
|
||||
|
||||
for _line in proc.stdout.splitlines():
|
||||
# Convert from bytestring first
|
||||
line = _line.decode('utf-8')
|
||||
|
@ -142,10 +144,17 @@ if args.refresh:
|
|||
client.commit()
|
||||
|
||||
if int(packets_val) != client.last_packets:
|
||||
client.last_activity = datetime.now()
|
||||
client.last_activity = current_date
|
||||
client.last_packets = packets_val
|
||||
client.commit()
|
||||
|
||||
# Also do a purge of clients that have no traffic for 24 hrs
|
||||
if client.last_activity:
|
||||
time_diff = client.last_activity-client.created
|
||||
if client.last_packets >= packets_val and time_diff.days >= 1:
|
||||
client.enabled = False
|
||||
client.commit()
|
||||
|
||||
for src_ip in args.src_ip:
|
||||
# Get client by IP or create a new one.
|
||||
client = Client(
|
||||
|
|
Loading…
Reference in a new issue