Feature: crowdsec widget
This commit is contained in:
parent
0af975b3d9
commit
b5e1e41410
17
docs/widgets/services/crowdsec.md
Normal file
17
docs/widgets/services/crowdsec.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: Crowdsec
|
||||||
|
description: Crowdsec Widget Configuration
|
||||||
|
---
|
||||||
|
|
||||||
|
Learn more about [Crowdsec](https://crowdsec.net).
|
||||||
|
|
||||||
|
Get your API key by registering a bouncer with your instance, see the [Crowdsec docs](https://docs.crowdsec.net/docs/local_api/intro#bouncers).
|
||||||
|
|
||||||
|
Allowed fields: ["totalDecisions", "activeBans"]
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
widget:
|
||||||
|
type: crowdsec
|
||||||
|
url: http://crowdsechostorip:port
|
||||||
|
key: yourcrowdsecbouncerkey
|
||||||
|
```
|
||||||
@ -44,6 +44,7 @@ nav:
|
|||||||
- widgets/services/channelsdvrserver.md
|
- widgets/services/channelsdvrserver.md
|
||||||
- widgets/services/cloudflared.md
|
- widgets/services/cloudflared.md
|
||||||
- widgets/services/coin-market-cap.md
|
- widgets/services/coin-market-cap.md
|
||||||
|
- widgets/services/crowdsec.md
|
||||||
- widgets/services/customapi.md
|
- widgets/services/customapi.md
|
||||||
- widgets/services/deluge.md
|
- widgets/services/deluge.md
|
||||||
- widgets/services/diskstation.md
|
- widgets/services/diskstation.md
|
||||||
|
|||||||
@ -872,5 +872,10 @@
|
|||||||
"labels": "Labels",
|
"labels": "Labels",
|
||||||
"users": "Users",
|
"users": "Users",
|
||||||
"totalValue": "Total Value"
|
"totalValue": "Total Value"
|
||||||
|
},
|
||||||
|
"crowdsec": {
|
||||||
|
"bans": "Bans",
|
||||||
|
"captchas": "Captchas",
|
||||||
|
"rateLimits": "Rate Limits"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ const components = {
|
|||||||
channelsdvrserver: dynamic(() => import("./channelsdvrserver/component")),
|
channelsdvrserver: dynamic(() => import("./channelsdvrserver/component")),
|
||||||
cloudflared: dynamic(() => import("./cloudflared/component")),
|
cloudflared: dynamic(() => import("./cloudflared/component")),
|
||||||
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
||||||
|
crowdsec: dynamic(() => import("./crowdsec/component")),
|
||||||
iframe: dynamic(() => import("./iframe/component")),
|
iframe: dynamic(() => import("./iframe/component")),
|
||||||
customapi: dynamic(() => import("./customapi/component")),
|
customapi: dynamic(() => import("./customapi/component")),
|
||||||
deluge: dynamic(() => import("./deluge/component")),
|
deluge: dynamic(() => import("./deluge/component")),
|
||||||
|
|||||||
39
src/widgets/crowdsec/component.jsx
Normal file
39
src/widgets/crowdsec/component.jsx
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { useTranslation } from "next-i18next";
|
||||||
|
|
||||||
|
import Container from "components/services/widget/container";
|
||||||
|
import Block from "components/services/widget/block";
|
||||||
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
|
export default function Component({ service }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { widget } = service;
|
||||||
|
|
||||||
|
const { data: bansData, error: bansError } = useWidgetAPI(widget, "bans");
|
||||||
|
const { data: captchasData, error: captchasError } = useWidgetAPI(widget, "captchas");
|
||||||
|
const { data: rateLimitsData, error: rateLimitsError } = useWidgetAPI(widget, "rateLimits");
|
||||||
|
|
||||||
|
if (bansError || captchasError || rateLimitsError) {
|
||||||
|
return <Container service={service} error={bansError ?? captchasError ?? rateLimitsError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bansData && !captchasData && !rateLimitsData) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="crowdsec.bans" />
|
||||||
|
<Block label="crowdsec.captchas" />
|
||||||
|
<Block label="crowdsec.rateLimits" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(bansData);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="crowdsec.bans" value={t("common.number", { value: bansData?.length ?? 0 })} />
|
||||||
|
<Block label="crowdsec.captchas" value={t("common.number", { value: captchasData?.length ?? 0 })} />
|
||||||
|
<Block label="crowdsec.rateLimits" value={t("common.number", { value: rateLimitsData?.length ?? 0 })} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
20
src/widgets/crowdsec/widget.js
Normal file
20
src/widgets/crowdsec/widget.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/v1/{endpoint}",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
bans: {
|
||||||
|
endpoint: "decisions?type=ban&origins=crowdsec",
|
||||||
|
},
|
||||||
|
captchas: {
|
||||||
|
endpoint: "decisions?type=captcha&origins=crowdsec",
|
||||||
|
},
|
||||||
|
rateLimits: {
|
||||||
|
endpoint: "decisions?type=rate-limit&origins=crowdsec",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
||||||
@ -12,6 +12,7 @@ import changedetectionio from "./changedetectionio/widget";
|
|||||||
import channelsdvrserver from "./channelsdvrserver/widget";
|
import channelsdvrserver from "./channelsdvrserver/widget";
|
||||||
import cloudflared from "./cloudflared/widget";
|
import cloudflared from "./cloudflared/widget";
|
||||||
import coinmarketcap from "./coinmarketcap/widget";
|
import coinmarketcap from "./coinmarketcap/widget";
|
||||||
|
import crowdsec from "./crowdsec/widget";
|
||||||
import customapi from "./customapi/widget";
|
import customapi from "./customapi/widget";
|
||||||
import deluge from "./deluge/widget";
|
import deluge from "./deluge/widget";
|
||||||
import diskstation from "./diskstation/widget";
|
import diskstation from "./diskstation/widget";
|
||||||
@ -125,6 +126,7 @@ const widgets = {
|
|||||||
channelsdvrserver,
|
channelsdvrserver,
|
||||||
cloudflared,
|
cloudflared,
|
||||||
coinmarketcap,
|
coinmarketcap,
|
||||||
|
crowdsec,
|
||||||
customapi,
|
customapi,
|
||||||
deluge,
|
deluge,
|
||||||
diskstation,
|
diskstation,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user