Skip to content

Commit

Permalink
Merge pull request #215 from openziti/add-app-info
Browse files Browse the repository at this point in the history
add app info and submit it to controller
  • Loading branch information
ekoby authored Jan 20, 2021
2 parents 776d4f3 + 3f0e58d commit d44884f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion inc_internal/internal_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ XX(token, string, none, jti, __VA_ARGS__)
XX(type, string, none, type, __VA_ARGS__) \
XX(version, string, none, version, __VA_ARGS__) \
XX(revision, string, none, revision, __VA_ARGS__) \
XX(branch, string, none, branch, __VA_ARGS__)
XX(branch, string, none, branch, __VA_ARGS__) \
XX(app_id, string, none, appID, __VA_ARGS__) \
XX(app_version, string, none, appVersion, __VA_ARGS__)

#define ZITI_ENV_INFO_MODEL(XX, ...) \
XX(os, string, none, os, __VA_ARGS__) \
Expand Down
3 changes: 3 additions & 0 deletions inc_internal/zt_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ limitations under the License.
#define TYPE_DIAL "Dial"
#define TYPE_BIND "Bind"

extern const char* APP_ID;
extern const char* APP_VERSION;

typedef struct ziti_channel ziti_channel_t;

typedef void (*reply_cb)(void *ctx, message *m);
Expand Down
8 changes: 8 additions & 0 deletions includes/ziti/ziti.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ typedef void (*ziti_close_cb)(ziti_connection conn);
ZITI_FUNC
extern int ziti_enroll(ziti_enroll_opts *opts, uv_loop_t *loop, ziti_enroll_cb enroll_cb, void *enroll_ctx);

/**
* Provide app information to Ziti SDK.
*
* App information is reported to Ziti Controller. Supplying this information is optional.
*/
ZITI_FUNC
extern void ziti_set_app_info(const char *app_id, const char *app_version);

/**
* @brief Initializes a Ziti Edge identity.
*
Expand Down
10 changes: 10 additions & 0 deletions library/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ limitations under the License.

const char* ZITI_SDK_CONFIG = "ZITI_SDK_CONFIG";

const char* APP_ID = NULL;
const char* APP_VERSION = NULL;

void ziti_set_app_info(const char *app_id, const char *app_version) {
FREE(APP_ID);
FREE(APP_VERSION);
APP_ID = strdup(app_id);
APP_VERSION = strdup(app_version);
}

int load_config_file(const char *filename, ziti_config **cfg) {
struct stat stats;
int s = stat(filename, &stats);
Expand Down
2 changes: 2 additions & 0 deletions library/ziti_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ void ziti_ctrl_login(
.version = (char *) ziti_get_build_version(0),
.revision = (char *) ziti_git_commit(),
.branch = (char *) ziti_git_branch(),
.app_id = (char *) APP_ID,
.app_version = (char *) APP_VERSION,
},
.env_info = {
.os = osInfo.sysname,
Expand Down
1 change: 1 addition & 0 deletions programs/ziti-prox-c/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ CommandLine main_cmd = make_command_set("ziti-prox-c",
NULL, main_cmds);

static int process_args(int argc, char *argv[]) {
ziti_set_app_info(main_cmd.name, to_str(ZITI_VERSION));
commandline_run(&main_cmd, argc, argv);
return 0;
}
Expand Down

0 comments on commit d44884f

Please sign in to comment.