/* Copyright (c) 2014 IOnU Security Inc. All rights reserved Created April 2014 by Kendrick Webster K2Client/servers.h - interface for server selection module Description: This module keeps track of the list of K2Daemon and K2Proxy servers and facilitates 'randomly' selecting the next server with which to attempt a connection. */ #pragma once /* non-zero if using K2Proxy (HTTP/TCP) instead of direct UDP connection with K2Daemon */ extern int is_using_proxy; /* Sets the list of servers to use. Example: "cg2.ionu.com,cg2.ionu.com:80,cg3.ionu.com:32000,cg3.ionu.com:80" Example: "10.200.1.81:32000,[2001:db8:1f70::999:de8:7648:6e8]:32000,2001:db8:1f70::999:de8:7648:6e8" Example: "http://ionu.com,https://ionu.com:443" Ports 80, 8080, 8888 indicate HTTP K2Proxy server, else UDP (K2Daemon), default port 32000 */ void set_servers(const char* servers_list); /* clears the server list, frees memory */ void clear_servers(void); /* Selects a server and calls with
= (struct sockaddr_in*) and = C string; Servers are chosen randomly, but preference is given to UDP (non proxy) servers. Thus the 'random' selection of a server first goes through a shuffled list of UDP hosts, then through a shuffled list of HTTP/TCP hosts. */ void select_server(void (*onServerSelected)(const void* address, const char* host));