项目作者: MhozaifaA

项目描述 :
The most powerful management to handle ui events
高级语言: C#
项目地址: git://github.com/MhozaifaA/OpenVPN-action.git
创建时间: 2021-06-04T22:10:48Z
项目社区:https://github.com/MhozaifaA/OpenVPN-action

开源协议:

下载


OpenVPN-action

The most powerful management to handle ui events

Quick start

  1. using OpenVPN_action;
  2. using OpenVPN_action.Enum;
  3. private readonly OpenVPNAction openVPN;
  4. public ctor()
  5. {
  6. ...
  7. // pass your own username / password
  8. openVPN = new OpenVPNAction(SecureSettingApp.GetEmail(), SecureSettingApp.GetPassword());
  9. openVPN.NumCycleOfReconnecting = 3;
  10. InitVPNEvent();
  11. ...
  12. }
  13. private void InitVPNEvent()
  14. {
  15. openVPN.OnConnecting += (info) => { ... };
  16. openVPN.OnConnected += (info) => { ... };
  17. openVPN.OnReconnecting += (info) => { ... };
  18. openVPN.OnDisconnected += (info) => { ... };
  19. openVPN.OnEndCycle += (info) => { ... };
  20. openVPN.OnCorrupted += (info) =>
  21. {
  22. ...
  23. //optional
  24. openVPN.RemoveRefuseRun();
  25. ...
  26. };
  27. }
  28. private async ValueTask ConnectDisconnect()
  29. {
  30. ...
  31. var state = openVPN.OpenVPNInfo.GetConnectionState();
  32. if ((state == ConnectionStates.Disconnect ||
  33. state == ConnectionStates.UnConfigured))
  34. {
  35. ...
  36. openVPN.Configuration(SettingApp.OpenVpn_Path, SettingApp.ovpnFile_Path);
  37. await openVPN.Start();
  38. await openVPN.Connect();
  39. return;
  40. }
  41. if(state == ConnectionStates.Connecting)
  42. {
  43. IsBlockVPN = false;
  44. await openVPN.Disconnect();
  45. HasAllowVPN = true;
  46. return;
  47. }
  48. if (state == ConnectionStates.Connected)
  49. {
  50. ...
  51. await openVPN.Disconnect();
  52. return;
  53. }
  54. ...
  55. }
simple scenario

Documentation

soon with many uses