iplock: iplock.cpp File Reference

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

iplock tool. More...

#include "iplock.h"
#include "version.h"
#include <libaddr/addr_parser.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <net/if.h>
#include <stdio.h>
#include <snapdev/poison.h>
Include dependency graph for iplock.cpp:

Go to the source code of this file.

Functions void file_deleter (FILE *f)  Free a FILE object. More...
  void pipe_deleter (FILE *pipe)  Free a FILE object opened by popen(). More...
  Variables advgetopt::option const g_iplock_block_or_unblock_options []  Scheme file options. More...
  advgetopt::options_environment g_iplock_block_or_unblock_options_environment   constexpr char const *const g_iplock_configuration_files []  The list of files (one) to the iplock.conf configuration file. More...
  advgetopt::option const g_iplock_configuration_options []  Scheme file options. More...
  advgetopt::options_environment const g_iplock_configuration_options_environment   constexpr char const *const g_iplock_count_configuration_files []  The configuration files for the –count command line option. More...
  advgetopt::option const g_iplock_count_options []  Scheme file options. More...
  advgetopt::options_environment const g_iplock_count_options_environment   advgetopt::option const g_iplock_options []  Command line options. More...
  advgetopt::options_environment const g_iplock_options_environment   Detailed Description

This implementation offers a way to easily and safely add and remove IP address one wants to block temporarily.

The tool makes use of the iptables tool to add and remove rules to one specific table which is expected to be included in your INPUT rules (with a -j <table-name>).

Definition in file iplock.cpp.

Function Documentation
void file_deleter ( FILE *  f)

This deleter is used to make sure that FILE objects get freed whenever the object holding it gets destroyed.

Parameters
[in]fThe FILE object to be freed.

Definition at line 591 of file iplock.cpp.

void pipe_deleter ( FILE *  pipe)

This deleter is used to make sure that FILE objects get freed whenever the object holding it gets destroyed.

Parameters
[in]pipeThe FILE object to be freed.

Definition at line 604 of file iplock.cpp.

Referenced by iplock::count::run().

Variable Documentation
advgetopt::option const g_iplock_block_or_unblock_options[]

This table includes all the variables supported by iplock in a scheme file such as http.conf.

Definition at line 361 of file iplock.cpp.

advgetopt::options_environment g_iplock_block_or_unblock_options_environment
Initial value:
=
{
.f_project_name = "schemes",
.f_options_files_directory = nullptr,
.f_environment_variable_name = nullptr,
.f_configuration_files = nullptr,
.f_configuration_filename = nullptr,
.f_configuration_directories = nullptr,
.f_environment_flags = 0,
.f_help_header = nullptr,
.f_help_footer = nullptr,
.f_version = IPLOCK_VERSION_STRING,
.f_license = nullptr,
.f_copyright = nullptr,
}
#define IPLOCK_VERSION_STRING
Definition: version.h.in:33
advgetopt::option const g_iplock_block_or_unblock_options[]
Scheme file options.
Definition: iplock.cpp:361

Definition at line 435 of file iplock.cpp.

Referenced by iplock::scheme::scheme().

constexpr char const* const g_iplock_configuration_files[]
Initial value:
{
"/etc/iplock/iplock.conf",
nullptr
}

This vector includes the project name ("iplock") and the path to the iplock configuration file.

The project name is used so one can place another copy of the iplock.conf file in a sub-directory named ".../iplock.d/..."

Note that we do not give users a way to enter their own configuration files. Those files can only be edited by root.

Definition at line 322 of file iplock.cpp.

advgetopt::option const g_iplock_configuration_options[]

This table includes all the variables supported by iplock in a scheme file such as http.conf.

Definition at line 233 of file iplock.cpp.

advgetopt::options_environment const g_iplock_configuration_options_environment
Initial value:
=
{
.f_project_name = "iplock",
.f_options_files_directory = nullptr,
.f_environment_variable_name = nullptr,
.f_configuration_files = g_iplock_configuration_files,
.f_configuration_filename = nullptr,
.f_configuration_directories = nullptr,
.f_environment_flags = 0,
.f_help_header = nullptr,
.f_help_footer = nullptr,
.f_version = IPLOCK_VERSION_STRING,
}
advgetopt::option const g_iplock_configuration_options[]
Scheme file options.
Definition: iplock.cpp:233
#define IPLOCK_VERSION_STRING
Definition: version.h.in:33
constexpr char const *const g_iplock_configuration_files[]
The list of files (one) to the iplock.conf configuration file.
Definition: iplock.cpp:322

Definition at line 332 of file iplock.cpp.

Referenced by iplock::command::command().

constexpr char const* const g_iplock_count_configuration_files[]
Initial value:
{
"/etc/iplock/count.conf",
nullptr
}

This vector includes a set of parameters used to load the –count options from a configuration file.

Definition at line 553 of file iplock.cpp.

advgetopt::option const g_iplock_count_options[]

This table includes all the variables supported by iplock in a scheme file such as http.conf.

Definition at line 462 of file iplock.cpp.

advgetopt::options_environment const g_iplock_count_options_environment
Initial value:
=
{
.f_project_name = "iplock",
.f_options = g_iplock_count_options,
.f_options_files_directory = nullptr,
.f_environment_variable_name = nullptr,
.f_configuration_files = g_iplock_count_configuration_files,
.f_configuration_filename = nullptr,
.f_configuration_directories = nullptr,
.f_environment_flags = 0,
.f_help_header = nullptr,
.f_help_footer = nullptr,
.f_version = IPLOCK_VERSION_STRING,
}
#define IPLOCK_VERSION_STRING
Definition: version.h.in:33
advgetopt::option const g_iplock_count_options[]
Scheme file options.
Definition: iplock.cpp:462
constexpr char const *const g_iplock_count_configuration_files[]
The configuration files for the –count command line option.
Definition: iplock.cpp:553

Definition at line 562 of file iplock.cpp.

Referenced by iplock::count::count().

advgetopt::option const g_iplock_options[]

This table includes all the options supported by iplock on the command line.

Definition at line 83 of file iplock.cpp.

advgetopt::options_environment const g_iplock_options_environment
Initial value:
=
{
.f_project_name = "iplock",
.f_options = g_iplock_options,
.f_options_files_directory = nullptr,
.f_environment_variable_name = "IPLOCK_OPTIONS",
.f_configuration_files = nullptr,
.f_configuration_filename = nullptr,
.f_configuration_directories = nullptr,
.f_environment_flags = 0,
.f_help_header = "Usage: %p [-<opt>] [ip]\n"
"where -<opt> is one or more of:",
.f_help_footer = nullptr,
.f_version = IPLOCK_VERSION_STRING,
.f_license = nullptr,
.f_copyright = nullptr,
}
#define IPLOCK_VERSION_STRING
Definition: version.h.in:33
advgetopt::option const g_iplock_options[]
Command line options.
Definition: iplock.cpp:83

Definition at line 203 of file iplock.cpp.

Referenced by iplock::iplock().

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