forked from enlightenment/efl
parent
4d50fdc728
commit
3fd0a6fb08
|
@ -65,10 +65,10 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup Ecore_Con_Events_Group Events
|
* @defgroup Ecore_Con_Events_Group Events
|
||||||
*
|
*
|
||||||
* @li ECORE_CON_CLIENT_ADD: Whenever a client connection is made to an
|
* @li ECORE_CON_CLIENT_ADD: Whenever a client connection is made to an
|
||||||
* @c Ecore_Con_Server, an event of this type is emitted, allowing the
|
* @c Ecore_Con_Server, an event of this type is emitted, allowing the
|
||||||
* retrieval of the client's ip with @ref ecore_con_client_ip_get and
|
* retrieval of the client's ip with @ref ecore_con_client_ip_get and
|
||||||
* associating data with the client using ecore_con_client_data_set.
|
* associating data with the client using ecore_con_client_data_set.
|
||||||
* @li ECORE_CON_EVENT_CLIENT_DEL: Whenever a client connection to an
|
* @li ECORE_CON_EVENT_CLIENT_DEL: Whenever a client connection to an
|
||||||
* @c Ecore_Con_Server, an event of this type is emitted. The contents of
|
* @c Ecore_Con_Server, an event of this type is emitted. The contents of
|
||||||
|
@ -282,7 +282,7 @@ EAPI extern int ECORE_CON_EVENT_CLIENT_ADD;
|
||||||
EAPI extern int ECORE_CON_EVENT_CLIENT_DEL;
|
EAPI extern int ECORE_CON_EVENT_CLIENT_DEL;
|
||||||
/** A server was created */
|
/** A server was created */
|
||||||
EAPI extern int ECORE_CON_EVENT_SERVER_ADD;
|
EAPI extern int ECORE_CON_EVENT_SERVER_ADD;
|
||||||
/** A server connection was lost */
|
/** A server connection was lost */
|
||||||
EAPI extern int ECORE_CON_EVENT_SERVER_DEL;
|
EAPI extern int ECORE_CON_EVENT_SERVER_DEL;
|
||||||
/** A client connected to the server has sent data */
|
/** A client connected to the server has sent data */
|
||||||
EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
|
EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ _ecore_con_client_free(Ecore_Con_Client *cl)
|
||||||
* the only example case I've found so far is if a client ssl handshakes
|
* the only example case I've found so far is if a client ssl handshakes
|
||||||
* and then immediately disconnects without sending any further data.
|
* and then immediately disconnects without sending any further data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* we lost our client! */
|
/* we lost our client! */
|
||||||
Ecore_Con_Event_Client_Del *e;
|
Ecore_Con_Event_Client_Del *e;
|
||||||
|
|
||||||
|
@ -1726,7 +1726,7 @@ _ecore_con_svr_tcp_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
|
||||||
if (new_fd < 0)
|
if (new_fd < 0)
|
||||||
/* error! */
|
/* error! */
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
if ((svr->client_limit >= 0) && (svr->reject_excess_clients) &&
|
if ((svr->client_limit >= 0) && (svr->reject_excess_clients) &&
|
||||||
(svr->client_count >= (unsigned int)svr->client_limit))
|
(svr->client_count >= (unsigned int)svr->client_limit))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -2155,7 +2155,7 @@ _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
|
|
||||||
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
|
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
|
||||||
_ecore_con_svr_cl_read(cl);
|
_ecore_con_svr_cl_read(cl);
|
||||||
|
|
||||||
else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE))
|
else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE))
|
||||||
_ecore_con_client_flush(cl);
|
_ecore_con_client_flush(cl);
|
||||||
|
|
||||||
|
@ -2374,4 +2374,3 @@ _ecore_con_lookup_done(void *data, Ecore_Con_Info *infos)
|
||||||
free(lk);
|
free(lk);
|
||||||
free(svr);
|
free(svr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,16 +246,16 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
||||||
{
|
{
|
||||||
if (result->ai_canonname)
|
if (result->ai_canonname)
|
||||||
canonname_len = strlen(result->ai_canonname) + 1;
|
canonname_len = strlen(result->ai_canonname) + 1;
|
||||||
|
|
||||||
tosend_len = sizeof(Ecore_Con_Info) + result->ai_addrlen +
|
tosend_len = sizeof(Ecore_Con_Info) + result->ai_addrlen +
|
||||||
canonname_len;
|
canonname_len;
|
||||||
|
|
||||||
if (!(tosend = alloca(tosend_len))) goto on_error;
|
if (!(tosend = alloca(tosend_len))) goto on_error;
|
||||||
memset(tosend, 0, tosend_len);
|
memset(tosend, 0, tosend_len);
|
||||||
|
|
||||||
container = (Ecore_Con_Info *)tosend;
|
container = (Ecore_Con_Info *)tosend;
|
||||||
container->size = tosend_len;
|
container->size = tosend_len;
|
||||||
|
|
||||||
memcpy(&container->info,
|
memcpy(&container->info,
|
||||||
result,
|
result,
|
||||||
sizeof(struct addrinfo));
|
sizeof(struct addrinfo));
|
||||||
|
@ -265,7 +265,7 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
||||||
memcpy(tosend + sizeof(Ecore_Con_Info) + result->ai_addrlen,
|
memcpy(tosend + sizeof(Ecore_Con_Info) + result->ai_addrlen,
|
||||||
result->ai_canonname,
|
result->ai_canonname,
|
||||||
canonname_len);
|
canonname_len);
|
||||||
|
|
||||||
if (!getnameinfo(result->ai_addr, result->ai_addrlen,
|
if (!getnameinfo(result->ai_addr, result->ai_addrlen,
|
||||||
hbuf, sizeof(hbuf), sbuf, sizeof(sbuf),
|
hbuf, sizeof(hbuf), sbuf, sizeof(sbuf),
|
||||||
NI_NUMERICHOST | NI_NUMERICSERV))
|
NI_NUMERICHOST | NI_NUMERICSERV))
|
||||||
|
@ -273,14 +273,14 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
||||||
memcpy(container->ip, hbuf, sizeof(container->ip));
|
memcpy(container->ip, hbuf, sizeof(container->ip));
|
||||||
memcpy(container->service, sbuf, sizeof(container->service));
|
memcpy(container->service, sbuf, sizeof(container->service));
|
||||||
}
|
}
|
||||||
|
|
||||||
err = write(fd[1], tosend, tosend_len);
|
err = write(fd[1], tosend, tosend_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
if (result)
|
if (result)
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
|
|
||||||
err = write(fd[1], "", 1);
|
err = write(fd[1], "", 1);
|
||||||
close(fd[1]);
|
close(fd[1]);
|
||||||
#ifdef __USE_ISOC99
|
#ifdef __USE_ISOC99
|
||||||
|
@ -289,7 +289,7 @@ on_error:
|
||||||
_exit(0);
|
_exit(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PARENT */
|
/* PARENT */
|
||||||
cbdata->handler =
|
cbdata->handler =
|
||||||
ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _ecore_con_info_exit_handler,
|
ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _ecore_con_info_exit_handler,
|
||||||
|
@ -302,7 +302,7 @@ on_error:
|
||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
info_slaves = (CB_Data *)eina_inlist_append(EINA_INLIST_GET(
|
info_slaves = (CB_Data *)eina_inlist_append(EINA_INLIST_GET(
|
||||||
info_slaves),
|
info_slaves),
|
||||||
EINA_INLIST_GET(cbdata));
|
EINA_INLIST_GET(cbdata));
|
||||||
|
@ -325,13 +325,13 @@ _ecore_con_info_readdata(CB_Data *cbdata)
|
||||||
{
|
{
|
||||||
torecv_len = container.size;
|
torecv_len = container.size;
|
||||||
torecv = malloc(torecv_len);
|
torecv = malloc(torecv_len);
|
||||||
|
|
||||||
memcpy(torecv, &container, sizeof(Ecore_Con_Info));
|
memcpy(torecv, &container, sizeof(Ecore_Con_Info));
|
||||||
|
|
||||||
size = read(ecore_main_fd_handler_fd_get(cbdata->fdh),
|
size = read(ecore_main_fd_handler_fd_get(cbdata->fdh),
|
||||||
torecv + sizeof(Ecore_Con_Info),
|
torecv + sizeof(Ecore_Con_Info),
|
||||||
torecv_len - sizeof(Ecore_Con_Info));
|
torecv_len - sizeof(Ecore_Con_Info));
|
||||||
if ((size > 0) &&
|
if ((size > 0) &&
|
||||||
((size_t)size == torecv_len - sizeof(Ecore_Con_Info)))
|
((size_t)size == torecv_len - sizeof(Ecore_Con_Info)))
|
||||||
{
|
{
|
||||||
recv = (Ecore_Con_Info *)torecv;
|
recv = (Ecore_Con_Info *)torecv;
|
||||||
|
@ -344,11 +344,11 @@ _ecore_con_info_readdata(CB_Data *cbdata)
|
||||||
(torecv + sizeof(Ecore_Con_Info) + recv->info.ai_addrlen);
|
(torecv + sizeof(Ecore_Con_Info) + recv->info.ai_addrlen);
|
||||||
else
|
else
|
||||||
recv->info.ai_canonname = NULL;
|
recv->info.ai_canonname = NULL;
|
||||||
|
|
||||||
recv->info.ai_next = NULL;
|
recv->info.ai_next = NULL;
|
||||||
|
|
||||||
cbdata->cb_done(cbdata->data, recv);
|
cbdata->cb_done(cbdata->data, recv);
|
||||||
|
|
||||||
free(torecv);
|
free(torecv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -356,7 +356,7 @@ _ecore_con_info_readdata(CB_Data *cbdata)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cbdata->cb_done(cbdata->data, NULL);
|
cbdata->cb_done(cbdata->data, NULL);
|
||||||
|
|
||||||
cbdata->cb_done = NULL;
|
cbdata->cb_done = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,7 @@ _ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr, int ssl_type)
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_server_credentials(&svr->anoncred_s));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_server_credentials(&svr->anoncred_s));
|
||||||
/* TODO: implement PSK */
|
/* TODO: implement PSK */
|
||||||
// SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_server_credentials(&svr->pskcred_s));
|
// SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_server_credentials(&svr->pskcred_s));
|
||||||
|
|
||||||
gnutls_anon_set_server_dh_params(svr->anoncred_s, svr->dh_params);
|
gnutls_anon_set_server_dh_params(svr->anoncred_s, svr->dh_params);
|
||||||
gnutls_certificate_set_dh_params(svr->cert, svr->dh_params);
|
gnutls_certificate_set_dh_params(svr->cert, svr->dh_params);
|
||||||
//gnutls_psk_set_server_dh_params(svr->pskcred_s, svr->dh_params);
|
//gnutls_psk_set_server_dh_params(svr->pskcred_s, svr->dh_params);
|
||||||
|
@ -316,7 +316,7 @@ _ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr, int ssl_type)
|
||||||
//SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_client_credentials(&svr->pskcred_c));
|
//SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_client_credentials(&svr->pskcred_c));
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_client_credentials(&svr->anoncred_c));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_client_credentials(&svr->anoncred_c));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -344,15 +344,15 @@ _ecore_con_ssl_server_init_gnutls(Ecore_Con_Server *svr)
|
||||||
#endif
|
#endif
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
const int mixed_proto[] =
|
const int mixed_proto[] =
|
||||||
{
|
{
|
||||||
#ifdef GNUTLS_VERSION_MAX
|
#ifdef GNUTLS_VERSION_MAX
|
||||||
GNUTLS_VERSION_MAX,
|
GNUTLS_VERSION_MAX,
|
||||||
#endif
|
#endif
|
||||||
GNUTLS_TLS1_1,
|
GNUTLS_TLS1_1,
|
||||||
GNUTLS_TLS1_0,
|
GNUTLS_TLS1_0,
|
||||||
GNUTLS_SSL3,
|
GNUTLS_SSL3,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (svr->type & ECORE_CON_USE_SSL2) /* not supported because of security issues */
|
if (svr->type & ECORE_CON_USE_SSL2) /* not supported because of security issues */
|
||||||
|
@ -397,14 +397,14 @@ _ecore_con_ssl_server_init_gnutls(Ecore_Con_Server *svr)
|
||||||
gnutls_dh_set_prime_bits(svr->session, 512);
|
gnutls_dh_set_prime_bits(svr->session, 512);
|
||||||
gnutls_transport_set_ptr(svr->session, (gnutls_transport_ptr_t)svr->fd);
|
gnutls_transport_set_ptr(svr->session, (gnutls_transport_ptr_t)svr->fd);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = gnutls_handshake(svr->session);
|
ret = gnutls_handshake(svr->session);
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_error_is_fatal(ret));
|
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_error_is_fatal(ret));
|
||||||
} while (ret < 0);
|
} while (ret < 0);
|
||||||
|
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
ERR("gnutls returned with error: %s - %s", gnutls_strerror_name(ret), gnutls_strerror(ret));
|
ERR("gnutls returned with error: %s - %s", gnutls_strerror_name(ret), gnutls_strerror(ret));
|
||||||
_ecore_con_ssl_server_shutdown_gnutls(svr);
|
_ecore_con_ssl_server_shutdown_gnutls(svr);
|
||||||
|
@ -562,14 +562,14 @@ _ecore_con_ssl_client_init_gnutls(Ecore_Con_Client *cl)
|
||||||
#endif
|
#endif
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
const int mixed_proto[] =
|
const int mixed_proto[] =
|
||||||
{
|
{
|
||||||
#ifdef GNUTLS_VERSION_MAX
|
#ifdef GNUTLS_VERSION_MAX
|
||||||
GNUTLS_VERSION_MAX,
|
GNUTLS_VERSION_MAX,
|
||||||
#endif
|
#endif
|
||||||
GNUTLS_TLS1_1,
|
GNUTLS_TLS1_1,
|
||||||
GNUTLS_TLS1_0,
|
GNUTLS_TLS1_0,
|
||||||
GNUTLS_SSL3,
|
GNUTLS_SSL3,
|
||||||
0 };
|
0 };
|
||||||
|
|
||||||
if (cl->host_server->type & ECORE_CON_USE_SSL2) /* not supported because of security issues */
|
if (cl->host_server->type & ECORE_CON_USE_SSL2) /* not supported because of security issues */
|
||||||
|
@ -602,7 +602,7 @@ _ecore_con_ssl_client_init_gnutls(Ecore_Con_Client *cl)
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_set_default_priority(cl->session));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_set_default_priority(cl->session));
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_protocol_set_priority(cl->session, proto));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_protocol_set_priority(cl->session, proto));
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_compression_set_priority(cl->session, compress));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_compression_set_priority(cl->session, compress));
|
||||||
|
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_ANON, cl->host_server->anoncred_s));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_ANON, cl->host_server->anoncred_s));
|
||||||
//SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_PSK, cl->host_server->pskcred_s));
|
//SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_PSK, cl->host_server->pskcred_s));
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_CERTIFICATE, cl->host_server->cert));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_CERTIFICATE, cl->host_server->cert));
|
||||||
|
@ -617,7 +617,7 @@ _ecore_con_ssl_client_init_gnutls(Ecore_Con_Client *cl)
|
||||||
gnutls_dh_set_prime_bits(cl->session, 2048);
|
gnutls_dh_set_prime_bits(cl->session, 2048);
|
||||||
gnutls_transport_set_ptr(cl->session, (gnutls_transport_ptr_t)cl->fd);
|
gnutls_transport_set_ptr(cl->session, (gnutls_transport_ptr_t)cl->fd);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = gnutls_handshake(cl->session);
|
ret = gnutls_handshake(cl->session);
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_error_is_fatal(ret));
|
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_error_is_fatal(ret));
|
||||||
|
@ -838,7 +838,7 @@ static Ecore_Con_Ssl_Error
|
||||||
_ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr)
|
_ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl = SSL_new(svr->ssl_ctx)));
|
SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl = SSL_new(svr->ssl_ctx)));
|
||||||
|
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(!SSL_set_fd(svr->ssl, svr->fd));
|
SSL_ERROR_CHECK_GOTO_ERROR(!SSL_set_fd(svr->ssl, svr->fd));
|
||||||
|
@ -1041,7 +1041,7 @@ _ecore_con_ssl_client_init_openssl(Ecore_Con_Client *cl)
|
||||||
int err = SSL_get_error(cl->ssl, ret);
|
int err = SSL_get_error(cl->ssl, ret);
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR((err == SSL_ERROR_SYSCALL) || (err == SSL_ERROR_SSL));
|
SSL_ERROR_CHECK_GOTO_ERROR((err == SSL_ERROR_SYSCALL) || (err == SSL_ERROR_SSL));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
Loading…
Reference in New Issue