Skip to content
Snippets Groups Projects
Commit e1549971 authored by alexander.lysikov's avatar alexander.lysikov
Browse files

fixed bug with a foreign continent in the server "auto"

parent ead0d836
No related branches found
No related tags found
1 merge request!90fixed bug with a foreign continent in the server "auto"
...@@ -156,7 +156,7 @@ static void s_http_simple_proc(dap_http_simple_t *a_http_simple, void *a_arg) ...@@ -156,7 +156,7 @@ static void s_http_simple_proc(dap_http_simple_t *a_http_simple, void *a_arg)
dap_string_t *l_reply_str = dap_string_new("[\n"); dap_string_t *l_reply_str = dap_string_new("[\n");
char *l_client_ip = a_http_simple->http->client->s_ip;//"77.222.110.44" char *l_client_ip = a_http_simple->http->client->s_ip;//"64.225.61.216"
geoip_info_t *l_geoip_info = chain_net_geoip_get_ip_info(l_client_ip); geoip_info_t *l_geoip_info = chain_net_geoip_get_ip_info(l_client_ip);
log_it(L_DEBUG, "Have %zd chain networks for cdb lists", s_cdb_net_count ); log_it(L_DEBUG, "Have %zd chain networks for cdb lists", s_cdb_net_count );
...@@ -232,28 +232,39 @@ static void s_http_simple_proc(dap_http_simple_t *a_http_simple, void *a_arg) ...@@ -232,28 +232,39 @@ static void s_http_simple_proc(dap_http_simple_t *a_http_simple, void *a_arg)
int8_t l_client_continent = l_geoip_info ? dap_chain_net_srv_order_continent_to_num(l_geoip_info->continent) : 0; int8_t l_client_continent = l_geoip_info ? dap_chain_net_srv_order_continent_to_num(l_geoip_info->continent) : 0;
// random node on client's continent // random node on client's continent
if (l_client_continent) { if(l_client_continent > 0 && l_continents_numbers[l_client_continent] > 1) {
int l_count = 0; int l_count = 0;
while (l_orders_num > 0) { while(l_orders_num > 0) {
size_t k = rand() % l_continents_numbers[l_client_continent]; size_t k = rand() % l_continents_numbers[l_client_continent];
dap_chain_net_srv_order_t *l_order = l_orders_pos[k]; size_t l_node_pos = -1;
const char *country_code = dap_chain_net_srv_order_get_country_code(l_order); for(size_t j2 = 0; j2 <= l_orders_num; j2++) {
if (country_code) { if(k == l_node_numbering[l_client_continent][j2]) {
// only for other countries l_node_pos = j2;
if (dap_strcmp(l_geoip_info->country_code, country_code)){ break;
if (!order_info_print(l_reply_str, l_net, l_order, "Auto", -1)) { }
dap_string_append_printf(l_reply_str, ",\n"); }
break; if(l_node_pos == -1) {
} // random node for the whole world
} l_node_pos = rand() % l_orders_num;
} }
if (l_count > 20) dap_chain_net_srv_order_t *l_order = l_orders_pos[l_node_pos];
break; const char *country_code = dap_chain_net_srv_order_get_country_code(l_order);
l_count++; if(country_code) {
} // only for other countries
if(dap_strcmp(l_geoip_info->country_code, country_code)) {
if(!order_info_print(l_reply_str, l_net, l_order, "Auto", -1)) {
dap_string_append_printf(l_reply_str, ",\n");
break;
}
}
}
if(l_count > 20)
break;
l_count++;
}
} }
// random node for the whole world // random node for the whole world
else { else {
int l_count = 0; int l_count = 0;
while(l_orders_num > 0) { while(l_orders_num > 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment