Sign up here and you can log into the forum!

Pandora - Accessing outside the U.S.

youtube/live365/pandora/flickr replacements & other web services

Pandora - Accessing outside the U.S.   

Postby bagira » Mon May 17, 2010 7:09 am

Hi all! :D

At the last weekend I figured out how can I use the Pandora from outside the U.S.. It was not so easy as I thought.
The idea was, that the device connect to Pandora through free USA proxy server. You can find free Transp.(!) proxy servers example here: http://www.proxylist.net/list/us/0/1/2/0
First of all I wrote a Pandora specific proxy script, after I generalized it. This script reads the proxy IP and PORT from the config file, if exists, and use them to connect to NOT SSL servers (in this case: tuner.pandora.com).
For connecting to HTTPS server the script use 2 GET parameter (on for IP, and on for PORT).

/conf/general-proxy.php
Code: Select all
<?php
   /*
      Name: General proxy (example: to use services from outside the U.S.)
      Created: 2010.05.17. Bagira
      Version: v1.2
   */

   // Default proxy
   $PROXY_IP = "66.42.182.178";
   $PROXY_PORT = 3128;

   // Get general proxy
   if (file_exists('/conf/config')) {
      $config = file_get_contents('/conf/config');
      if(preg_match('/GENERAL_PROXY=\'(.+):(.+)\'/', $config, $config_proxy)) {
         $PROXY_IP = $config_proxy[1];
         $PROXY_PORT = $config_proxy[2];
      };
   };

   // If NOT HTTP Envelope
   if (!isset($_SERVER["REQUEST_METHOD"]) || !isset($_SERVER["REQUEST_URI"]) || !isset($_SERVER["SERVER_PROTOCOL"]) || !isset($_SERVER["HTTP_HOST"]) || $_SERVER["HTTP_HOST"] == $_SERVER["SERVER_ADDR"]) {
      exit(); // ERROR: Not HTTP Envelope
   };

   // Retrieve POST data
   $postdata = file_get_contents("php://input");

   //DEBUG
   //error_log(print_r($_SERVER, TRUE));

   if (isset($_SERVER["HTTPS"])) {
      if (isset($_GET["ssl_ip"]) && isset($_GET["ssl_port"])) {
         $DEST_IP = "ssl://".$_GET["ssl_ip"];
         $DEST_PORT = $_GET["ssl_port"];
      } else {
         exit(); // ERROR: There is no SSL IP and PORT
      };
   } else {
      $DEST_IP = $PROXY_IP;
      $DEST_PORT = $PROXY_PORT;
   };

   // Connect
   $pp = fsockopen($DEST_IP, $DEST_PORT);

   if ($pp) {
      // Send header
      fputs($pp, $_SERVER["REQUEST_METHOD"]." ".$_SERVER["REQUEST_URI"]." ".$_SERVER["SERVER_PROTOCOL"]."\r\n");
      fputs($pp, "Host: ".$_SERVER["HTTP_HOST"]."\r\n");
      fputs($pp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)\r\n");
      if (isset($_SERVER["HTTP_ACCEPT"])) {
         fputs($pp, "Accept: ".$_SERVER["HTTP_ACCEPT"]."\r\n");
      };
      fputs($pp, "Keep-Alive: 115\r\n");
      fputs($pp, "Connection: keep-alive\r\n");
      if (isset($_SERVER["CONTENT_TYPE"])) {
         fputs($pp, "Content-Type: ".$_SERVER["CONTENT_TYPE"]."; charset=UTF-8\r\n");
      };
      if (isset($_SERVER["CONTENT_LENGTH"])) {
         fputs($pp, "Content-Length: ".$_SERVER["CONTENT_LENGTH"]."\r\n");
      };
      fputs($pp, "Pragma: no-cache\r\n");
      fputs($pp, "Cache-Control: no-cache\r\n");
      fputs($pp, "\r\n");

      // Send POST-DATA
      fputs($pp, $postdata);

      // Read and write RESPONSE
      while (!feof($pp)) {
         $buff .= fgets($pp, 4096);
      }
      // Close connection
      fclose($pp);

      list($header, $body) = split("\r\n\r\n", $buff);
      header("HTTP/1.0 201 Created");
      echo $body;
   };
?>

To define other proxy server, use script like (replace your favorite proxy IP, and PORT in this term: <PROXY IP>:<PROXY PORT>)
Code: Select all
config_tool -c GENERAL_PROXY='66.42.182.178:3128'
config_tool -s

The Pandora client use the SSL in almost all of their services (the SSL not uses proxy). So we need to configure lighttpd to serve HTTPS. I found a server.pem in the firmware, so we use this. Run the following:
Code: Select all
cp /usr/share/pyshared/twisted/test/server.pem /conf

We need some changes in hosts-resolving. Add this lines to
/conf/hosts
Code: Select all
127.0.0.1 tuner.pandora.com
127.0.0.1 autocomplete.pandora.com

We have to change the auth config of lighttpd, to not ask user and pass. We also need some url-rewrite. Propbably in the next FW this part of script can get in /etc/lighttpd/conf-available/30-pandora-proxy.conf (b-rad?)
/conf/05-auth.conf
Code: Select all
## Authentication for lighttpd
##
## Documentation: /usr/share/doc/lighttpd-doc/authentication.txt.gz
##                http://www.lighttpd.net/documentation/authentication.html

server.modules                += ( "mod_auth" )

auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/etc/lighttpd/.passwd"

$HTTP["host"] !~ "(\.pandora\.com$)|(^localhost$)|(^127\.0\.0\.1)|(^gdata\.youtube\.com$)|(^(www\.)?live365\.com$)" {
   auth.require = (
   "/" =>
      (
      "method" => "digest",
      "realm" => "WDLXTV-Webend",
      "require" => "user=wdlxtv"
      )
   )
}

# Pandora service need this
server.reject-expect-100-with-417 = "disable"

# Pandora service use SSL
$SERVER["socket"] == "0.0.0.0:443" {
      ssl.engine = "enable"
      ssl.pemfile = "/conf/server.pem"
}

# Pandora service url rewrite
$HTTP["host"] =~ "\.pandora\.com" {
   url.rewrite-once = (
      "^(.*)$" => "/proxy/general-proxy.php?ssl_ip=208.85.40.35&ssl_port=443",
   )
}
It was hard to find the solution for the Expect header - 417 error... :(

We are almost ready. :) We have to do some changes, to that after a reboot everything to be fine.

/conf/S00user-script
Code: Select all
#!/bin/sh

# Pandora
mount -o bind /conf/05-auth.conf /etc/lighttpd/conf-available/05-auth.conf

# S99user-script
[ -f /conf/S99user-script ] && dos2unix /conf/S99user-script && cat /conf/S99user-script >> /tmp/init.d/S99post-init

I think that S99user-script will also be a good feature in the next FW (b-rad?):
/conf/S99user-script
Code: Select all
#!/bin/sh
ln -s /conf/general-proxy.php /tmp/www/proxy/


After all, reboot your device and see that your Pandora link works or not.
To enter the registration code, you have to use your web browser. You have to setup the same proxy server in the browser settings to achieve http://www.pandora.com. My advice is to register to Pandora on web browser (in this case you will try out your found proxy server). At the registration you have to find a valid ZIP code (Google is your friend :) )
If you cannot read the code on the TV, just find it here: /tmp/result/device.generateDeviceActivationCode
The pandora_ep use the /tmp/result directory to store the received messages while communicate with the server.

If I forget something, let me know!

Cheers,
Bagira :D

ps.: I succesfully registered my WD at http://www.pandora.com with my already existing account and use this solution for a day (without any error) with b-rad's 1.02.21 firmware.
bagira
Beta Tester
 
Posts: 84
Joined: Mon May 03, 2010 10:58 am
Location: Hungary

Re: Pandora - Accessing outside the U.S.   

Postby Martor » Wed May 19, 2010 2:57 am

Hi bagira,
as I said previously, you are a genius! :)
Give it a try tonight and let you know.

I have already able to find US proxies, but I didn't know how to use this for WDLXTV.
Let you know if works for me ;)

Cheers!
Martin
1.02.21_V_WDLXTV.COM_WDLXTV_LIVE-0.5.1.1
Martor
DLX'er
 
Posts: 98
Joined: Sat Apr 10, 2010 9:58 pm
Location: Czech Republic

Re: Pandora - Accessing outside the U.S.   

Postby Martor » Sat May 22, 2010 12:23 pm

Thank you very much Bagira!
Hereby I am confirming fully running stuff which is working great! :)

Martin
1.02.21_V_WDLXTV.COM_WDLXTV_LIVE-0.5.1.1
Martor
DLX'er
 
Posts: 98
Joined: Sat Apr 10, 2010 9:58 pm
Location: Czech Republic

Re: Pandora - Accessing outside the U.S.   

Postby bagira » Sat May 22, 2010 12:31 pm

You're welcome Martin! :)
Bagira
bagira
Beta Tester
 
Posts: 84
Joined: Mon May 03, 2010 10:58 am
Location: Hungary

Re: Pandora - Accessing outside the U.S.   

Postby avdija » Mon May 24, 2010 4:53 am

WOW!
avdija
Donor
 
Posts: 4
Joined: Wed Apr 21, 2010 10:35 pm

Re: Pandora - Accessing outside the U.S.   

Postby dan » Sat May 29, 2010 12:21 pm

This works really great. Would you please add this to your firmware, b-rad?
dan
Developer
 
Posts: 40
Joined: Fri May 28, 2010 11:35 pm

Re: Pandora - Accessing outside the U.S.   

Postby b-rad.cc » Sat May 29, 2010 3:39 pm

No. Bypassing geographical restrictions like this is illegal in the united states, and wdlxtv and all wdlxtv.com sites are based out of the states--regardless if I currently live in canada. I will add the proxy bit and that is all, period. The rest will be up to you.
PM's are for private matters only, please post public matters on the forum to help others who might have the same issue.
:mrgreen:
User avatar
b-rad.cc
WDLXTV Team
 
Posts: 3003
Joined: Sat Apr 03, 2010 9:35 am
Location: New York

Re: Pandora - Accessing outside the U.S.   

Postby chriz77 » Tue Jun 08, 2010 12:23 pm

Hi all,

It did not work for me. Pandora's always telling me that I'm not an U.S. resident...

I created the following files (as described by bagira) at /conf:
general-proxy.php
05-auth.conf
S00user-script
S99user-script
I copied the file /usr/share/pyshared/twisted/test/server.pem to /conf

PING tuner.pandora.com (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.313 ms

At the end I rebooted the device.

I'm running the latest version of WDLXTV-LIVE

Has anybody an idea what could be wrong? - Many thanx in advance!

Cheers

Chris
chriz77
n00b
 
Posts: 1
Joined: Tue Jun 08, 2010 11:55 am
Location: Germany

Re: Pandora - Accessing outside the U.S.   

Postby bagira » Sat Jun 19, 2010 6:08 am

Hi chriz77!

Try to use another proxy IP and PORT. At this time the default proxy, which I hardcoded into the PHP file, doesn't work all time. I use now the following proxy: 204.114.12.157:80

The PING test is not a good solution to test your proxy if it works: the response is always come from your localhost. You can test your proxy with the following command:
Code: Select all
wget -q http://tuner.pandora.com/services/xmlrpc/?method=test.checkLicensing -O - |grep xml

If the response like this, the proxy you set will work (Don't matter about the error message in the xml):
Code: Select all
<?xml version="1.0" encoding="UTF-8"?><methodResponse><fault><value><struct><member><name>faultString</name><value>org.apache.xmlrpc.XmlRpcException: An unexpected error occurred</value></member><member><name>faultCode</name><value><int>0</int></value></member></struct></value></fault></methodResponse>

The Pandora communcate with the WDTV through files in the /tmp/result directory. You can see there the responses from the pandora's server.

Bagira
bagira
Beta Tester
 
Posts: 84
Joined: Mon May 03, 2010 10:58 am
Location: Hungary

Re: Pandora - Accessing outside the U.S.   

Postby djethen » Thu Jul 22, 2010 1:11 am

Hey i have done everything but i cant do one part..
When i enter
Code: Select all
# cp /usr/share/pyshared/twisted/test/server.pem /conf

i get this
Code: Select all
cp: cannot stat '/usr/share/pyshared/twisted/test/server.pem': No such file or directory

So what should i do to fix it..

And if i use this other internet service doesnt work like umsp chanels and youtube..
djethen
WDTVer
 
Posts: 28
Joined: Fri Apr 23, 2010 8:05 am

Next

Return to WDTVL Proxy Project

Who is online

Users browsing this forum: No registered users and 1 guest