David Farrell

NAME

Net::OpenVPN::Agent - a resilient anonimizing user agent that provides IP and useragent masking, full logging capability using OpenVPN and log4perl.

REQUIREMENTS

An account with HideMyAss.com VPN service (affiliate link) is required. This module has been tested on Linux and *may* work on other UNIX-based OSes. OpenVPN must be installed.

    use Net::OpenVPN::Agent;
    my $ua = Net::OpenVPN::Agent->new;
    my $html = $ua->get_page('http://google.com'); # connect to HMA VPN and request the page, decrement request count

METHODS

new

Returns a new Agent object. Requires a YAML config file called agent.conf in to be present in the root program directory.

Example agent.conf

    ---
    USERNAME: sillymoose
    PASSWORD: itsasecret
    SERVER_REQUEST_LIMIT_MAX: 31
    SERVER_REQUEST_LIMIT_MIN: 15
    SERVER_REQUEST_CHECK_LIMIT: 5
    RETRY_DELAY_SECS: 10
    TIMEOUT_SECS: 5
    COOKIES:
        - google.com:
            - PREF=ID=dd1e749e64f70eb6:U=99aeb3ab0a5582ce:FF=0:TM=1385654322:LM=1385654323:S=JNn9pYDiSZipdvLU

    AGENTS:
    - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
    - Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
    - Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)
    - Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)
    - Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 5.1; Trident/5.0)
    - Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
    - Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.15 (KHTML, like Gecko) Chrome/24.0.1295.0 Safari/537.15
    - Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8
    - Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/537.22 (KHTML like Gecko) Safari/537.22
    LOG_CONF:
    - log4perl.logger=DEBUG, Screen
    - log4perl.appender.Screen=Log::Dispatch::Screen
    - log4perl.appender.Screen.stderr=0
    - log4perl.appender.Screen.Threshold=DEBUG
    - log4perl.appender.Screen.layout=Log::Log4perl::Layout::SimpleLayout
  • USERNAME/PASSWORD: these are your HMA credentials

  • SERVER_REQUEST_LIMIT_MIN / MAX: this is lower-upper limit from which to randomly calculate the maximum number of GET requests to be allowed per server. Once this limit is reached, the Agent.pm object will automatically connect to a new HMA VPN server, changing the IP address.

  • SERVER_REQUEST_CHECK_LIMIT: this is the number of times Agent.pm will check your IP address after connecting to a new server. If after this limit Agent.pm was not able to get a new IP address, it will automatically disconnect and connect to a new HMA VPN server.

  • RETRY_DELAY_SECS: the number of seconds Agent.pm will delay before retrying a failed request to validate a new server connection.

  • COOKIES: any cookies you want Agent.pm to use.

  • AGENTS: a list of useragent strings. Every time Agent.pm connects to a new server and obtains a new IP address, a new useragent string will be randomly selected from this list.

  • LOG_CONF: a list of log4perl settings for the logging requests and results.

get_page

Requires a URL an argument. Performs an HTTP get and returns the HTML page. Will initiate an HMA VPN connection using OpenVPN. Every call to get_page decrements the page request limit ($self->{request_limit}). When the request limit reaches zero this method will connect to another HMA server.

get_ip_address

Will return the current IP address or 0 if the ip lookup is not successful.

DESTROY

Object destructor that cleans up any .conf files created by the UserAgent.

INTERNAL METHODS

_makeAgent

Internal Method. Returns a new useragent.

_get

Internal method. Requires a URL as a an argument. Performs an HTTP get and returns the response hashref. Does not connect to a HMA server and does not decrement the page request limit count. Internally this method is used to check the Agent's current IP address.

_connect_to_random_server

This internal method will invoke openvpn and connect to a new HMA server.

_get_ua_string

Internal method. Returns a randomly selected UA string from an array of useragents. This can be provided in the agent.conf YAML file as AGENTS. If none are provided, will return a useragent string containing this module name and version.

_decrement_request_limit

Internal method. Resets the current request limit to be a random number between the agent.conf variables SERVER_REQUEST_LIMIT_MIN and SERVER_REQUEST_LIMIT_MAXunless the request limit is greater than 1, in which case this method will decrement the count by 1.

_get_hma_config

Internal method. Gets the HMA OpenVPN config file.

_get_server_list

Internal method. Gets the current HMA server list.

_make_config_file

Internal method. Accepts a server_hashref and creates a config file, returning the filepath.

AUTHOR

David Farrell, <sillymoos at cpan.org> http://perltricks.com

BUGS

Please report any bugs or feature requests to bug-Net-OpenVPN-Agent at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-OpenVPN-Agent. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Net::OpenVPN::Agent

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2013 David Farrell.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

get_servers_by_country_code

Returns an arrayhash of HMA servers with a matching location. If no arguments are passed to this method, it will return the entire arrayhash of available servers.

get_servers_by_name

Returns an arrayhash of HMA severs with a matching name. If no arguments are passed to this method, it will return the entire arrayhash of available servers.