Skip to content

Commit

Permalink
Fixed wrong line offset when deleting peers; created bugfix version 0…
Browse files Browse the repository at this point in the history
….1.3
  • Loading branch information
Henri committed Jul 28, 2020
1 parent b103437 commit bec838f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 11 deletions.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

All notable changes to this project are documented in this file.

## [Unreleased]

### Added

- n/a

### Changed
- n/a

### Fixed
- n/a

## [0.1.3] - 2020-07-28

### Fixed

- Extended tests to detect wrong line offset when deleting peers.
- Fixed wrong line offset when deleting peers.

## [0.1.2] - 2020-07-11

### Added

- Prepared for first public release to PyPi.

## [0.1.1] - 2020-07-11

### Added

- First public release to Github.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ Please see below for more detailed usage information.
* wc = wgconfig.WGConfig('/etc/wireguard/wg0.conf')

* read_file()
Reads the Wireguard config file into memory
Reads the WireGuard config file into memory

* write_file(file)
Writes a Wireguard config file from memory to file
Writes a WireGuard config file from memory to file

Parameters:
* file (str, optional, default: None): Path of the WireGuard configuration file
Expand Down
4 changes: 2 additions & 2 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ Please see below for more detailed usage information.
* wc = wgconfig.WGConfig('/etc/wireguard/wg0.conf')

* read_file()
Reads the Wireguard config file into memory
Reads the WireGuard config file into memory

* write_file(file)
Writes a Wireguard config file from memory to file
Writes a WireGuard config file from memory to file

Parameters:
* file (str, optional, default: None): Path of the WireGuard configuration file
Expand Down
Binary file modified src/dist/wgconfig-0.1.2.tar.gz
Binary file not shown.
Binary file added src/dist/wgconfig-0.1.3.tar.gz
Binary file not shown.
9 changes: 5 additions & 4 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

setup_kwargs = {
'name': 'wgconfig',
'version': '0.1.2',
'version': '0.1.3',
'author': 'Dirk Henrici',
'author_email': '[email protected]',
'description': 'parsing and writing WireGuard configuration files',
'long_description': long_description,
'long_description_content_type': 'text/markdown',
'url': 'https://www.github.com/towalink/',
'url': 'https://www.github.com/towalink/wgconfig',
'packages': setuptools.find_packages(),
'classifiers': [
'Programming Language :: Python',
Expand All @@ -27,9 +27,10 @@
'Intended Audience :: Information Technology'
],
'python_requires': '>=3.5',
'keywords': 'WireGuard configuration wg',
'keywords': 'WireGuard configuration config wg',
'project_urls': {
'Repository': 'https://www.github.com/towalink/',
'Repository': 'https://www.github.com/towalink/wgconfig',
'PyPi': 'https://pypi.org/project/wgconfig/'
},
}

Expand Down
2 changes: 1 addition & 1 deletion src/wgconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def del_peer(self, key):
# Only keep needed lines
result = []
if section_firstline > 0:
result.extend(self.lines[0:(section_firstline - 1)])
result.extend(self.lines[0:section_firstline])
result.extend(self.lines[(section_lastline + 1):])
self.lines = result
# Invalidate data cache
Expand Down
16 changes: 14 additions & 2 deletions test/test_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,15 @@ def test_del_peer1(setup_testconfig1):
'Endpoint': '192.168.0.3:51820',
'PersistentKeepalive': 25,
'PublicKey': 'eBvBVLo6wH0XkBfIjeLPf8ydBTfU/gMqJOH4nmVXcDE=',
'_index_firstline': 8,
'_index_lastline': 15}}
'_index_firstline': 9,
'_index_lastline': 16}}
assert wc.peers == peers, 'first peer incorrectly deleted'
interface = {'Address': 'fe80::1/64',
'ListenPort': 51820,
'PrivateKey': '6FYKQKEtGFAb5HSwyj5cQl3wgS1E9d6SqVjdVksOn2s=',
'_index_firstline': 1,
'_index_lastline': 6}
assert wc.interface == interface, 'first peer incorrectly deleted'

def test_del_peer2(setup_testconfig1):
wc = setup_testconfig1
Expand All @@ -207,6 +213,12 @@ def test_del_peer2(setup_testconfig1):
'_index_firstline': 9,
'_index_lastline': 14}}
assert wc.peers == peers, 'second peer incorrectly deleted'
interface = {'Address': 'fe80::1/64',
'ListenPort': 51820,
'PrivateKey': '6FYKQKEtGFAb5HSwyj5cQl3wgS1E9d6SqVjdVksOn2s=',
'_index_firstline': 1,
'_index_lastline': 6}
assert wc.interface == interface, 'second peer incorrectly deleted'

def test_add_attr1(setup_testconfig1):
"""add_attr to existing attr with value list"""
Expand Down

0 comments on commit bec838f

Please sign in to comment.