added QSE_HTTPD_RSRC_PROXY_ALLOW_UPGRADE and related code with it
This commit is contained in:
parent
0cee2a3614
commit
65f3c473f9
@ -189,8 +189,9 @@ struct loccfg_t
|
||||
unsigned int allow_http: 1;
|
||||
unsigned int allow_connect: 1;
|
||||
unsigned int allow_intercept: 1;
|
||||
unsigned int allow_upgrade: 1;
|
||||
unsigned int dns_enabled: 1;
|
||||
unsigned int urs_enabled: 2;
|
||||
unsigned int urs_enabled: 1;
|
||||
qse_nwad_t dns_nwad; /* TODO: multiple dns */
|
||||
qse_nwad_t urs_nwad; /* TODO: multiple urs */
|
||||
int dns_timeout;
|
||||
@ -228,8 +229,7 @@ struct server_xtn_t
|
||||
qse_httpd_serverstd_freersrc_t orgfreersrc;
|
||||
qse_httpd_serverstd_query_t orgquery;
|
||||
|
||||
|
||||
qse_htb_t* cfgtab;
|
||||
qse_htb_t* cfgtab; /* key: host name, value: server_hostcfg_t */
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
@ -371,14 +371,14 @@ int cl_i = 0;
|
||||
system ("printenv");
|
||||
cl = getenv("CONTENT_LENGTH");
|
||||
if (cl) cl_i = atoi(cl);
|
||||
//if (cl_i)
|
||||
//{
|
||||
/*if (cl_i)
|
||||
{ */
|
||||
while (fgets (buf, sizeof(buf), stdin) != NULL)
|
||||
{
|
||||
printf ("%s", buf);
|
||||
}
|
||||
//}
|
||||
// system ("while read xxx; do echo $xxx; done; echo 123 456 789");
|
||||
/*}
|
||||
system ("while read xxx; do echo $xxx; done; echo 123 456 789");*/
|
||||
printf ("</pre></body></html>\n");
|
||||
|
||||
return 0;
|
||||
@ -614,6 +614,11 @@ proxy_ok:
|
||||
root->u.proxy.urs_prerewrite_mod = loccfg->proxy.urs_prerewrite_mod;
|
||||
}
|
||||
|
||||
if (loccfg->proxy.allow_upgrade)
|
||||
{
|
||||
root->u.proxy.flags |= QSE_HTTPD_RSRC_PROXY_ALLOW_UPGRADE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1436,7 +1441,6 @@ static int load_loccfg_access (qse_httpd_t* httpd, qse_xli_t* xli, qse_xli_list_
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int load_loccfg_proxy (qse_httpd_t* httpd, qse_xli_t* xli, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
{
|
||||
qse_xli_pair_t* pair;
|
||||
@ -1472,6 +1476,11 @@ static int load_loccfg_proxy (qse_httpd_t* httpd, qse_xli_t* xli, qse_xli_list_t
|
||||
if (!pair && default_proxy) pair = qse_xli_findpair (xli, default_proxy, QSE_T("intercept"));
|
||||
if (pair) cfg->proxy.allow_intercept = get_boolean ((qse_xli_str_t*)pair->val);
|
||||
|
||||
pair = QSE_NULL;
|
||||
if (proxy) pair = qse_xli_findpair (xli, proxy, QSE_T("upgrade"));
|
||||
if (!pair && default_proxy) pair = qse_xli_findpair (xli, default_proxy, QSE_T("upgrade"));
|
||||
if (pair) cfg->proxy.allow_upgrade = get_boolean ((qse_xli_str_t*)pair->val);
|
||||
|
||||
pair = QSE_NULL;
|
||||
if (proxy) pair = qse_xli_findpair (xli, proxy, QSE_T("pseudonym"));
|
||||
if (!pair && default_proxy) pair = qse_xli_findpair (xli, default_proxy, QSE_T("pseudonym"));
|
||||
@ -1949,6 +1958,7 @@ static int open_config_file (qse_httpd_t* httpd)
|
||||
{ QSE_T("server-default.proxy.http"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server-default.proxy.connect"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server-default.proxy.intercept"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server-default.proxy.upgrade"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server-default.proxy.pseudonym"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server-default.proxy.dns-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server-default.proxy.dns-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
@ -2005,6 +2015,7 @@ static int open_config_file (qse_httpd_t* httpd)
|
||||
{ QSE_T("server.host.location.proxy.http"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server.host.location.proxy.connect"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server.host.location.proxy.intercept"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server.host.location.proxy.upgrade"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server.host.location.proxy.pseudonym"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server.host.location.proxy.dns-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
{ QSE_T("server.host.location.proxy.dns-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||
|
@ -136,6 +136,7 @@ server-default {
|
||||
http = yes;
|
||||
connect = yes;
|
||||
intercept = yes;
|
||||
upgrade = yes;
|
||||
|
||||
#pseudonym = "nice-host";
|
||||
|
||||
|
@ -769,11 +769,12 @@ enum qse_httpd_rsrc_proxy_flag_t
|
||||
{
|
||||
QSE_HTTPD_RSRC_PROXY_RAW = (1 << 0), /* raw proxying. set this for CONNECT */
|
||||
QSE_HTTPD_RSRC_PROXY_TRANSPARENT = (1 << 1),
|
||||
QSE_HTTPD_RSRC_PROXY_DST_STR = (1 << 2), /* destination is an unresovled string pointed to by dst.str */
|
||||
QSE_HTTPD_RSRC_PROXY_ENABLE_DNS = (1 << 3), /* dns service enabled (udp) */
|
||||
QSE_HTTPD_RSRC_PROXY_ENABLE_URS = (1 << 4), /* url rewriting enabled (udp) */
|
||||
QSE_HTTPD_RSRC_PROXY_DNS_SERVER = (1 << 5), /* dns address specified */
|
||||
QSE_HTTPD_RSRC_PROXY_URS_SERVER = (1 << 6), /* urs address specified */
|
||||
QSE_HTTPD_RSRC_PROXY_ALLOW_UPGRADE = (1 << 2),
|
||||
QSE_HTTPD_RSRC_PROXY_DST_STR = (1 << 3), /* destination is an unresovled string pointed to by dst.str */
|
||||
QSE_HTTPD_RSRC_PROXY_ENABLE_DNS = (1 << 4), /* dns service enabled (udp) */
|
||||
QSE_HTTPD_RSRC_PROXY_ENABLE_URS = (1 << 5), /* url rewriting enabled (udp) */
|
||||
QSE_HTTPD_RSRC_PROXY_DNS_SERVER = (1 << 6), /* dns address specified */
|
||||
QSE_HTTPD_RSRC_PROXY_URS_SERVER = (1 << 7), /* urs address specified */
|
||||
};
|
||||
typedef enum qse_httpd_rsrc_proxy_flag_t qse_httpd_rsrc_proxy_flag_t;
|
||||
|
||||
@ -828,7 +829,7 @@ typedef enum qse_httpd_rsrc_reloc_flag_t qse_httpd_rsrc_reloc_flag_t;
|
||||
typedef struct qse_httpd_rsrc_reloc_t qse_httpd_rsrc_reloc_t;
|
||||
struct qse_httpd_rsrc_reloc_t
|
||||
{
|
||||
int flags;
|
||||
int flags; /**< 0 or bitwise-ORed of #qse_httpd_rsrc_reloc_flag_t */
|
||||
const qse_mchar_t* dst;
|
||||
};
|
||||
|
||||
@ -836,7 +837,7 @@ typedef struct qse_httpd_rsrc_t qse_httpd_rsrc_t;
|
||||
struct qse_httpd_rsrc_t
|
||||
{
|
||||
qse_httpd_rsrc_type_t type;
|
||||
int flags; /**< bitwised-ORed of #qse_httpd_rsrc_flag_t */
|
||||
int flags; /**< 0 or bitwise-ORed of #qse_httpd_rsrc_flag_t */
|
||||
union
|
||||
{
|
||||
struct
|
||||
|
@ -42,6 +42,7 @@ enum qse_httpd_serverstd_root_type_t
|
||||
QSE_HTTPD_SERVERSTD_ROOT_PATH,
|
||||
QSE_HTTPD_SERVERSTD_ROOT_TEXT,
|
||||
QSE_HTTPD_SERVERSTD_ROOT_PROXY,
|
||||
QSE_HTTPD_SERVERSTD_ROOT_RELOC,
|
||||
QSE_HTTPD_SERVERSTD_ROOT_ERROR
|
||||
};
|
||||
typedef enum qse_httpd_serverstd_root_type_t qse_httpd_serverstd_root_type_t;
|
||||
@ -65,6 +66,7 @@ struct qse_httpd_serverstd_root_t
|
||||
} text;
|
||||
|
||||
qse_httpd_rsrc_proxy_t proxy;
|
||||
qse_httpd_rsrc_reloc_t reloc;
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -56,9 +56,10 @@ struct task_proxy_t
|
||||
#define PROXY_X_FORWARDED_FOR (1 << 15) /* X-Forwarded-For: added */
|
||||
#define PROXY_VIA (1 << 16) /* Via: added to the request */
|
||||
#define PROXY_VIA_RETURNING (1 << 17) /* Via: added to the response */
|
||||
#define PROXY_UPGRADE_REQUESTED (1 << 18)
|
||||
#define PROXY_PROTOCOL_SWITCHED (1 << 19)
|
||||
#define PROXY_GOT_BAD_REQUEST (1 << 20)
|
||||
#define PROXY_ALLOW_UPGRADE (1 << 18)
|
||||
#define PROXY_UPGRADE_REQUESTED (1 << 19)
|
||||
#define PROXY_PROTOCOL_SWITCHED (1 << 20)
|
||||
#define PROXY_GOT_BAD_REQUEST (1 << 21)
|
||||
int flags;
|
||||
qse_httpd_t* httpd;
|
||||
qse_httpd_client_t* client;
|
||||
@ -977,6 +978,7 @@ static int task_init_proxy (
|
||||
|
||||
if (arg->rsrc->flags & QSE_HTTPD_RSRC_PROXY_RAW) proxy->flags |= PROXY_RAW;
|
||||
if (arg->rsrc->flags & QSE_HTTPD_RSRC_PROXY_TRANSPARENT) proxy->flags |= PROXY_TRANSPARENT;
|
||||
if (arg->rsrc->flags & QSE_HTTPD_RSRC_PROXY_ALLOW_UPGRADE) proxy->flags |= PROXY_ALLOW_UPGRADE;
|
||||
|
||||
proxy->peer.local = arg->rsrc->src.nwad;
|
||||
if (arg->rsrc->flags & QSE_HTTPD_RSRC_PROXY_DST_STR)
|
||||
@ -1278,7 +1280,7 @@ qse_mbs_ncat (proxy->reqfwdbuf, spc, QSE_COUNTOF(spc));
|
||||
snatch_needed = 1;
|
||||
}
|
||||
|
||||
if (qse_htre_getheaderval(arg->req, QSE_MT("Upgrade")))
|
||||
if ((proxy->flags & PROXY_ALLOW_UPGRADE) && qse_htre_getheaderval(arg->req, QSE_MT("Upgrade")))
|
||||
{
|
||||
/* Upgrade: is found in the request header */
|
||||
const qse_htre_hdrval_t* hv;
|
||||
|
@ -2814,6 +2814,11 @@ static int make_resource (
|
||||
req->flags |= QSE_HTRE_ATTR_PROXIED;
|
||||
return 0;
|
||||
|
||||
case QSE_HTTPD_SERVERSTD_ROOT_RELOC:
|
||||
target->type = QSE_HTTPD_RSRC_RELOC;
|
||||
target->u.reloc = tmp.root.u.reloc;
|
||||
return 0;
|
||||
|
||||
case QSE_HTTPD_SERVERSTD_ROOT_ERROR:
|
||||
target->type = QSE_HTTPD_RSRC_ERROR;
|
||||
target->u.error.code = tmp.root.u.error.code;
|
||||
|
Loading…
Reference in New Issue
Block a user