iplock: iplock Class Reference

iplock  3.0.18
A command line tool to add and remove rules from your firewall without you having to be root.

#include <iplock.h>

Classes class  batch  Block the specified IP addresses. More...
  class  block  Block the specified IP addresses. More...
  class  block_or_unblock   class  command   class  count  Generate a count of all the entries by IP address. More...
  class  flush  Block the specified IP addresses. More...
  class  scheme   class  unblock  Unblock the specified IP addresses. More...
  Public Member Functions  iplock (int argc, char *argv[])  Initialize the iplock object. More...
  void run_command ()  Run the selected command. More...
  Private Member Functions void make_root ()  Before running a command, make sure we are root. More...
  void set_command (command::pointer_t c)  Save the command pointer in f_command. More...
  Private Attributes command::pointer_t f_command = command::pointer_t()   Detailed Description

Definition at line 35 of file iplock.h.

Constructor & Destructor Documentation
iplock::iplock ( int  argc, char *  argv[]  )

This function parses the command line and determines the command that the end user selected (i.e. –block, –unblock, or –count.)

If the user specified –help or –version, then this function prints the help screen or version of iplock and exits the process immediately.

If no command was specified on the command line, then an error is written to stderr and the process exits immediately.

Parameters
[in]argcThe number of arguments in argv. [in]argvThe argument strings.

Definition at line 1740 of file iplock.cpp.

References f_command, g_iplock_options_environment, IPLOCK_VERSION_STRING, and set_command().

Member Function Documentation
void iplock::make_root ( ) private

This function gets called by the run_command() function.

The function exits the process with an error if becoming root is not possible. This can happen if (1) the process is run by systemd and systemd prevents such, (2) the binary is not marked with the 's' bit.

Definition at line 1827 of file iplock.cpp.

Referenced by run_command().

void iplock::run_command ( )

The constructor parses the command line options and from that deterimes which command the user selected. This function runs that command by calling its run() function.

This function first makes sure the user is running as root. This may change in the future if some of the commands may otherwise be run as a regular user.

Definition at line 1852 of file iplock.cpp.

References f_command, and make_root().

Referenced by main().

void iplock::set_command ( command::pointer_t  c) private

This function saves the specified c command pointer to the f_command parameter.

It is done that way so we can very easily detect whether more than one command was specified on the command line.

Parameters
[in]cThe pointer to the command line to save in iplock.

Definition at line 1807 of file iplock.cpp.

References f_command.

Referenced by iplock().

Member Data Documentation
command::pointer_t iplock::f_command = command::pointer_t() private

Definition at line 174 of file iplock.h.

Referenced by iplock(), run_command(), and set_command().


The documentation for this class was generated from the following files:

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly