diff --git a/DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.html b/DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.html index 4f17d9b..df842bf 100644 --- a/DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.html +++ b/DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.html @@ -1,8 +1,31 @@
- + - + + + Welcome To DenyIP + Lets get started. + +
+

To manage the firewall, DenyIP needs the ipset package. The download of ipset will make a request to the internet. +

+
+
+ +
+
+
+ You can find out more about ipset at openwrt.org/packages/pkgdata/ipset
If you have installed ipset and this window does not update, please reload this module/page a few times and be patient...
+
+
+
+ DenyIP diff --git a/DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.ts b/DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.ts index a1406a4..4987493 100644 --- a/DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.ts +++ b/DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.ts @@ -15,11 +15,42 @@ export class DenyIPComponent implements OnInit { userIP = ""; userType = ""; + hasIpset: boolean = true; hasInit: boolean = false; + isInstalling: boolean = false; isAdding: boolean = false; isResetting: boolean = false; isUpdating: boolean = false; + ipsetCheck(): void { + this.API.request({ + module: 'DenyIP', + action: "ipsetCheck" + }, (response) => { + if (response == "ok") { + this.hasIpset = true; + this.init(); + } else { + this.hasIpset = false; + } + }) + } + + ipsetInstall(): void { + this.isInstalling = true; + this.API.request({ + module: 'DenyIP', + action: "ipsetInstall" + }, (response) => { + if (response == "ok") { + this.ipsetCheck() + } else { + this.error = response; + } + this.isInstalling = false; + }) + } + init(): void { this.API.request({ module: 'DenyIP', @@ -29,6 +60,8 @@ export class DenyIPComponent implements OnInit { this.error = response; } else { this.hasInit = true; + this.get4(); + this.get6(); } }) } @@ -100,8 +133,6 @@ export class DenyIPComponent implements OnInit { } ngOnInit() { - this.init(); - this.get4(); - this.get6(); + this.ipsetCheck(); } } diff --git a/DenyIP/projects/DenyIP/src/module.json b/DenyIP/projects/DenyIP/src/module.json index 3998b01..c2c6659 100644 --- a/DenyIP/projects/DenyIP/src/module.json +++ b/DenyIP/projects/DenyIP/src/module.json @@ -2,7 +2,7 @@ "name": "DenyIP", "title": "DenyIP", "description": "Declare IP addresses and refuse their traffic", - "version": "1.0.0", + "version": "1.0.1", "author": "90N45", "firmware_required": "1.0.0", "devices": ["wifipineapplemk7", "wifipineappleent1"] diff --git a/DenyIP/projects/DenyIP/src/module.py b/DenyIP/projects/DenyIP/src/module.py index 21a7f85..fccc32d 100644 --- a/DenyIP/projects/DenyIP/src/module.py +++ b/DenyIP/projects/DenyIP/src/module.py @@ -4,12 +4,34 @@ import logging import os import subprocess from pineapple.modules import Module, Request +import pineapple.helpers.opkg_helpers as opkg module = Module('DenyIP', logging.DEBUG) addresses_4 = [] addresses_6 = [] +@module.handles_action("ipsetCheck") +def ipset_check(request): + try: + if opkg.check_if_installed("ipset", module.logger) == True: + return "ok" + else: + return "Not installed" + except Exception as e: + return "Error: " + str(e) + +@module.handles_action("ipsetInstall") +def ipset_install(request): + try: + status, error = opkg.install_dependency("ipset", module.logger) + if status == True: + return "ok" + else: + return "Error: " + error + except Exception as e: + return "Error: " + str(e) + @module.handles_action("init") def init(request): try: