File tree Expand file tree Collapse file tree 4 files changed +28
-0
lines changed
netjsonconfig/backends/openwrt/converters Expand file tree Collapse file tree 4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,12 @@ def __intermediate_vpn(self, vpn):
1515 "enabled" : not vpn .pop ("disabled" , False ),
1616 }
1717 )
18+ if (ciphers := vpn .get ("tls_cipher" )) and isinstance (ciphers , str ):
19+ vpn ["tls_cipher" ] = []
20+ # only add non empty strings
21+ for part in ciphers .split (":" ):
22+ if part :
23+ vpn ["tls_cipher" ].append (part )
1824 return super ().__intermediate_vpn (vpn , remove = ["" ])
1925
2026 def __netjson_vpn (self , vpn ):
@@ -24,4 +30,6 @@ def __netjson_vpn(self, vpn):
2430 vpn ["disabled" ] = vpn .pop ("enabled" , "0" ) == "0"
2531 vpn ["name" ] = vpn .pop (".name" )
2632 del vpn [".type" ]
33+ if (ciphers := vpn .get ("tls_cipher" )) and isinstance (ciphers , list ) and ciphers :
34+ vpn ["tls_cipher" ] = ":" .join (ciphers )
2735 return super ().__netjson_vpn (vpn )
Original file line number Diff line number Diff line change @@ -257,6 +257,11 @@ def test_client_mode(self):
257257 "status_version" : 1 ,
258258 "tls_client" : True ,
259259 "tls_auth" : "tls_auth.key 1" ,
260+ "tls_cipher" : (
261+ "TLS-DHE-RSA-WITH-AES-256-CBC-SHA:"
262+ "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA:"
263+ "@SECLEVEL=0"
264+ ),
260265 "topology" : "p2p" ,
261266 "tun_ipv6" : True ,
262267 "up" : "/home/user/up-command.sh" ,
@@ -302,6 +307,7 @@ def test_client_mode(self):
302307status /var/log/openvpn.status 30
303308status-version 1
304309tls-auth tls_auth.key 1
310+ tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA:TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0
305311tls-client
306312topology p2p
307313tun-ipv6
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ def test_parse_server(self):
7474script-security 0
7575status /var/log/openvpn.status 10
7676status-version 1
77+ tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA:TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0
7778tls-server
7879user nobody
7980verb 3
@@ -110,6 +111,11 @@ def test_parse_server(self):
110111 "script_security" : 0 ,
111112 "status" : "/var/log/openvpn.status 10" ,
112113 "status_version" : 1 ,
114+ "tls_cipher" : (
115+ "TLS-DHE-RSA-WITH-AES-256-CBC-SHA:"
116+ "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA:"
117+ "@SECLEVEL=0"
118+ ),
113119 "tls_server" : True ,
114120 "user" : "nobody" ,
115121 "verb" : 3 ,
Original file line number Diff line number Diff line change @@ -211,6 +211,11 @@ def test_parse_server_mode_data_ciphers(self):
211211 "script_security" : 1 ,
212212 "status" : "/var/log/openvpn.status 30" ,
213213 "status_version" : 1 ,
214+ "tls_cipher" : (
215+ "TLS-DHE-RSA-WITH-AES-256-CBC-SHA:"
216+ "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA:"
217+ "@SECLEVEL=0"
218+ ),
214219 "tls_client" : True ,
215220 "tun_ipv6" : True ,
216221 "up" : "/home/user/up-command.sh" ,
@@ -254,6 +259,9 @@ def test_parse_server_mode_data_ciphers(self):
254259 option script_security '1'
255260 option status '/var/log/openvpn.status 30'
256261 option status_version '1'
262+ list tls_cipher 'TLS-DHE-RSA-WITH-AES-256-CBC-SHA'
263+ list tls_cipher 'TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA'
264+ list tls_cipher '@SECLEVEL=0'
257265 option tls_client '1'
258266 option tun_ipv6 '1'
259267 option up '/home/user/up-command.sh'
You can’t perform that action at this time.
0 commit comments