forked from UNIX_IO/ed2kNET
ED2K .NET Server (F#)
- F# 99.5%
- Shell 0.5%
|
|
||
|---|---|---|
| .idea | ||
| doc | ||
| .gitignore | ||
| BinaryWrite.fs | ||
| build.sh | ||
| compose-postgres.yml | ||
| Config.fs | ||
| config.json | ||
| ConfigReload.fs | ||
| CryptoExtended.fs | ||
| docker-compose.yml | ||
| ed2k.fs | ||
| ed2kClient.fs | ||
| ed2kNET.code-workspace | ||
| ed2kNET.fsproj | ||
| ed2kSearch.fs | ||
| ed2kServer.fs | ||
| EncryptionTCP.fs | ||
| EncryptionUDP.fs | ||
| FileFilter.fs | ||
| filefilter.json | ||
| FileRegister.fs | ||
| global.json | ||
| Interfaces.fs | ||
| LICENSE | ||
| Logging.fs | ||
| Mqtt.fs | ||
| ObfuscationTCP.fs | ||
| ObfuscationUDP.fs | ||
| package.sh | ||
| Program.fs | ||
| RC4.fs | ||
| README.md | ||
| SearchQueryBuilder.fs | ||
| ServerProto.fs | ||
| ServerTasks.fs | ||
| Stats.fs | ||
| Test.fs | ||
| Utility.fs | ||
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.jsonfile. - 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
- Clone or download the repository.
- Navigate to the project directory.
- Restore dependencies:
dotnet restore - Build the project:
dotnet build - 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 configurationsIpv6ListenAddress: 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 10sWelcomeMessage: Public welcome message the ed2k client will seeServerName: Official server nameServerDescription: Public server descriptionFileFilterPath: defines a filter for files (in RegEx statements) which rejects shared files if matched any ruleMetricsEnabled: 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 toMqttUsername: MQTT username (empty on default)MqttPasssword: MQTT passwordMqttTopicPrefix: MQTT topic, used to publish server informationSeedIP: Seed eServer used to request ServerList (Lugdunum)SeedPort: Seed eServer TCP portGlobalUdpLimit: Global limit for UDP packets processed within the intervalGlobalUdpInterval: Interval in seconds for the global UDP rate limitPostgresDB: Enable Postgres usage, requires provided DbConnectionStringDbConnectionString: 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 forconfig.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 + 4UDP port for client communicationTCP + 12UDP port for Obfuscation/Server Obs PingTCP + 14UDP 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