Metadata-Version: 1.1
Name: ipsecparse
Version: 0.3.0
Summary: Parse and edit your ipsec configuration files
Home-page: https://github.com/leforestier/ipsecparse
Author: Benjamin Le Forestier
Author-email: benjamin@leforestier.org
License: UNKNOWN
Description: .. image:: https://travis-ci.org/leforestier/ipsecparse.svg
            :target: https://travis-ci.org/leforestier/ipsecparse
        
        Parse and edit your ipsec configuration files (ipsec.conf)
        
        Installation
        ~~~~~~~~~~~~
        
        To install ipsecparse, simply:
        
        .. code-block:: console
        
            pip install ipsecparse
        
        Examples
        ~~~~~~~~
        
        .. code:: python
        
            # Load the configuration from a string.
        
            from ipsecparse import loads
        
            conf = loads(open('/etc/ipsec.conf').read())
        
            # The configuration is represented as a dictionnary
            # (actually a subclass of OrderedDict)
        
            # Each section of the configuration is an OrderedDict.
        
            # Let's modify some settings:
        
            conf['config', 'setup']['nat_traversal'] = 'yes'
        
            conf['conn', 'myconn']['left'] = '192.168.0.10'
        
            # Create a connection:
        
            conf['conn', 'mynewconn'] = {
                'leftsubnet': '10.0.0.0/16',
                'right': '192.168.0.1'
            }
        
            # You can also use an OrderedDict if order matters to you:
        
            from collections import OrderedDict
        
            conf['conn', 'mynewconn'] = OrderedDict(
                lefsubnet = '10.0.0.0/16',
                right = '192.168.0.1'
            )
        
            # Delete a connection:
        
            del conf['conn', 'mynewconn']
        
            # Same thing with certification authorities. Create a CA:
        
            conf['ca', 'myca'] = {
                'cacert': 'MyCert.pem',
                'crluri': 'http://crl.example.com/mycrl.crl',
                'auto': 'add'
            }
        
            # Delete it:
        
            del conf['ca', 'myca']
        
            # Add an include:
        
            conf['include', '/etc/ipsec.d/ipsec.include'] = True
        
            # Delete it:
        
            del conf['include', '/etc/ipsec.d/ipsec.include']
        
            # Display the new configuration as a string:
        
            print(conf.dumps())
        
            # with four spaces indents instead of the default tabulations:
        
            print(conf.dumps(indent = '    '))
        
            # Replace the old configuration file:
        
            with open('/etc/ipsec.conf', 'w') as fd:
                fd.write(conf.dumps())
        
            # Search for connections inside the configuration.
            # Pass a callable to the `conn_filter` method.
        
            for name, section in conf.conn_filter(
                lambda conn: conn.get('leftsubnet') == '10.0.0.0/16'
            ):
                section['auto'] = 'start'
        
            # Or use the Key and Keys class
            # (just to make queries a bit shorter)
        
            from ipsecparse import Key, Keys
        
            for name, section in conf.conn_filter(
                Key('leftsubnet') == '10.0.0.0/16'
            ):
                section['auto'] = 'start'
        
            for name, section in conf.conn_filter(
                Keys('left', 'right').contains('192.168.0.1')
            ):
                del conf['conn', name]
        
        
        GitHub repo: https://github.com/leforestier/ipsecparse
        
Keywords: ipsec,conf,configuration,parser,parsing,ipsec.conf,openswan
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
