Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtorrent module #344

Merged
merged 8 commits into from
Dec 14, 2015
Merged

rtorrent module #344

merged 8 commits into from
Dec 14, 2015

Conversation

wrayan
Copy link
Contributor

@wrayan wrayan commented Feb 10, 2014

First try of a rtorrent module based on Chris Lucas' rtorrent-python api and the utorrent module code.

Source doesn't look pretty and the template definately needs some more love but basic features are supported:

  • connect to rtorrent (scgi url tested)
  • list all torrents with the following information
    • torrent name
    • download progress bar, percentage, time remaining
    • status (seeding/busy/done/inactive)
    • seed ratio

@gugahoi
Copy link
Collaborator

gugahoi commented Feb 12, 2014

Ok, I started to take a look at this but have failed to get it working. I am not sure if I am the one who is not familiar with rTorrent but nothing has worked here. Did u test it at all before sending this PR? Could you help me set everything up so I can take a gander at the rTorrent module?

Edit: OK, seems like I got the RPC to work in rtorrent after a lot of research. Will start reviewing soon.

- fixed typo causing password error
- added connection verification
- added some verbosity to the template (connection error, empty torrent list)
- added debug logging for connection errors
@wrayan
Copy link
Contributor Author

wrayan commented Feb 12, 2014

Mh yeah usually adding "scgi_port = localhost:5000" in .rtorrent.rc should do the trick. The URL you need to enter in rtorrent module then is: scgi:https://127.0.0.1:5000

If your rtorrent is not running on the same machine however, you'd usually additionally set up apache httpd with mod_scgi and htaccess for security reasons instead of just binding rtorrent's scgi service directly to public ip. Example for apache configuration block:

SCGIMount /RPC2 127.0.0.1:5000
<location /RPC2>

    AuthName "rTorrent secure access"
    AuthType Basic
    AuthBasicProvider file
    AuthUserFile /etc/apache2/htpasswd.rtorrent
    Require user rtorrent
</location>

In that case, URL for rtorrent module would be http:https://example.com/RPC2 and you need to enter user/pass for authentication.

However, I found a typo in my code so login with user/pass would not have worked at all. Fixed that and added some verbosity, see latest commit. Ah and yes, I tested both login methods before push (rtorrent 0.9.3 / libtorrent 0.13.3) to avoid another stupid typo bug :)

- added word-break and hyphens declarations so long torrent names don't
  break layout any longer. Tested on Chrome 32 and Firefox 27, feedback about
  other browsers welcome.
- nicer formatting
- removed unneeded stuff from stylesheet
@gugahoi
Copy link
Collaborator

gugahoi commented Feb 15, 2014

Ye I managed to get this working.
A couple of pointers: it would be best to keep with other modules practices and separate ip and port in settings. Also there is no need to have the user input "scgi:https://" this should be in the code.
Lastly any specific reason why "rtorrentdl" and not just "rtorrent" when referencing the module?

@wrayan
Copy link
Contributor Author

wrayan commented Feb 15, 2014

Mmh you were right if scgi was the only protocol option. However, as http and https are also supported, in addition to host/ip and port we'd need a select box for the protocol and another input box for the location (http:https://host/location). Could do that of course but I think it only makes configuration more complicated.

Regarding module name - "rtorrent" is already used for the rtorrent-python module and I didn't want to use absolute imports. However, I'm still a python newbie and don't know much about best practices yet so if you know a better way to get around this I'll be happy to implement it :)

- removed fetching of torrent file lists as this was
  really slow and the information wasn't used anyway; will
  maybe come back later in a torrent details view
- added global and per-torrent up-/download-rate information
- torrent list can be set to fixed size now
@gugahoi
Copy link
Collaborator

gugahoi commented Feb 16, 2014

I see what you mean. But I still prefer to keep it with the other module's standards and have ip/port separate and if necessary have a dropdown with scgi/http/https. To be honest I only realised I needed to input the entire address one I looked at the code and that might be because I am just used to that.

I see the conflict with having both things called "rtorrent" and I understand if you find it too much work but you can always try changing all the "rtorrent" references in the library to something else like "rtorrentlib" or you can try some more complex import commands. I do realise this is mostly detail so if you find it too complicated you are welcome to ignore this.

If you can change the settings I will be happy to merge this! Thanks for the contribution anyways!

- seperate input boxes for protocol, url and port in settings dialog
- basic qualification and verification for configuration settings
  - if no port is defined, assume 80 for http and 443 for https
  - if protocol is scgi, ignore username / password
@wrayan
Copy link
Contributor Author

wrayan commented Feb 16, 2014

Allright, settings dialog changed. Regarding module name, I'll go with the current solution for now.

- fix scrollbar in torrent list shown when not needed
@wrayan wrayan changed the title initial branch commit rtorrent module Apr 15, 2014
@JedMeister
Copy link

@gugahoi is there a reason why this hasn't been merged?

I'm planning on giving it a test anyway but I would be much rather be running your main branch than a fork.

Or is there a fundamental reason why it can't or won't?

@JedMeister
Copy link

@wrayan I am not having luck with this. I suspect that it may be something that I have done wrong... In the module it says connection error and in the Maraschino logs it says :: DEBUG :: RTORRENTDL :: EXCEPTION - mismatched tag: line 6, column 2

I would investigate further but I have no idea where to start looking (which file has a mismatched tag on line 6, col 2?)... Any ideas?

FWIW I am using nginx to provide xmlrpc via https on port 12322 (i.e. https://127.0.0.1:12322/RPC2). I assume that it is configured right as ruTorrent can connect ok... I also tried configuring rtorrent xmlrpc to use port 5000 (it was using a unix socket).

@JedMeister
Copy link

@wrayan after digging a little more I think my issue is caused by access via https while using a self signed cert...

@gugahoi
Copy link
Collaborator

gugahoi commented Dec 13, 2015

I am sorry, completely forgot about it @JedMeister. Is it working for you?

@JedMeister
Copy link

NP @gugahoi.

I couldn't get it to work directly via rTorrent sgci (I was using a unix socket which this code doesn't appear to support; but also tested after reconfiguring it to use localhost port 5000).

Nor could I get it to work via the existing https port that I was already using for ruTorrent (web frontend for rTorrent).

But I configured a new Nginx site to provide /RPC2 via localhost http:

server {
        listen 127.0.0.1:5000 default_server;
        listen [::1]:5000 default_server;

        server_name localhost;

    location /RPC2 {
        scgi_pass unix:/var/run/rtorrent/rpc.socket;
        include     scgi_params;
        scgi_param SCRIPT_NAME /RPC2;
    }
}

Then it all worked fine. I imagine that if I had a proper (CA signed) https cert then https would work too. AFAIK by default Python requires CA https certs (fails on self signed) but I could be wrong and perhaps there is some other issue.

Bottom line, yes it works. It could possibly do with a polish, but I don't know python very well nor do I know the Maraschino code so I won't be able to do that anytime soon. IMO it provides value as is.

@gugahoi
Copy link
Collaborator

gugahoi commented Dec 14, 2015

Exactly what I was hoping to hear 😄

gugahoi added a commit that referenced this pull request Dec 14, 2015
@gugahoi gugahoi merged commit 4c344b2 into mrkipling:master Dec 14, 2015
@JedMeister
Copy link

Awesome. Thanks! 😄

@wrayan
Copy link
Contributor Author

wrayan commented Dec 14, 2015

@JedMeister thanks for reporting this. You're right, ssl doesn't seem to work at all. I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants