Fix missing dependency
- Auto check for dependency ipset - Install ipset if missingmaster
parent
58a088d2dd
commit
0accef5356
|
@ -1,8 +1,31 @@
|
||||||
<div style="display: flex; justify-content: center; align-items: center;">
|
<div style="display: flex; justify-content: center; align-items: center;">
|
||||||
<span *ngIf="!hasInit" style="display: flex; justify-content: center; align-items: center; height: 10vh;">
|
<span *ngIf="!hasInit && hasIpset" style="display: flex; justify-content: center; align-items: center; height: 10vh;">
|
||||||
<mat-spinner diameter="25"></mat-spinner>
|
<mat-spinner diameter="25"></mat-spinner>
|
||||||
</span>
|
</span>
|
||||||
<mat-card *ngIf="hasInit" style="width: 40%;">
|
<mat-card *ngIf="!hasIpset" style="width: 40%;">
|
||||||
|
<mat-card-content>
|
||||||
|
<mat-card-title>Welcome To DenyIP</mat-card-title>
|
||||||
|
<mat-card-subtitle>Lets get started.</mat-card-subtitle>
|
||||||
|
<mat-divider></mat-divider>
|
||||||
|
<br>
|
||||||
|
<p>To manage the firewall, DenyIP needs the ipset package. The download of ipset will make a request to the internet.
|
||||||
|
</p>
|
||||||
|
<br>
|
||||||
|
<div style="display: flex; justify-content: center; align-items: center;">
|
||||||
|
<button style="width: 45%; height: 34px; display: flex; justify-content: center; align-items: center;" mat-flat-button color="accent" (click)="ipsetInstall()">
|
||||||
|
<span *ngIf="!isInstalling">Install ipset</span>
|
||||||
|
<span *ngIf="isInstalling">
|
||||||
|
<mat-spinner [diameter]="20"></mat-spinner>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div style="display: flex; justify-content: center; align-items: center;">
|
||||||
|
<span><small>You can find out more about ipset at <a href="https://openwrt.org/packages/pkgdata/ipset">openwrt.org/packages/pkgdata/ipset</a><br>If you have installed ipset and this window does not update, please reload this module/page a few times and be patient...</small></span>
|
||||||
|
</div>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
<mat-card *ngIf="hasInit && hasIpset" style="width: 40%;">
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<mat-card-title style="text-align: center;">DenyIP</mat-card-title>
|
<mat-card-title style="text-align: center;">DenyIP</mat-card-title>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
|
|
|
@ -15,11 +15,42 @@ export class DenyIPComponent implements OnInit {
|
||||||
|
|
||||||
userIP = "";
|
userIP = "";
|
||||||
userType = "";
|
userType = "";
|
||||||
|
hasIpset: boolean = true;
|
||||||
hasInit: boolean = false;
|
hasInit: boolean = false;
|
||||||
|
isInstalling: boolean = false;
|
||||||
isAdding: boolean = false;
|
isAdding: boolean = false;
|
||||||
isResetting: boolean = false;
|
isResetting: boolean = false;
|
||||||
isUpdating: 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 {
|
init(): void {
|
||||||
this.API.request({
|
this.API.request({
|
||||||
module: 'DenyIP',
|
module: 'DenyIP',
|
||||||
|
@ -29,6 +60,8 @@ export class DenyIPComponent implements OnInit {
|
||||||
this.error = response;
|
this.error = response;
|
||||||
} else {
|
} else {
|
||||||
this.hasInit = true;
|
this.hasInit = true;
|
||||||
|
this.get4();
|
||||||
|
this.get6();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -100,8 +133,6 @@ export class DenyIPComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.init();
|
this.ipsetCheck();
|
||||||
this.get4();
|
|
||||||
this.get6();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "DenyIP",
|
"name": "DenyIP",
|
||||||
"title": "DenyIP",
|
"title": "DenyIP",
|
||||||
"description": "Declare IP addresses and refuse their traffic",
|
"description": "Declare IP addresses and refuse their traffic",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"author": "90N45",
|
"author": "90N45",
|
||||||
"firmware_required": "1.0.0",
|
"firmware_required": "1.0.0",
|
||||||
"devices": ["wifipineapplemk7", "wifipineappleent1"]
|
"devices": ["wifipineapplemk7", "wifipineappleent1"]
|
||||||
|
|
|
@ -4,12 +4,34 @@ import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from pineapple.modules import Module, Request
|
from pineapple.modules import Module, Request
|
||||||
|
import pineapple.helpers.opkg_helpers as opkg
|
||||||
|
|
||||||
module = Module('DenyIP', logging.DEBUG)
|
module = Module('DenyIP', logging.DEBUG)
|
||||||
|
|
||||||
addresses_4 = []
|
addresses_4 = []
|
||||||
addresses_6 = []
|
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")
|
@module.handles_action("init")
|
||||||
def init(request):
|
def init(request):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue