X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fmeshlink_internal.h;h=f9225ee5cca65f98ac29a71f0c883d2edfc1bcdf;hb=26fdd4fc9d2a2cc12b0118c3061a65ab3f3ee6c4;hp=dd8c7d329f38929e499d3c5b935ba2594d00862f;hpb=a5a8005b2d89712e124ab7295165a3e229abdad5;p=meshlink diff --git a/src/meshlink_internal.h b/src/meshlink_internal.h index dd8c7d32..f9225ee5 100644 --- a/src/meshlink_internal.h +++ b/src/meshlink_internal.h @@ -42,8 +42,8 @@ static const char meshlink_invitation_label[] = "MeshLink invitation"; static const char meshlink_tcp_label[] = "MeshLink TCP"; static const char meshlink_udp_label[] = "MeshLink UDP"; -#define MESHLINK_CONFIG_VERSION 1 -#define MESHLINK_INVITATION_VERSION 1 +#define MESHLINK_CONFIG_VERSION 2 +#define MESHLINK_INVITATION_VERSION 2 struct CattaServer; struct CattaSServiceBrowser; @@ -55,17 +55,8 @@ typedef struct listen_socket_t { struct io_t udp; sockaddr_t sa; sockaddr_t broadcast_sa; - bool bindto; } listen_socket_t; -typedef enum proxytype_t { - PROXY_NONE = 0, - PROXY_SOCKS4, - PROXY_SOCKS4A, - PROXY_SOCKS5, - PROXY_HTTP, -} proxytype_t; - struct meshlink_open_params { char *confbase; char *appname; @@ -82,6 +73,7 @@ struct meshlink_open_params { typedef struct { int pinginterval; int pingtimeout; + int fast_retry_period; unsigned int min_connects; unsigned int max_connects; int edge_weight; @@ -99,8 +91,10 @@ struct meshlink_handle { struct node_t *self; meshlink_log_cb_t log_cb; meshlink_log_level_t log_level; + void *packet; // The most important network-related members come first + int reachable; int listen_sockets; listen_socket_t listen_socket[MAXSOCKETS]; @@ -126,13 +120,14 @@ struct meshlink_handle { int contradicting_del_edge; int sleeptime; time_t connection_burst_time; - time_t last_config_check; time_t last_hard_try; + time_t last_unreachable; timeout_t pingtimer; timeout_t periodictimer; struct connection_t *everyone; uint64_t prng_state[4]; + uint32_t session_id; int next_pit; int pits[10]; @@ -164,12 +159,14 @@ struct meshlink_handle { bool default_blacklist; bool discovery; // Whether Catta is enabled or not - + bool inviter_commits_first; // Configuration char *confbase; - FILE *conffile; + FILE *lockfile; void *config_key; + char *external_address_url; + struct list_t *invitation_addresses; // Thread management pthread_t thread; @@ -188,23 +185,12 @@ struct meshlink_handle { char *catta_servicetype; unsigned int catta_interfaces; - // State used for meshlink_join() - int sock; - char cookie[18], hash[18]; - bool success; - sptps_t sptps; - char *data; - size_t thedatalen; - size_t blen; - char line[4096]; - char buffer[4096]; - - // Proxy configuration, currently not exposed. - char *proxyhost; - char *proxyport; - char *proxyuser; - char *proxypass; - proxytype_t proxytype; + // ADNS + pthread_t adns_thread; + pthread_cond_t adns_cond; + meshlink_queue_t adns_queue; + meshlink_queue_t adns_done_queue; + signal_t adns_signal; }; /// A handle for a MeshLink node. @@ -237,6 +223,7 @@ typedef struct meshlink_aio_buffer { struct meshlink_channel { struct node_t *node; void *priv; + bool in_callback; struct utcp_connection *c; meshlink_aio_buffer_t *aio_send; @@ -266,6 +253,6 @@ static inline int prng(meshlink_handle_t *mesh, uint64_t max) { } /// Fudge value of ~0.1 seconds, in microseconds. -static const unsigned int TIMER_FUDGE = 0x20000; +static const unsigned int TIMER_FUDGE = 0x8000000; #endif