ctucx.git: fritzbox-exporter

prometheus exporter for lte fritzboxes [used @ fbexporter.ctu.cx]

commit b0faf94254fb6c98f775737c8629544e389b61d0
parent 028155f33c38eda55a2239868bd75121136af5af
Author: Isabelle K <hi@f2k1.de>
Date: Wed, 20 Jan 2021 19:03:13 +0100

removed unused libaries and replaced initInterval with initTimeInterval which prevented compiling on nim >=1.4
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/asyncHttpServer.nim b/src/asyncHttpServer.nim
@@ -1,6 +1,6 @@
 import asyncdispatch, asynchttpserver, macros
 import strutils, parseutils
-import cookies, uri, times, os, re, json
+import cookies, uri, times, re, json
 import tables
 
 export asyncdispatch, asynchttpserver, cookies, uri

@@ -46,10 +46,10 @@ proc parseQuery*(data: string): Table[string, string] =
   for i in data:
     let timed = i.split("=")
     if timed.len > 1:
-      result.add(decodeUrl(timed[0]), decodeUrl(timed[1]))
+      result[decodeUrl(timed[0])] = decodeUrl(timed[1])
 
 proc daysForward*(days: int): DateTime =
-  return getTime().utc + initInterval(days = days)
+  return getTime().utc + initTimeInterval(days = days)
 
 template setCookie* (key: string, value: string, time: DateTime) =
   headers.add("Set-Cookie", setCookie(key, value, time, request.headers["host"], noName=true))

@@ -211,4 +211,4 @@ macro pages*(server: ServerRef, body: untyped): untyped =
 macro start*(server: ServerRef): untyped =
   result = quote do:
     echo "Server starts on http://", `server`.address, ":", `server`.port
-    waitFor `server`.server.serve(Port(`server`.port), receivepages, `server`.address)-
\ No newline at end of file
+    waitFor `server`.server.serve(Port(`server`.port), receivepages, `server`.address)
diff --git a/src/utils.nim b/src/utils.nim
@@ -1,4 +1,4 @@
-import times, posix, strutils, json
+import strutils, json
 
 proc CtrlCHook* () {.noconv.} =
   echo "Ctrl+C fired! \nStopping Server now!"

@@ -67,4 +67,4 @@ proc getTxTraffic* (data: JsonNode, mode: string): int =
 
 proc getRxTraffic* (data: JsonNode, mode: string): int =
   if data[mode].hasKey("BytesReceivedHigh") and data[mode].hasKey("BytesReceivedLow"):
-    return data[mode]["BytesReceivedHigh"].getInt shl 32 + data[mode]["BytesReceivedLow"].getInt-
\ No newline at end of file
+    return data[mode]["BytesReceivedHigh"].getInt shl 32 + data[mode]["BytesReceivedLow"].getInt