svr->event_count = eina_list_append(svr->event_count, e);
_ecore_con_server_timer_update(svr);
e->server = svr;
+ if (svr->ecs)
+ {
+ svr->ecs_state = svr->ecs->lookup ? ECORE_CON_SOCKS_STATE_RESOLVED : ECORE_CON_SOCKS_STATE_DONE;
+ eina_stringshare_replace(&svr->proxyip, NULL);
+ svr->proxyport = 0;
+ }
ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
_ecore_con_event_server_del_free, NULL);
_ecore_con_event_count++;
e = ecore_con_event_server_write_alloc();
EINA_SAFETY_ON_NULL_RETURN(e);
+ INF("Wrote %d bytes", num);
svr->event_count = eina_list_append(svr->event_count, e);
e->server = svr;
e->size = num;
{
svr->handshaking = EINA_TRUE;
svr->ssl_state = ECORE_CON_SSL_STATE_INIT;
- DBG("beginning ssl handshake");
- if (ecore_con_ssl_server_init(svr))
+ DBG("%s ssl handshake", svr->ecs_state ? "Queuing" : "Beginning");
+ if ((!svr->ecs_state) && ecore_con_ssl_server_init(svr))
goto error;
}
if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED))
return;
- if (svr->handshaking)
+ if (svr->handshaking && (!svr->ecs_state))
{
DBG("Continuing ssl handshake");
if (!ecore_con_ssl_server_init(svr))
_ecore_con_server_timer_update(svr);
}
- if (!(svr->type & ECORE_CON_SSL))
+ if (svr->ecs_state || !(svr->type & ECORE_CON_SSL))
{
+ errno = 0;
num = read(svr->fd, buf, sizeof(buf));
/* 0 is not a valid return value for a tcp socket */
if ((num > 0) || ((num < 0) && (errno == EAGAIN)))
size_t buf_len, buf_offset;
const void *buf;
+ DBG("(svr=%p,buf=%p)", svr, svr->buf);
#ifdef _WIN32
if (ecore_con_local_win32_server_flush(svr))
return;
*/
if (num <= 0) return;
- if (svr->handshaking)
+ if ((!svr->ecs_state) && svr->handshaking)
{
DBG("Continuing ssl handshake");
if (ecore_con_ssl_server_init(svr))
return;
}
- if (!(svr->type & ECORE_CON_SSL))
+ if (svr->ecs_state || (!(svr->type & ECORE_CON_SSL)))
count = write(svr->fd, buf + buf_offset, num);
else
count = ecore_con_ssl_server_write(svr, buf + buf_offset, num);
ecore_con_event_proxy_bind(svr);
}
svr->ecs_state = ECORE_CON_SOCKS_STATE_DONE;
- INF("PROXY STATE++");
+ INF("PROXY CONNECTED");
if (svr->ecs_recvbuf) eina_binbuf_free(svr->ecs_recvbuf);
svr->ecs_recvbuf = NULL;
+ svr->ecs_buf_offset = svr->ecs_addrlen = 0;
+ memset(svr->ecs_addr, 0, sizeof(svr->ecs_addr));
ecore_con_event_server_add(svr);
+ if (svr->buf && eina_binbuf_length_get(svr->buf))
+ ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
}
return;
error:
if (!svr->ip) return EINA_FALSE;
if (svr->ecs_buf) return EINA_FALSE;
- if (svr->handshaking && svr->ssl_state) return EINA_FALSE;
if (svr->ecs_state != ECORE_CON_SOCKS_STATE_INIT) return EINA_FALSE;
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
if (v4)