mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Implement abstract tracker class
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// OpenVPNReachabilityTracker.h
|
||||||
|
// OpenVPN Adapter
|
||||||
|
//
|
||||||
|
// Created by Sergey Abramchuk on 17.07.17.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <openvpn/apple/reachable.hpp>
|
||||||
|
|
||||||
|
using namespace openvpn;
|
||||||
|
|
||||||
|
class OpenVPNReachabilityTracker : public ReachabilityTracker {
|
||||||
|
OpenVPNReachabilityTracker(const bool enable_internet, const bool enable_wifi, void* handler);
|
||||||
|
|
||||||
|
virtual void reachability_tracker_event(const ReachabilityBase& rb, SCNetworkReachabilityFlags flags) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void* handler;
|
||||||
|
|
||||||
|
};
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// OpenVPNReachabilityTracker.m
|
||||||
|
// OpenVPN Adapter
|
||||||
|
//
|
||||||
|
// Created by Sergey Abramchuk on 17.07.17.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "OpenVPNReachability+Internal.h"
|
||||||
|
#import "OpenVPNReachabilityTracker.h"
|
||||||
|
|
||||||
|
OpenVPNReachabilityTracker::OpenVPNReachabilityTracker(const bool enable_internet, const bool enable_wifi, void* handler) : ReachabilityTracker(enable_internet, enable_wifi) {
|
||||||
|
this->handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenVPNReachabilityTracker::reachability_tracker_event(const ReachabilityBase& rb, SCNetworkReachabilityFlags flags) {
|
||||||
|
OpenVPNReachability* handler = (__bridge OpenVPNReachability* )this->handler;
|
||||||
|
|
||||||
|
ReachabilityInterface::Status status = rb.status();
|
||||||
|
switch (status) {
|
||||||
|
case ReachabilityInterface::NotReachable:
|
||||||
|
[handler updateReachabilityStatus:OpenVPNReachabilityStatusNotReachable];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ReachabilityInterface::ReachableViaWiFi:
|
||||||
|
[handler updateReachabilityStatus:OpenVPNReachabilityStatusReachableViaWiFi];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ReachabilityInterface::ReachableViaWWAN:
|
||||||
|
[handler updateReachabilityStatus:OpenVPNReachabilityStatusReachableViaWWAN];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user