Deluge

提供: ArchWiki
2022年7月16日 (土) 18:17時点におけるKgx (トーク | 投稿記録)による版 (→‎ファイアウォール: 翻訳)
ナビゲーションに移動 検索に移動

関連記事

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

インストール

deluge パッケージからインストールできます。GTK+ クライアントを使うには pygtkAUR パッケージが必要です。Be sure to read and install the optional dependencies for the gtk client deluge-gtk to enable desktop notifications and appindicator notifications.

デーモン

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
ノート: usermod を使用してグループ所属を変更する場合、変更を有効にする前にログアウト/ログインが必要です。

ファイアウォール

Deluge は、シード用の着信接続を許可するために、TCP および UDP の少なくとも1つのポートを開く必要があります。Deluge が着信接続用のポートを開くことができない場合、ユーザーは使用するポート(複数可)を開く必要があります。この例では、ポート56881 から 56889 が TCP および UDP 用に開かれています。

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

NAT ルーター/ファイアウォールの背後にいるユーザーは、転送に対応するポートを設定する必要があります。 UPnP も使用できますが、事前定義されたポートが必要なため、システムのローカルファイアウォールでは機能しません。

ノート: これを単一のポートに制限することができます。TCP と UDP の両方を必ず有効にしてください。

多くのデフォルト設定では、接続追跡 (conntrack) で iptables を使用して 無効な パケットをドロップするように設定すると、大量の正当なトレント トラフィック (特に DHT トラフィック) が 無効 としてドロップされる場合があります。これは通常、conntrack のメモリ制限、またはピア間のパケット間の長い時間によって発生します (最下部の [1] および [2] を参照)。この問題の症状には、特にトレント クライアントが 1 〜 2 日以上継続してアクティブな場合に、トレントがシードされないこと、DHT を有効にして、deluge/libtorrent が 48 時間以上継続して実行され、多くのトレントがアクティブな場合でも、常に低いオーバーヘッド トラフィック (ある報告では、入出力ともに 3KiB/s 未満) が発生することなどがあります。このため、リスニング ポートを ACCEPT に設定しても、最適なパフォーマンスを得るためには、すべてのトレント トラフィックの接続追跡を無効にする必要があるかもしれません (conntrack のメモリ問題など、無効なパケットをドロップする原因が、これらのポートへのトラフィック/ポートからのトラフィックを受け入れるルールに優先する場合があるためです。)

トレントの接続追跡を完全にオフにするには、Deluge の受信トラフィックと送信トラフィックの両方にポートを指定します。

ノート: libtorrent で着信接続を制限することはお勧めしません。これにより、異なるトレントであっても、同じクライアントへの複数の接続を維持する機能が制限されます。

次のコマンドを発行します(関連するポート範囲を置き換えた後)

# 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

これらのポートで接続追跡が無効になると、これらの重要な ICMP メッセージ (タイプ3 (Destination Unreachable),4 (Source Quench),11 (Time Exceeded),および12 (Parameter Problem) が無効と宣言されるため、ICMP 許容値が望ましいです。それら自体(netfilter はそれらが関連付けられている接続を認識しないため)およびそれらは潜在的にブロックされます。

警告: 1024:65535 のポート範囲は、すべての DNS クエリを壊します。

プラグイン

完全なプラグインのリストは 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).
ノート:
  • The default password for the web interface is deluge.
  • 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.
ヒント: 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.

Once running, users may connect to the web client by browsing to http://127.0.0.1:8112, if using encryption on https://127.0.0.1:8112 and/or by the host IP-address.

システムサービス

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.

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


Web ui .torrent upload does not work

Users running the web ui behind a reverse proxy need to allow embedding for .torrent upload to work (X-Frame-Options ALLOW)

Execute script not found or not executable

When using the Execute plugin, the following error message is logged when deluge tries to execute the script:

[ERROR   ][deluge_execute.core           :145 ] Execute script not found or not executable

If deluged is running as a system service, note that it likely will not be able to access the home directory of other users. Consider putting custom scripts in /usr/local/bin/.

Script permission issues can be debugged as the deluge user using sudo:

$ sudo -u deluge /path/to/script

Torrents list has completely disappeared after an unexpected shutdown

This usually means the state file has gotten corrupted. It has been an intermittent issue since last decade. There should be one backup state file along with a copy of all the previously-running torrents in your deluge profile folder (for systemd users this is usually /srv/deluge/.config/deluge/state) that can be restored to remedy this issue. However, it can get overwritten pretty quickly, especially if you only notice your torrents list after several reboots. A suggested course of action to keep it from happening again is to automate a daily backup of the state file and the torrents.

参照