Line data Source code
1 : #include "../../shared/fd_config.h"
2 : #include "../../shared/commands/run/run.h"
3 : #include "../../../disco/tiles.h"
4 : #include "../../../disco/topo/fd_topob.h"
5 :
6 : #include <unistd.h> /* pause */
7 :
8 : extern fd_topo_obj_callbacks_t * CALLBACKS[];
9 :
10 : fd_topo_run_tile_t
11 : fdctl_tile_run( fd_topo_tile_t const * tile );
12 :
13 : static void
14 0 : bundle_client_topo( config_t * config ) {
15 0 : fd_topo_t * topo = &config->topo;
16 0 : fd_topob_new( &config->topo, config->name );
17 0 : topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );
18 :
19 0 : fd_topob_wksp( topo, "metric_in" );
20 :
21 : /* Tiles */
22 :
23 0 : fd_topob_wksp( topo, "bundle" );
24 0 : fd_topo_tile_t * bundle_tile = fd_topob_tile( topo, "bundle", "bundle", "metric_in", ULONG_MAX, 0, 1 );
25 :
26 0 : fd_topob_wksp( topo, "sign" );
27 0 : fd_topo_tile_t * sign_tile = fd_topob_tile( topo, "sign", "sign", "metric_in", ULONG_MAX, 0, 1 );
28 :
29 0 : fd_topob_wksp( topo, "metric" );
30 0 : fd_topo_tile_t * metric_tile = fd_topob_tile( topo, "metric", "metric", "metric_in", ULONG_MAX, 0, 0 );
31 :
32 : /* Links */
33 :
34 0 : fd_topob_link( topo, "bundle_verif", "bundle", config->tiles.verify.receive_buffer_size, FD_TPU_PARSED_MTU, 1UL )
35 0 : ->permit_no_consumers = 1;
36 0 : fd_topob_link( topo, "bundle_sign", "bundle", 65536UL, 9UL, 1UL );
37 0 : fd_topob_link( topo, "sign_bundle", "bundle", 128UL, 64UL, 1UL );
38 :
39 0 : fd_topob_tile_out( topo, "bundle", 0UL, "bundle_verif", 0UL );
40 0 : fd_topob_tile_out( topo, "bundle", 0UL, "bundle_sign", 0UL );
41 0 : fd_topob_tile_out( topo, "sign", 0UL, "sign_bundle", 0UL );
42 0 : fd_topob_tile_in( topo, "bundle", 0UL, "metric_in", "sign_bundle", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_UNPOLLED );
43 0 : fd_topob_tile_in( topo, "sign", 0UL, "metric_in", "bundle_sign", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
44 :
45 : /* Tile config */
46 :
47 0 : strncpy( bundle_tile->bundle.url, config->tiles.bundle.url, sizeof(bundle_tile->bundle.url) );
48 0 : bundle_tile->bundle.url_len = strnlen( config->tiles.bundle.url, 255 );
49 0 : strncpy( bundle_tile->bundle.sni, config->tiles.bundle.tls_domain_name, 256 );
50 0 : bundle_tile->bundle.sni_len = strnlen( config->tiles.bundle.tls_domain_name, 255 );
51 0 : strncpy( bundle_tile->bundle.identity_key_path, config->paths.identity_key, sizeof(bundle_tile->bundle.identity_key_path) );
52 0 : strncpy( bundle_tile->bundle.key_log_path, config->development.bundle.ssl_key_log_file, sizeof(bundle_tile->bundle.key_log_path) );
53 0 : bundle_tile->bundle.buf_sz = config->development.bundle.buffer_size_kib<<10;
54 0 : bundle_tile->bundle.ssl_heap_sz = config->development.bundle.ssl_heap_size_mib<<20;
55 0 : bundle_tile->bundle.keepalive_interval_nanos = config->tiles.bundle.keepalive_interval_millis * (ulong)1e6;
56 0 : bundle_tile->bundle.tls_cert_verify = !!config->tiles.bundle.tls_cert_verify;
57 :
58 0 : strncpy( sign_tile->sign.identity_key_path, config->paths.identity_key, sizeof(sign_tile->sign.identity_key_path) );
59 :
60 0 : if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( config->tiles.metric.prometheus_listen_address, &metric_tile->metric.prometheus_listen_addr ) ) )
61 0 : FD_LOG_ERR(( "failed to parse prometheus listen address `%s`", config->tiles.metric.prometheus_listen_address ));
62 0 : metric_tile->metric.prometheus_listen_port = config->tiles.metric.prometheus_listen_port;
63 :
64 : /* Wrap up */
65 :
66 0 : fd_topob_finish( topo, CALLBACKS );
67 0 : fd_topo_print_log( /* stdout */ 1, topo );
68 0 : }
69 :
70 : static void
71 : bundle_client_cmd_args( int * pargc,
72 : char *** pargv,
73 0 : args_t * args ) {
74 0 : (void)pargc; (void)pargv; (void)args;
75 0 : }
76 :
77 : static void
78 : bundle_client_cmd_fn( args_t * args,
79 0 : config_t * config ) {
80 0 : (void)args;
81 0 : fd_topo_t * topo = &config->topo;
82 0 : bundle_client_topo( config );
83 0 : initialize_workspaces( config );
84 0 : initialize_stacks( config );
85 0 : fd_topo_join_workspaces( topo, FD_SHMEM_JOIN_MODE_READ_WRITE );
86 :
87 0 : fd_topo_run_single_process( topo, 2, config->uid, config->gid, fdctl_tile_run, NULL );
88 :
89 0 : for(;;) pause();
90 0 : }
91 :
92 : action_t fd_action_bundle_client = {
93 : .name = "bundle-client",
94 : .args = bundle_client_cmd_args,
95 : .fn = bundle_client_cmd_fn,
96 : .perm = NULL,
97 : .description = "Run bundle tile in isolation",
98 : .is_diagnostic = 1 /* allow running against live clusters */
99 : };
|