mirror of
https://github.com/cesanta/mongoose.git
synced 2026-12-05 22:08:23 +00:00
sending 405 for proxy request if connect is not allowed
This commit is contained in:
1 parent
e0b9e4abfd
commit
ce60379af6
1 file changed
+9
-6
+9
-6
@@ -4200,7 +4200,6 @@ static void open_local_endpoint(struct connection *conn, int skip_user) {
|
|||||||
file_stat_t st;
|
file_stat_t st;
|
||||||
int exists = 0;
|
int exists = 0;
|
||||||
#endif
|
#endif
|
||||||
const char *pxy = conn->server->config_options[ENABLE_PROXY];
|
|
||||||
|
|
||||||
// If EP_USER was set in a prev call, reset it
|
// If EP_USER was set in a prev call, reset it
|
||||||
conn->endpoint_type = EP_NONE;
|
conn->endpoint_type = EP_NONE;
|
||||||
@@ -4229,10 +4228,14 @@ static void open_local_endpoint(struct connection *conn, int skip_user) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pxy != NULL && !strcmp(pxy, "yes") &&
|
if (strcmp(conn->mg_conn.request_method, "CONNECT") == 0 ||
|
||||||
(strcmp(conn->mg_conn.request_method, "CONNECT") == 0 ||
|
mg_strncasecmp(conn->mg_conn.uri, "http", 4) == 0) {
|
||||||
memcmp(conn->mg_conn.uri, "http", 4) == 0)) {
|
const char *enp = conn->server->config_options[ENABLE_PROXY];
|
||||||
proxify_connection(conn);
|
if (enp == NULL || strcmp(enp, "yes") != 0) {
|
||||||
|
send_http_error(conn, 405, NULL);
|
||||||
|
} else {
|
||||||
|
proxify_connection(conn);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4286,7 +4289,7 @@ static int is_valid_uri(const char *uri) {
|
|||||||
unsigned short n;
|
unsigned short n;
|
||||||
return uri[0] == '/' ||
|
return uri[0] == '/' ||
|
||||||
strcmp(uri, "*") == 0 || // OPTIONS method can use asterisk URI
|
strcmp(uri, "*") == 0 || // OPTIONS method can use asterisk URI
|
||||||
memcmp(uri, "http", 4) == 0 || // Naive check for the absolute URI
|
mg_strncasecmp(uri, "http", 4) == 0 || // Naive check for the absolute URI
|
||||||
sscanf(uri, "%*[^ :]:%hu", &n) > 0; // CONNECT method can use host:port
|
sscanf(uri, "%*[^ :]:%hu", &n) > 0; // CONNECT method can use host:port
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user