Skip to content

Commit

Permalink
Merge pull request #169 from openziti/dev
Browse files Browse the repository at this point in the history
Update to TSDK v0.20.20, libtlsuv
  • Loading branch information
smilindave26 authored Feb 8, 2023
2 parents 8b24f97 + cfcf4e1 commit 43fdea2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
22 changes: 12 additions & 10 deletions CZiti.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
5A0E4A8C24530E2500C56DCF /* libziti.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A0E4A8A24530E1E00C56DCF /* libziti.a */; };
5A0E4A8E24534DDE00C56DCF /* libsodium.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A0E4A8D24534DDE00C56DCF /* libsodium.a */; };
5A0E4A8F24534DE500C56DCF /* libsodium.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A0E4A8D24534DDE00C56DCF /* libsodium.a */; };
5A1D8AD629940BE500101BD7 /* libtlsuv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A1D8AD529940BE500101BD7 /* libtlsuv.a */; };
5A1D8AD729940C3A00101BD7 /* libtlsuv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A1D8AD529940BE500101BD7 /* libtlsuv.a */; };
5A411E0B251FE40B005EE351 /* Bridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A0AC94E247783440021E8D9 /* Bridge.swift */; };
5A5538E82556F92100C02F03 /* ZitiPostureChecks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A5538E72556F92100C02F03 /* ZitiPostureChecks.swift */; };
5A5538E92556F92100C02F03 /* ZitiPostureChecks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A5538E72556F92100C02F03 /* ZitiPostureChecks.swift */; };
Expand Down Expand Up @@ -46,7 +48,6 @@
5AA298BD2585961C001F7502 /* NetifDriver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AA298BB2585961C001F7502 /* NetifDriver.swift */; };
5AAAEDE62464D8AB00C56383 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AAAEDE52464D8AB00C56383 /* main.swift */; };
5AAAEDEA2464D8FB00C56383 /* libCZiti.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF68244B7C3C00F4B4E0 /* libCZiti.a */; };
5AB6DF7E244B8F2000F4B4E0 /* libuv_mbed.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF77244B8F2000F4B4E0 /* libuv_mbed.a */; };
5AB6DF7F244B8F2000F4B4E0 /* libmbedx509.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF78244B8F2000F4B4E0 /* libmbedx509.a */; };
5AB6DF80244B8F2000F4B4E0 /* libmbedcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF79244B8F2000F4B4E0 /* libmbedcrypto.a */; };
5AB6DF82244B8F2000F4B4E0 /* libmbedtls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF7B244B8F2000F4B4E0 /* libmbedtls.a */; };
Expand All @@ -55,7 +56,6 @@
5AB6DFBA244BA64300F4B4E0 /* libmbedtls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF7B244B8F2000F4B4E0 /* libmbedtls.a */; };
5AB6DFBB244BA64700F4B4E0 /* libmbedx509.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF78244B8F2000F4B4E0 /* libmbedx509.a */; };
5AB6DFBC244BA64B00F4B4E0 /* libuv_a.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF7C244B8F2000F4B4E0 /* libuv_a.a */; };
5AB6DFBE244BA65400F4B4E0 /* libuv_mbed.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB6DF77244B8F2000F4B4E0 /* libuv_mbed.a */; };
5AB8309E247432C40089AF93 /* ZitiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AB8308F247432C40089AF93 /* ZitiError.swift */; };
5AB8309F247432C40089AF93 /* ZitiIntercept.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AB83090247432C40089AF93 /* ZitiIntercept.swift */; };
5AB830A0247432C40089AF93 /* ZitiKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AB83091247432C40089AF93 /* ZitiKeychain.swift */; };
Expand Down Expand Up @@ -186,6 +186,7 @@
5A0AC94E247783440021E8D9 /* Bridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bridge.swift; sourceTree = "<group>"; };
5A0E4A8A24530E1E00C56DCF /* libziti.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libziti.a; path = "deps/ziti-sdk-c/build-os-arch/library/libziti.a"; sourceTree = "<group>"; };
5A0E4A8D24534DDE00C56DCF /* libsodium.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsodium.a; path = "deps/ziti-sdk-c/build-os-arch/_deps/libsodium-build/lib/libsodium.a"; sourceTree = "<group>"; };
5A1D8AD529940BE500101BD7 /* libtlsuv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtlsuv.a; path = "deps/ziti-tunnel-sdk-c/build-os-arch/_deps/tlsuv-build/libtlsuv.a"; sourceTree = "<group>"; };
5A298539283C271E0056C9A7 /* workspace-settings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "workspace-settings.xcconfig"; sourceTree = "<group>"; };
5A29E5EE268164CF00EED54C /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
5A5538E72556F92100C02F03 /* ZitiPostureChecks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZitiPostureChecks.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -279,7 +280,7 @@
5AA2989125857759001F7502 /* liblwipcore.a in Frameworks */,
5A0E4A8E24534DDE00C56DCF /* libsodium.a in Frameworks */,
5A0E4A8B24530E1E00C56DCF /* libziti.a in Frameworks */,
5AB6DF7E244B8F2000F4B4E0 /* libuv_mbed.a in Frameworks */,
5A1D8AD629940BE500101BD7 /* libtlsuv.a in Frameworks */,
5AB6DF7F244B8F2000F4B4E0 /* libmbedx509.a in Frameworks */,
5AB6DF80244B8F2000F4B4E0 /* libmbedcrypto.a in Frameworks */,
5AB6DF82244B8F2000F4B4E0 /* libmbedtls.a in Frameworks */,
Expand All @@ -294,7 +295,7 @@
5AA2989725857789001F7502 /* libziti-tunnel-sdk-c.a in Frameworks */,
5AA2989825857789001F7502 /* libziti-tunnel-cbs-c.a in Frameworks */,
5AA2989925857789001F7502 /* liblwipcore.a in Frameworks */,
5AB6DFBE244BA65400F4B4E0 /* libuv_mbed.a in Frameworks */,
5A1D8AD729940C3A00101BD7 /* libtlsuv.a in Frameworks */,
5AB6DFBC244BA64B00F4B4E0 /* libuv_a.a in Frameworks */,
5AB6DFB9244BA63F00F4B4E0 /* libmbedcrypto.a in Frameworks */,
5AB6DFBB244BA64700F4B4E0 /* libmbedx509.a in Frameworks */,
Expand Down Expand Up @@ -398,6 +399,7 @@
5AB6DF76244B8F2000F4B4E0 /* Frameworks */ = {
isa = PBXGroup;
children = (
5A1D8AD529940BE500101BD7 /* libtlsuv.a */,
5ADAE979280F7EFD007D1DF4 /* libresolv.9.tbd */,
5AFE864327E3C62800D47A47 /* libresolv.tbd */,
5AFE864127E3C56000D47A47 /* libresolv.9.tbd */,
Expand Down Expand Up @@ -1027,9 +1029,9 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/uv-mbed-src/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/tlsuv-src/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/http_parser-src",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/uv-mbed-src/deps/uv_link_t/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/tlsuv-src/deps/uv_link_t/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/libuv-src/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/ziti-sdk-c-src/includes",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/include",
Expand All @@ -1040,7 +1042,7 @@
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/lwip-contrib-src/ports/unix/port/include",
);
LIBRARY_SEARCH_PATHS = (
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/uv-mbed-build",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/tlsuv-build",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/mbedtls-build/library",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/uv-mbed-build",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/libuv-build",
Expand Down Expand Up @@ -1088,9 +1090,9 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/uv-mbed-src/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/tlsuv-src/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/http_parser-src",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/uv-mbed-src/deps/uv_link_t/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/tlsuv-src/deps/uv_link_t/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/libuv-src/include",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/ziti-sdk-c-src/includes",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/include",
Expand All @@ -1101,7 +1103,7 @@
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/lwip-contrib-src/ports/unix/port/include",
);
LIBRARY_SEARCH_PATHS = (
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/uv-mbed-build",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/tlsuv-build",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/mbedtls-build/library",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/uv-mbed-build",
"$(PROJECT_DIR)/deps/ziti-tunnel-sdk-c/build-$(PLATFORM_NAME)-$(CURRENT_ARCH)/_deps/libuv-build",
Expand Down
2 changes: 1 addition & 1 deletion lib/Ziti-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
#include <ziti/ziti.h>
#include <ziti/ziti_src.h>
#include <ziti/ziti_model.h>
#include <uv_mbed/um_http.h>
#include <tlsuv/http.h>
#include "ziti/ziti_tunnel.h"
#include "ziti/ziti_tunnel_cbs.h"
#include "ziti/netif_driver.h"
Expand Down
34 changes: 17 additions & 17 deletions lib/ZitiIntercept.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class ZitiIntercept : NSObject, ZitiUnretained {

let name:String
let urlStr:String
var clt = um_http_t()
var zs = um_src_t()
var clt = tlsuv_http_t()
var zs = tlsuv_src_t()
var hdrs:[String:String]? = nil

static var releasePending:[ZitiIntercept] = []
Expand All @@ -31,15 +31,15 @@ class ZitiIntercept : NSObject, ZitiUnretained {
self.name = name
self.urlStr = urlStr
ziti_src_init(ziti.loop, &zs, name.cString(using: .utf8), ziti.ztx)
um_http_init_with_src(ziti.loop, &clt, urlStr.cString(using: .utf8), &zs)
um_http_idle_keepalive(&clt, idleTime)
tlsuv_http_init_with_src(ziti.loop, &clt, urlStr.cString(using: .utf8), &zs)
tlsuv_http_idle_keepalive(&clt, idleTime)

super.init()

clt.data = self.toVoidPtr()
}

static private let on_http_close:um_http_close_cb = { h in
static private let on_http_close:tlsuv_http_close_cb = { h in
guard let ctx = h?.pointee.data, let mySelf = zitiUnretained(ZitiIntercept.self, ctx) else {
return
}
Expand All @@ -48,32 +48,32 @@ class ZitiIntercept : NSObject, ZitiUnretained {

func close() {
ZitiIntercept.releasePending.append(self)
um_http_close(&clt, ZitiIntercept.on_http_close)
tlsuv_http_close(&clt, ZitiIntercept.on_http_close)
}

func createRequest(_ zup:ZitiUrlProtocol, _ urlPath:String,
_ on_resp:@escaping um_http_resp_cb,
_ on_body:@escaping um_http_body_cb,
_ ctx:UnsafeMutableRawPointer) -> UnsafeMutablePointer<um_http_req_t>? {
_ on_resp:@escaping tlsuv_http_resp_cb,
_ on_body:@escaping tlsuv_http_body_cb,
_ ctx:UnsafeMutableRawPointer) -> UnsafeMutablePointer<tlsuv_http_req_t>? {

var req:UnsafeMutablePointer<um_http_req_t>? = nil
var req:UnsafeMutablePointer<tlsuv_http_req_t>? = nil

let method = zup.request.httpMethod ?? "GET"
req = um_http_req(&clt, method, urlPath.cString(using: .utf8), on_resp, ctx)
req = tlsuv_http_req(&clt, method, urlPath.cString(using: .utf8), on_resp, ctx)
req?.pointee.resp.body_cb = on_body

if req != nil {
// Add request headers
zup.request.allHTTPHeaderFields?.forEach { h in
um_http_req_header(req,
tlsuv_http_req_header(req,
h.key.cString(using: .utf8),
h.value.cString(using: .utf8))
}

// add any headers specified via service config
if let hdrs = hdrs {
hdrs.forEach { hdr in
um_http_req_header(req, hdr.key, hdr.value)
tlsuv_http_req_header(req, hdr.key, hdr.value)
}
}

Expand All @@ -83,14 +83,14 @@ class ZitiIntercept : NSObject, ZitiUnretained {
if let nfv = ziti_get_version()?.pointee {
zv = "\(String(cString: nfv.version))-@\(String(cString: nfv.revision))"
}
um_http_req_header(req,
tlsuv_http_req_header(req,
"User-Agent".cString(using: .utf8),
"\(ZitiUrlProtocol.self); ziti-sdk-c/\(zv)".cString(using: .utf8))
}

// if no Accept, add it
if zup.request.allHTTPHeaderFields?["Accept"] == nil {
um_http_req_header(req,
tlsuv_http_req_header(req,
"Accept".cString(using: .utf8),
"*/*".cString(using: .utf8))
}
Expand All @@ -100,7 +100,7 @@ class ZitiIntercept : NSObject, ZitiUnretained {
let ptr = UnsafeMutablePointer<Int8>.allocate(capacity: body.count)
let bytes:[Int8] = body.map{ Int8(bitPattern: $0) }
ptr.initialize(from: bytes, count: body.count)
um_http_req_data(req, ptr, body.count, nil)
tlsuv_http_req_data(req, ptr, body.count, nil)
ptr.deallocate()
} else if let stream = zup.request.httpBodyStream {
if let clv = zup.request.allHTTPHeaderFields?["Content-Length"], let contentLen = Int(clv) {
Expand All @@ -114,7 +114,7 @@ class ZitiIntercept : NSObject, ZitiUnretained {
stream.close()

_ = ptr.withMemoryRebound(to: Int8.self, capacity: body.count) {
um_http_req_data(req, $0, body.count, nil)
tlsuv_http_req_data(req, $0, body.count, nil)
}
ptr.deallocate()
} else {
Expand Down
6 changes: 3 additions & 3 deletions lib/ZitiUrlProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import CZitiPrivate
var stopped = false
var finished = false

var req:UnsafeMutablePointer<um_http_req_t>? = nil
var req:UnsafeMutablePointer<tlsuv_http_req_t>? = nil
var resp:HTTPURLResponse?

var clientThread:Thread? // Thread that calls start/stopLoading, handles client notifications
Expand Down Expand Up @@ -285,7 +285,7 @@ import CZitiPrivate
//
// MARK: - um_http callbacks
//
static private let on_http_resp:um_http_resp_cb = { resp, ctx in
static private let on_http_resp:tlsuv_http_resp_cb = { resp, ctx in
guard let resp = resp, let mySelf = zitiUnretained(ZitiUrlProtocol.self, ctx) else {
log.wtf("unable to decode context")
return
Expand Down Expand Up @@ -349,7 +349,7 @@ import CZitiPrivate
}
}

static private let on_http_body:um_http_body_cb = { req, body, len in
static private let on_http_body:tlsuv_http_body_cb = { req, body, len in
guard let req = req, let mySelf = zitiUnretained(ZitiUrlProtocol.self ,req.pointee.data) else {
log.wtf("unable to decode context")
return
Expand Down

0 comments on commit 43fdea2

Please sign in to comment.