定义future_result_t,整理ssl_stream.h
This commit is contained in:
@@ -8,8 +8,8 @@ enum e_future_error
|
|||||||
|
|
||||||
struct promise;
|
struct promise;
|
||||||
struct future;
|
struct future;
|
||||||
|
typedef void future_result_t;
|
||||||
typedef void (future_success_cb)(void * result, void * user);
|
typedef void (future_success_cb)(future_result_t* result, void * user);
|
||||||
typedef void (future_failed_cb)(enum e_future_error err, const char * what, void * user);
|
typedef void (future_failed_cb)(enum e_future_error err, const char * what, void * user);
|
||||||
typedef void (promise_ctx_destroy_cb)(struct promise * p);
|
typedef void (promise_ctx_destroy_cb)(struct promise * p);
|
||||||
|
|
||||||
|
|||||||
19
platform/include/internal/ssl_stream.h
Normal file
19
platform/include/internal/ssl_stream.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "tfe_future.h"
|
||||||
|
|
||||||
|
struct ssl_client_hello
|
||||||
|
{
|
||||||
|
int version;
|
||||||
|
char* sni;
|
||||||
|
char* cipher_suites;
|
||||||
|
};
|
||||||
|
struct ssl_client_hello* ssl_get_peek_result(future_result_t* result);
|
||||||
|
void ssl_free_peek_result(struct ssl_client_hello* client_hello);
|
||||||
|
void ssl_async_peek_client_hello(struct future* future, evutil_socket_t fd, struct event_base *evbase);
|
||||||
|
|
||||||
|
void ssl_async_connect_origin(struct future* future, const struct ssl_client_hello* client_hello, evutil_socket_t fd, const char* sni, struct event_base *evbase);
|
||||||
|
|
||||||
|
struct ssl_downstream * ssl_downstream_create();
|
||||||
|
void ssl_upstream_free(struct ssl_upstream * p);
|
||||||
|
void ssl_downstream_free(struct ssl_downstream * p);
|
||||||
|
|
||||||
@@ -116,11 +116,3 @@ struct tfe_stream_private * tfe_stream_create(evutil_socket_t fd_downstream, evu
|
|||||||
|
|
||||||
void tfe_stream_setup(struct tfe_stream_private * _stream);
|
void tfe_stream_setup(struct tfe_stream_private * _stream);
|
||||||
|
|
||||||
void ssl_async_connect_origin(struct future * future, evutil_socket_t fd, const char * sni,
|
|
||||||
struct event_base * evbase, struct tfe_config * opts);
|
|
||||||
|
|
||||||
void ssl_async_peek_sni(struct future * future, evutil_socket_t fd, struct event_base * evbase);
|
|
||||||
|
|
||||||
struct ssl_downstream * ssl_downstream_create();
|
|
||||||
void ssl_upstream_free(struct ssl_upstream * p);
|
|
||||||
void ssl_downstream_free(struct ssl_downstream * p);
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ struct peek_client_hello_ctx
|
|||||||
{
|
{
|
||||||
|
|
||||||
unsigned char sni_peek_retries; /* max 64 SNI parse retries */
|
unsigned char sni_peek_retries; /* max 64 SNI parse retries */
|
||||||
|
|
||||||
struct event* ev;
|
struct event* ev;
|
||||||
struct event_base* evbase;
|
struct event_base* evbase;
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ void peek_client_hello_ctx_free(void* ctx)
|
|||||||
free(_ctx);
|
free(_ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct ssl_client_hello* ssl_get_peek_result(void* result)
|
struct ssl_client_hello* ssl_get_peek_result(future_result_t* result)
|
||||||
{
|
{
|
||||||
struct ssl_client_hello* p=(struct ssl_client_hello* )result, *copy=NULL;
|
struct ssl_client_hello* p=(struct ssl_client_hello* )result, *copy=NULL;
|
||||||
copy=ALLOC(struct ssl_client_hello*,1);
|
copy=ALLOC(struct ssl_client_hello*,1);
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ void ssl_conn_origin_on_fail(enum e_future_error err, const char * what, void *
|
|||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void peek_sni_on_succ(void * result, void * user)
|
void peek_client_hello_on_succ(void * result, void * user)
|
||||||
{
|
{
|
||||||
struct tfe_stream_private * _stream = (struct tfe_stream_private *) user;
|
struct tfe_stream_private * _stream = (struct tfe_stream_private *) user;
|
||||||
assert(_stream->session_type == SESSION_PROTO_SSL);
|
assert(_stream->session_type == SESSION_PROTO_SSL);
|
||||||
@@ -475,7 +475,7 @@ void peek_sni_on_succ(void * result, void * user)
|
|||||||
_stream->thrmgr_ref->evbase, NULL);
|
_stream->thrmgr_ref->evbase, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void peek_sni_on_fail(enum e_future_error err, const char * what, void * user)
|
void peek_client_hello_on_fail(enum e_future_error err, const char * what, void * user)
|
||||||
{
|
{
|
||||||
//TODO:
|
//TODO:
|
||||||
assert(0);
|
assert(0);
|
||||||
@@ -501,8 +501,8 @@ void tfe_stream_setup(struct tfe_stream_private * _stream)
|
|||||||
case SESSION_PROTO_SSL:
|
case SESSION_PROTO_SSL:
|
||||||
// for SSL, defer dst connection setup to initial_readcb
|
// for SSL, defer dst connection setup to initial_readcb
|
||||||
_stream->ssl_downstream = ssl_downstream_create();
|
_stream->ssl_downstream = ssl_downstream_create();
|
||||||
_stream->async_future = future_create(peek_sni_on_succ, peek_sni_on_fail, _stream);
|
_stream->async_future = future_create(peek_client_hello_on_succ, peek_client_hello_on_fail, _stream);
|
||||||
ssl_async_peek_sni(_stream->ssl_downstream->future_sni_peek, _stream->fd_downstream,
|
ssl_async_peek_client_hello(_stream->ssl_downstream->future_sni_peek, _stream->fd_downstream,
|
||||||
_stream->thrmgr_ref->evbase);
|
_stream->thrmgr_ref->evbase);
|
||||||
thread->stat.value[SSL_NUM]++;
|
thread->stat.value[SSL_NUM]++;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user