{"id":21124498,"url":"https://github.com/zauberware/botkit-middleware-socket-limiter","last_synced_at":"2025-08-21T20:15:23.740Z","repository":{"id":79330164,"uuid":"137995261","full_name":"zauberware/botkit-middleware-socket-limiter","owner":"zauberware","description":"Botkit middleware for limiting socket traffic","archived":false,"fork":false,"pushed_at":"2018-06-20T11:08:51.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T05:26:58.871Z","etag":null,"topics":["botkit","botkit-middleware","chatbot","security","socket","websocket"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zauberware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-20T07:22:42.000Z","updated_at":"2018-08-29T17:00:13.000Z","dependencies_parsed_at":"2023-02-27T04:45:43.346Z","dependency_job_id":null,"html_url":"https://github.com/zauberware/botkit-middleware-socket-limiter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fbotkit-middleware-socket-limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fbotkit-middleware-socket-limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fbotkit-middleware-socket-limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fbotkit-middleware-socket-limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zauberware","download_url":"https://codeload.github.com/zauberware/botkit-middleware-socket-limiter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243567192,"owners_count":20311998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["botkit","botkit-middleware","chatbot","security","socket","websocket"],"created_at":"2024-11-20T04:16:45.141Z","updated_at":"2025-03-14T11:25:35.595Z","avatar_url":"https://github.com/zauberware.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# botkit-middleware-socket-limiter\nBotkit middleware for limiting socket traffic\n\n- [Botkit Middleware Socket Limiter](#botkit-middleware-socket-limiter)\n    - [Installation](#installation)\n    - [What does it do?](#what-does-it-do)\n    - [Function Overview](#function-overview)\n    - [Usage](#usage)\n\nThis middleware plugin for [Botkit](http://howdy.ai/botkit) allows developers to protect their websocket server from attacks.\n\n## Installation\n\n```bash\nnpm install botkit-middleware-socket-limiter --save\n```\n\n## What does it do?\nThis middleware aims to protect your server that hosts botkit Socketbots from malicious attacks. Websockets are vulnerable to DDoS, that could be triggered by someone trying to open a large amount of websockets, someone trying to send a high frequency of messages over the websocket or someone trying to send too big messages over the websocket. In order to prevent those scenarios, this middleware keeps track of the websocket usage associated with a certain IP.\n\nAt least, that is what we want it to do. This project is meant to be work in progress and we are happy to welcome anyone who wants to contribute to it via a pull request. We will describe the way we think the socket limiter middleware could work but if you have a better idea how to realize the functionality, please let us know!\n\n\n## Function Overview\n\n### [Receive Middleware](https://github.com/howdyai/botkit/blob/master/docs/middleware.md#receive-middleware)\n\n*   `middleware.receive`: analyse the websocket statistics from the message sender. If unusual activity is detected, close websocket and block sender.\n\n\n## Usage\n\n\n### Bot Setup with the socket limiter middleware\n\nSet up a Socketbot with Botkit\n\n```javascript\nvar Botkit = require('botkit');\nvar controller = Botkit.socketbot({});\n```\n\nOpen a websocket server\n\n```javascript\ncontroller.openSocketServer(controller.httpserver);\n```\n\nAnd start the brain\n\n```javascript\ncontroller.startTicking();\n```\n\nCreate a middleware object\n\n```javascript\nvar socketLimiterMiddleware = require('botkit-middleware-socket-limiter');\n```\n\nWhen your Socketbot receives a message, let is use the socket limiter middleware\n\n```javascript\ncontroller.middleware.receive.use(function(bot, message, next) {\n    socketLimiterMiddleware.receive(bot, message, next);\n});\n```\n\n## Features\n\n### Store\nThe socket limiter middleware stores current websocket statistics in order to detect malicious behaviour. It stores the IPs with the amount of open websockets, messages per websocket, connection time and message frequency.\n\nA redis store should be a good option for storing the data.\n\n### Options\nIt is possible to configure the socket limiter middleware and overwrite the default options. Possible options to set on middleware creation are the following:\n\n| Property                      | Required | Default        | Description                                                                                                                                                                                                                          |\n| ------------------------| :---------- | :------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| maxMessageSize                          | No        | TBD   | Maximum size a message sent over the socket connection is allowed to have. |\n| maxSocketConnections                 | No        | TBD   | Maximum amount of all websocket connections. |\n| maxSocketConnectionsPerIP     | No        | TBD   | Maximum allowed amount of socket connections per IP. |\n| maxMessageAmountPerMinute | No        | TBD   | Maximum amount of messages that are allowed to be sent in a minute |\n\nYou can specifiy those options in an options object and pass it to the middleware on creation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzauberware%2Fbotkit-middleware-socket-limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzauberware%2Fbotkit-middleware-socket-limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzauberware%2Fbotkit-middleware-socket-limiter/lists"}