@liberstudio/cloudflare-list 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/attacks.service.d.ts +2 -2
- package/dist/attacks.service.js +4 -7
- package/dist/middleware/attack-logger.middleware.js +1 -1
- package/package.json +6 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Liberstudio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { HttpService } from "@nestjs/axios";
|
|
2
|
-
import type { CloudflareAttacksOptions } from "./interfaces";
|
|
2
|
+
import type { CloudflareAttacksOptions, CloudflareResponse } from "./interfaces";
|
|
3
3
|
export declare class AttacksService {
|
|
4
4
|
private readonly httpService;
|
|
5
5
|
private readonly options;
|
|
6
6
|
private readonly logger;
|
|
7
7
|
private readonly API_URL;
|
|
8
8
|
constructor(httpService: HttpService, options: CloudflareAttacksOptions);
|
|
9
|
-
updateIpList(ip: string): Promise<
|
|
9
|
+
updateIpList(ip: string): Promise<CloudflareResponse>;
|
|
10
10
|
}
|
package/dist/attacks.service.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.AttacksService = void 0;
|
|
|
20
20
|
const common_1 = require("@nestjs/common");
|
|
21
21
|
const axios_1 = require("@nestjs/axios");
|
|
22
22
|
const axios_2 = __importDefault(require("axios"));
|
|
23
|
+
const rxjs_1 = require("rxjs");
|
|
23
24
|
let AttacksService = class AttacksService {
|
|
24
25
|
constructor(httpService, options) {
|
|
25
26
|
this.httpService = httpService;
|
|
@@ -28,22 +29,18 @@ let AttacksService = class AttacksService {
|
|
|
28
29
|
this.API_URL = `https://api.cloudflare.com/client/v4/accounts`;
|
|
29
30
|
}
|
|
30
31
|
async updateIpList(ip) {
|
|
31
|
-
const apiToken = this.options
|
|
32
|
-
const accountId = this.options.accountId.trim();
|
|
33
|
-
const listId = this.options.listId.trim();
|
|
34
|
-
const comment = this.options.comment || "Auto-blocked";
|
|
32
|
+
const { accountId, listId, apiToken, comment } = this.options;
|
|
35
33
|
const url = `${this.API_URL}/${accountId}/rules/lists/${listId}/items`;
|
|
36
34
|
this.logger.error(`Aggiungo IP ${ip} alla lista Cloudflare`);
|
|
37
35
|
const formattedIp = ip.includes("/") ? ip : `${ip}/32`;
|
|
38
36
|
const body = [{ ip: formattedIp, comment }];
|
|
39
37
|
try {
|
|
40
|
-
const response = await
|
|
38
|
+
const response = await (0, rxjs_1.firstValueFrom)(this.httpService.post(url, body, {
|
|
41
39
|
headers: {
|
|
42
40
|
Authorization: `Bearer ${apiToken}`,
|
|
43
41
|
"Content-Type": "application/json",
|
|
44
|
-
Accept: "application/json", // Aggiungi questo esplicitamente
|
|
45
42
|
},
|
|
46
|
-
});
|
|
43
|
+
}));
|
|
47
44
|
return response.data;
|
|
48
45
|
}
|
|
49
46
|
catch (error) {
|
|
@@ -57,7 +57,7 @@ let AttackLoggerMiddleware = class AttackLoggerMiddleware {
|
|
|
57
57
|
if (res.statusCode === 404) {
|
|
58
58
|
this.processSuspiciousRequest(req).catch((err) => {
|
|
59
59
|
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
60
|
-
this.logger.error(`Errore nel processando
|
|
60
|
+
this.logger.error(`Errore nel processando la richiesta verso Cloudflare: ${msg}`);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liberstudio/cloudflare-list",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "Modulo NestJS per gestione IP List Cloudflare",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Liberstudio-Dev/lbr-cloudflare-list.git"
|
|
11
|
+
},
|
|
7
12
|
"files": [
|
|
8
13
|
"dist"
|
|
9
14
|
],
|