====== Installing MLDonkey 3.2.1 ======
How to have MLDonkey running on a **Debian 12 Bookworm**.
===== Compiling the source code =====
The compilation procedure can be executed on a development machine, where you install all the required packages. Then you can copy only the **mlnet** binary into the production host.
Download the source code from the new **[[https://github.com/ygrek/mldonkey|GitHub repository]]** (the old [[http://mldonkey.sourceforge.net/|Sourceforge repository]] was abandoned in August 2023). We downloaded the tag **Release 3.2.1**.
mkdir -p /usr/local/src/mldonkey
cd /usr/local/src/mldonkey
wget https://github.com/ygrek/mldonkey/archive/refs/tags/release-3-2-1.zip
unzip mldonkey-release-3-2-1.zip
Some Debian packages are required to make the basic compile. We don't need the **GUI**, so we compile to have only the **Command Line Interface** (CLI) and the **web interface**; the package ''liblablgtk2-gnome-ocaml-dev'' referred by the build instructions is not required:
apt install ocaml camlp4 libnum-ocaml-dev
You may want to install some additional libraries to get more options working:
apt install libmagic-dev libgd-dev libbz2-dev
/usr/local/src/mldonkey/mldonkey-release-3-2-1
./configure
make
make install
The binary **mlnet** can be copied into another machine **(/usr/local/bin/** is the suggested directory). You can verify tha all the libraries are insalled using the command **ldd mlnet**.
===== Running as non-privileged user =====
mkdir /var/lib/mldonkey
addgroup --system mldonkey
adduser --system --home /var/lib/mldonkey --no-create-home \
--shell /usr/sbin/nologin --ingroup mldonkey mldonkey
chown -h mldonkey:mldonkey /var/lib/mldonkey
chown -R mldonkey:mldonkey /var/lib/mldonkey/
su --shell=/bin/bash - mldonkey
If the program is started by the root user, you can force a setuid to the non privileged user by settings into the **downloads.ini** the following option (in the example the 128 is the GID of the MLDonkey user):
run_as_useruid = 128
FIXME Need to create a **systemd unit** to start the program.
==== Logging ====
mkdir /var/log/mldonkey
chown -R mldonkey:mldonkey /var/log/mldonkey
FIXME Need to create the **/etc/logrotate.d/mldonkey-server** logrotate file.
===== Opening the firewall =====
The ports used by the program are declared in several configuration **.ini** files:
downloads.ini: telnet_port = 4000
downloads.ini: gui_port = 4001
downloads.ini: http_port = 4080
# ED2k TCP port. The UDP port is TCP + 4.
donkey.ini: port = 16566
donkey.ini: Kademlia = { port = 10709 }
bittorrent.ini: tracker_port = 6881
bittorrent.ini: client_port = 6882
bittorrent.ini: dht_port = 16873
===== Using the Command Line Interface =====
telnet localhost 4000
> auth admin MySecret
Full access enabled
===== Initializing the server list =====
As explaind into this [[https://www.emule-security.org/e107_plugins/faq/faq.php?0.cat.6.5|eMule FAQ]], you need a list of some servers to initialize your client to the **[[wp>EDonkey network]]**.
The default URL used by MLDonkey to fetch the server list is **[[http://www.gruk.org/server.met.gz]]**, but it seems outdated now (October 2024). So we fetched the list from the URL provided by the FAQ: **[[http://upd.emule-security.org/server.met]]**.
To change the source URL for **server.met**, edit the **downloads.ini** file while the program is stopped, and change the following part:
web_infos = [
("server.met", 0, "http://upd.emule-security.org/server.met");
...
The number zero is the period between updates (in hours), a period of zero means the file is only loaded once on startup. The file will be fetched and stored into the **$HOME/.mldonkey/web_infos/** directory.
Alternatively you can add single servers by hand: to view the servers listed by the emule-security.org site in an human-readable format, visit the URL **[[https://www.emule-security.org/serverlist/]]**; so you can view each IP address and port. You can manually add each server from the MLDonkey command line:
> n 45.82.80.155 5687
New server 45.82.80.155:5687
===== Initializing the Kademlia network =====
FIXME It seems that the [[wp>Kademlia]] implementation of MLDonky is not compatible with e.g. the aMule 2.3.3 implementation (which is know as the [[wp>Kad network]]). See the **[[https://github.com/ygrek/mldonkey/issues/93|issue 93]]**.
The implementation of Kademlia in MLDonkey was derived from the Overnet component. Overnet, which is now discontinued, was an attempt to enhance the [[wp>eDonkey2000]] program, to make it working without the use of central servers.
As explained by this [[https://www.emule-security.org/e107_plugins/faq/faq.php?0.cat.6.6|eMule FAQ]], a list of some other users already connected to the Kademlia network can be downloaded here: **[[http://upd.emule-security.org/nodes.dat]]**.
Copy the **nodes.dat** file into the MLDonkey home directory and execute the following MLDonkey command line:
> kad_load nodes.dat
285 overnet peers loaded
Then you can check if the connection succeeded:
> kad_stats
Kademlia is enabled
Kademlia Connectivity: NOT enough online peers ,there maybe a problem with incoming udp packets
It is possibile also to boot the Kademlia network with just one peer using the command:
> kad_boot
The Kademlia network **is not properly initialized** if you have zero peers:
> kad_boots
Boot peers: 0
===== The GeoIP database =====
MLDonkey uses a GeoIP database to show the country of servers and peers by the respective IP addresses. That database must be updated regularly, because IP assignments change over time. Unfortunately the default URL to download the database contained into the configuration file is outdated: [[http://www.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz]] returns a **404 Not Found** (October 2024).
It seems that the GeoIP is a //discontinued legacy database//, but fortunately there is this site **[[https://mailfud.org/geoip-legacy/]]** that provides updated versions of it. The download URL is **[[https://mailfud.org/geoip-legacy/GeoIP.dat.gz]]**, but you cannot use it directly into the configuration file.
If you set this in **download.ini**:
(* WARNING: cannot use https URLs *)
web_infos = [
("geoip.dat", 168, "https://mailfud.org/geoip-legacy/GeoIP.dat.gz");
...
the MLDonkey program will try to connect the mailfud.org server on port TCP/0 instead of TCP/443. Specifying the port into the URL (e.g. **%%https://mailfud.org:443%%/...**) does not solve the problem because the HTTPS session does not start. I opened **[[https://github.com/ygrek/mldonkey/issues/119|issue 119]]**.
Fortunately you can download the **GeoIP.dat.gz** file using your browser and copy it into the **$HOME/.mldonkey/web_infos/** directory; at the starting of the program it will be uncompressed and used.
If you want the auto-update to work, you have to find (or host yourself) an **HTTP/1.0** server which provides that file.
===== Web References =====
* **[[https://www.emule-security.org/e107_plugins/faq/faq.php?0.cat.6.6|How to connect to Kademlia network?]]**
* **[[https://en.wikipedia.org/wiki/Kademlia|Kademlia (Wikipedia)]]**
* **[[https://medium.com/coinmonks/a-brief-overview-of-kademlia-and-its-use-in-various-decentralized-platforms-da08a7f72b8f|A Brief Overview of Kademlia]]**
* **[[https://mailfud.org/geoip-legacy/|Free updated GeoIP legacy databases]]**
* **[[https://pages.di.unipi.it/ricci/A-performance-evaluation-of-the-Kad-protocol.pdf|A performance evaluation of the Kad protocol]]**