A torrent on the Dingoo A320, or why is it needed?
In stock: the Dlink DSL2650u router from the previous topic , which has a USB host and is flashed with OpenWRT firmware, and the Dingoo A320 prefix on which OpenDingux is installed (Linux for Dingoo). Task: Organize round-the-clock distribution of torrents in order to slightly increase the rating on the tracker. Kill the whole day with an interesting activity and improve your knowledge of Linux.
The topic is written more for entertainment purposes than as a practical guide, since many may be confused by the expediency of the undertaking.
What can be useful to extract from the topic?
- Learn how to connect and mount flash drives to a router
- How to raise a torrent client (transmission) on a router
- How to connect a UsbNet device and install bridge in a local network
- How interesting it is to kill all day
- Router: 300mhz CPU, ~ 30mb (29668kb) RAM
- Dingoo A320: 333mhz CPU (accelerates to 430mhz), ~ 30mb (29500kb) RAM
First attempts
At first, attempts were made to raise the distribution directly on the router: a 4GB flash drive is inserted into the USB and torrents are distributed from there. Following the wiki page , I installed the necessary packages with the command:
opkg install usbutils kmod-usb-core kmod-usb-ohci kmod-usb-uhci kmod-usb2 kmod-usb-storage kmod-usb-storage-extras block-mount block-hotplug kmod-fs-ext4After connecting, the flash drive was normally detected and two devices / dev / sda and / dev / sda1 appeared . The flash drive was formatted in FAT32, so I had to deliver packages:
opkg install kmod-fs-vfat kmod-nls-cp437 kmod-nls-utf8 kmod-nls-cp1251The last two packages are optional, since mount mounts in cp437 encoding, and does not accept any parameters about changing the encoding. In any case, if you cannot mount the partition, you need to see the reason in the output of dmesg .
You can configure auto-mount, for this you need to edit the file
/etc/config/fstab. For self-assembly, the previously installed block-hotplug package is responsible . See the OpenWRT documentation for more details . After connecting and mounting the flash drive, you need to install transmission . Why he? Because it can work as a daemon, it has an rpc and web interface. RPC means the ability to control distribution directly on the computer in a convenient gui interface. And the first guide found on the Internet was about him. Therefore:
opkg install transmission-daemon transmission-webAfter installation, you need to edit the configuration file
/etc/config/transmission. Setting transmission in OpenWRT is not the topic, so contact here for more information . The web interface is available at 192.168.1.1: 9091, RPC connects there too. As an RPC client, a transmission-remote-gui-bin package from AUR was downloaded and installed (in Archlinux). After setting up and starting transmission , the disappointment came - the router is too weak for this. RAM was running out, the processor was loaded to the eyeballs, and after a few minutes the router stopped responding to calls. The only salvation was a reboot. I tried to make a swap partition on a USB flash drive and connect it to the router. I broke the flash drive into two sections, allocated 100mb for the swap, formatted it, connected it ... but the situation did not change much. The testimony of the free team showed that in swap I was engaged in no more than 1mb.
Therefore, the flight of thought flew further.
And then bradea came

I continued to think that you can connect to an accessible usb port for business use. Only the Motorola Z6 mobile phone (on Linux) and the Dingoo A320 came to mind. Since the motorola was not at hand, he continued experiments with dinga. With Dingux (and OpenDingux), you can make a network through UsbNet. Having looked at the name of the module (cdc_ether), I began to install it in OpenWRT. Such a package turned out to be installed without problems:
opkg install kmod-usb-net-cdc-etherAfter connecting to
ifconfigThere is a new interface: usb0. Having established an IP address via DHCP (udhcpd is used on Dingux), I checked that everything worked. The task was to distribute the Internet via usb0, and, preferably, make access from the local network. Thoughts about creating a series of rules for iptables, for masquerading, for transferring packets, etc., spun in my head , but the solution turned out to be much simpler: you need to add usb0 to ifname in the file /etc/config/networkin the section . The result was this line: It
remains to force Dingoo to receive data via DHCP, and not to install static 10.1.0.2. Rummaging through the initialization script , I saw that several user variables were used.config interface lanoption ifname "eth1.0 usb0"/etc/init.d/networkif [ -z $DINGOO_IP_ADDRESS ]; then DINGOO_IP_ADDRESS="10.1.0.2"; fi
if [ -z $PC_IP_ADDRESS ]; then
if [ $DINGOO_IP_ADDRESS != "10.1.0.1" ]; then PC_IP_ADDRESS="10.1.0.1"
else PC_IP_ADDRESS="10.1.0.2"
fi
fi
if [ -z $DINGOO_NETMASK ]; then DINGOO_NETMASK="255.255.255.252"; fi
if [ -z $PC_NETMASK ]; then PC_NETMASK=$DINGOO_NETMASK; fi
I asked smart people who are related to the development of OpenDingux, where you can override them. Since there are no write permissions in / etc (there is a squashfs image), the developers made it possible to override the variables in the file
/usr/local/etc/initvars. I couldn’t get IP by DHCP, so I decided to manually set the IP address 192.168.1.2: In
addition, I need to register the DNS server address in
Restarting all services, I made sure the circuit works: Dingoo responds from the network, network and Internet respond from Dingoo. A separate problem was when I assigned IP not 192.168.1.2, but a larger one - 192.168.1.254, and did not pay attention to the subnet mask (Dingoo's standard mask is 255.255.255.252), and for a long time I could not understand why nothing was working.DINGOO_IP_ADDRESS=192.168.1.2
PC_IP_ADDRESS=192.168.1.1
DINGOO_NETMASK=255.255.255.0/usr/local/etc/resolv.confnameserver 192.168.1.1Install transmission
OpenDingux does not have such a convenient repository as in OpenWRT, so transmission had to be handled. Toolchain (a set of utilities for compiling for a specific platform) is taken from here . I downloaded the sources, read it
./configure --help, having disabled all unnecessary, I started trying to compile.
Depending on the dependencies, I had to build openssl, libevent and curl. I copied the binary file transmission-daemon along with the missing libraries on Dingoo to / usr / local / apps / transmission and created a regular script to run. The result was a list of files:
and such a script:
There was a problem with starting, transmission wrote briefly “Bus error”. Using the scientific poke method, it turned out that the problem disappears if you do not specify the watch directory. Perhaps the kernel in Dingux without inotify support../configure --host=mipsel-linux-uclibc --disable-gtk --disable-mac --disable-cli --disable-libnotify --disable-libappindicator --disable-libcanberra --disable-nls --disable-utp
makels /usr/local/apps/transmission/
libcurl.so.4 libevent-2.0.so.5 transmission transmission-daemon#!/bin/sh
LD_LIBRARY_PATH=.
./transmission-daemon -T -w /usr/local/torrent/ -g /usr/local/torrent/config -a 192.168.1.* -e /usr/local/torrent/logConclusion
You are unrealistically persistent if you have read up to this point. Now I just download torrents for subsequent distribution. Empirically selected limits on the number of peers (50), on the download speed (300KB / sec) and upload (200KB / sec). It works stably, you can experiment with higher limits.
Why not raise it on the router after all, with equal hardware? Firstly, less interesting, and secondly, the router has a whole bunch of other tasks - distributing the Internet and taking resources from it is not good. A 4GB miniSD card allows you to pump a small number of torrents for distribution, but thanks for that.
I did not install the web interface, since I still need to play with the web server. I control through RPC and Transgui .
Why not buy a NAS for these purposes? I’m not yet ready for such a big purchase, and I’m not so actively using torrents. In this problem, the solution, rather than the result, was more interesting to me.
I would like to express my gratitude to the OpenWRT development team, we made a very thoughtful system with an application repository, a unified system of configs. Draws on the whole distribution, only for routers.
And finally, a few links: