@@ -53,9 +53,23 @@ def __intermediate_vpn(self, config, remove=None):
5353 # do not display status-version if status directive not present
5454 if 'status' not in config and 'status_version' in config :
5555 del config ['status_version' ]
56+ config = self .__output_data_ciphers (config )
5657 config = self .__add_tls_auth_key (config )
5758 return self .sorted_dict (config )
5859
60+ def __output_data_ciphers (self , config ):
61+ data_ciphers = config .get ('data_ciphers' , None )
62+ if not data_ciphers :
63+ return config
64+ output = ''
65+ for cipher in data_ciphers :
66+ cipher_text = cipher ['cipher' ]
67+ if cipher ['optional' ]:
68+ cipher_text = f'?{ cipher_text } '
69+ output = f'{ output } :{ cipher_text } '
70+ config ['data_ciphers' ] = output [1 :]
71+ return config
72+
5973 def __add_tls_auth_key (self , config ):
6074 tls_auth = config .get ('tls_auth' , None )
6175 if not tls_auth :
@@ -109,4 +123,18 @@ def __netjson_vpn(self, vpn):
109123 else :
110124 remote .append (dict (host = items [0 ], port = int (items [1 ])))
111125 vpn ['remote' ] = remote
126+ vpn = self .__netjson_data_ciphers (vpn )
127+ return vpn
128+
129+ def __netjson_data_ciphers (self , vpn ):
130+ data_ciphers_text = vpn .get ('data_ciphers' )
131+ if not data_ciphers_text :
132+ return vpn
133+ data_ciphers = []
134+ ciphers = data_ciphers_text .split (':' )
135+ for cipher in ciphers :
136+ optional = cipher .startswith ('?' )
137+ cipher_text = cipher if not optional else cipher [1 :]
138+ data_ciphers .append ({'cipher' : cipher_text , 'optional' : optional })
139+ vpn ['data_ciphers' ] = data_ciphers
112140 return vpn
0 commit comments