mirror of
https://github.com/bol-van/zapret2.git
synced 2026-09-02 07:11:31 +04:00
nfqws2: do not require / in the beginning of URI in http
This commit is contained in:
@@ -178,3 +178,8 @@ v0.8.1
|
|||||||
* nfqws2: alternative representation of payload filter in execution_plan item
|
* nfqws2: alternative representation of payload filter in execution_plan item
|
||||||
* nfqws2: --payload-disable
|
* nfqws2: --payload-disable
|
||||||
* nfqws2: gracefully shutdown on SIGINT and SIGTERM
|
* nfqws2: gracefully shutdown on SIGINT and SIGTERM
|
||||||
|
* nfqws2: harden wireguard detection. do not detect if reserved bytes 1..3 != 0
|
||||||
|
|
||||||
|
0.8.5
|
||||||
|
|
||||||
|
* nfqws2: do not require / in the beginning of URI in http
|
||||||
|
|||||||
+22
-8
@@ -243,24 +243,38 @@ void ResolveMultiPos(const uint8_t *data, size_t sz, t_l7payload l7payload, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *http_methods[] = { "GET /","POST /","HEAD /","OPTIONS ","PUT /","DELETE /","CONNECT ","TRACE /",NULL };
|
static const char *http_methods[] = { "GET ","POST ","HEAD ","OPTIONS ","PUT ","DELETE ","CONNECT ","TRACE ",NULL };
|
||||||
const char *HttpMethod(const uint8_t *data, size_t len)
|
static const char *HttpMethod(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
const char **method;
|
const char **method;
|
||||||
size_t method_len;
|
size_t method_len;
|
||||||
for (method = http_methods; *method; method++)
|
|
||||||
|
if (len>=4)
|
||||||
{
|
{
|
||||||
method_len = strlen(*method);
|
for (method = http_methods; *method; method++)
|
||||||
if (method_len <= len && !memcmp(data, *method, method_len))
|
{
|
||||||
return *method;
|
method_len = strlen(*method);
|
||||||
|
if (method_len <= len && !memcmp(data, *method, method_len))
|
||||||
|
return *method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
bool IsHttp(const uint8_t *data, size_t len)
|
bool IsHttp(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
return !!HttpMethod(data,len);
|
if (!HttpMethod(data,len)) return false;
|
||||||
|
// GET /uri HTTP/1.1
|
||||||
|
// skip method
|
||||||
|
for(; len && *data!=' ' && *data!='\t' && *data!='\r' && *data!='\n'; data++, len--);
|
||||||
|
if (!len || *data!=' ' && *data!='\t') return false;
|
||||||
|
for(; len && (*data==' '|| *data=='\t'); data++, len--);
|
||||||
|
// skip URI
|
||||||
|
for(; len && *data!=' ' && *data!='\t' && *data!='\r' && *data!='\n'; data++, len--);
|
||||||
|
if (!len || *data!=' ' && *data!='\t') return false;
|
||||||
|
for(; len && (*data==' '|| *data=='\t'); data++, len--);
|
||||||
|
if (len<10 || *data=='\r' || *data=='\n') return false;
|
||||||
|
return !memcmp(data,"HTTP/1.",7);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsHostAt(const uint8_t *p)
|
static bool IsHostAt(const uint8_t *p)
|
||||||
{
|
{
|
||||||
return \
|
return \
|
||||||
|
|||||||
@@ -90,8 +90,6 @@ ssize_t TLSPos(t_marker posmarker, int16_t pos, const uint8_t *data, size_t sz);
|
|||||||
ssize_t ResolvePos(const uint8_t *data, size_t sz, t_l7payload l7payload, const struct proto_pos *sp);
|
ssize_t ResolvePos(const uint8_t *data, size_t sz, t_l7payload l7payload, const struct proto_pos *sp);
|
||||||
void ResolveMultiPos(const uint8_t *data, size_t sz, t_l7payload l7payload, const struct proto_pos *marker, int marker_count, ssize_t *pos, int *pos_count);
|
void ResolveMultiPos(const uint8_t *data, size_t sz, t_l7payload l7payload, const struct proto_pos *marker, int marker_count, ssize_t *pos, int *pos_count);
|
||||||
|
|
||||||
extern const char *http_methods[9];
|
|
||||||
const char *HttpMethod(const uint8_t *data, size_t len);
|
|
||||||
bool IsHttp(const uint8_t *data, size_t len);
|
bool IsHttp(const uint8_t *data, size_t len);
|
||||||
bool HttpFindHost(uint8_t **pHost,uint8_t *buf,size_t bs);
|
bool HttpFindHost(uint8_t **pHost,uint8_t *buf,size_t bs);
|
||||||
// header must be passed like this : "\nHost:"
|
// header must be passed like this : "\nHost:"
|
||||||
|
|||||||
Reference in New Issue
Block a user