Hi, I'm developing proof-of-concept for our application running over openziti network. Application has a number of servers where each server provides the same type of service and clients are getting a list of available servers, with distinctive names, chooses one of them and connects to it. As I understand this is the case for "terminators" so I created a local openziti network in docker, with one controller and one edge router, configured two service and client identities and run C SDK's example programs\sample-host\sample-host.c with supplying ".identity" in both ziti_listen_with_options() and ziti_dial_with_options() (which as I understand is the way to configure terminator's identity in the code and connect to it.
Now, I need to list all available terminators for the service, but I cannot find C SDK API for it. GO SDK has GetServiceTerminators() and I see it is calling to some HTTP endpoint? But I don't see anything related in C SDK. So, the question is, - how do I list all available terminators, for the service, using C SDK?
Hi @ikozhurin, welcome to the community and to OpenZiti! So very sorry but your post was flagged as spam. It's clearly not spam so I unflagged it. Discourse's spam-filter is a little tough on first-time posters sometimes!
It's an interesting question. If I understand correctly, it sounds like you want to show a list of clients that are available so that your user can pick the proper client. That does sound like something a terminator could be used for, yes. I don't know if there's a helper function in the CSDK for this yet.
@ekoby (or anyone else that might know), is this sort of functionality available?
Currently, there is no function for it. I added an issue
Can I implement one on my own? If there is another code in C SDK that calls to the similar controller's API I can follow it, if you point it out.
I am going to knock it off shortly.
Doing it outside of SDK code is more cumbersome because there several internal helper functions that make it easier to implement. But if you're curious, here is the outline of changes:
- define terminator model based on github.com/openziti/edge-api/client.yml (see
ziti_model.h
) - implement internal API
ziti_ctrl
function to make the REST request to/service/{id}/terminators
(seeziti_ctrl.c
) - expose it from the public API layer.
@ekoby thank you! I will watch the issue tracker
the issue is now fixed and API is available on main
@ekoby This was very fast, thanks! Got a question about controller connection/context, - I'm using initialization from ziti-sdk-c\programs\sample-host\sample-host.c like following:
DIE(ziti_load_config(&cfg, argv[2]));
DIE(ziti_context_init(&ztx, &cfg));
DIE(ziti_context_set_options(ztx, &(ziti_options){
.event_cb = on_ziti_init,
.events = ZitiContextEvent| ZitiServiceEvent,
}));
DIE(ziti_context_run(ztx, loop));
But, as I understand the test code, listing terminators requires controller connection:
REQUIRE(ziti_load_config(&config, conf) == ZITI_OK);
REQUIRE(load_tls(&config, &tls, &creds) == ZITI_OK);
REQUIRE(ziti_ctrl_init(loop, &ctrl, &config.controllers, tls) == ZITI_OK);
Is it a separate connection, which is not made on ziti_context_init() and should be managed as an additional connection?
Also, if ziti_controller is needed, it is not exposed externally?
the test is exercising internal code (ziti_controller is internal).
externally, you'd call ziti_list_terminators
declared here
@ekoby it all works, thanks!