Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DenyIP v1.0.1 - Fix missing dependency #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
<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>
</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-title style="text-align: center;">DenyIP</mat-card-title>
<mat-divider></mat-divider>
Expand Down
37 changes: 34 additions & 3 deletions DenyIP/projects/DenyIP/src/lib/components/DenyIP.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -29,6 +60,8 @@ export class DenyIPComponent implements OnInit {
this.error = response;
} else {
this.hasInit = true;
this.get4();
this.get6();
}
})
}
Expand Down Expand Up @@ -100,8 +133,6 @@ export class DenyIPComponent implements OnInit {
}

ngOnInit() {
this.init();
this.get4();
this.get6();
this.ipsetCheck();
}
}
2 changes: 1 addition & 1 deletion DenyIP/projects/DenyIP/src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
22 changes: 22 additions & 0 deletions DenyIP/projects/DenyIP/src/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@
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:
Expand Down