Awesome
Introduction
Nostr-filter is a user-friendly filtering program designed to improve the management of your Nostr relay server. This program enables you to easily filter out undesired events, block specific users, and limit access from certain IP addresses or ranges. By employing regular expressions for content filtering, a list of public keys for user blocking, and a list of CIDR notations for IP address filtering, you can effortlessly tailor the settings to your preferences and ensure a smooth and optimized experience for your Nostr relay users.
Fork Differences and Features
atrifat/nostr-filter is a custom fork of imksoo/nostr-filter which focuses on additional filtering features using atrifat/nostr-monitoring-tool data such as:
- Language filtering
- SFW/NSFW Content filtering
- Hate speech (Toxic Comments) filtering
- Sentiment filtering
- Topic filtering
- and other features listed in atrifat/nostr-monitoring-tool
atrifat/nostr-filter is also main component of atrifat/nostr-filter-relay which act as frontend proxy filter relay.
Installation
To run nostr-filter
, you need to have Docker and Docker Compose installed.
- Clone this repository.
Change directory to the cloned repository.
cd nostr-filter/
- Build the Docker image.
docker compose build
- Start the Docker container.
docker compose up -d
Configuration
In the .env file, you can configure the following options:
LISTEN_PORT=8081
UPSTREAM_HTTP_URL=http://192.168.1.1:8080
UPSTREAM_WS_URL=ws://192.168.1.1:8080
In the filter.ts file, you can configure the following options:
- Content Filters contentFilters is an array of regular expression patterns used to filter Nostr event contents. To add a new filtering pattern, simply add a new regular expression pattern to the array. For example:
const contentFilters: RegExp[] = [
/avive/i,
/web3/i,
/lnbc/,
// Add more patterns below
];
- Blocked Public Keys blockedPubkeys is an array of public keys that represent users you wish to block. To block a user, add their public key to the array. For example:
const blockedPubkeys: string[] = [
"examplePublicKey1",
"examplePublicKey2",
// Add more public keys to block below
];
- Client IP Address CIDR Filters cidrRanges is an array of CIDR notations representing IP addresses or ranges that you want to filter. To add a new CIDR filter, simply add the IP address or range to the array. For example:
const cidrRanges: string[] = [
"1.2.3.4/32",
"5.67.89.101/32",
// Add more IP addresses or ranges below
];
Once you have configured the settings according to your needs, the script will filter Nostr event contents, block users, and filter client IP addresses based on your defined patterns and lists.
Usage
To use nostr-filter, you need a Nostr client that sends messages to the WebSocket server. You can connect to the Nostr relay using the URL ws://<server_address>:<listen_port>.
Contributing
We welcome contributions from the community. If you would like to contribute to nostr-filter, please follow these steps:
- Fork the repository.
- Create a new branch for your changes.
- Make your changes and commit them to your branch.
- Submit a pull request with a description of your changes.
Please make sure to follow the code style and conventions used in the project. If you have any questions or need help, feel free to open an issue.
License
nostr-filter is licensed under the MIT License.