Jump to content

"Actions" doesn't work!!


simonbcn

Recommended Posts


# curl -u admin:admin http://192.168.200.120:8080/gui/token.html
<html><div id='token' style='display:none;'>2x2Dra2xSQ4bfNvJZUQrlZicoCFxQF9hBPfNhLBU0QuIrhrIb75sZ7yJgUw=</div></html>

# curl -u admin:admin "http://192.168.200.120:8080/gui/?list=1&token=2x2Dra2xSQ4bfNvJZUQrlZicoCFxQF9hBPfNhLBU0QuIrhrIb75sZ7yJgUw="
invalid request

Link to comment
Share on other sites

Can you check Firebug (if you're using Firefox) or Chromium's Developer Tools (if you're using Chromium) to see what requests WebUI is making, and how it differs from your own requests (other than token value)? If nothing, then I'm not really sure what to say... perhaps a session cookie issue of some sort?

Link to comment
Share on other sites

  • 1 month later...

Actions do work through the web API, and you can use them with token auth. Here is an example script implementing the ?list=1 command:


#!/bin/bash

# Get token
export token=$(curl -G -s -c ~/.utorrent/ucookie.txt -n http://192.168.0.4:8080/gui/token.html|sed
's/<[^<>]*>//g')
# echo $token

#
curl -G -s -n -b ~/.utorrent/ucookie.txt -d token=$token -d list=1 http://192.168.0.4:8080/gui/

I also have scripts for ?command, ?add-url, and a couple more.

Link to comment
Share on other sites

  • 6 months later...

Been fighting this as well for about the last three-ish days.

Keep getting "invalid login" as well.

Yes, I've been using the correct IP:Port/gui/?list=1

No, I have no interest in using the Auth_tokens at this time as I'd like to get this working before implementing auth_token.

ubuntu 10.04.2

WebUI 0.381

utorrent 3.0-25053

Relevant part of the config file:

ut_webui_port: 8081
webui_dir_files: webui.zip
token_auth_enable: 0

This is the program that I've been trying to set up:

#!/usr/bin/perl -w

use strict;
use Net::uTorrent;

my $utorrent = Net::uTorrent->new (
hostname => '192.168.1.50',
port => '8081',
user => 'admin',
pass => 'is correct',
);
die unless $utorrent->login_success;

my $token = $utorrent->token();

my $torrent_list = $utorrent->torrents();

print $token;
print $torrent_list;
#print "\nSuccess!!\n";

Below is what I get when I run the above program against my installation of utorrent.

romanmir perl $ ./utorrent.pl
malformed JSON string, neither array, object, number, string or atom, at character
offset 2 (before "invalid request") at /usr/local/share/perl/5.10.1/Net/uTorrent.pm
line 82.

Link to comment
Share on other sites

Confirm login details using webui. The config file is not necessarily what you are using. You can change the login details using webui Tools button, and also check token_auth in the advanced section.

I also see several problems in your code. Why are you trying to parse out a token when token_auth is (supposed to ) be switched off? The correct URL for getting a token would be http://192.168.1.50:8081/gui/token.html. The token will not be returned in a JSON string, but in an HTML string, which can also be parsed as XML.

The correct URL for other actions (not getting a token) is http://192.168.1.50:8081/gui/? followed by the relevant action string. I don't see this URL being formed in your code.

Link to comment
Share on other sites

Yeah, the code that I have there isn't intended to do anything but test a few things. Once I get any sort of result other than "invalid request" I'm gonna be doing other things with this.

I'm looking in the "Advanced" section of the settings webui settings and I'm not seeing anything about use token_auth. Now in the previous webui version I did see that under advanced. Unless I'm missing something.

It's entirely possible I was looking at this from the wrong perspective. i was thinking that the .conf file controls the behavior of the application. But are you are saying it's the other way around?

As far as where the actual get request comes from, I believe it comes from the Net::uTorrent module being use in this script.

Thanks for your response.

Link to comment
Share on other sites

@lithopsian

It was as you said. It turns out that the conf file that gets created has no bearing on the actual settings. Seems pretty unintuitive on a linux machine. But, whatever. :rolleyes:

Perhaps that could be added to the docs in the future?

In any case, thank you for pointing me in the right direction.

Rom

Link to comment
Share on other sites

The .conf file does have an effect but only the first time utserver is executed, which means that there is no other configuration for it to act on. The first time it runs it will create its own configuration then it will always ignore the .conf file. It is something of a bootstrap for the program that has no user interface.

It would be nice if it would always read the .conf file so you could easily set things like the port without having to get the webui connected, but having configuration data in two places could also be confusing.

I see the Net:uTorrent module must have a lot of logic I don't see. Glad it works now.

Link to comment
Share on other sites

The .conf file does have an effect but only the first time utserver is executed, which means that there is no other configuration for it to act on. The first time it runs it will create its own configuration then it will always ignore the .conf file.

It would be nice if it would always read the .conf file so you could easily set things like the port without having to get the webui connected, but having configuration data in two places could also be confusing.

uTorrent Server reads the configuration file every time it starts, when it receives a hangup signal, or when it detects a file-based maintenance request to do so. Some settings are as you say, defaults that apply only when settings.dat does not exist. Other settings are read and applied every time. See the documentation for information on which settings are applied when.

Link to comment
Share on other sites

uTorrent Server reads the configuration file every time it starts, when it receives a hangup signal, or when it detects a file-based maintenance request to do so. Some settings are as you say, defaults that apply only when settings.dat does not exist. Other settings are read and applied every time. See the documentation for information on which settings are applied when.

My documentation says:

The settings for which the values are always applied from the configuration
file when the file is read by the server include:

• dir_request
• finish_cmd
• logmask
• preferred_interface
• state_cmd
• ut_webui_dir

The implication is that this is not a complete list. Whether it is or not, the values that I would find most useful to be able to change in the .conf file, such as the port, address, and login settings, do not seem to be read every time.

Link to comment
Share on other sites

  • 5 months later...

# curl -u admin:admin http://192.168.200.120:8080/gui/token.html
<html><div id='token' style='display:none;'>2x2Dra2xSQ4bfNvJZUQrlZicoCFxQF9hBPfNhLBU0QuIrhrIb75sZ7yJgUw=</div></html>

# curl -u admin:admin "http://192.168.200.120:8080/gui/?list=1&token=2x2Dra2xSQ4bfNvJZUQrlZicoCFxQF9hBPfNhLBU0QuIrhrIb75sZ7yJgUw="
invalid request

Not quite. But since nobody answered this, I suppose I will:

#!/bin/bash
# Get token
export token=$(curl -G -s -u user:pass -c ~/.utorrent/ucookie.txt http://192.168.0.4:8080/gui/token.html | sed 's/<[^<>]*>//g')
curl -G -s -u user:pass -b ~/.utorrent/ucookie.txt -d token=$token -d list=1 http://192.168.0.4:8080/gui/

What's important here is that the cookie is sent along with all subsequent requests (I don't know when this changed, but it needs to be sent along now). Also, the username/password needs to accompany all subsequent requests as well.

Frankly I don't see much adoption of the auth system when it is not documented well enough for people to use. Shame on the devs for not making this more usable.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...