Skip to content

Commit

Permalink
update ziti-sdk-c to v0.30.1 (#518)
Browse files Browse the repository at this point in the history
* display correct dns range in help message

* update ziti-sdk-c to v0.30.1

* use latest ubuntu runners and run linux builds in containers

* use score returned by `ziti_address_match`.

* use correct tun and dns IPs on darwin.
  • Loading branch information
scareything committed Oct 14, 2022
1 parent 97aad5e commit b6eec50
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ jobs:
name: Windows x86_64
arch: x86_64

- os: ubuntu-18.04
- os: ubuntu-latest
container: ubuntu:18.04
name: Linux x86_64
install: libsystemd-dev
arch: x86_64

- os: ubuntu-18.04
- os: ubuntu-latest
container: ubuntu:18.04
name: Linux arm
install: crossbuild-essential-armhf libsystemd-dev
toolchain: Linux-arm.cmake
cmake_opts: -DCMAKE_BUILD_TYPE=Release
arch: arm

- os: ubuntu-18.04
- os: ubuntu-latest
container: ubuntu:18.04
name: Linux arm64
install: crossbuild-essential-arm64 libsystemd-dev
toolchain: Linux-arm64.cmake
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ jobs:
name: Windows x86_64
arch: x86_64

- os: ubuntu-18.04
- os: ubuntu-latest
container: ubuntu:18.04
name: Linux x86_64
install: libsystemd-dev
toolchain: default.cmake
arch: x86_64

- os: ubuntu-18.04
- os: ubuntu-latest
container: ubuntu:18.04
name: Linux arm
install: crossbuild-essential-armhf libsystemd-dev
toolchain: Linux-arm.cmake
cmake_opts: -DCMAKE_BUILD_TYPE=Release
arch: arm

- os: ubuntu-18.04
- os: ubuntu-latest
container: ubuntu:18.04
name: Linux arm64
install: crossbuild-essential-arm64 libsystemd-dev
toolchain: Linux-arm64.cmake
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)
if(NOT ZITI_SDK_C_BRANCH)
#allow using a different branch of the CSDK easily
set(ZITI_SDK_C_BRANCH "0.30.0")
set(ZITI_SDK_C_BRANCH "0.30.1")
endif()

# if TUNNEL_SDK_ONLY then don't descend into programs/ziti-edge-tunnel
Expand Down
1 change: 0 additions & 1 deletion lib/ziti-tunnel-cbs/ziti_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ int ziti_dns_setup(tunneler_context tnlr, const char *dns_addr, const char *dns_
ziti_address *reserved[] = { &tun_zaddr, &dns_zaddr };
size_t n = sizeof(reserved) / sizeof(ziti_address *);
for (int i = 0; i < n; i++) {
ip_addr_t ip4;
struct in_addr *in4_p = (struct in_addr *) &reserved[i]->addr.cidr.ip;
model_map_setl(&ziti_dns.ip_addresses, in4_p->s_addr, calloc(1, sizeof(dns_entry_t)));
}
Expand Down
24 changes: 9 additions & 15 deletions lib/ziti-tunnel/intercept.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,18 @@ const ziti_address *address_match(const ziti_address *addr, const address_list_t
int score, best_score = -1;

STAILQ_FOREACH(a, addresses, entries) {
if (ziti_address_match(addr, &a->za)) {
if (addr->type == ziti_address_cidr) {
score = (int) (addr->addr.cidr.bits - a->za.addr.cidr.bits);
TNL_LOG(VERBOSE, "ziti_address_cidr match score %d", score);
} else if (addr->type == ziti_address_hostname) {
score = 0;
TNL_LOG(VERBOSE, "ziti_address_hostname match score %d", score);
}
if (best_score == -1 || score < best_score) {
best_score = score;
best_addr = &a->za;
if (best_score == 0) {
// won't find a better match so get out now
break;
}
score = ziti_address_match(addr, &a->za);
TNL_LOG(VERBOSE, "ziti_address_match score %d", score);
if (best_score == -1 || score < best_score) {
best_score = score;
best_addr = &a->za;
if (best_score == 0) {
// won't find a better match so get out now
break;
}
}
}

return best_addr;
}

Expand Down
10 changes: 6 additions & 4 deletions programs/ziti-edge-tunnel/ziti-edge-tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ static int run_tunnel(uv_loop_t *ziti_loop, uint32_t tun_ip, uint32_t dns_ip, co
ip_addr_t dns_ip4_addr = IPADDR4_INIT(htonl(dns_subnet_u32));
snprintf(dns_subnet, sizeof(dns_subnet), "%s/%d", ipaddr_ntoa(&dns_ip4_addr), dns_subnet_zaddr.addr.cidr.bits);
#if __APPLE__ && __MACH__
tun = utun_open(tun_error, sizeof(tun_error), dns_subnet);
tun = utun_open(tun_error, sizeof(tun_error), ip_range);
#elif __linux__
tun = tun_open(ziti_loop, tun_ip, dns_ip, dns_subnet, tun_error, sizeof(tun_error));
#elif _WIN32
Expand Down Expand Up @@ -1674,7 +1674,9 @@ static struct option run_host_options[] = {
{ "refresh", optional_argument, NULL, 'r'},
};

static const char* default_cidr = "100.64.0.1/10";
#ifndef DEFAULT_DNS_CIDR
#define DEFAULT_DNS_CIDR "100.64.0.1/10"
#endif
static const char* dns_upstream = NULL;
static bool host_only = false;

Expand Down Expand Up @@ -1817,7 +1819,7 @@ static void run(int argc, char *argv[]) {
if (ip_range_temp != NULL) {
configured_cidr = ip_range_temp;
} else {
configured_cidr = strdup(default_cidr);
configured_cidr = strdup(DEFAULT_DNS_CIDR);
}
}

Expand Down Expand Up @@ -2757,7 +2759,7 @@ static CommandLine run_cmd = make_command("run", "run Ziti tunnel (required supe
"\t-v|--verbose N\tset log level, higher level -- more verbose (default 3)\n"
"\t-r|--refresh N\tset service polling interval in seconds (default 10)\n"
"\t-d|--dns-ip-range <ip range>\tspecify CIDR block in which service DNS names"
" are assigned in N.N.N.N/n format (default 100.64.0.0/10)\n",
" are assigned in N.N.N.N/n format (default " DEFAULT_DNS_CIDR ")\n",
run_opts, run);
static CommandLine run_host_cmd = make_command("run-host", "run Ziti tunnel to host services",
"-i <id.file> [-r N] [-v N]",
Expand Down

0 comments on commit b6eec50

Please sign in to comment.