Beispiel #1
0
 public PacketTunnelProvider()
 {
     Console.WriteLine("VpnCreate");
     vpnAdapter          = new OpenVPNAdapter();
     vpnReachability     = new OpenVPNReachability();
     configHandler       = new ConfigHandler(this);
     vpnAdapter.Delegate = new Delegator(this, configHandler);
 }
Beispiel #2
0
        public override void OpenVPNAdapterDidReceiveClockTick(OpenVPNAdapter openVPNAdapter)
        {
            var t = openVPNAdapter.TransportStatistics;

            if (t != null)
            {
                _configHandler.Update(t.BytesIn, t.BytesOut);
            }
        }
Beispiel #3
0
        public override void OpenVPNAdapter(OpenVPNAdapter openVPNAdapter, OpenVPNAdapterEvent @event, string message)
        {
            _adapter = openVPNAdapter;
            var vpnEvent = @event.ToString();

            switch (vpnEvent)
            {
            case "Connected":
                _provider.StartHandler();
                break;

            case "Disconnected":
                _provider.StopHandler();
                break;
            }
            Console.WriteLine("DelegatorMessage " + vpnEvent + " " + message);
        }
Beispiel #4
0
        public override async void OpenVPNAdapter(OpenVPNAdapter openVPNAdapter, NEPacketTunnelNetworkSettings networkSettings, Action <OpenVPNAdapterPacketFlow> completionHandler)
        {
            _adapter = openVPNAdapter;
            if (networkSettings != null && networkSettings.DnsSettings != null)
            {
                networkSettings.DnsSettings.MatchDomains = new string[] { };
            }
            Console.WriteLine("Delegator Applying Config");
            await _provider.SetTunnelNetworkSettingsAsync(networkSettings);

            try
            {
                //_adapter.CreatePacketFlow(_provider.PacketFlow, completionHandler);
                var _custom = new CustomPacketFlow(_provider.PacketFlow);
                completionHandler(_custom);
                Console.WriteLine("Configuration Applied");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #5
0
 public override void OpenVPNAdapter(OpenVPNAdapter openVPNAdapter, string logMessage)
 {
     //base.OpenVPNAdapter(openVPNAdapter, logMessage);
     Console.WriteLine("LogMessage " + logMessage);
 }
Beispiel #6
0
 public override void OpenVPNAdapter(OpenVPNAdapter openVPNAdapter, NSError error)
 {
     _adapter = openVPNAdapter;
     Console.WriteLine("Delegator Error " + error.LocalizedDescription +
                       error.Description + error.LocalizedRecoverySuggestion);
 }