transmission-remote character mangle

Ask for help and report issues not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
microchip
Posts: 9
Joined: Sat May 20, 2017 12:14 pm

transmission-remote character mangle

Post by microchip »

Hi,

When using transmission-remote I noticed torrent wasn't downloaded . So I used a proxy to monitor requests from transmission-remote and I discovered the URL used was mangled :

Code: Select all

https://foo.com/?id=4
became in transmission-remote

Code: Select all

https://foo.com/?id:4
How can I prevent transmission-remote to change "=" by ":" ?
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: transmission-remote character mangle

Post by mike.dld »

How are you invoking the transmission-remote command exactly? Maybe it's not transmission-remote but your shell where replacement is taking place? For instance, are you quoting the URL when using it as an argument?
microchip
Posts: 9
Joined: Sat May 20, 2017 12:14 pm

Re: transmission-remote character mangle

Post by microchip »

Hi,

I'm invoking it programmatically. I tried with and without quotes and I got the same issue.

Please see below outputs from my script and the corresponding proxy capture :

Without quotes :

Code: Select all

[u'transmission-remote', u'127.0.0.1', u'-c', u'/opt/multimedia/incomplete', u'--add', u'https://foo.com/torrents/download/?id=42424242', u'-w', u'/mnt/videos/series/somewhere', u'--pex', u'--dht']

Host:                       127.0.0.1:9091
User-Agent:                 transmission-remote/2.92 (14714)
Accept:                     */*
Accept-Encoding:            deflate, gzip
Proxy-Connection:           Keep-Alive
X-Transmission-Session-Id:  89manZFyDnnlyUcrtA0aDKBXVFfsGJ82rHgny4yF8cb7YvRG
Content-Length:             161
Content-Type:               application/x-www-form-urlencoded

{"arguments":{"download-dir":"/mnt/videos/series/somewhere","filename":"https://foo.com/torrents/download/?id:42424242"},"method":"torrent-add","tag":8}
With quotes:

Code: Select all

[u'transmission-remote', u'127.0.0.1', u'-c', u'/opt/multimedia/incomplete', u'--add', u'"https://foo.com/torrents/download/?id=42424242"', u'-w', u'/mnt/videos/series/somewhere', u'--pex', u'--dht']

Host:                       127.0.0.1:9091                          
User-Agent:                 transmission-remote/2.92 (14714)                 
Accept:                     */*                                              
Accept-Encoding:            deflate, gzip                                    
Proxy-Connection:           Keep-Alive                                       
X-Transmission-Session-Id:  89manZFyDnnlyUcrtA0aDKBXVFfsGJ82rHgny4yF8cb7YvRG 
Content-Length:             165                                              
Content-Type:               application/x-www-form-urlencoded                

{"arguments":{"download-dir":"/mnt/videos/series/somewhere","filename":"\"https://foo.com/torrents/download/?id:42424242\""},"method":"torrent-add","tag":8}
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: transmission-remote character mangle

Post by mike.dld »

Could you try running the same command manually in terminal and see if that works? Could you also try passing -b/--debug argument to transmission-remote to see what it thinks it sends (will print to stderr), w/o proxy?

If you have strace (or if you're okay with installing it), could you also check and see what does this print:

Code: Select all

# strace -s 1024 -f daemon/transmission-remote ...your arguments here... 2>&1 | fgrep http
P.S. Tried your command line with current nightly, works fine. This seems like a late question, but what's your OS and Transmission version?
microchip
Posts: 9
Joined: Sat May 20, 2017 12:14 pm

Re: transmission-remote character mangle

Post by microchip »

I used command-line with debug and proxy enable:

Code: Select all

https_proxy="https://localhost:8080" http_proxy="http://localhost:8080" transmission-remote 127.0.0.1 -b -c /opt/multimedia/incomplete --add "https://www.foo.com/torrents/download/?id=5703370" -w /mnt/videos/series/something --pex --dht
posting:
--------
{"arguments":{"incomplete-dir":"/opt/multimedia/incomplete","incomplete-dir-enabled":true},"method":"session-set"}

--------
* Couldn't find host 127.0.0.1 in the .netrc file; using defaults
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST http://127.0.0.1:9091/transmission/rpc/ HTTP/1.1
Host: 127.0.0.1:9091
User-Agent: transmission-remote/2.92 (14714)
Accept: */*
Accept-Encoding: deflate, gzip
Proxy-Connection: Keep-Alive
Content-Length: 115
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 115 out of 115 bytes
< HTTP/1.1 409 Conflict
< Server: Transmission
< X-Transmission-Session-Id: WP9Hba77pA1bi2Sv0UbNlQHbPMPuGmHBpArc15aa4l7QgM9w
< Date: Mon, 22 May 2017 18:06:03 GMT
< Content-Length: 580
< Content-Type: text/html; charset=ISO-8859-1
< 
* Connection #0 to host localhost left intact
posting:
--------
{"arguments":{"incomplete-dir":"/opt/multimedia/incomplete","incomplete-dir-enabled":true},"method":"session-set"}

--------
* Couldn't find host 127.0.0.1 in the .netrc file; using defaults
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST http://127.0.0.1:9091/transmission/rpc/ HTTP/1.1
Host: 127.0.0.1:9091
User-Agent: transmission-remote/2.92 (14714)
Accept: */*
Accept-Encoding: deflate, gzip
Proxy-Connection: Keep-Alive
X-Transmission-Session-Id: WP9Hba77pA1bi2Sv0UbNlQHbPMPuGmHBpArc15aa4l7QgM9w
Content-Length: 115
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 115 out of 115 bytes
< HTTP/1.1 200 OK
< Server: Transmission
< Content-Encoding: gzip
< Content-Type: application/json; charset=UTF-8
< Date: Mon, 22 May 2017 18:06:03 GMT
< Content-Length: 56
< 
* Connection #0 to host localhost left intact
got response (len 36):
--------
{"arguments":{},"result":"success"}

--------
127.0.0.1:9091/transmission/rpc/ responded: "success"
posting:
--------
{"arguments":{"download-dir":"/mnt/videos/series/something","filename":"https://www.foo.com/torrents/download/?id=5703370"},"method":"torrent-add","tag":8}

--------
* Couldn't find host 127.0.0.1 in the .netrc file; using defaults
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST http://127.0.0.1:9091/transmission/rpc/ HTTP/1.1
Host: 127.0.0.1:9091
User-Agent: transmission-remote/2.92 (14714)
Accept: */*
Accept-Encoding: deflate, gzip
Proxy-Connection: Keep-Alive
X-Transmission-Session-Id: WP9Hba77pA1bi2Sv0UbNlQHbPMPuGmHBpArc15aa4l7QgM9w
Content-Length: 161
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 161 out of 161 bytes
< HTTP/1.1 200 OK
< Server: Transmission
< Content-Encoding: gzip
< Content-Type: application/json; charset=UTF-8
< Date: Mon, 22 May 2017 18:06:03 GMT
< Content-Length: 85
< 
* Connection #0 to host localhost left intact
got response (len 68):
--------
{"arguments":{},"result":"invalid or corrupt torrent file","tag":8}

--------
Error: invalid or corrupt torrent file
posting:
--------
{"arguments":{"dht-enabled":true,"pex-enabled":true},"method":"session-set"}

--------
* Couldn't find host 127.0.0.1 in the .netrc file; using defaults
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST http://127.0.0.1:9091/transmission/rpc/ HTTP/1.1
Host: 127.0.0.1:9091
User-Agent: transmission-remote/2.92 (14714)
Accept: */*
Accept-Encoding: deflate, gzip
Proxy-Connection: Keep-Alive
X-Transmission-Session-Id: WP9Hba77pA1bi2Sv0UbNlQHbPMPuGmHBpArc15aa4l7QgM9w
Content-Length: 77
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 77 out of 77 bytes
< HTTP/1.1 200 OK
< Server: Transmission
< Content-Encoding: gzip
< Content-Type: application/json; charset=UTF-8
< Date: Mon, 22 May 2017 18:06:03 GMT
< Content-Length: 56
< 
* Connection #0 to host localhost left intact
got response (len 36):
--------
{"arguments":{},"result":"success"}

--------
127.0.0.1:9091/transmission/rpc/ responded: "success"
fgrep

Code: Select all

strace -s 1024 -f transmission-remote 127.0.0.1 -b -c /opt/multimedia/incomplete --add "https://www.foo.com/torrents/download/?id=5703370" -w /mnt/videos/series/something --pex --dht 2>&1 | fgrep http
execve("/usr/bin/transmission-remote", ["transmission-remote", "127.0.0.1", "-b", "-c", "/opt/multimedia/incomplete", "--add", "https://www.foo.com/torrents/download/?id=5703370", "-w", "/mnt/videos/series/something", "--pex", "--dht"], [/* 48 vars */]) = 0
recvfrom(3, "HTTP/1.1 409 Conflict\r\nServer: Transmission\r\nX-Transmission-Session-Id: dS9r8HR01JC0i6OgOxC7TDudLFV357P6c0W3jZOxn6fPPQHn\r\nDate: Mon, 22 May 2017 18:11:49 GMT\r\nContent-Length: 580\r\nContent-Type: text/html; charset=ISO-8859-1\r\n\r\n<h1>409: Conflict</h1><p>Your request had an invalid session-id header.</p><p>To fix this, follow these steps:<ol><li> When reading a response, get its X-Transmission-Session-Id header and remember it<li> Add the updated header to your outgoing requests<li> When you get this 409 error message, resend your request with the updated header</ol></p><p>This requirement has been added to help prevent <a href=\"http://en.wikipedia.org/wiki/Cross-site_request_forgery\">CSRF</a> attacks.</p><p><code>X-Transmission-Session-Id: dS9r8HR01JC0i6OgOxC7TDudLFV357P6c0W3jZOxn6fPPQHn</code></p>", 16384, 0, NULL, NULL) = 807
stat("https://www.foo.com/torrents/download/?id=5703370", 0x7fff8663a360) = -1 ENOENT (No such file or directory)
write(2, "posting:\n--------\n{\"arguments\":{\"download-dir\":\"/mnt/videos/series/something\",\"filename\":\"https://www.foo.com/torrents/download/?id=5703370\"},\"method\":\"torrent-add\",\"tag\":8}\n\n--------\n", 189posting:
{"arguments":{"download-dir":"/mnt/videos/series/something","filename":"https://www.foo.com/torrents/download/?id=5703370"},"method":"torrent-add","tag":8}
sendto(3, "POST /transmission/rpc/ HTTP/1.1\r\nHost: 127.0.0.1:9091\r\nUser-Agent: transmission-remote/2.92 (14714)\r\nAccept: */*\r\nAccept-Encoding: deflate, gzip\r\nX-Transmission-Session-Id: dS9r8HR01JC0i6OgOxC7TDudLFV357P6c0W3jZOxn6fPPQHn\r\nContent-Length: 161\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n{\"arguments\":{\"download-dir\":\"/mnt/videos/series/something\",\"filename\":\"https://www.foo.com/torrents/download/?id=5703370\"},\"method\":\"torrent-add\",\"tag\":8}\n", 466, MSG_NOSIGNAL, NULL, 0) = 466
I'm using GNU/Linux and transmission-remote/2.92.

Well everything seems fine in the dump so I really don't whats going on. With the debug output I forgot the proxy output but in this case the "=" characters has been changed to ":".

PS: its ok if the torrent is not downloaded I just want to test "=" ":" characters.
Last edited by microchip on Mon May 22, 2017 6:27 pm, edited 1 time in total.
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: transmission-remote character mangle

Post by mike.dld »

Well, this settles it, transmission-remote doesn't replace "=" with ":". Two things I would try:
  • manually running transmission-remote with proxy enabled and checking proxy log (you did the first part already but didn't mention whether there was a ":" in proxy log)
  • running transmission-remote with strace from within your (Python?) script to see if it still prints "=" to stderr in execve call.
microchip
Posts: 9
Joined: Sat May 20, 2017 12:14 pm

Re: transmission-remote character mangle

Post by microchip »

So strange. With strace and python execve call is ok but the proxy isn't happy. Usually, I'm not using the proxy that just for debugging purpose. I'll try without the proxy and with wireshark instead.
microchip
Posts: 9
Joined: Sat May 20, 2017 12:14 pm

Re: transmission-remote character mangle

Post by microchip »

Well, wireshark shows "=" and not ":" so I'm going to investigate again.
Post Reply