Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 0.35.0 #64

Merged
merged 3 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ launchSettings.json
.runsettings
Samples/Properties
TestProject/Properties
.run
ZitiNativeApiForDotnetCore/Testing/
2 changes: 1 addition & 1 deletion OpenZiti.NET/OpenZiti.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="NLog" Version="5.0.4" />
<PackageReference Include="OpenZiti.NET.native" Version="0.34.4.153" />
<PackageReference Include="OpenZiti.NET.native" Version="0.35.0.168" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Text.Json" Version="6.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Expand Down
4 changes: 2 additions & 2 deletions OpenZiti.NET/OpenZiti.NET.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<authors>openziti.org</authors>
<owners>OpenZiti Maintainers</owners>
<license type="expression">Apache-2.0</license>
<projectUrl>https://openziti.github.io/ziti-sdk-csharp</projectUrl>
<projectUrl>https://github.com/openziti/ziti-sdk-csharp</projectUrl>
<icon>images\ziti-v2.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<!--<summary1>A nuget package which wraps the native ziti C SDK into a package easily consumable from .NET</summary1>-->
Expand All @@ -22,7 +22,7 @@
<dependency id="Microsoft.Extensions.Logging" version="7.0.0" exclude="Build,Analyzers" xmlns="" />
<dependency id="Newtonsoft.Json" version="13.0.1" exclude="Build,Analyzers" xmlns="" />
<dependency id="NLog" version="5.0.4" exclude="Build,Analyzers" xmlns="" />
<dependency id="OpenZiti.NET.native" version="0.34.4.153" exclude="Build,Analyzers" xmlns="" />
<dependency id="OpenZiti.NET.native" version="0.35.0.168" exclude="Build,Analyzers" xmlns="" />
<dependency id="System.Memory" version="4.5.5" exclude="Build,Analyzers" xmlns="" />
<dependency id="System.Text.Json" version="6.0.6" exclude="Build,Analyzers" xmlns="" />
</group>
Expand Down
2 changes: 1 addition & 1 deletion ZitiNativeApiForDotnetCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ message("cross-compiling: ${CMAKE_CROSSCOMPILING}")
# message(STATUS "CMAKE_ENV: ${_variableName}=${${_variableName}}")
#endforeach()

include(FetchContent)
add_subdirectory(cmake_deps)
add_subdirectory(library)
#add_subdirectory(programs)
Expand All @@ -47,7 +48,6 @@ if("${generate_csharp_enum}" STREQUAL "yes")
message("sharp-errors output to: ${OUTPUT_FILE}")
endif()

include(FetchContent)
string(TOLOWER "${ZITI_RUN_DEFGEN}" ziti_run_defgen)
if("${ziti_run_defgen}" STREQUAL "yes")
FetchContent_Declare(
Expand Down
5 changes: 5 additions & 0 deletions ZitiNativeApiForDotnetCore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ and `URL`. See the CMakeLists.txt file for how it's done.
To run the defgen step, when configuring cmake pass: -DZITI_RUN_DEFGEN. It will then invoke `defgen.bat` during the
configuration step. If the file changes, **make sure you commit the file**.

Example command to run defgen during the `cmake` configuration step:
```
cmake --preset win64 -S . -DZITI_RUN_DEFGEN=yes
```

After it runs, defgen leaves behind three extraneous files: ziti-exports.txt, ziti.dll, ziti.exp. It leaves these
files behind in case you need to do deubgging on the process but these files should not be checked in
(they are .gitignore'ed).
Expand Down
142 changes: 100 additions & 42 deletions ZitiNativeApiForDotnetCore/includes/ziti4dotnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,104 @@
extern "C" {
#endif

#define FIELD_WITH_CHECK(FIELD_TYPE, FIELD_NAME) uint32_t FIELD_NAME##_offset; \
uint32_t FIELD_NAME##_size; \
const char* FIELD_NAME##_checksum; \
FIELD_TYPE FIELD_NAME
typedef struct ziti_types_s {
FIELD_WITH_CHECK(uint32_t, total_size);

FIELD_WITH_CHECK(ziti_auth_query_mfa, ziti_auth_query_mfa);
FIELD_WITH_CHECK(ziti_id_cfg, ziti_id_cfg);
FIELD_WITH_CHECK(ziti_config, ziti_config);
FIELD_WITH_CHECK(api_path, api_path);
FIELD_WITH_CHECK(ziti_api_versions, ziti_api_versions);
FIELD_WITH_CHECK(ziti_version, ziti_version);
FIELD_WITH_CHECK(ziti_identity, ziti_identity);
FIELD_WITH_CHECK(ziti_process, ziti_process);
FIELD_WITH_CHECK(ziti_posture_query, ziti_posture_query);
FIELD_WITH_CHECK(ziti_posture_query_set, ziti_posture_query_set);
FIELD_WITH_CHECK(ziti_session_type, ziti_session_type);
FIELD_WITH_CHECK(ziti_service, ziti_service);
FIELD_WITH_CHECK(ziti_address, ziti_address_host);
FIELD_WITH_CHECK(ziti_address, ziti_address_cidr);
FIELD_WITH_CHECK(ziti_client_cfg_v1, ziti_client_cfg_v1);
FIELD_WITH_CHECK(ziti_intercept_cfg_v1, ziti_intercept_cfg_v1);
FIELD_WITH_CHECK(ziti_server_cfg_v1, ziti_server_cfg_v1);
FIELD_WITH_CHECK(ziti_listen_options, ziti_listen_options);
FIELD_WITH_CHECK(ziti_host_cfg_v1, ziti_host_cfg_v1);
FIELD_WITH_CHECK(ziti_host_cfg_v2, ziti_host_cfg_v2);
FIELD_WITH_CHECK(ziti_mfa_enrollment, ziti_mfa_enrollment);
FIELD_WITH_CHECK(ziti_port_range, ziti_port_range);
FIELD_WITH_CHECK(ziti_options, ziti_options);

//events
FIELD_WITH_CHECK(ziti_event_t, ziti_context_event);
FIELD_WITH_CHECK(ziti_event_t, ziti_router_event);
FIELD_WITH_CHECK(ziti_event_t, ziti_service_event);
FIELD_WITH_CHECK(ziti_event_t, ziti_mfa_auth_event);
FIELD_WITH_CHECK(ziti_event_t, ziti_api_event);


} ziti_types_t;
#define ALIGNMENT_CHECK(FIELD_TYPE) \
typedef struct ziti_alignment_check_##FIELD_TYPE##_s { \
uint32_t offset; \
uint32_t size; \
const char* checksum; \
} ziti_alignment_check_##FIELD_TYPE
#define ALIGNMENT_FIELD(FIELD_TYPE, FIELD_NAME) \
ziti_alignment_check_##FIELD_TYPE FIELD_NAME

ALIGNMENT_CHECK(ziti_auth_query_mfa);
ALIGNMENT_CHECK(ziti_id_cfg);
ALIGNMENT_CHECK(ziti_config);
ALIGNMENT_CHECK(api_path);
ALIGNMENT_CHECK(ziti_api_versions);
ALIGNMENT_CHECK(ziti_version);
ALIGNMENT_CHECK(ziti_identity);
ALIGNMENT_CHECK(ziti_process);
ALIGNMENT_CHECK(ziti_posture_query);
ALIGNMENT_CHECK(ziti_posture_query_set);
ALIGNMENT_CHECK(ziti_session_type);
ALIGNMENT_CHECK(ziti_service);
ALIGNMENT_CHECK(ziti_address);
ALIGNMENT_CHECK(ziti_client_cfg_v1);
ALIGNMENT_CHECK(ziti_intercept_cfg_v1);
ALIGNMENT_CHECK(ziti_server_cfg_v1);
ALIGNMENT_CHECK(ziti_listen_options);
ALIGNMENT_CHECK(ziti_host_cfg_v1);
ALIGNMENT_CHECK(ziti_host_cfg_v2);
ALIGNMENT_CHECK(ziti_mfa_enrollment);
ALIGNMENT_CHECK(ziti_port_range);
ALIGNMENT_CHECK(ziti_options);
ALIGNMENT_CHECK(ziti_event_t);

#define ALIGNMENT_DATA(FIELD_TYPE, FIELD_NAME) \
FIELD_TYPE FIELD_NAME##_data

typedef struct ziti_types_v2_s {
uint32_t size; //declare as a pointer but use as a value
// declare all the alignements: offset, size, checksum
ALIGNMENT_FIELD(ziti_auth_query_mfa, ziti_auth_query_mfa);
ALIGNMENT_FIELD(ziti_id_cfg, ziti_id_cfg);
ALIGNMENT_FIELD(ziti_config, ziti_config);
ALIGNMENT_FIELD(api_path, api_path);
ALIGNMENT_FIELD(ziti_api_versions, ziti_api_versions);
ALIGNMENT_FIELD(ziti_version, ziti_version);
ALIGNMENT_FIELD(ziti_identity, ziti_identity);
ALIGNMENT_FIELD(ziti_process, ziti_process);
ALIGNMENT_FIELD(ziti_posture_query, ziti_posture_query);
ALIGNMENT_FIELD(ziti_posture_query_set, ziti_posture_query_set);
ALIGNMENT_FIELD(ziti_session_type, ziti_session_type);
ALIGNMENT_FIELD(ziti_service, ziti_service);
ALIGNMENT_FIELD(ziti_address, ziti_address_host);
ALIGNMENT_FIELD(ziti_address, ziti_address_cidr);
ALIGNMENT_FIELD(ziti_client_cfg_v1, ziti_client_cfg_v1);
ALIGNMENT_FIELD(ziti_intercept_cfg_v1, ziti_intercept_cfg_v1);
ALIGNMENT_FIELD(ziti_server_cfg_v1, ziti_server_cfg_v1);
ALIGNMENT_FIELD(ziti_listen_options, ziti_listen_options);
ALIGNMENT_FIELD(ziti_host_cfg_v1, ziti_host_cfg_v1);
ALIGNMENT_FIELD(ziti_host_cfg_v2, ziti_host_cfg_v2);
ALIGNMENT_FIELD(ziti_mfa_enrollment, ziti_mfa_enrollment);
ALIGNMENT_FIELD(ziti_port_range, ziti_port_range);
ALIGNMENT_FIELD(ziti_options, ziti_options);
ALIGNMENT_FIELD(ziti_event_t, ziti_context_event);
ALIGNMENT_FIELD(ziti_event_t, ziti_router_event);
ALIGNMENT_FIELD(ziti_event_t, ziti_service_event);
ALIGNMENT_FIELD(ziti_event_t, ziti_mfa_auth_event);
ALIGNMENT_FIELD(ziti_event_t, ziti_api_event);

// now declare "_data" elemnets - the __ACTUAL__ structs
ALIGNMENT_DATA(ziti_auth_query_mfa, ziti_auth_query_mfa);
ALIGNMENT_DATA(ziti_id_cfg, ziti_id_cfg);
ALIGNMENT_DATA(ziti_config, ziti_config);
ALIGNMENT_DATA(api_path, api_path);
ALIGNMENT_DATA(ziti_api_versions, ziti_api_versions);
ALIGNMENT_DATA(ziti_version, ziti_version);
ALIGNMENT_DATA(ziti_identity, ziti_identity);
ALIGNMENT_DATA(ziti_process, ziti_process);
ALIGNMENT_DATA(ziti_posture_query, ziti_posture_query);
ALIGNMENT_DATA(ziti_posture_query_set, ziti_posture_query_set);
ALIGNMENT_DATA(ziti_session_type, ziti_session_type);
ALIGNMENT_DATA(ziti_service, ziti_service);
ALIGNMENT_DATA(ziti_address, ziti_address_host);
ALIGNMENT_DATA(ziti_address, ziti_address_cidr);
ALIGNMENT_DATA(ziti_client_cfg_v1, ziti_client_cfg_v1);
ALIGNMENT_DATA(ziti_intercept_cfg_v1, ziti_intercept_cfg_v1);
ALIGNMENT_DATA(ziti_server_cfg_v1, ziti_server_cfg_v1);
ALIGNMENT_DATA(ziti_listen_options, ziti_listen_options);
ALIGNMENT_DATA(ziti_host_cfg_v1, ziti_host_cfg_v1);
ALIGNMENT_DATA(ziti_host_cfg_v2, ziti_host_cfg_v2);
ALIGNMENT_DATA(ziti_mfa_enrollment, ziti_mfa_enrollment);
ALIGNMENT_DATA(ziti_port_range, ziti_port_range);
ALIGNMENT_DATA(ziti_options, ziti_options);
ALIGNMENT_DATA(ziti_event_t, ziti_context_event);
ALIGNMENT_DATA(ziti_event_t, ziti_router_event);
ALIGNMENT_DATA(ziti_event_t, ziti_service_event);
ALIGNMENT_DATA(ziti_event_t, ziti_mfa_auth_event);
ALIGNMENT_DATA(ziti_event_t, ziti_api_event);
} ziti_types_v2;

Z4D_API int z4d_ziti_close(ziti_connection con);
Z4D_API int z4d_uv_run(void* loop);
Expand All @@ -78,7 +136,7 @@ Z4D_API void z4d_free_char_array(char **a, int size);
Z4D_API void z4d_ziti_dump_log(ziti_context ztx);
Z4D_API void z4d_ziti_dump_file(ziti_context ztx, const char* outputFile);

Z4D_API ziti_types_t* z4d_struct_test();
Z4D_API ziti_types_v2* z4d_struct_test();
Z4D_API ziti_posture_query* z4d_ziti_posture_query();

typedef void (*z4d_cb)(void* context);
Expand All @@ -88,4 +146,4 @@ Z4D_API void z4d_callback_on_loop(uv_loop_t* loop, void* context, z4d_cb cb);
}
#endif

#endif /* ZITI4DOTNET_H */
#endif /* ZITI4DOTNET_H */
Loading