in reply to [Resolved]Proxy link rotation

You say it's not working, without explaining what the "not working" is. Does it fail to compile? Does it die? Doesn't it use a proxy? Doesn't it rotate? Can't it read the file? Can it be something simple as not having permission to read "/etc/squid/repeater/lib/routes.cfg"? You're not checking whether the open succeeds or not.

Can you rephrase your question and 1) explain what goes wrong (that is, what are you seeing that makes you think "it doesn't work"), and 2) contains a short, stand-alone, runnable piece of code that shows the problem?

Replies are listed 'Best First'.
Re^2: Proxy link rotation
by kazak (Beadle) on Jan 27, 2012 at 16:08 UTC
    Sorry JavaFan my bad again, so:

    1. Not working:

    When I try to use a random array element for rotation, proxy is going directly without parent proxies at all, but when I'm copying\pasting any element of "@valid_routes" array into my code and use it directly, everything is going ok, proxy is used for serving requests. In other words:

    If I'm using:

    $cur_proxy$j - it's not working

    http://111.111.111.111:12345/ - it's working. This IP was pasted from simple .txt file. As far as I can see this should prove that request is being prepared, authorization on parent proxy is going Ok, and approach used for rotation of UserAgent string may be right. Also I checked @valid_routes, it's filled before each request.

    So now I'm just running out of ideas, what it might be.
      I don't quite know what you're saying -- I cannot relate everything to the code you're posted. For instance, now you're talking about $cur_proxy[$j], as if @cur_proxy is an array, but in your original code, $cur_proxy is a string.

      Let me ask it again, can you provide us with a small, standalone piece of code that shows the errorneous behaviour?

         $ua->proxy(['http'], $cur_proxy);

        It's here, $cur_proxy should be a string looking like this: http://111.111.111.111:12345/, randomly chosen from array . If I use $cur_proxy, this string is ignored, and traffic goes directly without any proxification. But if I comment out:

        my $cur_proxy = $valid_routes[$j]; $ua->proxy(['http'], $cur_proxy);

        and rewrite it like this:

         $ua->proxy(['http'], 'http://111.111.111.111:12345/')

        traffic goes through a proxy, as it should. So I need to make rotation work, somehow.