xwmario / rutorrent

Automatically exported from code.google.com/p/rutorrent
0 stars 0 forks source link

proxy support in cookies plugin to fetch torrents from certain trackers #795

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Some trackers don't allow browsing from certain IP addresses. 
example: extremeshare.org outputs 404 when trying to access the tracker from 
IPs which are not romanian, resulting in a failure when trying to add a torrent 
using a direct torrent url.

i created a modified version of snoopy class and cookies.php which allows usage 
of proxies.

this a simple working concept and it needs corrections & improvements.

example of cookies format in settings panel:

tracker_domain:proxy_host:proxy_port|uid=0000;pass=90x00x0x0x0x0;

cookies.php is attached to this report.

snoopy modifications:
-----------------------
    public function fetchComplex($URI,$method="GET",$content_type="",$body="")
    {
        global $rootPath;
        $parts = parse_url($URI);
        $this->host = $parts["host"];
        if(rTorrentSettings::get()->isPluginRegistered('cookies') && !empty($this->host))
        {
            require_once($rootPath."/plugins/cookies/cookies.php"); 
            $cookies = rCookies::load();
            $this->cookies = array_merge($this->cookies,$cookies->getCookiesForHost($this->host));

            if(($proxy = $cookies->getProxyForHost($this->host)) !== false) {
                $this->proxy_host = $proxy[0];
                $this->proxy_port = $proxy[1];
            }

        }
        $this->cookies = array_merge($this->cookies,self::getURLCookies($URI));
        if(rTorrentSettings::get()->isPluginRegistered('loginmgr'))
        {
            require_once($rootPath."/plugins/loginmgr/accounts.php");   
            $am = accountManager::load();
            if($am===false)
            {
                $am = new accountManager();
                $am->obtain($rootPath."/plugins/loginmgr/accounts");
            }
            $acc = $am->getAccount($URI);
            if($acc)
                return($am->fetch( $acc, $this, $URI, $method, $content_type, $body ));
        }
        return($this->fetch($URI,$method,$content_type,$body));
    }

Original issue reported on code.google.com by lowraid...@gmail.com on 13 Jan 2013 at 9:28

Attachments: