Line data Source code
1 : #include "../../shared/fd_config.h"
2 : #include "../../shared/commands/run/run.h"
3 : #include "../../../disco/topo/fd_topob.h"
4 : #include "../../../disco/fd_txn_m.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, 0 );
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, 0 );
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, 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.out_depth = config->tiles.verify.receive_buffer_size;
55 0 : bundle_tile->bundle.ssl_heap_sz = config->development.bundle.ssl_heap_size_mib<<20;
56 0 : bundle_tile->bundle.keepalive_interval_nanos = config->tiles.bundle.keepalive_interval_millis * (ulong)1e6;
57 0 : bundle_tile->bundle.tls_cert_verify = !!config->tiles.bundle.tls_cert_verify;
58 :
59 0 : strncpy( sign_tile->sign.identity_key_path, config->paths.identity_key, sizeof(sign_tile->sign.identity_key_path) );
60 :
61 0 : if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( config->tiles.metric.prometheus_listen_address, &metric_tile->metric.prometheus_listen_addr ) ) )
62 0 : FD_LOG_ERR(( "failed to parse prometheus listen address `%s`", config->tiles.metric.prometheus_listen_address ));
63 0 : metric_tile->metric.prometheus_listen_port = config->tiles.metric.prometheus_listen_port;
64 :
65 : /* Wrap up */
66 :
67 0 : fd_topob_finish( topo, CALLBACKS );
68 0 : fd_topo_print_log( /* stdout */ 1, topo );
69 0 : }
70 :
71 : static void
72 : bundle_client_cmd_args( int * pargc,
73 : char *** pargv,
74 0 : args_t * args ) {
75 0 : (void)pargc; (void)pargv; (void)args;
76 0 : }
77 :
78 : static void
79 : bundle_client_cmd_fn( args_t * args,
80 0 : config_t * config ) {
81 0 : (void)args;
82 0 : fd_topo_t * topo = &config->topo;
83 0 : bundle_client_topo( config );
84 0 : initialize_workspaces( config );
85 0 : initialize_stacks( config );
86 0 : fd_topo_join_workspaces( topo, FD_SHMEM_JOIN_MODE_READ_WRITE, FD_TOPO_CORE_DUMP_LEVEL_DISABLED );
87 :
88 0 : fd_topo_run_single_process( topo, 2, config->uid, config->gid, fdctl_tile_run );
89 :
90 0 : for(;;) pause();
91 0 : }
92 :
93 : action_t fd_action_bundle_client = {
94 : .name = "bundle-client",
95 : .args = bundle_client_cmd_args,
96 : .fn = bundle_client_cmd_fn,
97 : .perm = NULL,
98 : .description = "Run bundle tile in isolation",
99 : .is_diagnostic = 1 /* allow running against live clusters */
100 : };
|