@@ -52,6 +52,7 @@ status_t cli_core_set(ta_core_t* const core, int key, char* const value) {
52
52
#endif
53
53
char * strtol_p = NULL ;
54
54
long int strtol_temp ;
55
+ uint8_t idx ;
55
56
switch (key ) {
56
57
// TA configuration
57
58
case TA_HOST_CLI :
@@ -67,57 +68,33 @@ status_t cli_core_set(ta_core_t* const core, int key, char* const value) {
67
68
break ;
68
69
case TA_THREAD_COUNT_CLI :
69
70
strtol_temp = strtol (value , & strtol_p , 10 );
70
- if (strtol_p != value && errno != ERANGE && strtol_temp >= INT_MIN && strtol_temp <= INT_MAX ) {
71
- ta_conf -> thread_count = (int )strtol_temp ;
71
+ if (strtol_p != value && errno != ERANGE && strtol_temp >= 0 && strtol_temp <= UCHAR_MAX ) {
72
+ ta_conf -> thread_count = (uint8_t )strtol_temp ;
72
73
} else {
73
74
ta_log_error ("Malformed input or illegal input character\n" );
74
75
}
75
76
break ;
76
77
77
78
// IRI configuration
78
79
case IRI_HOST_CLI :
79
- iota_service -> http .host = value ;
80
- break ;
81
- case IRI_PORT_CLI :
82
- strtol_temp = strtol (value , & strtol_p , 10 );
83
- if (strtol_p != value && errno != ERANGE && strtol_temp >= INT_MIN && strtol_temp <= INT_MAX ) {
84
- iota_service -> http .port = (int )strtol_temp ;
85
- } else {
86
- ta_log_error ("Malformed input or illegal input character\n" );
80
+ idx = 0 ;
81
+ for (char * p = strtok (value , "," ); p && idx < MAX_IRI_LIST_ELEMENTS ; p = strtok (NULL , "," ), idx ++ ) {
82
+ ta_conf -> iota_host_list [idx ] = p ;
87
83
}
84
+ iota_service -> http .host = ta_conf -> iota_host_list [0 ];
88
85
break ;
89
- case IRI_ADDRESS_CLI :
90
- for (int i = 0 ; i < MAX_IRI_LIST_ELEMENTS ; i ++ ) {
91
- if (!ta_conf -> host_list [i ]) {
92
- char * host , * port ;
93
- host = strtok (value , ":" );
94
- port = strtok (NULL , "" );
95
- if (!port ) {
96
- ta_log_error ("Malformed input or illegal input character\n" );
97
- break ;
98
- }
99
-
100
- if (i == 0 ) {
101
- iota_service -> http .host = host ;
102
- strtol_temp = strtol (port , NULL , 10 );
103
- if (strtol_p != value && errno != ERANGE && strtol_temp >= INT_MIN && strtol_temp <= INT_MAX ) {
104
- iota_service -> http .port = (int )strtol_temp ;
105
- } else {
106
- ta_log_error ("Malformed input or illegal input character\n" );
107
- }
108
- }
109
- ta_conf -> host_list [i ] = host ;
110
- strtol_temp = strtol (port , NULL , 10 );
111
- if (strtol_p != value && errno != ERANGE && strtol_temp >= INT_MIN && strtol_temp <= INT_MAX ) {
112
- ta_conf -> port_list [i ] = (int )strtol_temp ;
113
- } else {
114
- ta_log_error ("Malformed input or illegal input character\n" );
115
- }
116
- break ;
86
+ case IRI_PORT_CLI :
87
+ idx = 0 ;
88
+ for (char * p = strtok (value , "," ); p && idx < MAX_IRI_LIST_ELEMENTS ; p = strtok (NULL , "," ), idx ++ ) {
89
+ strtol_temp = strtol (p , & strtol_p , 10 );
90
+ if (strtol_p != p && errno != ERANGE && strtol_temp >= 0 && strtol_temp <= USHRT_MAX ) {
91
+ ta_conf -> iota_port_list [idx ] = (uint16_t )strtol_temp ;
92
+ } else {
93
+ ta_log_error ("Malformed input or illegal input character\n" );
117
94
}
118
95
}
96
+ iota_service -> http .port = ta_conf -> iota_port_list [0 ];
119
97
break ;
120
-
121
98
case HEALTH_TRACK_PERIOD :
122
99
strtol_temp = strtol (value , NULL , 10 );
123
100
if (strtol_p != value && errno != ERANGE && strtol_temp >= INT_MIN && strtol_temp <= INT_MAX ) {
@@ -207,6 +184,7 @@ status_t cli_core_set(ta_core_t* const core, int key, char* const value) {
207
184
break ;
208
185
}
209
186
}
187
+
210
188
return SC_OK ;
211
189
}
212
190
@@ -228,8 +206,10 @@ status_t ta_core_default_init(ta_core_t* const core) {
228
206
ta_conf -> version = TA_VERSION ;
229
207
ta_conf -> host = TA_HOST ;
230
208
ta_conf -> port = TA_PORT ;
231
- memset (ta_conf -> host_list , 0 , sizeof (ta_conf -> host_list ));
232
- memset (ta_conf -> port_list , 0 , sizeof (ta_conf -> port_list ));
209
+ memset (ta_conf -> iota_host_list , 0 , sizeof (ta_conf -> iota_host_list ));
210
+ for (int i = 0 ; i < MAX_IRI_LIST_ELEMENTS ; i ++ ) {
211
+ ta_conf -> iota_port_list [i ] = IRI_PORT ;
212
+ }
233
213
ta_conf -> thread_count = TA_THREAD_COUNT ;
234
214
ta_conf -> proxy_passthrough = false;
235
215
ta_conf -> health_track_period = IRI_HEALTH_TRACK_PERIOD ;
0 commit comments