14 Commits

Author SHA1 Message Date
Dener Araújo
f4db4b0b16 Merge pull request #8 from deneraraujo/develop
Fix quotes warning on ovpnapi header
2020-09-20 00:13:29 -03:00
Dener Araújo
7f8dc34742 Merge pull request #7 from deneraraujo/hotfix/syntax_warning
Fix quotes warning on ovpnapi header
2020-09-20 00:09:57 -03:00
Dener Araújo
fe65f6e8dc Fix quotes warning on ovpnapi header 2020-09-20 00:07:13 -03:00
Dener Araújo
01e05a6b0b Merge pull request #6 from deneraraujo/develop
Fix weird linker error, re-adding file references
2020-09-19 23:31:22 -03:00
Dener Araújo
c017621fe5 Merge pull request #5 from deneraraujo/hotfix/linker_error
Fix weird linker error, re-adding file references
2020-09-19 23:30:33 -03:00
Dener Araújo
faa20d9006 Fix weird linker error, re-adding file references 2020-09-19 23:26:26 -03:00
Dener Araújo
9b48f3b650 Merge pull request #4 from deneraraujo/develop
Develop
2020-09-07 05:23:29 -03:00
Dener Araújo
a633990923 Merge pull request #3 from deneraraujo/feature/dhcp-option
Add links to new files in the "include" folder
2020-09-07 05:21:25 -03:00
Dener Araújo
266fab991e Add links to new files in the "include" folder 2020-09-07 05:10:35 -03:00
Dener Araújo
fa98daeac9 Merge pull request #2 from deneraraujo/develop
Develop
2020-09-06 15:29:00 -03:00
Dener Araújo
580c8f3684 Merge pull request #1 from deneraraujo/feature/dhcp-option
Feature/dhcp option
2020-09-06 15:27:59 -03:00
Dener Araújo
50a9e535d3 Update umbrella header with new files 2020-09-06 15:13:02 -03:00
Dener Araújo
865f56794f Add support to option "dhcp-option" in ovpn file 2020-09-06 15:03:47 -03:00
Sergey Abramchuk
c50ec0a6af Merge tag '0.7.0' into develop 2020-08-19 20:14:48 +03:00
15 changed files with 173 additions and 4 deletions

View File

@@ -60,6 +60,10 @@
C97E5FEC24124B73005C2EBC /* mbedTLS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "OpenVPNAdapter::mbedTLS::Product" /* mbedTLS.framework */; };
C9EABF3124110BE200D828D4 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9EABF3024110BE200D828D4 /* SystemConfiguration.framework */; };
C9EABF772411215C00D828D4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9EABF642411189800D828D4 /* UIKit.framework */; platformFilter = ios; };
EDC86AE92516F50000504FFA /* OpenVPNDhcpOptionEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = EDC86AE62516F50000504FFA /* OpenVPNDhcpOptionEntry.h */; };
EDC86AEA2516F50000504FFA /* OpenVPNDhcpOptionEntry.mm in Sources */ = {isa = PBXBuildFile; fileRef = EDC86AE72516F50000504FFA /* OpenVPNDhcpOptionEntry.mm */; };
EDC86AEB2516F50000504FFA /* OpenVPNDhcpOptionEntry+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = EDC86AE82516F50000504FFA /* OpenVPNDhcpOptionEntry+Internal.h */; };
EDC86AF22516F52300504FFA /* OpenVPNDhcpOptionEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = EDC86AF12516F52300504FFA /* OpenVPNDhcpOptionEntry.h */; };
OBJ_250 /* lz4.c in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_16 /* lz4.c */; };
OBJ_251 /* lz4frame.c in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_17 /* lz4frame.c */; };
OBJ_252 /* lz4hc.c in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_18 /* lz4hc.c */; };
@@ -289,6 +293,10 @@
C9EABF7424111D6100D828D4 /* OpenVPNAdapter.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = OpenVPNAdapter.xcconfig; sourceTree = "<group>"; };
C9EABF7524111E9C00D828D4 /* LZ4.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = LZ4.xcconfig; sourceTree = "<group>"; };
C9EABF7624111F1600D828D4 /* mbedTLS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = mbedTLS.xcconfig; sourceTree = "<group>"; };
EDC86AE62516F50000504FFA /* OpenVPNDhcpOptionEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenVPNDhcpOptionEntry.h; sourceTree = "<group>"; };
EDC86AE72516F50000504FFA /* OpenVPNDhcpOptionEntry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OpenVPNDhcpOptionEntry.mm; sourceTree = "<group>"; };
EDC86AE82516F50000504FFA /* OpenVPNDhcpOptionEntry+Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OpenVPNDhcpOptionEntry+Internal.h"; sourceTree = "<group>"; };
EDC86AF12516F52300504FFA /* OpenVPNDhcpOptionEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenVPNDhcpOptionEntry.h; sourceTree = "<group>"; };
OBJ_100 /* debug.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = debug.c; sourceTree = "<group>"; };
OBJ_101 /* des.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = des.c; sourceTree = "<group>"; };
OBJ_102 /* dhm.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = dhm.c; sourceTree = "<group>"; };
@@ -724,6 +732,9 @@
OBJ_27 /* library */ = {
isa = PBXGroup;
children = (
EDC86AE62516F50000504FFA /* OpenVPNDhcpOptionEntry.h */,
EDC86AE72516F50000504FFA /* OpenVPNDhcpOptionEntry.mm */,
EDC86AE82516F50000504FFA /* OpenVPNDhcpOptionEntry+Internal.h */,
C97E5F752412300A005C2EBC /* OpenVPNAdapterEvent.h */,
C97E5F7724123019005C2EBC /* OpenVPNAdapterPacketFlow.h */,
C97E5F7B24123036005C2EBC /* OpenVPNCompressionMode.h */,
@@ -789,6 +800,7 @@
OBJ_48 /* include */ = {
isa = PBXGroup;
children = (
EDC86AF12516F52300504FFA /* OpenVPNDhcpOptionEntry.h */,
OBJ_49 /* OpenVPNCompressionMode.h */,
OBJ_50 /* OpenVPNKeyType.h */,
OBJ_51 /* OpenVPNAdapterEvent.h */,
@@ -996,6 +1008,7 @@
C97E5F9E2412314A005C2EBC /* OpenVPNConfigurationEvaluation.h in Headers */,
C97E5FA62412317B005C2EBC /* OpenVPNReachabilityStatus.h in Headers */,
OBJ_287 /* OpenVPNPrivateKey.h in Headers */,
EDC86AEB2516F50000504FFA /* OpenVPNDhcpOptionEntry+Internal.h in Headers */,
C97E5F7424122FE6005C2EBC /* OpenVPNAdapter.h in Headers */,
OBJ_288 /* OpenVPNInterfaceStats.h in Headers */,
OBJ_290 /* OpenVPNReachability.h in Headers */,
@@ -1012,6 +1025,7 @@
OBJ_293 /* OpenVPNMinTLSVersion.h in Headers */,
C97E5F7224122F5C005C2EBC /* OpenVPNClient.h in Headers */,
OBJ_294 /* OpenVPNAdapter.h in Headers */,
EDC86AE92516F50000504FFA /* OpenVPNDhcpOptionEntry.h in Headers */,
OBJ_295 /* OpenVPNConnectionInfo.h in Headers */,
OBJ_296 /* OpenVPNReachabilityStatus.h in Headers */,
C97E5F822412305C005C2EBC /* OpenVPNConnectionInfo.h in Headers */,
@@ -1030,6 +1044,7 @@
C910EAE724EBB5210081AF13 /* OpenVPNConfigurationEvaluation.h in Headers */,
C97E5FAC241231AA005C2EBC /* OpenVPNServerEntry+Internal.h in Headers */,
C97E5F90241230B3005C2EBC /* OpenVPNIPv6Preference.h in Headers */,
EDC86AF22516F52300504FFA /* OpenVPNDhcpOptionEntry.h in Headers */,
C97E5FE624124B0E005C2EBC /* Umbrella-Header.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -1215,6 +1230,7 @@
OBJ_269 /* OpenVPNInterfaceStats.mm in Sources */,
OBJ_270 /* OpenVPNNetworkSettingsBuilder.m in Sources */,
OBJ_271 /* OpenVPNPacket.mm in Sources */,
EDC86AEA2516F50000504FFA /* OpenVPNDhcpOptionEntry.mm in Sources */,
OBJ_272 /* OpenVPNPacketFlowBridge.mm in Sources */,
OBJ_273 /* OpenVPNPrivateKey.m in Sources */,
OBJ_274 /* OpenVPNConfigurationEvaluation.mm in Sources */,

View File

@@ -663,6 +663,14 @@ namespace openvpn {
se.friendlyName = i->friendlyName;
eval.serverList.push_back(se);
}
// Added by Dener Araújo - 2020-09-06
for (ParseClientConfig::DhcpOptionList::const_iterator i = cc.dhcpOptionList().begin(); i != cc.dhcpOptionList().end(); ++i)
{
DhcpOptionEntry de;
de.type = i->type;
de.address = i->address;
eval.dhcpOptionList.push_back(de);
}
}
catch (const std::exception& e)
{

View File

@@ -47,6 +47,15 @@ namespace openvpn {
std::string friendlyName;
};
// Added by Dener Araújo - 2020-09-06
// Represents an "dhcp-option" with its type (DNS, WINS, etc) and its address
// (client reads)
struct DhcpOptionEntry
{
std::string type;
std::string address;
};
// return properties of config
// (client reads)
struct EvalConfig
@@ -91,6 +100,10 @@ namespace openvpn {
// optional list of user-selectable VPN servers
std::vector<ServerEntry> serverList;
// Added by Dener Araújo - 2020-09-06
// optional list of "dhcp-option"
std::vector<DhcpOptionEntry> dhcpOptionList;
};
// used to pass credentials to VPN core

View File

@@ -59,6 +59,17 @@ namespace openvpn {
{
};
// Added by Dener Araújo - 2020-09-06
struct DhcpOptionEntry {
std::string type;
std::string address;
};
// Added by Dener Araújo - 2020-09-06
struct DhcpOptionList : public std::vector<DhcpOptionEntry>
{
};
struct RemoteItem {
std::string host;
std::string port;
@@ -283,6 +294,30 @@ namespace openvpn {
}
}
// Added by Dener Araújo - 2020-09-06
// dhpc-option
{
const OptionList::IndexList *dhcpList = options.get_index_ptr("dhcp-option");
if (dhcpList)
{
for (OptionList::IndexList::const_iterator i = dhcpList->begin(); i != dhcpList->end(); ++i)
{
const Option& o = options[*i];
o.touch();
const std::string arg1 = o.get_optional(1, 256);
const std::string arg2 = o.get_optional(2, 256);
DhcpOptionEntry dhcp;
dhcp.type = arg1;
dhcp.address = arg2;
dhcpOptionList_.push_back(std::move(dhcp));
}
}
}
// protocol configuration
{
protoConfig.reset(new ProtoContext::Config());
@@ -435,6 +470,10 @@ namespace openvpn {
// return first remote directive in config
const RemoteItem& firstRemoteListItem() const { return firstRemoteListItem_; }
// Added by Dener Araújo - 2020-09-06
// dhpc-option
const DhcpOptionList& dhcpOptionList() const { return dhcpOptionList_; }
std::string to_string() const
{
@@ -524,6 +563,18 @@ namespace openvpn {
root["mode"] = Json::Value("client");
root["dev"] = Json::Value(dev);
// Added by Dener Araújo - 2020-09-06
root["dhcp-options"] = Json::Value(Json::arrayValue);
for (size_t i = 0; i < dhcpOptionList_.size(); i++)
{
const DhcpOptionEntry& item = dhcpOptionList_[i];
Json::Value el = Json::Value(Json::objectValue);
el["type"] = Json::Value(item.type);
el["address"] = Json::Value(item.address);
root["dhcp-options"].append(el);
}
root["dev-type"] = Json::Value(protoConfig->layer.dev_type());
root["remotes"] = Json::Value(Json::arrayValue);
for (size_t i = 0; i < remoteList->size(); i++)
@@ -716,6 +767,7 @@ namespace openvpn {
ProtoContext::Config::Ptr protoConfig;
SSLLib::SSLAPI::Config::Ptr sslConfig;
std::string dev;
DhcpOptionList dhcpOptionList_; // Added by Dener Araújo - 2020-09-06
};
}

View File

@@ -26,6 +26,7 @@ FOUNDATION_EXPORT const unsigned char OpenVPNAdapterVersionString[];
#import <OpenVPNAdapter/OpenVPNConfiguration.h>
#import <OpenVPNAdapter/OpenVPNCredentials.h>
#import <OpenVPNAdapter/OpenVPNServerEntry.h>
#import <OpenVPNAdapter/OpenVPNDhcpOptionEntry.h> // Added by Dener Araújo - 2020-09-06
#import <OpenVPNAdapter/OpenVPNConfigurationEvaluation.h>
#import <OpenVPNAdapter/OpenVPNConnectionInfo.h>
#import <OpenVPNAdapter/OpenVPNSessionToken.h>

View File

@@ -0,0 +1 @@
../library/OpenVPNDhcpOptionEntry.h

View File

@@ -10,6 +10,7 @@
typedef NS_ENUM(NSInteger, OpenVPNTransportProtocol);
@class OpenVPNServerEntry;
@class OpenVPNDhcpOptionEntry; //Added by Dener Araújo - 2020-09-06
@interface OpenVPNConfigurationEvaluation : NSObject
@@ -78,6 +79,12 @@ typedef NS_ENUM(NSInteger, OpenVPNTransportProtocol);
*/
@property (nullable, readonly, nonatomic) NSArray<OpenVPNServerEntry *> *servers;
/**
Added by Dener Araújo - 2020-09-06
Optional list of "dhcp-option"
*/
@property (nullable, readonly, nonatomic) NSArray<OpenVPNDhcpOptionEntry *> *dhcpOptions;
- (nonnull instancetype) init NS_UNAVAILABLE;
@end

View File

@@ -13,6 +13,7 @@
#import "OpenVPNConfiguration+Internal.h"
#import "OpenVPNServerEntry+Internal.h"
#import "OpenVPNDhcpOptionEntry+Internal.h" //Added by Dener Araújo - 2020-09-06
using namespace openvpn;
@@ -56,6 +57,20 @@ using namespace openvpn;
_servers = servers;
}
//Added by Dener Araújo - 2020-09-06
_dhcpOptions = nil;
if (!eval.dhcpOptionList.empty()) {
NSMutableArray *dhcpOptions = [NSMutableArray new];
for (ClientAPI::DhcpOptionEntry entry : eval.dhcpOptionList) {
OpenVPNDhcpOptionEntry *dhcpOptionEntry = [[OpenVPNDhcpOptionEntry alloc] initWithDhcpOptionEntry:entry];
[dhcpOptions addObject:dhcpOptionEntry];
}
_dhcpOptions = dhcpOptions;
}
}
return self;
}

View File

@@ -0,0 +1,18 @@
//
// OpenVPNDhcpOptionEntry+Internal.h
// Pods
//
// Created by Dener Araújo on 06/09/20.
//
#import "OpenVPNDhcpOptionEntry.h"
#include <ovpnapi.hpp>
using namespace openvpn;
@interface OpenVPNDhcpOptionEntry (Internal)
- (instancetype)initWithDhcpOptionEntry:(ClientAPI::DhcpOptionEntry)entry;
@end

View File

@@ -0,0 +1,17 @@
//
// OpenVPNDhcpOptionEntry.h
// Pods
//
// Created by Dener Araújo on 06/09/20.
//
#import <Foundation/Foundation.h>
@interface OpenVPNDhcpOptionEntry : NSObject
@property (nullable, readonly, nonatomic) NSString *type;
@property (nullable, readonly, nonatomic) NSString *address;
- (nonnull instancetype) init NS_UNAVAILABLE;
@end

View File

@@ -0,0 +1,21 @@
//
// OpenVPNDhcpOptionEntry.mm
// OpenVPNAdapter
//
// Created by Dener Araújo on 06/09/20.
//
#import "OpenVPNDhcpOptionEntry.h"
#import "OpenVPNDhcpOptionEntry+Internal.h"
@implementation OpenVPNDhcpOptionEntry
- (instancetype)initWithDhcpOptionEntry:(ClientAPI::DhcpOptionEntry)entry {
if (self = [super init]) {
_type = !entry.type.empty() ? [NSString stringWithUTF8String:entry.type.c_str()] : nil;
_address = !entry.address.empty() ? [NSString stringWithUTF8String:entry.address.c_str()] : nil;
}
return self;
}
@end

View File

@@ -22,6 +22,6 @@
#ifndef OVPNAPI_H
#define OVPNAPI_H
#include "ovpncli.hpp"
#include <ovpncli.hpp>
#endif

View File

@@ -262,7 +262,7 @@ int mbedtls_entropy_update_manual( mbedtls_entropy_context *ctx,
*/
static int entropy_gather_internal( mbedtls_entropy_context *ctx )
{
int ret, i, have_one_strong = 0;
int ret = 0, i, have_one_strong = 0; // Updated by Dener Araújo - 2020-09-06
unsigned char buf[MBEDTLS_ENTROPY_MAX_GATHER];
size_t olen;

View File

@@ -78,7 +78,7 @@ int mbedtls_hmac_drbg_update_ret( mbedtls_hmac_drbg_context *ctx,
unsigned char rounds = ( additional != NULL && add_len != 0 ) ? 2 : 1;
unsigned char sep[1];
unsigned char K[MBEDTLS_MD_MAX_SIZE];
int ret;
int ret = 0; // Updated by Dener Araújo - 2020-09-06
for( sep[0] = 0; sep[0] < rounds; sep[0]++ )
{

View File

@@ -544,7 +544,7 @@ int mbedtls_x509_crl_parse( mbedtls_x509_crl *chain, const unsigned char *buf, s
{
#if defined(MBEDTLS_PEM_PARSE_C)
int ret;
size_t use_len;
size_t use_len = 0; // Updated by Dener Araújo - 2020-09-06
mbedtls_pem_context pem;
int is_pem = 0;