mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2024-10-06 17:22:07 +08:00
Call clock_tick method
This commit is contained in:
parent
1464cd1ce9
commit
036e9f9ab4
@ -16,5 +16,6 @@ using namespace openvpn;
|
||||
|
||||
- (void)handleEvent:(const ClientAPI::Event *)event;
|
||||
- (void)handleLog:(const ClientAPI::LogInfo *)log;
|
||||
- (void)tick;
|
||||
|
||||
@end
|
||||
|
@ -99,12 +99,12 @@ NS_SWIFT_NAME(handle(logMessage:));
|
||||
@interface OpenVPNAdapter (Public)
|
||||
|
||||
/**
|
||||
Returns core copyright
|
||||
Return core copyright
|
||||
*/
|
||||
@property (class, nonnull, readonly, nonatomic) NSString *copyright;
|
||||
|
||||
/**
|
||||
Returns platform description
|
||||
Return platform description
|
||||
*/
|
||||
@property (class, nonnull, readonly, nonatomic) NSString *platform;
|
||||
|
||||
|
@ -41,6 +41,7 @@ NSString * const OpenVPNAdapterErrorEventKey = @"me.ss-abramchuk.openvpn-adapter
|
||||
|
||||
@property (weak, nonatomic) id<OpenVPNAdapterPacketFlow> packetFlow;
|
||||
|
||||
- (OpenVPNEvent)getEventIdentifierByName:(NSString *)eventName;
|
||||
- (NSString *)getSubnetFromPrefixLength:(NSNumber *)prefixLength;
|
||||
|
||||
@end
|
||||
@ -85,43 +86,14 @@ NSString * const OpenVPNAdapterErrorEventKey = @"me.ss-abramchuk.openvpn-adapter
|
||||
}
|
||||
}
|
||||
|
||||
- (OpenVPNEvent)getEventIdentifierByName:(NSString *)eventName {
|
||||
NSDictionary *events = @{
|
||||
@"DISCONNECTED": @(OpenVPNEventDisconnected),
|
||||
@"CONNECTED": @(OpenVPNEventConnected),
|
||||
@"RECONNECTING": @(OpenVPNEventReconnecting),
|
||||
@"RESOLVE": @(OpenVPNEventResolve),
|
||||
@"WAIT": @(OpenVPNEventWait),
|
||||
@"WAIT_PROXY": @(OpenVPNEventWaitProxy),
|
||||
@"CONNECTING": @(OpenVPNEventConnecting),
|
||||
@"GET_CONFIG": @(OpenVPNEventGetConfig),
|
||||
@"ASSIGN_IP": @(OpenVPNEventAssignIP),
|
||||
@"ADD_ROUTES": @(OpenVPNEventAddRoutes),
|
||||
@"ECHO": @(OpenVPNEventEcho),
|
||||
@"INFO": @(OpenVPNEventInfo),
|
||||
@"PAUSE": @(OpenVPNEventPause),
|
||||
@"RESUME": @(OpenVPNEventResume),
|
||||
@"TRANSPORT_ERROR": @(OpenVPNEventTransportError),
|
||||
@"TUN_ERROR": @(OpenVPNEventTunError),
|
||||
@"CLIENT_RESTART": @(OpenVPNEventClientRestart),
|
||||
@"AUTH_FAILED": @(OpenVPNEventAuthFailed),
|
||||
@"CERT_VERIFY_FAIL": @(OpenVPNEventCertVerifyFail),
|
||||
@"TLS_VERSION_MIN": @(OpenVPNEventTLSVersionMin),
|
||||
@"CLIENT_HALT": @(OpenVPNEventClientHalt),
|
||||
@"CONNECTION_TIMEOUT": @(OpenVPNEventConnectionTimeout),
|
||||
@"INACTIVE_TIMEOUT": @(OpenVPNEventInactiveTimeout),
|
||||
@"DYNAMIC_CHALLENGE": @(OpenVPNEventDynamicChallenge),
|
||||
@"PROXY_NEED_CREDS": @(OpenVPNEventProxyNeedCreds),
|
||||
@"PROXY_ERROR": @(OpenVPNEventProxyError),
|
||||
@"TUN_SETUP_FAILED": @(OpenVPNEventTunSetupFailed),
|
||||
@"TUN_IFACE_CREATE": @(OpenVPNEventTunIfaceCreate),
|
||||
@"TUN_IFACE_DISABLED": @(OpenVPNEventTunIfaceDisabled),
|
||||
@"EPKI_ERROR": @(OpenVPNEventEPKIError),
|
||||
@"EPKI_INVALID_ALIAS": @(OpenVPNEventEPKIInvalidAlias),
|
||||
};
|
||||
#pragma mark Clock Tick
|
||||
|
||||
- (void)tick {
|
||||
NSAssert(self.delegate != nil, @"delegate property should not be nil");
|
||||
|
||||
OpenVPNEvent event = events[eventName] != nil ? (OpenVPNEvent)[(NSNumber *)events[eventName] unsignedIntegerValue] : OpenVPNEventUnknown;
|
||||
return event;
|
||||
if ([self.delegate respondsToSelector:@selector(tick)]) {
|
||||
[self.delegate tick];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@ -262,6 +234,45 @@ NSString * const OpenVPNAdapterErrorEventKey = @"me.ss-abramchuk.openvpn-adapter
|
||||
|
||||
#pragma mark Utils
|
||||
|
||||
- (OpenVPNEvent)getEventIdentifierByName:(NSString *)eventName {
|
||||
NSDictionary *events = @{
|
||||
@"DISCONNECTED": @(OpenVPNEventDisconnected),
|
||||
@"CONNECTED": @(OpenVPNEventConnected),
|
||||
@"RECONNECTING": @(OpenVPNEventReconnecting),
|
||||
@"RESOLVE": @(OpenVPNEventResolve),
|
||||
@"WAIT": @(OpenVPNEventWait),
|
||||
@"WAIT_PROXY": @(OpenVPNEventWaitProxy),
|
||||
@"CONNECTING": @(OpenVPNEventConnecting),
|
||||
@"GET_CONFIG": @(OpenVPNEventGetConfig),
|
||||
@"ASSIGN_IP": @(OpenVPNEventAssignIP),
|
||||
@"ADD_ROUTES": @(OpenVPNEventAddRoutes),
|
||||
@"ECHO": @(OpenVPNEventEcho),
|
||||
@"INFO": @(OpenVPNEventInfo),
|
||||
@"PAUSE": @(OpenVPNEventPause),
|
||||
@"RESUME": @(OpenVPNEventResume),
|
||||
@"TRANSPORT_ERROR": @(OpenVPNEventTransportError),
|
||||
@"TUN_ERROR": @(OpenVPNEventTunError),
|
||||
@"CLIENT_RESTART": @(OpenVPNEventClientRestart),
|
||||
@"AUTH_FAILED": @(OpenVPNEventAuthFailed),
|
||||
@"CERT_VERIFY_FAIL": @(OpenVPNEventCertVerifyFail),
|
||||
@"TLS_VERSION_MIN": @(OpenVPNEventTLSVersionMin),
|
||||
@"CLIENT_HALT": @(OpenVPNEventClientHalt),
|
||||
@"CONNECTION_TIMEOUT": @(OpenVPNEventConnectionTimeout),
|
||||
@"INACTIVE_TIMEOUT": @(OpenVPNEventInactiveTimeout),
|
||||
@"DYNAMIC_CHALLENGE": @(OpenVPNEventDynamicChallenge),
|
||||
@"PROXY_NEED_CREDS": @(OpenVPNEventProxyNeedCreds),
|
||||
@"PROXY_ERROR": @(OpenVPNEventProxyError),
|
||||
@"TUN_SETUP_FAILED": @(OpenVPNEventTunSetupFailed),
|
||||
@"TUN_IFACE_CREATE": @(OpenVPNEventTunIfaceCreate),
|
||||
@"TUN_IFACE_DISABLED": @(OpenVPNEventTunIfaceDisabled),
|
||||
@"EPKI_ERROR": @(OpenVPNEventEPKIError),
|
||||
@"EPKI_INVALID_ALIAS": @(OpenVPNEventEPKIInvalidAlias),
|
||||
};
|
||||
|
||||
OpenVPNEvent event = events[eventName] != nil ? (OpenVPNEvent)[(NSNumber *)events[eventName] unsignedIntegerValue] : OpenVPNEventUnknown;
|
||||
return event;
|
||||
}
|
||||
|
||||
- (NSString *)getSubnetFromPrefixLength:(NSNumber *)prefixLength {
|
||||
uint32_t bitmask = UINT_MAX << (sizeof(uint32_t) * 8 - prefixLength.integerValue);
|
||||
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
virtual void event(const ClientAPI::Event& ev) override;
|
||||
virtual void log(const ClientAPI::LogInfo& log) override;
|
||||
|
||||
virtual void clock_tick() override;
|
||||
|
||||
private:
|
||||
void* adapter;
|
||||
};
|
||||
|
@ -33,7 +33,6 @@ bool OpenVPNClient::pause_on_connection_timeout() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Provide interfacing with an OS-layer Keychain
|
||||
void OpenVPNClient::external_pki_cert_request(ClientAPI::ExternalPKICertRequest& certreq) { }
|
||||
void OpenVPNClient::external_pki_sign_request(ClientAPI::ExternalPKISignRequest& signreq) { }
|
||||
|
||||
@ -44,3 +43,7 @@ void OpenVPNClient::event(const ClientAPI::Event& ev) {
|
||||
void OpenVPNClient::log(const ClientAPI::LogInfo& log) {
|
||||
[(__bridge OpenVPNAdapter* )adapter handleLog:&log];
|
||||
}
|
||||
|
||||
void OpenVPNClient::clock_tick() {
|
||||
[(__bridge OpenVPNAdapter* )adapter tick];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user