Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement websocket boostrapping for http2 #1604

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,9 @@ tfw_handle_validation_req(TfwHttpReq *req, TfwCacheEntry *ce)
if ((ce->resp_status != 200) && (ce->resp_status != 206))
return true;
/* RFC 7232 Section 5. */
/* TODO: Add CONNECT */
if ((req->method == TFW_HTTP_METH_OPTIONS)
|| (req->method == TFW_HTTP_METH_TRACE))
|| (req->method == TFW_HTTP_METH_TRACE)
|| (req->method == TFW_HTTP_METH_CONNECT))
return true;

/* If-None-Match: */
Expand Down
2 changes: 1 addition & 1 deletion fw/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ tfw_connection_recv(TfwConn *conn, struct sk_buff *skb)
skb->next = skb->prev = NULL;
if (unlikely(TFW_CONN_PROTO(conn) == TFW_FSM_WS
|| TFW_CONN_PROTO(conn) == TFW_FSM_WSS))
r = tfw_ws_msg_process(conn, skb);
r = tfw_ws_msg_process(conn, &conn->stream, skb);
else
r = tfw_http_msg_process(conn, skb);
} else {
Expand Down
15 changes: 13 additions & 2 deletions fw/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ enum {

#define TFW_CONN_TYPE2IDX(t) TFW_FSM_TYPE(t)

/**
* Paired connection for websocket protocol implementation.
*
* @conn - TfwCliConn or TfwSrvConn paired connection;
* @stream - stream for http/2 websocket multiplexing or NULL
*/
typedef struct tfw_pair_conn_t {
TfwConn *conn;
TfwStream *stream;
} TfwPairConn;

/**
* Session/Presentation layer (in OSI terms) handling.
*
Expand Down Expand Up @@ -94,7 +105,7 @@ enum {
* @timer - The keep-alive/retry timer for the connection;
* @stream - instance for control messages processing;
* @peer - TfwClient or TfwServer handler. Hop-by-hop peer;
* @pair - Paired TfwCliConn or TfwSrvConn for websocket connections;
* @pair - paired connection for websocket protocol case;
* @sk - an appropriate sock handler;
* @destructor - called when a connection is destroyed;
*/
Expand All @@ -107,7 +118,7 @@ typedef struct tfw_conn_t TfwConn;
struct timer_list timer; \
TfwStream stream; \
TfwPeer *peer; \
TfwConn *pair; \
TfwPairConn pair; \
struct sock *sk; \
void (*destructor)(void *);

Expand Down
1 change: 1 addition & 0 deletions fw/hpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ typedef enum {
TFW_TAG_HDR_H2_SCHEME,
TFW_TAG_HDR_H2_AUTHORITY,
TFW_TAG_HDR_H2_PATH,
TFW_TAG_HDR_H2_PROTOCOL,
TFW_TAG_HDR_ACCEPT,
TFW_TAG_HDR_AUTHORIZATION,
TFW_TAG_HDR_CACHE_CONTROL,
Expand Down
Loading