mod_proxy_wstunnel.c revision 17b8f879f5db1528f12cd7610bccf5cd1bad5c25
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mod_proxy.h"
#include "ap_mpm.h"
typedef struct ws_baton_t {
request_rec *r;
int is_client;
} ws_baton_t;
int client_error = 0;
request_rec *r = baton->r;
conn_rec *c = r->connection;
const apr_pollfd_t *signalled;
while(1) {
!= APR_SUCCESS) {
if (APR_STATUS_IS_EINTR(rv)) {
continue;
}
else if (APR_STATUS_IS_TIMEUP(rv)) {
return SUSPENDED;
}
else {
return HTTP_INTERNAL_SERVER_ERROR;
}
}
"woke from poll(), i=%d", pollcnt);
if (pollevent & APR_POLLIN) {
"sock was readable");
}
else if ((pollevent & APR_POLLERR)
|| (pollevent & APR_POLLHUP)) {
}
if (rv != APR_SUCCESS)
client_error = 1;
}
if (pollevent & APR_POLLIN) {
"client was readable");
}
}
else {
"unknown socket in pollset");
}
}
if (rv != APR_SUCCESS) {
break;
}
}
"finished with poll() - cleaning up");
if (client_error) {
return HTTP_INTERNAL_SERVER_ERROR;
}
return OK;
}
static void proxy_wstunnel_callback(void *b) {
int status;
}
else {
return;
}
}
/*
* Canonicalise http-like URLs.
* scheme is the scheme for the URL
* url is the URL starting with the first '/'
* def_port is the default port for this scheme.
*/
{
const char *err;
char *scheme;
/* ap_port_of_scheme() */
url += 3;
scheme = "ws:";
}
url += 4;
scheme = "wss:";
}
else {
return DECLINED;
}
/*
* do syntactic check.
* We break the URL into host, port, path, search
*/
if (err) {
return HTTP_BAD_REQUEST;
}
/*
* process the path. With proxy-nocanon set (by
* mod_proxy) we use the raw, unparsed uri
*/
}
else {
r->proxyreq);
}
return HTTP_BAD_REQUEST;
/* if literal IPv6 address */
}
return OK;
}
{
int rv;
#ifdef DEBUGGING
#endif
do {
if (rv == APR_SUCCESS) {
return APR_EPIPE;
if (APR_BRIGADE_EMPTY(bb))
break;
#ifdef DEBUGGING
len = -1;
"read %" APR_OFF_T_FMT
#endif
if (rv == APR_SUCCESS) {
}
else {
"error on %s - ap_pass_brigade",
name);
}
"error on %s - ap_get_brigade",
name);
}
} while (rv == APR_SUCCESS);
if (APR_STATUS_IS_EAGAIN(rv)) {
rv = APR_SUCCESS;
}
return rv;
}
/* Search thru the input filters and remove the reqtimeout one */
{
if (!filter) {
return;
}
while (next) {
break;
}
}
if (reqto) {
}
}
/*
* process the request and write the response.
*/
char *url, char *server_portstr)
{
conn_rec *c = r->connection;
char *buf;
apr_bucket *e;
char *old_cl_val = NULL;
char *old_te_val = NULL;
int status;
&old_cl_val, &old_te_val);
return rv;
}
return rv;
"error apr_pollset_create()");
return HTTP_INTERNAL_SERVER_ERROR;
}
#if 0
#endif
pollfd.p = p;
r->output_filters = c->output_filters;
r->proto_output_filters = c->output_filters;
r->input_filters = c->input_filters;
r->proto_input_filters = c->input_filters;
baton->r = r;
status = ap_mpm_register_socket_callback(sockets, baton->subpool, 1, proxy_wstunnel_callback, baton);
if (status == APR_SUCCESS) {
return SUSPENDED;
}
else if (status == APR_ENOTIMPL) {
}
else {
"error creating websockets tunnel");
return HTTP_INTERNAL_SERVER_ERROR;
}
}
return status;
}
/*
*/
{
int status;
char server_portstr[32];
char *scheme;
int retry;
conn_rec *c = r->connection;
apr_pool_t *p = r->pool;
scheme = "WSS";
}
scheme = "WS";
}
else {
return DECLINED;
}
/* create space for state information */
r->server);
if (backend) {
}
return status;
}
retry = 0;
while (retry < 2) {
/* Step One: Determine Who To Connect To */
sizeof(server_portstr));
break;
/* Step Two: Make the Connection */
"failed to make connection to backend: %s",
break;
}
/* Step Three: Create conn_rec */
if (!backend->connection) {
break;
}
/* Step Three: Process the Request */
break;
}
/* Do not close the socket */
}
return status;
}
static void ap_proxy_http_register_hook(apr_pool_t *p)
{
}
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command apr_table_t */
ap_proxy_http_register_hook /* register hooks */
};