I can write a bit of code in python, never done c, which it looks like the daemon is written in, but i am willing to attempt if someone will point me in the right dirrection.
Here is my general idea of what the code might look like in non-c, i would also add two lines to the settings.json file, period and transferCap:
Code: Select all
# write out to a log file atleast once a day with the current date and the total bytes up and down in one line def usage(date, totalUsageBytes): usageLog = open(usage.log) usageLog.write(%2D %2M %4Y; %20d\n %(date, totalUsageBytes) ) usageLog.close() # check the log file created above atleast once a day, go through looking for the first line where the date is less than the value of the period setting in the setings.json file, check if the usage listed on that line plus the transferCap setting is greater than or equal to the current total usage, and if it is, set upload and download speed to .1 kbps, then undo it when it falls below. def transfer_cap(): currentDate = getDate() usageLog = open(usage.log) for line in usageLog.lines(): parts = line.split(';') date = parts if date + period >= currentDate usage = parts break if usage >= transferCap maxUp = 0.1 maxDown = 0.1 else: maxUp = default maxDown = default