Deluge

提供: ArchWiki
2019年1月18日 (金) 03:06時点におけるKusakata.bot (トーク | 投稿記録)による版 (文字列「Category:BitTorrent クライアント]]」を「Category:BitTorrent]]」に置換)
ナビゲーションに移動 検索に移動

関連記事

Deluge は Python 2 で書かれたフル機能の BitTorrent アプリケーションです。以下のような様々な機能が揃っています: クライアント/サーバーモデル、DHT のサポート、マグネットリンク、プラグインシステム、UPnP のサポート、フルストリーム暗号、プロキシのサポート、3つの異なるクライアントアプリケーション。サーバーデーモンが動作している間、ユーザーはコンソールクライアントや GTK+ ベースの GUI、またはウェブベースの UI を使って接続することができます。完全な機能のリストは こちら から見れます。

インストール

deluge パッケージからインストールできます。GTK+ クライアントを使うには pygtk パッケージが必要です。

デーモン

Deluge はクライアント・サーバーモデルで稼働します。サーバーはデーモンとも呼ばれバックグラウンドで動作してクライアント (コンソール, gtk, ウェブベース) が接続してくるのを待機します。クライアントが切断してもデーモンはキューに入った torrent ファイルの転送を実行し続けます。

インストール時、pacman は非特権の deluge ユーザーを作成します。付属の /usr/bin/deluged デーモンを実行するためのユーザーです。デーモンを起動する方法は複数存在します:

  1. Systemd のシステムサービス (deluge ユーザーとして実行)。
  2. Systemd のユーザーサービス (他のユーザーとして実行)。
  3. 直接実行 (他のユーザーとして実行)。
ヒント: セキュリティをできるかぎり高めるために、deluged は systemd のシステムサービス (deluged.service) で実行することを推奨します。deluge ユーザーはシェルにアクセスすることがなくホスト環境の他のグループに入っていません。非特権の deluge ユーザーとして実行する場合、Xorg やクライアントを起動しなくてもシステムサービスを起動できるというメリットもあります。

システムサービス

deluged.service サービスを起動してください。ブート時に起動したい場合は有効化してください。

ユーザーサービス

警告: 複数のユーザーでデーモンを実行する場合、ユーザーごとにデフォルトポート (58846) を変更する必要があります。

ユーザーサービスを使うことで systemd --user が実行されたときに deluged を起動することができます。以下のユーザーサービスファイルを作成することで使うことが可能です:

/etc/systemd/user/deluged.service
[Unit]
Description=Deluge Daemon
After=network.target

[Service]
ExecStart=/usr/bin/deluged -d -P %h/.config/deluge/deluge.pid

[Install]
WantedBy=default.target

ユーザーから deluge のユーザーサービスを起動・有効化してください:

$ systemctl --user start deluged
$ systemctl --user enable deluged

deluged のユーザーサービスは $HOME/.config/systemd/user/ に配置することもできます。ユーザーサービスについて詳しくは systemd/ユーザー を見て下さい。

設定

Deluge はクライアントを使って設定することも、$HOME/.config/deluge/ にある JSON フォーマットの設定ファイルを編集して設定することもできます ($HOMEdeluged を動作させるユーザーのホームディレクトリです、デーモンが deluge ユーザーによって動作している場合、デフォルトのホームディレクトリは /srv/deluge/ になります)。

ダウンロード・アップロードに共有ディレクトリを使う

systemd の deluged.service を使用する場合、共有ディレクトリはシステムの他のユーザーがデータにアクセスできるように共有する必要があります。一般的な設定例:

  1. 共有ディレクトリの所有者と所有グループを deluge:deluge に変更。
  2. 共有ディレクトリのファイルのパーミッションと属性を最低でも 770 に設定。
  3. (ファイルにアクセスする必要がある) ユーザーを deluge グループに追加。

/mnt/torrent_data を使用する場合:

# chown -R deluge:deluge /mnt/torrent_data
# chmod 770 /mnt/torrent_data
# usermod -a -G deluge YOURUSER
ノート: When usermod is used to change group affiliation, a logout/login is required before changes take effect.

ファイアウォール

Deluge requires at least one port open for TCP and UDP to allow incoming connections for seeding. If deluge complaining that it cannot open a port for incoming connections, users must open port(s) to be used. In this example, ports 56881 through 56889 are opened for TCP and UDP:

# iptables -A INPUT -p tcp --dport 56881:56889 -j ACCEPT
# iptables -A INPUT -p udp --dport 56881:56889 -j ACCEPT

User who are behind a NAT router/firewall must setup the corresponding ports to be forwarded. UPnP may also be used, but that will not work with the local firewall on the system because it requires predefined ports.

ノート: One can limit this to a single port, just be sure to enable both TCP and UDP.

On many default configurations, when using iptables with connection tracking (conntrack) set to drop "INVALID" packets, sometimes a great deal of legitimate torrent traffic (especially DHT traffic) is dropped as "invalid." This is typically caused by either conntrack's memory restrictions, or from long periods between packets among peers (see [1] towards the bottom and [2]). Symptoms of this problem include torrents not seeding, especially when the torrent client has been active for more than a day or two continuously, and consistently low overhead traffic (in one experience, less than 3KiB/s in either in or out) with DHT enabled, even when deluge/libtorrent has been continuously running for more than forty-eight hours and many torrents are active. For this reason, it may be necessary to disable connection tracking of all torrent traffic for optimal performance, even with the listening ports set to ACCEPT (as the causes for dropping INVALID packets, for instance conntrack's memory problems, may supercede any rules to accept traffic to/from those ports).

To fully turn off connection tracking for torrents, specify ports for both Incoming and Outgoing traffic in Deluge, for instance, 56881-56889 for incoming connections and 56890-57200 for outgoing connections.

ノート: Limiting incoming connections is not recommended with libtorrent as this will limit the ability to keep multiple connections to the same client, even for different torrents.

Then issue the following commands (after substituting the relevant port ranges):

# iptables -t raw -I PREROUTING -p udp --dport 56881:57200 -j NOTRACK
# iptables -t raw -I OUTPUT -p udp --sport 56881:57200 -j NOTRACK
# iptables -t raw -I PREROUTING -p tcp --dport 56881:57200 -j NOTRACK
# iptables -t raw -I OUTPUT -p tcp --sport 56881:57200 -j NOTRACK
# iptables -I INPUT -p icmp --icmp-type 3 -j ACCEPT
# iptables -I INPUT -p icmp --icmp-type 4 -j ACCEPT
# iptables -I INPUT -p icmp --icmp-type 11 -j ACCEPT
# iptables -I INPUT -p icmp --icmp-type 12 -j ACCEPT

The ICMP allowances are desirable because once connection tracking is disabled on those ports, those important ICMP messages (types 3 (Destination Unreachable), 4 (Source Quench), 11 (Time Exceeded) and 12 (Parameter Problem)) would otherwise be declared INVALID themselves (as netfilter would not know of any connections that they are associated with), and they would potentially be blocked.

警告: A port range of 1024:65535 would break every DNS query.

プラグイン

ノート: プラグインは Python 2.7 でコンパイルしてください。例: $ python2.7 setup.py build

完全なプラグインのリストは Deluge Wiki にあります。

ltConfig is a useful plugin that allows direct modification to libtorrent settings and has preset support.

It offers additional settings like announce_ip (IP to announce to trackers), half_open_limit (Remove maximum half-open connections limit) and more possible privacy and (seed) speedboost features.

クライアント

コンソール

コンソールクライアントは次のコマンドで起動できます:

$ deluge-console

利用可能なコマンドのリストを確認したいときは help コマンドを使って下さい。

GTK+

ノート: It is necessary to disable Classic Mode in Edit -> Preferences -> Interface for daemon (server) setups.

GTK+ クライアントは次のコマンドで起動できます:

$ deluge-gtk

または:

$ deluge

GTK+ クライアントには便利なプラグインがたくさん付いています:

  • AutoAdd - .torrent ファイルのディレクトリを監視。
  • Blocklist - IP ブロックリストをダウンロード・インポート。
  • Execute - イベントによってコマンドを実行。
  • Extractor - ダウンロード完了時に圧縮ファイルを解凍 (ディスク I/O の使用量が増えることがあるので注意)
  • Label - Allows labels to be assigned to torrents, as well as state, tracker, and keyword filters
  • Notifications - Provides notifications (email, pop-up, blink, sound) for events as well as other plugins
  • Scheduler - Limits active torrents and their speed on a per-hour, per-day basis
  • WebUi - Allows the Web UI to be started via the GTK+ client

Web

A web-client is also provided should users not want GTK or shell-based access to the daemon. Just as with deluge daemon mentioned above, the web client as can be started several different ways:

  1. Systemd system service (runs as the deluge user).
  2. Systemd user service (runs as another user).
  3. Running it directly (runs as another user).
ヒント: For the highest level of security, running deluge-web via the systemd system service (deluge-web.service) is recommended since the deluge user has no shell access (limited account) or other group affiliation on the host system. In addition to the security benefits of running as the non-privileged deluge user, the system service can also run at boot without the need to start Xorg or a client.

The python2-mako dependency is needed for the web client to work. When the web client is initially started, it will create $HOME/.config/deluge/web.conf. The password in this file is hashed with SHA1 and salted. The default password is "deluge".

Several things to note:

  • The web client offers many of the same features of the GTK+ UI, including the plugin system.
  • It is recommended to use HTTPS for the Web client to protect against a man-in-the-middle attack.
  • Users may be greeted by a warning from the browser that the SSL certificate is untrusted. Add an exception to this in the browser to continue on. See the OpenSSL page for information on creating your own certificate.
  • If multiple users are running a daemon, the default port (8112) will need to be changed for each user.

Once running, users may connect to the web client by browsing to http://hostname:8112 or if using encryption: https://hostname:8112

システムサービス

Deluge には Deluge のウェブ UI を起動するのに使用する systemd システムユニットである deluge-web.service が付属しています。Deluge Web UI は Connection Manager を使用して同一ホスト上で複数の Deluge クライアントを管理します。ウェブ UI クライアントからホストの Deluge クライアントに接続するには deluged サービスを起動有効化してください。

ユーザーサービス

ユーザーサービスを使うことで systemd --user が実行されたときに deluge-web を起動することができます。以下のユーザーサービスファイルを作成することで使うことが可能です:

/etc/systemd/user/deluge-web.service
[Unit]
Description=Deluge Web UI
After=deluged.service

[Service]
ExecStart=/usr/bin/deluge-web --ssl

[Install]
WantedBy=default.target

ユーザーから deluge のユーザーサービスを起動・有効化してください:

$ systemctl --user start deluge-web
$ systemctl --user enable deluge-web

deluge-web のユーザーサービスは $HOME/.config/systemd/user/ に配置することもできます。ユーザーサービスについて詳しくは systemd/ユーザーを見てください。

ヘッドレスセットアップ

Deluge is quite useful on a headless system, often referred to as a seed box, because of its client/server model. To set up deluge on a headless system, set up the daemon as shown above.

ユーザーの作成

To allow interaction with the server remotely, create a user in $HOME/.config/deluge/auth. For example:

$ echo "delugeuser:p422WoRd:10" >> $HOME/.config/deluge/auth
ノート:
  • The user/password created does not have to match any system users, and to maintain good security practices it should not!
  • The user/password in this file are not hashed or salted like in the web client config.
  • The user/password must match the user/password found in /srv/deluge/.config/deluge/auth otherwise the authentication fails.

The number 10 corresponds to a level of Admin. Refer to the following table for additional values:

Level Name Level Value
None 0
Read Only 1
Normal 5
Admin 10
ノート: In Deluge 1.35, these values have no effect, but multiuser options are under development.

リモートの許可

デフォルト設定ではリモート接続は許可されていません。$HOME/.config/deluge/core.conf の "allow_remote" 設定を変更してください:

"allow_remote": true,
ノート:
  • $HOME/.config/deluge/core.conf は最初に設定を変更したときに自動的に作成されます。存在しない場合、deluge-console で値を設定できます: config --set allow_remote true
  • デーモンの実行中に設定を変更しても反映されません。サービスを停止してからファイルを変更してください。

ファイアウォール

リモートアクセス用にポートを開いてください。以下の例ではデフォルトのデーモンポート (58846) を使います:

# iptables -A INPUT -p tcp --dport 58846 -j ACCEPT

ファイアウォールのルールに関する詳細は iptables を見て下さい。

Users behind a NAT router/firewall must forward the port to access the daemon from outside the network if this behavior is desired.

接続

コンソールクライアントの場合:

connect <host>[:<port>] <user> <password>

GTK+ クライアントの場合: Edit > Connection Manager > Add

ウェブクライアントの場合: Connection Manager > Add

SSH トンネル

An SSH tunnel can be created to use an encrypted connection on any client. This requires an extra loopback address to be added, but this can be automated at boot. Without this step, the connection would be considered local. The actual command to establish an SSH tunnel cannot be automated as it requires user input. There are a few possible ways to go about doing that.

/etc/systemd/system/extra_lo_addr.service
[Unit]
Description=extra loopback address
Wants=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ip addr add 127.0.0.2/8 dev lo
ExecStop=/sbin/ip addr del 127.0.0.2/8 dev lo

[Install]
WantedBy=multi-user.target
$ ssh -fNL 127.0.0.2:58846:localhost:58846 <ssh host>

The port 58846 should be replaced with the port the deluge server is running on and <ssh host> should be replaced with the server hosting both deluge and the SSH server.

トラブルシューティング

No module named service_identity

delugeddeluge-console を実行したときに以下のようなメッセージが表示される場合:

:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named service_identity'.  
Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied.  
Without the service_identity module and a recent enough pyOpenSSL to support it, Twisted can perform only rudimentary TLS 
client hostname verification.  Many valid certificate/hostname mappings may be rejected.

python2-twisted の任意の依存パッケージである python2-service-identity がインストールされていないことが原因です。FS#43806 を見てください。

参照