summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-ipsecparse.spec414
-rw-r--r--sources1
3 files changed, 416 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..ee15d4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/ipsecparse-0.3.0.tar.gz
diff --git a/python-ipsecparse.spec b/python-ipsecparse.spec
new file mode 100644
index 0000000..455b23b
--- /dev/null
+++ b/python-ipsecparse.spec
@@ -0,0 +1,414 @@
+%global _empty_manifest_terminate_build 0
+Name: python-ipsecparse
+Version: 0.3.0
+Release: 1
+Summary: Parse and edit your ipsec configuration files
+License: GNU Library or Lesser General Public License (LGPL)
+URL: https://github.com/leforestier/ipsecparse
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/05/7d/24709be12867e3d202f82927db9879ebe4a9a20ef1b1c940bf95615ee1cf/ipsecparse-0.3.0.tar.gz
+BuildArch: noarch
+
+
+%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
+
+
+%package -n python3-ipsecparse
+Summary: Parse and edit your ipsec configuration files
+Provides: python-ipsecparse
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-ipsecparse
+.. 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
+
+
+%package help
+Summary: Development documents and examples for ipsecparse
+Provides: python3-ipsecparse-doc
+%description help
+.. 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
+
+
+%prep
+%autosetup -n ipsecparse-0.3.0
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-ipsecparse -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.3.0-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..956fcf5
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+b7ca8ce1748877812f7c0f9e2338d6a1 ipsecparse-0.3.0.tar.gz