Captive::Portal::Role::Utils - common utils for Captive::Portal
Utility roles needed by other modules. All roles die on error.
Returns the corresponding MAC address for given IP address from /proc/net/arp on success or undef on failure.
Helper method, convert ipv4 address to hexadecimal representation.
Example: '10.1.2.254' -> '0a0102fe'
Helper method, normalize ip adresses, strip leading zeros in octets.
Example: '012.2.3.000' -> '12.2.3.0'
Running under root, like normal cronjobs do, should drop to the same uid/gid as the http daemon (and fcgi script). uid/gid is taken from config as RUN_USER/RUN_GROUP.
Wrapper to run external commands, capture and return (stdout/stderr).
Last optional parameter item is a hashref with options for spawn_cmd itself:
{ timeout => 2, # default 2s ignore_exit_codes => [], # exit codes without exception }
If the external command doesn't return after timeout, the command is interrupted and an exception is thrown.
Exit codes != 0 and not defined in ignore_exit_codes throw exceptions.
Template callback converting DNS name(s) to ip address(es), see perldoc Template::Manual::Variables. With this helper, DNS-names in firewall templates are translated to ipv4 adresses.
Example:
'10.10.10.10' -> '10.10.10.10' 'www.acme.rog' -> [10.1.2.3, 10.1.2.4, 10.1.2.5, ...] [ftp.uni-ulm.de, www.uni-ulm.de] -> [134.60.1.5, 134.60.1.25]
Karl Gaissmaier, <gaissmai at cpan.org>
<gaissmai at cpan.org>
Copyright 2010-2013 Karl Gaissmaier, all rights reserved.
This distribution is free software; you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version, or
b) the Artistic License version 2.0.
To install Captive::Portal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Captive::Portal
CPAN shell
perl -MCPAN -e shell install Captive::Portal
For more information on module installation, please visit the detailed CPAN module installation guide.