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",
)
}
We are almost ready.
/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
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.







