Rename to DenyIP

pull/72/head
90N45 2023-04-09 23:28:10 +02:00
parent 45ea4c59d9
commit e88fb62c18
27 changed files with 67 additions and 67 deletions

View File

@ -1,7 +0,0 @@
/*
* Public API Surface of BlackIP
*/
export * from './lib/services/BlackIP.service';
export * from './lib/components/BlackIP.component';
export * from './lib/BlackIP.module';

View File

@ -3,38 +3,38 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
"BlackIP": {
"DenyIP": {
"projectType": "library",
"root": "projects/BlackIP",
"sourceRoot": "projects/BlackIP/src",
"root": "projects/DenyIP",
"sourceRoot": "projects/DenyIP/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/BlackIP/tsconfig.lib.json",
"project": "projects/BlackIP/ng-package.json"
"tsConfig": "projects/DenyIP/tsconfig.lib.json",
"project": "projects/DenyIP/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/BlackIP/tsconfig.lib.prod.json"
"tsConfig": "projects/DenyIP/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/BlackIP/src/test.ts",
"tsConfig": "projects/BlackIP/tsconfig.spec.json",
"karmaConfig": "projects/BlackIP/karma.conf.js"
"main": "projects/DenyIP/src/test.ts",
"tsConfig": "projects/DenyIP/tsconfig.spec.json",
"karmaConfig": "projects/DenyIP/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/BlackIP/tsconfig.lib.json",
"projects/BlackIP/tsconfig.spec.json"
"projects/DenyIP/tsconfig.lib.json",
"projects/DenyIP/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
@ -43,5 +43,5 @@
}
}
}},
"defaultProject": "BlackIP"
"defaultProject": "DenyIP"
}

View File

@ -1,11 +1,11 @@
{
"name": "BlackIP",
"name": "DenyIP",
"version": "0.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "BlackIP",
"name": "DenyIP",
"version": "0.0.0",
"dependencies": {
"@angular/animations": "~9.1.11",

View File

@ -1,5 +1,5 @@
{
"name": "BlackIP",
"name": "DenyIP",
"version": "0.0.0",
"scripts": {
"ng": "ng",

View File

@ -1,6 +1,6 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/BlackIP",
"dest": "../../dist/DenyIP",
"lib": {
"entryFile": "src/public-api.ts"
}

View File

@ -1,5 +1,5 @@
{
"name": "BlackIP",
"name": "DenyIP",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^8.2.14",

View File

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BlackIPComponent } from './components/BlackIP.component';
import { DenyIPComponent } from './components/DenyIP.component';
import { RouterModule, Routes } from '@angular/router';
import {MaterialModule} from './modules/material/material.module';
@ -10,11 +10,11 @@ import {FlexLayoutModule} from '@angular/flex-layout';
import {FormsModule} from '@angular/forms';
const routes: Routes = [
{ path: '', component: BlackIPComponent }
{ path: '', component: DenyIPComponent }
];
@NgModule({
declarations: [BlackIPComponent],
declarations: [DenyIPComponent],
imports: [
CommonModule,
RouterModule.forChild(routes),
@ -22,6 +22,6 @@ const routes: Routes = [
FlexLayoutModule,
FormsModule,
],
exports: [BlackIPComponent]
exports: [DenyIPComponent]
})
export class BlackIPModule { }
export class DenyIPModule { }

View File

@ -4,16 +4,16 @@
</span>
<mat-card *ngIf="hasInit" style="width: 40%;">
<mat-card-content>
<mat-card-title style="text-align: center;">BlackIP</mat-card-title>
<mat-card-title style="text-align: center;">DenyIP</mat-card-title>
<mat-divider></mat-divider>
<br>
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="width: 45%;">
<i style="color: grey;"><small>IPv4 Blacklist</small></i>
<i style="color: grey;"><small>IPv4 Deny List</small></i>
<textarea style="width: 100%; height: 150px; background-color: #efefef; border-color: #cecece; border-radius: 2px; resize: vertical;" disabled>{{ addresses4 }}</textarea>
</div>
<div style="width: 45%;">
<i style="color: grey;"><small>IPv6 Blacklist</small></i>
<i style="color: grey;"><small>IPv6 Deny List</small></i>
<textarea style="width: 100%; height: 150px; background-color: #efefef; border-color: #cecece; border-radius: 2px; resize: vertical;" disabled>{{ addresses6 }}</textarea>
</div>
</div>

View File

@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core';
import { ApiService } from '../services/api.service';
@Component({
selector: 'lib-BlackIP',
templateUrl: './BlackIP.component.html',
styleUrls: ['./BlackIP.component.css']
selector: 'lib-DenyIP',
templateUrl: './DenyIP.component.html',
styleUrls: ['./DenyIP.component.css']
})
export class BlackIPComponent implements OnInit {
export class DenyIPComponent implements OnInit {
constructor(private API: ApiService) { }
error = "";
@ -22,7 +22,7 @@ export class BlackIPComponent implements OnInit {
init(): void {
this.API.request({
module: 'BlackIP',
module: 'DenyIP',
action: "init"
}, (response) => {
if (response != "ok") {
@ -35,7 +35,7 @@ export class BlackIPComponent implements OnInit {
get4(): void {
this.API.request({
module: 'BlackIP',
module: 'DenyIP',
action: "get4"
}, (response) => {
this.addresses4 = response;
@ -44,7 +44,7 @@ export class BlackIPComponent implements OnInit {
get6(): void {
this.API.request({
module: 'BlackIP',
module: 'DenyIP',
action: "get6"
}, (response) => {
this.addresses6 = response;
@ -54,7 +54,7 @@ export class BlackIPComponent implements OnInit {
add(): void {
this.isAdding = true;
this.API.request({
module: 'BlackIP',
module: 'DenyIP',
action: "add",
user_ip: this.userIP,
user_type: this.userType
@ -73,7 +73,7 @@ export class BlackIPComponent implements OnInit {
clear(): void {
this.isResetting = true;
this.API.request({
module: 'BlackIP',
module: 'DenyIP',
action: "clear"
}, (response) => {
if (response != "ok") {
@ -89,7 +89,7 @@ export class BlackIPComponent implements OnInit {
update(): void {
this.isUpdating = true;
this.API.request({
module: 'BlackIP',
module: 'DenyIP',
action: "update"
}, (response) => {
if (response != "ok") {

View File

@ -3,6 +3,6 @@ import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class BlackIPService {
export class DenyIPService {
constructor() {}
}

View File

@ -1,7 +1,7 @@
{
"name": "BlackIP",
"title": "BlackIP",
"description": "Blacklist IP addresses and refuse their traffic",
"name": "DenyIP",
"title": "DenyIP",
"description": "Declare IP addresses and refuse their traffic",
"version": "1.0.0",
"author": "90N45",
"firmware_required": "1.0.0",

View File

@ -5,7 +5,7 @@ import os
import subprocess
from pineapple.modules import Module, Request
module = Module('BlackIP', logging.DEBUG)
module = Module('DenyIP', logging.DEBUG)
addresses_4 = []
addresses_6 = []
@ -13,12 +13,12 @@ addresses_6 = []
@module.handles_action("init")
def init(request):
try:
blacklist = str(os.popen("ipset list").read())
if not "Name: blacklist" in blacklist:
subprocess.run(["ipset", "create", "blacklist", "hash:ip", "hashsize", "4096"])
subprocess.run(["ipset", "create", "blacklist6", "hash:net", "hashsize", "4096", "family", "inet6"])
subprocess.run(["iptables", "-I", "FORWARD", "-m", "set", "--match-set", "blacklist", "src", "-j", "DROP",])
subprocess.run(["iptables", "-I", "FORWARD", "-m", "set", "--match-set", "blacklist6", "src", "-j", "DROP",])
denylist = str(os.popen("ipset list").read())
if not "Name: denylist" in denylist:
subprocess.run(["ipset", "create", "denylist", "hash:ip", "hashsize", "4096"])
subprocess.run(["ipset", "create", "denylist6", "hash:net", "hashsize", "4096", "family", "inet6"])
subprocess.run(["iptables", "-I", "FORWARD", "-m", "set", "--match-set", "denylist", "src", "-j", "DROP",])
subprocess.run(["iptables", "-I", "FORWARD", "-m", "set", "--match-set", "denylist6", "src", "-j", "DROP",])
return "ok"
except Exception as e:
return "Error: " + str(e)
@ -39,27 +39,27 @@ def add_ip(request):
return "ok"
@module.handles_action("get4")
def fetch_blacklist4(request):
def fetch_denylist4(request):
try:
blacklist = ""
denylist = ""
for address in addresses_4:
blacklist = blacklist + address + "\n"
return blacklist
denylist = denylist + address + "\n"
return denylist
except Exception as e:
return "Error: " + str(e)
@module.handles_action("get6")
def fetch_blacklist6(request):
def fetch_denylist6(request):
try:
blacklist = ""
denylist = ""
for address in addresses_6:
blacklist = blacklist + address + "\n"
return blacklist
denylist = denylist + address + "\n"
return denylist
except Exception as e:
return "Error: " + str(e)
@module.handles_action("clear")
def clear_blacklist(request):
def clear_denylist(request):
addresses_4.clear()
addresses_6.clear()
return "ok"
@ -67,14 +67,14 @@ def clear_blacklist(request):
@module.handles_action("update")
def update(request):
try:
blacklist = ""
subprocess.run(["ipset", "flush", "blacklist"])
subprocess.run(["ipset", "flush", "blacklist6"])
denylist = ""
subprocess.run(["ipset", "flush", "denylist"])
subprocess.run(["ipset", "flush", "denylist6"])
for address in addresses_4:
subprocess.run(["ipset", "add", "blacklist", address])
subprocess.run(["ipset", "add", "denylist", address])
for address in addresses_6:
subprocess.run(["ipset", "add", "blacklist6", address])
subprocess.run(["ipset", "add", "denylist6", address])
return "ok"
except Exception as e:
return "Error: " + str(e)

View File

Before

Width:  |  Height:  |  Size: 970 B

After

Width:  |  Height:  |  Size: 970 B

View File

@ -0,0 +1,7 @@
/*
* Public API Surface of DenyIP
*/
export * from './lib/services/DenyIP.service';
export * from './lib/components/DenyIP.component';
export * from './lib/DenyIP.module';