Ziti dump connection stats (#601)

* cmake version only match tags starting with a number

(cherry picked from commit 4f4d458d47)

* add connection start/connect/idle time tracking

* add additional connection dump data:
- marker
- transfer data
- bridge info (if bridged)

* ziti dump context uptime
This commit is contained in:
ekoby
2023-12-21 15:04:47 -05:00
committed by GitHub
parent 671d149613
commit 0fa97ded63
8 changed files with 384 additions and 21 deletions
+216
View File
@@ -0,0 +1,216 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RequiresClausePosition: OwnLine
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...
+1 -1
View File
@@ -1,7 +1,7 @@
function(get_version version_file version_var branch_var commit_var)
execute_process(
COMMAND git describe --tags HEAD
COMMAND git describe --tags --match=[0-9]* HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_INFO
OUTPUT_STRIP_TRAILING_WHITESPACE
+4
View File
@@ -80,6 +80,10 @@ enum header_id {
TraceSourceRequestIdHeader = 1019,
TraceError = 1020,
ListenerId = 1021,
ConnTypeHeader = 1022,
SupportsInspectHeader = 1023,
SupportsBindSuccessHeader = 1024,
ConnectionMarkerHeader = 1025,
};
enum crypto_method {
+18 -2
View File
@@ -1,9 +1,9 @@
// Copyright (c) 2022-2023. NetFoundry Inc.
// Copyright (c) 2022-2023. NetFoundry Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@@ -39,6 +39,9 @@
#define UUID_STR_LEN 37
#endif
#define MARKER_BIN_LEN 6
#define MARKER_CHAR_LEN sodium_base64_ENCODED_LEN(MARKER_BIN_LEN, sodium_base64_VARIANT_URLSAFE_NO_PADDING)
#define ZTX_LOG(lvl, fmt, ...) ZITI_LOG(lvl, "ztx[%u] " fmt, ztx->id, ##__VA_ARGS__)
extern const char *APP_ID;
@@ -191,6 +194,8 @@ struct ziti_conn {
struct key_pair key_pair;
struct ziti_conn_req *conn_req;
char marker[MARKER_CHAR_LEN];
uint32_t edge_msg_seq;
ziti_channel_t *channel;
@@ -214,6 +219,14 @@ struct ziti_conn {
crypto_secretstream_xchacha20poly1305_state crypt_o;
crypto_secretstream_xchacha20poly1305_state crypt_i;
// stats
bool bridged;
uint64_t start;
uint64_t connect_time;
uint64_t last_activity;
uint64_t sent;
uint64_t received;
};
};
@@ -294,6 +307,7 @@ struct ziti_ctx {
int ziti_timeout;
/* context wide metrics */
uint64_t start;
rate_t up_rate;
rate_t down_rate;
@@ -391,6 +405,8 @@ const ziti_env_info* get_env_info();
extern uv_timer_t *new_ztx_timer(ziti_context ztx);
int conn_bridge_info(ziti_connection conn, char *buf, size_t buflen);
#ifdef __cplusplus
}
#endif
+11 -3
View File
@@ -1,9 +1,9 @@
// Copyright (c) 2023. NetFoundry Inc.
// Copyright (c) 2023. NetFoundry Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@@ -298,9 +298,11 @@ static int dispose(ziti_connection server) {
static void process_dial(struct binding_s *b, message *msg) {
struct ziti_conn *conn = b->conn;
size_t peer_key_len;
size_t peer_key_len, marker_len;
uint8_t *peer_key;
uint8_t *marker;
bool peer_key_sent = message_get_bytes_header(msg, PublicKeyHeader, &peer_key, &peer_key_len);
bool marker_sent = message_get_bytes_header(msg, ConnectionMarkerHeader, &marker, &marker_len);
if (!peer_key_sent && conn->encrypted) {
ZITI_LOG(ERROR, "failed to establish crypto for encrypted service: did not receive peer key");
@@ -311,6 +313,12 @@ static void process_dial(struct binding_s *b, message *msg) {
ziti_connection client;
ziti_conn_init(conn->ziti_ctx, &client, NULL);
init_transport_conn(client);
if (marker_sent) {
snprintf(client->marker, sizeof(client->marker), "%.*s", (int) marker_len, marker);
} else {
snprintf(client->marker, sizeof(client->marker), "-");
}
client->start = uv_now(conn->ziti_ctx->loop);
if (peer_key_sent) {
client->encrypted = true;
+74 -2
View File
@@ -1,9 +1,9 @@
// Copyright (c) 2022-2023. NetFoundry Inc.
// Copyright (c) 2022-2023. NetFoundry Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@@ -53,6 +53,8 @@ static void close_bridge(struct ziti_bridge_s *br);
static void on_input(uv_stream_t *s, ssize_t len, const uv_buf_t *b);
static void on_udp_input(uv_udp_t *udp, ssize_t len, const uv_buf_t *b, const struct sockaddr *addr, unsigned int flags);
static int fmt_addr(struct sockaddr_storage *ss, char *host, size_t host_len, int *port);
extern int ziti_conn_bridge(ziti_connection conn, uv_handle_t *handle, uv_close_cb on_close) {
if (handle == NULL) return UV_EINVAL;
@@ -82,6 +84,7 @@ extern int ziti_conn_bridge(ziti_connection conn, uv_handle_t *handle, uv_close_
uv_handle_set_data(handle, br);
ziti_conn_set_data(conn, br);
conn->bridged = true;
ziti_conn_set_data_cb(conn, on_ziti_data);
int rc = (br->input->type == UV_UDP) ?
@@ -175,6 +178,7 @@ extern int ziti_conn_bridge_fds(ziti_connection conn, uv_os_fd_t input, uv_os_fd
uv_handle_set_data(br->input, br);
ziti_conn_set_data(conn, br);
conn->bridged = true;
ziti_conn_set_data_cb(conn, on_ziti_data);
int rc = uv_read_start((uv_stream_t *) br->input, bridge_alloc, on_input);
@@ -412,3 +416,71 @@ void on_input(uv_stream_t *s, ssize_t len, const uv_buf_t *b) {
}
}
}
int conn_bridge_info(ziti_connection conn, char *buf, size_t buflen) {
if (conn == NULL || !conn->bridged) {
return ZITI_INVALID_STATE;
}
struct ziti_bridge_s *br = conn->data;
const char *proto = NULL;
struct sockaddr_storage local;
int local_len = sizeof(local);
struct sockaddr_storage remote;
int remote_len = sizeof(remote);
int lport = 0;
int rport = 0;
char remote_str[128] = "unknown";
char local_str[128] = "unknown";
size_t remote_str_size = sizeof(remote_str);
switch (br->output->type) {
case UV_NAMED_PIPE: {
char name[256];
size_t name_size = sizeof(name);
if (uv_pipe_getpeername((const uv_pipe_t *) br->output, name, &name_size) == 0) {
snprintf(buf, buflen, "pipe: -> %.*s", (int)name_size, name);
return ZITI_OK;
} else {
return ZITI_INVALID_STATE;
}
}
case UV_TCP:
proto = "tcp";
uv_tcp_getsockname((const uv_tcp_t *) br->output, (struct sockaddr *) &local, &local_len);
uv_tcp_getpeername((const uv_tcp_t *) br->output, (struct sockaddr *) &remote, &remote_len);
break;
case UV_UDP:
uv_udp_getsockname((const uv_udp_t *) br->output, (struct sockaddr *) &local, &local_len);
uv_udp_getpeername((const uv_udp_t *) br->output, (struct sockaddr *) &remote, &remote_len);
proto = "udp";
break;
default:
return ZITI_INVALID_STATE;
}
fmt_addr(&local, local_str, sizeof(local), &lport);
fmt_addr(&remote, remote_str, sizeof(remote_str), &rport);
snprintf(buf, buflen, "%s: %s:%d -> %s:%d", proto, local_str, lport, remote_str, rport);
return ZITI_OK;
}
static int fmt_addr(struct sockaddr_storage *ss, char *host, size_t host_len, int *port) {
void *addr = NULL;
if (ss->ss_family == AF_INET) {
struct sockaddr_in *in_addr = (struct sockaddr_in *) ss;
*port = ntohs(in_addr->sin_port);
addr = &in_addr->sin_addr;
} else if (ss->ss_family == AF_INET6) {
struct sockaddr_in6 *in_addr = (struct sockaddr_in6 *) ss;
*port = ntohs(in_addr->sin6_port);
addr = &in_addr->sin6_addr;
} else {
*port = -1;
return ZITI_INVALID_STATE;
}
uv_inet_ntop(ss->ss_family, addr, host, host_len);
return ZITI_OK;
}
+24 -4
View File
@@ -1,9 +1,9 @@
// Copyright (c) 2022-2023. NetFoundry Inc.
// Copyright (c) 2022-2023. NetFoundry Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@@ -23,7 +23,8 @@
static const char *INVALID_SESSION = "Invalid Session";
static const int MAX_CONNECT_RETRY = 3;
#define CONN_LOG(lvl, fmt, ...) ZITI_LOG(lvl, "conn[%u.%u/%s] " fmt, conn->ziti_ctx->id, conn->conn_id, conn_state_str[conn->state], ##__VA_ARGS__)
#define CONN_LOG(lvl, fmt, ...) ZITI_LOG(lvl, "conn[%u.%u/%.*s/%s] " fmt, \
conn->ziti_ctx->id, conn->conn_id, (int)sizeof(conn->marker), conn->marker, conn_state_str[conn->state], ##__VA_ARGS__)
@@ -78,6 +79,9 @@ const char *ziti_conn_state(ziti_connection conn) {
static void conn_set_state(struct ziti_conn *conn, enum conn_state state) {
CONN_LOG(VERBOSE, "transitioning %s => %s", conn_state_str[conn->state], conn_state_str[state]);
conn->state = state;
if (state == Connected) {
conn->connect_time = uv_now(conn->ziti_ctx->loop) - conn->start;
}
}
static ziti_dial_opts *clone_ziti_dial_opts(const ziti_dial_opts *dial_opts) {
@@ -515,6 +519,11 @@ static int do_ziti_dial(ziti_connection conn, const char *service, ziti_dial_opt
return ZITI_INVALID_STATE;
}
char marker[MARKER_BIN_LEN];
uv_random(NULL, NULL, marker, sizeof(marker), 0, NULL);
sodium_bin2base64(conn->marker, sizeof(conn->marker), marker, sizeof(marker),
sodium_base64_VARIANT_URLSAFE_NO_PADDING);
NEWP(req, struct ziti_conn_req);
conn->service = strdup(service);
conn->conn_req = req;
@@ -539,6 +548,8 @@ static int do_ziti_dial(ziti_connection conn, const char *service, ziti_dial_opt
uv_idle_init(conn->ziti_ctx->loop, conn->flusher);
conn->flusher->data = conn;
conn->start = uv_now(conn->ziti_ctx->loop);
process_connect(conn);
return ZITI_OK;
}
@@ -601,6 +612,7 @@ static void ziti_write_req(struct ziti_write_req_s *req) {
memcpy(m->body, req->buf, req->len);
}
}
conn->sent += req->len;
send_message(conn, m, req);
}
}
@@ -742,6 +754,7 @@ static void flush_connection(ziti_connection conn) {
CONN_LOG(TRACE, "starting flusher");
uv_idle_start(conn->flusher, on_flush);
}
conn->last_activity = uv_now(conn->ziti_ctx->loop);
}
static bool flush_to_service(ziti_connection conn) {
@@ -848,6 +861,7 @@ void conn_inbound_data_msg(ziti_connection conn, message *msg) {
CONN_LOG(VERBOSE, "decrypted %lld bytes", plain_len);
buffer_append(conn->inbound, plain_text, plain_len);
metrics_rate_update(&conn->ziti_ctx->down_rate, (int64_t) plain_len);
conn->received += plain_len;
}
}
@@ -862,6 +876,7 @@ void conn_inbound_data_msg(ziti_connection conn, message *msg) {
memcpy(plain_text, msg->body, msg->header.body_len);
buffer_append(conn->inbound, plain_text, msg->header.body_len);
metrics_rate_update(&conn->ziti_ctx->down_rate, msg->header.body_len);
conn->received += msg->header.body_len;
}
int32_t flags;
@@ -1006,6 +1021,11 @@ static int ziti_channel_start_connection(struct ziti_conn *conn, ziti_channel_t
.length = sizeof(conn_id),
.value = (uint8_t *) &conn_id
},
{
.header_id = ConnectionMarkerHeader,
.length = sizeof(conn->marker),
.value = (uint8_t *) conn->marker,
},
{
.header_id = SeqHeader,
.length = sizeof(msg_seq),
@@ -1038,7 +1058,7 @@ static int ziti_channel_start_connection(struct ziti_conn *conn, ziti_channel_t
.value = NULL,
}
};
int nheaders = 3;
int nheaders = 4;
if (conn->encrypted) {
init_key_pair(&conn->key_pair);
nheaders++;
+36 -9
View File
@@ -1,9 +1,9 @@
// Copyright (c) 2022-2023. NetFoundry Inc.
// Copyright (c) 2022-2023. NetFoundry Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@@ -421,6 +421,7 @@ static void ziti_start_internal(ziti_context ztx, void *init_req) {
if (!ztx->enabled) {
ztx->enabled = true;
uv_prepare_start(ztx->prepper, ztx_prepare);
ztx->start = uv_now(ztx->loop);
ziti_ctrl_get_version(&ztx->controller, version_cb, ztx);
ziti_set_unauthenticated(ztx);
@@ -622,10 +623,15 @@ int ziti_get_appdata(ziti_context ztx, const char *key, void *data,
void ziti_dump(ziti_context ztx, int (*printer)(void *arg, const char *fmt, ...), void *ctx) {
uint64_t now = uv_now(ztx->loop);
printer(ctx, "\n=================\nZiti Context:\n");
printer(ctx, "ID:\t%d\n", ztx->id);
printer(ctx, "Enabled:\t%s\n", ziti_is_enabled(ztx) ? "true" : "false");
printer(ctx, "Config:\t%s\n", ztx->opts.config);
if (ziti_is_enabled(ztx)) {
printer(ctx, "enabled[true] uptime[%" PRIu64 "s]\n", (now - ztx->start)/1000);
} else {
printer(ctx, "enabled[false]");
}
printer(ctx, "Config Source:\t%s\n", ztx->config.cfg_source ? ztx->config.cfg_source : "(none)");
printer(ctx, "Controller:\t%s\n", ztx_controller(ztx));
printer(ctx, "Config types:\n");
for (int i = 0; ztx->opts.config_types && ztx->opts.config_types[i]; i++) {
@@ -697,16 +703,27 @@ void ziti_dump(ziti_context ztx, int (*printer)(void *arg, const char *fmt, ...)
}
}
printer(ctx, "\n==================\nConnections:\n");
printer(ctx, "\n==================\n"
"Connections:\n");
ziti_connection conn;
const char *id;
char bridge_info[128];
MODEL_MAP_FOREACH(id, conn, &ztx->connections) {
if (conn->type == Transport && conn->parent == NULL) {
printer(ctx, "conn[%d]: state[%s] service[%s] using ch[%d] %s\n",
conn->conn_id, ziti_conn_state(conn), conn->service,
printer(ctx, "conn[%d/%s]: state[%s] service[%s] using ch[%d/%s]\n",
conn->conn_id, conn->marker, ziti_conn_state(conn), conn->service,
FIELD_OR_ELSE(conn->channel, id, -1),
FIELD_OR_ELSE(conn->channel, name, "(none)")
);
printer(ctx, "\tconnect_time[%" PRIu64 "] idle_time[%" PRIu64 "] "
"sent[%" PRIu64 "] recv[%" PRIu64 "] recv_buff[%" PRIu64 "]\n",
conn->connect_time, now - conn->last_activity, conn->sent, conn->received,
buffer_available(conn->inbound));
if (conn_bridge_info(conn, bridge_info, sizeof(bridge_info)) == ZITI_OK) {
printer(ctx, "\tbridge: %s\n", bridge_info);
}
}
if (conn->type == Server) {
@@ -717,11 +734,18 @@ void ziti_dump(ziti_context ztx, int (*printer)(void *arg, const char *fmt, ...)
while (it != NULL) {
uint32_t child_id = model_map_it_lkey(it);
ziti_connection child = model_map_it_value(it);
printer(ctx, "\tchild[%d]: state[%s] caller_id[%s] ch[%d] %s\n",
child_id, ziti_conn_state(child), ziti_conn_source_identity(child),
printer(ctx, "\tchild[%d/%s]: state[%s] caller_id[%s] ch[%d/%s]\n",
child_id, child->marker, ziti_conn_state(child), ziti_conn_source_identity(child),
FIELD_OR_ELSE(child->channel, id, -1),
FIELD_OR_ELSE(child->channel, name, "(none)")
);
printer(ctx, "\t\taccept_time[%" PRIu64 "] idle_time[%" PRIu64 "] "
"sent[%" PRIu64 "] recv[%" PRIu64 "] recv_buff[%" PRIu64 "]\n",
child->connect_time, now - child->last_activity, child->sent, child->received,
buffer_available(child->inbound));
if (conn_bridge_info(child, bridge_info, sizeof(bridge_info)) == ZITI_OK) {
printer(ctx, "\t\tbridge: %s\n", bridge_info);
}
it = model_map_it_next(it);
}
}
@@ -1844,6 +1868,9 @@ int ziti_context_init(ziti_context *ztx, const ziti_config *config) {
ctx->config.id.ca = strdup(cfg_ca);
}
if (config->cfg_source) {
ctx->config.cfg_source = strdup(config->cfg_source);
}
ctx->config.controller_url = strdup(config->controller_url);
if (config->id.key) ctx->config.id.key = strdup(config->id.key);
if (config->id.cert) ctx->config.id.cert = strdup(config->id.cert);