connectivity-api
openvpn-connection.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authors:
17  * Pete Woods <pete.woods@canonical.com>
18  */
19 
20 #pragma once
21 
23 
24 namespace connectivityqt
25 {
26 
27 class Q_DECL_EXPORT OpenvpnConnection : public VpnConnection
28 {
29  Q_OBJECT
30 
31 public:
32  UNITY_DEFINES_PTRS(OpenvpnConnection);
33 
34  Q_ENUMS(ConnectionType)
36  {
37  TLS,
40  STATIC_KEY
41  };
42 
43  Q_ENUMS(DevType)
44  enum DevType
45  {
46  TUN,
47  TAP
48  };
49 
50  Q_ENUMS(Cipher)
51  enum Cipher
52  {
68  AES_256_CBC_HMAC_SHA1
69  };
70 
71  Q_ENUMS(Auth)
72  enum Auth
73  {
77  MD5,
83  RIPEMD160
84  };
85 
86  Q_ENUMS(TlsType)
87  enum TlsType
88  {
90  CLIENT
91  };
92 
93  Q_ENUMS(KeyDir)
94  enum KeyDir
95  {
98  ONE
99  };
100 
101  Q_ENUMS(ProxyType)
103  {
106  SOCKS
107  };
108 
109  OpenvpnConnection(const QDBusObjectPath& path, const QDBusConnection& connection);
110 
111  virtual ~OpenvpnConnection();
112 
113  Type type() const override;
114 
115  // Basic properties
116 
117  Q_PROPERTY(QString ca READ ca WRITE setCa NOTIFY caChanged)
118  QString ca() const;
119 
120  Q_PROPERTY(QString cert READ cert WRITE setCert NOTIFY certChanged)
121  QString cert() const;
122 
123  Q_PROPERTY(QString certPass READ certPass WRITE setCertPass NOTIFY certPassChanged)
124  QString certPass() const;
125 
126  Q_PROPERTY(ConnectionType connectionType READ connectionType WRITE setConnectionType NOTIFY connectionTypeChanged)
127  ConnectionType connectionType() const;
128 
129  Q_PROPERTY(QString key READ key WRITE setKey NOTIFY keyChanged)
130  QString key() const;
131 
132  Q_PROPERTY(QString localIp READ localIp WRITE setLocalIp NOTIFY localIpChanged)
133  QString localIp() const;
134 
135  Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
136  QString password() const;
137 
138  Q_PROPERTY(QString remote READ remote WRITE setRemote NOTIFY remoteChanged)
139  QString remote() const;
140 
141  Q_PROPERTY(QString remoteIp READ remoteIp WRITE setRemoteIp NOTIFY remoteIpChanged)
142  QString remoteIp() const;
143 
144  Q_PROPERTY(QString staticKey READ staticKey WRITE setStaticKey NOTIFY staticKeyChanged)
145  QString staticKey() const;
146 
147  Q_PROPERTY(KeyDir staticKeyDirection READ staticKeyDirection WRITE setStaticKeyDirection NOTIFY staticKeyDirectionChanged)
148  KeyDir staticKeyDirection() const;
149 
150  Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
151  QString username() const;
152 
153  // Advanced general properties
154 
155  Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged)
156  int port() const;
157 
158  Q_PROPERTY(bool portSet READ portSet WRITE setPortSet NOTIFY portSetChanged)
159  bool portSet() const;
160 
161  Q_PROPERTY(int renegSeconds READ renegSeconds WRITE setRenegSeconds NOTIFY renegSecondsChanged)
162  int renegSeconds() const;
163 
164  Q_PROPERTY(bool renegSecondsSet READ renegSecondsSet WRITE setRenegSecondsSet NOTIFY renegSecondsSetChanged)
165  bool renegSecondsSet() const;
166 
167  Q_PROPERTY(bool compLzo READ compLzo WRITE setCompLzo NOTIFY compLzoChanged)
168  bool compLzo() const;
169 
170  Q_PROPERTY(bool protoTcp READ protoTcp WRITE setProtoTcp NOTIFY protoTcpChanged)
171  bool protoTcp() const;
172 
173  Q_PROPERTY(QString dev READ dev WRITE setDev NOTIFY devChanged)
174  QString dev() const;
175 
176  Q_PROPERTY(DevType devType READ devType WRITE setDevType NOTIFY devTypeChanged)
177  DevType devType() const;
178 
179  Q_PROPERTY(bool devTypeSet READ devTypeSet WRITE setDevTypeSet NOTIFY devTypeSetChanged)
180  bool devTypeSet() const;
181 
182  Q_PROPERTY(int tunnelMtu READ tunnelMtu WRITE setTunnelMtu NOTIFY tunnelMtuChanged)
183  int tunnelMtu() const;
184 
185  Q_PROPERTY(bool tunnelMtuSet READ tunnelMtuSet WRITE setTunnelMtuSet NOTIFY tunnelMtuSetChanged)
186  bool tunnelMtuSet() const;
187 
188  Q_PROPERTY(int fragmentSize READ fragmentSize WRITE setFragmentSize NOTIFY fragmentSizeChanged)
189  int fragmentSize() const;
190 
191  Q_PROPERTY(bool fragmentSizeSet READ fragmentSizeSet WRITE setFragmentSizeSet NOTIFY fragmentSizeSetChanged)
192  bool fragmentSizeSet() const;
193 
194  Q_PROPERTY(bool mssFix READ mssFix WRITE setMssFix NOTIFY mssFixChanged)
195  bool mssFix() const;
196 
197  Q_PROPERTY(bool remoteRandom READ remoteRandom WRITE setRemoteRandom NOTIFY remoteRandomChanged)
198  bool remoteRandom() const;
199 
200  // Advanced security properties
201 
202  Q_PROPERTY(Cipher cipher READ cipher WRITE setCipher NOTIFY cipherChanged)
203  Cipher cipher() const;
204 
205  Q_PROPERTY(int keysize READ keysize WRITE setKeysize NOTIFY keysizeChanged)
206  int keysize() const;
207 
208  Q_PROPERTY(bool keysizeSet READ keysizeSet WRITE setKeysizeSet NOTIFY keysizeSetChanged)
209  bool keysizeSet() const;
210 
211  Q_PROPERTY(Auth auth READ auth WRITE setAuth NOTIFY authChanged)
212  Auth auth() const;
213 
214  // Advanced TLS auth properties
215 
216  Q_PROPERTY(QString tlsRemote READ tlsRemote WRITE setTlsRemote NOTIFY tlsRemoteChanged)
217  QString tlsRemote() const;
218 
219  Q_PROPERTY(TlsType remoteCertTls READ remoteCertTls WRITE setRemoteCertTls NOTIFY remoteCertTlsChanged)
220  TlsType remoteCertTls() const;
221 
222  Q_PROPERTY(bool remoteCertTlsSet READ remoteCertTlsSet WRITE setRemoteCertTlsSet NOTIFY remoteCertTlsSetChanged)
223  bool remoteCertTlsSet() const;
224 
225  Q_PROPERTY(QString ta READ ta WRITE setTa NOTIFY taChanged)
226  QString ta() const;
227 
228  Q_PROPERTY(KeyDir taDir READ taDir WRITE setTaDir NOTIFY taDirChanged)
229  KeyDir taDir() const;
230 
231  Q_PROPERTY(bool taSet READ taSet WRITE setTaSet NOTIFY taSetChanged)
232  bool taSet() const;
233 
234  // Advanced proxy settings
235 
236  Q_PROPERTY(ProxyType proxyType READ proxyType WRITE setProxyType NOTIFY proxyTypeChanged)
237  ProxyType proxyType() const;
238 
239  Q_PROPERTY(QString proxyServer READ proxyServer WRITE setProxyServer NOTIFY proxyServerChanged)
240  QString proxyServer() const;
241 
242  Q_PROPERTY(int proxyPort READ proxyPort WRITE setProxyPort NOTIFY proxyPortChanged)
243  int proxyPort() const;
244 
245  Q_PROPERTY(bool proxyRetry READ proxyRetry WRITE setProxyRetry NOTIFY proxyRetryChanged)
246  bool proxyRetry() const;
247 
248  Q_PROPERTY(QString proxyUsername READ proxyUsername WRITE setProxyUsername NOTIFY proxyUsernameChanged)
249  QString proxyUsername() const;
250 
251  Q_PROPERTY(QString proxyPassword READ proxyPassword WRITE setProxyPassword NOTIFY proxyPasswordChanged)
252  QString proxyPassword() const;
253 
254 public Q_SLOTS:
255  // Basic properties
256 
257  void setCa(const QString &value);
258 
259  void setCert(const QString &value);
260 
261  void setCertPass(const QString &value);
262 
263  void setConnectionType(ConnectionType connectionType);
264 
265  void setKey(const QString &value);
266 
267  void setLocalIp(const QString &value);
268 
269  void setPassword(const QString &value);
270 
271  void setRemote(const QString &value);
272 
273  void setRemoteIp(const QString &value);
274 
275  void setStaticKey(const QString &value);
276 
277  void setStaticKeyDirection(KeyDir value);
278 
279  void setUsername(const QString &value);
280 
281  // Advanced general properties
282 
283  void setPort(int value);
284 
285  void setPortSet(bool value);
286 
287  void setRenegSeconds(int value);
288 
289  void setRenegSecondsSet(bool value);
290 
291  void setCompLzo(bool value);
292 
293  void setProtoTcp(bool value);
294 
295  void setDev(const QString &value);
296 
297  void setDevType(DevType value);
298 
299  void setDevTypeSet(bool value);
300 
301  void setTunnelMtu(int value);
302 
303  void setTunnelMtuSet(bool value);
304 
305  void setFragmentSize(int value);
306 
307  void setFragmentSizeSet(bool value);
308 
309  void setMssFix(bool value);
310 
311  void setRemoteRandom(bool value);
312 
313  // Advanced security properties
314 
315  void setCipher(Cipher value);
316 
317  void setKeysize(int value);
318 
319  void setKeysizeSet(bool value);
320 
321  void setAuth(Auth value);
322 
323  // Advanced TLS auth properties
324 
325  void setTlsRemote(const QString &value);
326 
327  void setRemoteCertTls(TlsType value);
328 
329  void setRemoteCertTlsSet(bool value);
330 
331  void setTa(const QString &value);
332 
333  void setTaDir(KeyDir value);
334 
335  void setTaSet(bool value);
336 
337  // Advanced proxy settings
338 
339  void setProxyType(ProxyType value);
340 
341  void setProxyServer(const QString &value);
342 
343  void setProxyPort(int value);
344 
345  void setProxyRetry(bool value);
346 
347  void setProxyUsername(const QString &value);
348 
349  void setProxyPassword(const QString &value);
350 
351 Q_SIGNALS:
352  // Basic properties
353 
354  void caChanged(const QString &value);
355 
356  void certChanged(const QString &value);
357 
358  void certPassChanged(const QString &value);
359 
360  void connectionTypeChanged(ConnectionType connectionType);
361 
362  void keyChanged(const QString &value);
363 
364  void localIpChanged(const QString &value);
365 
366  void passwordChanged(const QString &value);
367 
368  void remoteChanged(const QString &value);
369 
370  void remoteIpChanged(const QString &value);
371 
372  void staticKeyChanged(const QString &value);
373 
374  void staticKeyDirectionChanged(KeyDir value);
375 
376  void usernameChanged(const QString &value);
377 
378  // Advanced general properties
379 
380  void portChanged(int value);
381 
382  void portSetChanged(bool value);
383 
384  void renegSecondsChanged(int value);
385 
386  void renegSecondsSetChanged(bool value);
387 
388  void compLzoChanged(bool value);
389 
390  void protoTcpChanged(bool value);
391 
392  void devChanged(const QString &value);
393 
394  void devTypeChanged(DevType value);
395 
396  void devTypeSetChanged(bool value);
397 
398  void tunnelMtuChanged(int value);
399 
400  void tunnelMtuSetChanged(bool value);
401 
402  void fragmentSizeChanged(int value);
403 
404  void fragmentSizeSetChanged(bool value);
405 
406  void mssFixChanged(bool value);
407 
408  void remoteRandomChanged(bool value);
409 
410  // Advanced security properties
411 
412  void cipherChanged(Cipher value);
413 
414  void keysizeChanged(int value);
415 
416  void keysizeSetChanged(bool value);
417 
418  void authChanged(Auth value);
419 
420  // Advanced TLS auth properties
421 
422  void tlsRemoteChanged(const QString &value);
423 
424  void remoteCertTlsChanged(TlsType value);
425 
426  void remoteCertTlsSetChanged(bool value);
427 
428  void taChanged(const QString &value);
429 
430  void taDirChanged(KeyDir value);
431 
432  void taSetChanged(bool value);
433 
434  // Advanced proxy tings
435 
436  void proxyTypeChanged(ProxyType value);
437 
438  void proxyServerChanged(const QString &value);
439 
440  void proxyPortChanged(int value);
441 
442  void proxyRetryChanged(bool value);
443 
444  void proxyUsernameChanged(const QString &value);
445 
446  void proxyPasswordChanged(const QString &value);
447 
448 protected:
449  class Priv;
450  std::shared_ptr<Priv> d;
451 };
452 
453 }
Definition: vpn-connection.h:31
Definition: openvpn-connection.h:39
Definition: openvpn-connection.h:97
Definition: openvpn-connection.h:60
Definition: openvpn-connection.h:58
Definition: openvpn-connection.h:78
Definition: openvpn-connection.h:104
Definition: openvpn-connection.h:53
Definition: openvpn-connection.h:61
Definition: openvpn-connection.h:65
Definition: openvpn-connection.h:74
Definition: openvpn-connection.h:96
DevType
Definition: openvpn-connection.h:44
Cipher
Definition: openvpn-connection.h:51
Definition: openvpn-connection.h:105
Definition: openvpn-connection.h:63
ConnectionType
Definition: openvpn-connection.h:35
Definition: openvpn-connection.h:75
Definition: openvpn-connection.h:79
Definition: connectivity.cpp:32
TlsType
Definition: openvpn-connection.h:87
KeyDir
Definition: openvpn-connection.h:94
Definition: openvpn-connection.h:37
Definition: openvpn-connection.h:89
Definition: openvpn-connection.h:82
ProxyType
Definition: openvpn-connection.h:102
Definition: openvpn-connection.h:56
Definition: openvpn-connection.h:62
Definition: openvpn-connection.h:38
Definition: openvpn-connection.h:54
Definition: openvpn-connection.h:81
std::shared_ptr< Priv > d
Definition: openvpn-connection.h:449
Auth
Definition: openvpn-connection.h:72
Definition: openvpn-connection.h:59
Definition: openvpn-connection.h:55
Definition: openvpn-connection.h:77
Definition: openvpn-connection.h:27
Definition: openvpn-connection.h:46
Definition: openvpn-connection.h:66
Definition: openvpn-connection.h:76
Definition: openvpn-connection.h:64
Definition: openvpn-connection.h:57
Definition: openvpn-connection.h:80