ED2K .NET Server (F#)
  • F# 99.5%
  • Shell 0.5%
Find a file
2026-05-05 09:21:44 +01:00
.idea Update .gitignore files to exclude additional generated files 2026-03-14 23:57:46 +01:00
doc Add: Example Telegraf configuration for MQTT consumer setup 2026-02-09 15:55:46 +01:00
.gitignore Update .gitignore files to exclude additional generated files 2026-03-14 23:57:46 +01:00
BinaryWrite.fs Update: Refactor WriteTo methods to utilize multiBinaryWrite functions for improved code reusability and maintainability 2026-02-14 01:42:56 +01:00
build.sh Add scripts for building and packaging releases (build.sh and package.sh) 2026-01-18 15:01:29 +01:00
compose-postgres.yml - added example Postgres docker compose file 2026-03-24 21:30:45 +01:00
Config.fs Implement dynamic configuration reloading, integrate MQTT and Prometheus updates, and increment version to 0.4.4.5. 2026-04-10 23:14:08 +02:00
config.json Enable PostgreSQL support for ed2kDB alongside SQLite. 2026-03-22 13:34:58 +01:00
ConfigReload.fs Update log messages in ConfigReload to use consistent English phrasing 2026-04-10 23:33:24 +02:00
CryptoExtended.fs Add ChaCha20-Poly1305 support alongside AES256-GCM, refactor encryption logic, and update connection negotiation and stream handling for AEAD flexibility. 2026-01-25 19:46:20 +01:00
docker-compose.yml Add docker-compose.yml for ed2kNET service configuration 2026-03-08 10:58:21 +01:00
ed2k.fs Track separate UDP client and server request statistics, publish them in network metrics, and increment version to 0.4.2.4. 2026-03-14 14:53:08 +01:00
ed2kClient.fs Update: Refactor UserHash implementation and replace with MD4Hash for consistency in hash handling 2026-02-12 23:23:48 +01:00
ed2kNET.code-workspace Initial ed2k server FSharp project (basic parsing works). 2021-09-30 19:00:28 +02:00
ed2kNET.fsproj Update version numbers and enhance logging in DbWorkerService 2026-04-28 23:11:14 +02:00
ed2kSearch.fs Refactor boolean search constraint parsing to correctly handle Or operations and improve nested group handling logic. 2026-01-11 13:22:59 +01:00
ed2kServer.fs Add detailed search timing metrics and improve tracking for search operations. 2026-04-20 22:49:01 +02:00
EncryptionTCP.fs Update: Add AsyncReadInto method to INetwork interface and implement support across core types for improved streaming efficiency 2026-02-14 01:42:55 +01:00
EncryptionUDP.fs Refactor: Update UDP descriptor creation and endpoint handling 2026-02-17 01:10:35 +01:00
FileFilter.fs Add: Implement file filtering system with JSON-based configuration and rule enforcement 2026-02-03 10:56:26 +01:00
filefilter.json Add: Implement file filtering system with JSON-based configuration and rule enforcement 2026-02-03 10:56:26 +01:00
FileRegister.fs Update version numbers and enhance logging in DbWorkerService 2026-04-28 23:11:14 +02:00
global.json - snapshot 2025 2025-08-01 21:48:30 +02:00
Interfaces.fs Refactor: Update UDP descriptor creation and endpoint handling 2026-02-17 01:10:35 +01:00
LICENSE - ed2kNET / officially licensed under GPLv3 2025-12-21 13:22:21 +01:00
Logging.fs Introduce log directory management and update Docker volume mapping 2026-03-02 15:05:02 +01:00
Mqtt.fs Add detailed search timing metrics and improve tracking for search operations. 2026-04-20 22:49:01 +02:00
ObfuscationTCP.fs Update: Add AsyncReadInto method to INetwork interface and implement support across core types for improved streaming efficiency 2026-02-14 01:42:55 +01:00
ObfuscationUDP.fs Refactor UDP padding logic and adjust seeding/cleanup intervals 2026-02-23 23:46:19 +01:00
package.sh Add scripts for building and packaging releases (build.sh and package.sh) 2026-01-18 15:01:29 +01:00
Program.fs Update version numbers and enhance logging in DbWorkerService 2026-04-28 23:11:14 +02:00
RC4.fs Refactor RC4 module: Add optCreateKey with skipDiscard option, update createKey to use it, and enhance ObfuscationUDP to optimize key handling. 2026-01-24 19:28:55 +01:00
README.md Update log messages in ConfigReload to use consistent English phrasing 2026-04-10 23:33:24 +02:00
SearchQueryBuilder.fs Add numeric comparison support for CompleteSources in search queries 2026-03-08 10:13:07 +01:00
ServerProto.fs Update server UDP handling logic to account for announcement status, improve obfuscated ping logging, and increment version to 0.4.3.5 2026-03-17 00:45:31 +01:00
ServerTasks.fs Refactor server task creation to use dynamic configuration retrieval via getConfig function. 2026-04-18 10:17:47 +02:00
Stats.fs Add detailed search timing metrics and improve tracking for search operations. 2026-04-20 22:49:01 +02:00
Test.fs Enable PostgreSQL support for ed2kDB alongside SQLite. 2026-03-22 13:34:58 +01:00
Utility.fs Refactor exception logging to use formatException for enhanced error detail handling. 2026-03-22 14:30:24 +01:00

ed2kNET (v0.4.4.5)

ed2kNET is an implementation of the eDonkey2000 (ed2k) protocol written in F#. The project includes both server and client protocol specifications and allows for the operation of a basic ed2k server.

Features

  • ed2k Server Protocol: Implementation of core functionalities for an eDonkey server.
  • Search Functionality: Support for ed2k search queries with various filters (filename, size, type, etc.).
  • Client Interaction: Basic support for client handshakes and reachability checks.
  • Obfuscation support (TCP/UDP): Includes implementations for RC4 and protocol obfuscation for both TCP and UDP.
  • Modern Protocol Support: Support for Large Files (>4GB), Unicode, and NewTags.
  • Server protcol Support: First open-source eServer able to exchange ServerLists with Lugdunum
  • Multi-Socket UDP: Separate UDP sockets for IPv4 and IPv6 for better connectivity.
  • Configurable: Simple configuration via a config.json file.
  • Testing IPv6 Support: Client's may connect to both IPv6 or IPv4 stack
  • Real Aead Encryption support: Server supports both AEAD (AES256-GCM / ChaCha20-Poly1305) and legacy obfuscation.
  • Security: X25519 (Elliptic Curve) key exchange for secure communication.
  • File filtering (RegEx support): Support for filtering files using regular expressions.
  • Database Storage: Recorded files are stored in Postgres or SQLite database
  • Metrics / Prometheus dotNET support: Support for metrics and Prometheus integration.

TODOs

  • blacklisting
  • ...

Prerequisites

  • .NET 9.0 SDK or newer.
  • F# (installed with the .NET SDK).
  • LibSodium (installed libsodium libraries)
  • SQLite3 (installed SQLite3 libraries) [optional]
  • Note: single executable bundles libraries

Installation & Execution

  1. Clone or download the repository.
  2. Navigate to the project directory.
  3. Restore dependencies:
    dotnet restore
    
  4. Build the project:
    dotnet build
    
  5. Start the server:
    dotnet run
    

Configuration

The server settings can be adjusted in the config.json file:

{
  "ServerConfig": {
    "PublicIP": "",
    "ListenAddress": "0.0.0.0",
    "ListenPort": 4232,
    "Ipv6Enable": false,
    "Ipv6ListenAddress": "[::]",
    "Ipv6ListenPort": 4235,
    "MaxFiles": 6000000,
    "MaxClients": 60000,
    "ObsUdpKey": 0,
    "LogLevel": 2,
    "ConsoleShowStats": true,
    "WelcomeMessage": "-= This is ed2kNET - dotNET Ed2k/eServer =-\r\nExperimental Ed2k/eServer reimplementation\r\n",
    "ServerName": "Hydra ed2kNET Server",
    "ServerDescription": "Experimental Ed2k Server",
    "FileFilterPath": "filefilter.json",
    "MetricsEnabled": true,
    "MetricsPort": 9351,
    "MqttEnabled": false,
    "MqttHost": "",
    "MqttPort": 1883,
    "MqttUsername": "",
    "MqttPassword": "",
    "MqttTopicPrefix": "ed2k/server",
    "SeedIP": "",
    "SeedPort": 0,
    "GlobalUdpLimit": 3000,
    "GlobalUdpInterval": 30,
    "PostgresDB": false,
    "DbConnectionString": "Host=127.0.0.1;Port=5432;Username=ed2k;Password=password;Database=ed2k;"
  }
}
  • PublicIP: Required in Docker environments (must be set to public Server IP)
  • ListenAddress: The IPv4 address the server listens on. (should be default in Docker)
  • ListenPort: The port for inbound TCP connections. (UDP client port is always TCP+4)
  • Ipv6Enable: Enable IPv6 ability in dual-stack configurations
  • Ipv6ListenAddress: The IPv6 address the server listens on. (should be default in Docker)
  • MaxFiles / MaxClients: Limits for server operation.
  • ObsUdpKey: Stub entry (is always random on next restart)
  • LogLevel: Verbosity of the logs (0-3).
  • ConsoleShowStats: Print [STAT] output on console every 10s
  • WelcomeMessage: Public welcome message the ed2k client will see
  • ServerName: Official server name
  • ServerDescription: Public server description
  • FileFilterPath: defines a filter for files (in RegEx statements) which rejects shared files if matched any rule
  • MetricsEnabled: Enable Prometheus metrics.
  • MetricsPort: Metrics HTTP port (unencrypted, will not publish client related information)
  • MqttEnabled: Enable MQTT reporting. (WIP)
  • MqttPort: MQTT port to send requests to
  • MqttUsername: MQTT username (empty on default)
  • MqttPasssword: MQTT password
  • MqttTopicPrefix: MQTT topic, used to publish server information
  • SeedIP: Seed eServer used to request ServerList (Lugdunum)
  • SeedPort: Seed eServer TCP port
  • GlobalUdpLimit: Global limit for UDP packets processed within the interval
  • GlobalUdpInterval: Interval in seconds for the global UDP rate limit
  • PostgresDB: Enable Postgres usage, requires provided DbConnectionString
  • DbConnectionString: DSN in order to connect to remote postgres

Project Structure

  • Logging.fs: Flexible logging system with support for rotation.
  • Utility.fs: General purpose utility functions for byte and span manipulation.
  • BinaryWrite.fs: Low-level helpers for binary data serialization.
  • Interfaces.fs: Common abstractions for network communication (INetwork, IBuffered).
  • ed2kSearch.fs: Implementation of the search engine and query filtering.
  • ed2k.fs: Core eDonkey2000 protocol specifications, opcodes, and data structures.
  • ed2kClient.fs: Communication logic for client-side interactions.
  • Config.fs: Configuration loader and management for config.json.
  • Stats.fs: Collection of server metrics and performance statistics.
  • Mqtt.fs: MQTT integration for real-time server monitoring and reporting.
  • RC4.fs: Implementation of the RC4 stream cipher for legacy obfuscation.
  • ObfuscationUDP.fs / ObfuscationTCP.fs: Legacy protocol obfuscation support.
  • CryptoExtended.fs: Modern cryptography (X25519 key exchange and AEAD encryption).
  • EncryptionUDP.fs / EncryptionTCP.fs: AEAD-based secure communication layers.
  • FileFilter.fs: Regular expression-based filtering system for shared files.
  • FileRegister.fs: Central registry for shared files and source management.
  • ed2kServer.fs: Logic for handling client requests and generating server responses.
  • ServerProto.fs: Server-to-server protocol implementation (e.g., ServerList exchange with Lugdunum).
  • ServerTasks.fs: Management of background tasks for TCP/UDP listeners and status updates.
  • Program.fs: Entry point and main server orchestration logic.

Docker image usage

Please keep in mind that for Server exchange protocol support to work, the eServer requires multiple UDP inbound/outbound ports. The user cannot change these!

In order these are:

  • TCP + 4 UDP port for client communication
  • TCP + 12 UDP port for Obfuscation/Server Obs Ping
  • TCP + 14 UDP port for obfuscated server communication

Because of this you must also set a PublicIP in the config.json (see docker-compose.yml)

License

This project is licensed under the GPLv3 license. For more information, see the LICENSE file.

Author

Copyright (C) 2019-2025 georg@bege.email See Telegram channel: HydraP2P / https://t.me/+krHfzWREKcc3NjVi