Skip to content

Commit

Permalink
[fix:openwrt] Remove fragment option from OpenVPN config when set to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy committed Nov 5, 2024
1 parent 8afbb38 commit 379e155
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions netjsonconfig/backends/openwrt/converters/openvpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class OpenVpn(OpenWrtConverter, BaseOpenVpn):
_uci_types = ['openvpn']

def __intermediate_vpn(self, vpn):
if vpn.get('fragment') == 0:
del vpn['fragment']
vpn.update(
{
'.name': self._get_uci_name(vpn.pop('name')),
Expand Down
10 changes: 6 additions & 4 deletions tests/openwrt/test_openvpn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from copy import deepcopy

from netjsonconfig import OpenWrt
from netjsonconfig.utils import _TabsMixin
Expand Down Expand Up @@ -71,7 +72,6 @@ class TestOpenVpn(_TabsMixin, unittest.TestCase):
option enabled '1'
option engine 'rsax'
option fast_io '1'
option fragment '0'
option group 'nogroup'
option keepalive '20 60'
option key 'key.pem'
Expand Down Expand Up @@ -104,7 +104,9 @@ def test_render_server_mode(self):

def test_parse_server_mode(self):
c = OpenWrt(native=self._server_uci)
self.assertEqual(c.config, self._server_netjson)
expected = deepcopy(self._server_netjson)
del expected['openvpn'][0]['fragment']
self.assertEqual(c.config, expected)

_client_netjson = {
"openvpn": [
Expand All @@ -119,7 +121,7 @@ def test_parse_server_mode(self):
"down": "/home/user/down-command.sh",
"disabled": False,
"fast_io": False,
"fragment": 0,
"fragment": 68,
"key": "key.pem",
"log": "/var/log/openvpn.log",
"mode": "p2p",
Expand Down Expand Up @@ -165,7 +167,7 @@ def test_parse_server_mode(self):
option down '/home/user/down-command.sh'
option enabled '1'
option fast_io '0'
option fragment '0'
option fragment '68'
option key 'key.pem'
option log '/var/log/openvpn.log'
option mode 'p2p'
Expand Down

0 comments on commit 379e155

Please sign in to comment.