This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
267 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8; -*- | ||
|
||
from httpolice.citation import RFC | ||
from httpolice.known.base import KnownDict | ||
from httpolice.structure import ForwardedParam | ||
from httpolice.syntax import rfc3986, rfc7230, rfc7239 | ||
|
||
|
||
def argument_required(_): # pragma: no cover | ||
return True | ||
|
||
def no_argument(_): | ||
return False | ||
|
||
def parser_for(name): | ||
return known.get_info(name).get('parser') | ||
|
||
|
||
known = KnownDict(ForwardedParam, [ | ||
{'_': ForwardedParam(u'by'), | ||
'_citations': [RFC(7239, section=(5, 1))], | ||
'description': u'IP-address of incoming interface of a proxy', | ||
'parser': rfc7239.node}, | ||
{'_': ForwardedParam(u'for'), | ||
'_citations': [RFC(7239, section=(5, 2))], | ||
'description': u'IP-address of client making a request through a proxy', | ||
'parser': rfc7239.node}, | ||
{'_': ForwardedParam(u'host'), | ||
'_citations': [RFC(7239, section=(5, 3))], | ||
'description': u'Host header field of the incoming request', | ||
'parser': rfc7230.Host}, | ||
{'_': ForwardedParam(u'proto'), | ||
'_citations': [RFC(7239, section=(5, 4))], | ||
'description': u'Application protocol used for incoming request', | ||
'parser': rfc3986.scheme}, | ||
], extra_info=['description', 'parser']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8; -*- | ||
|
||
from httpolice.citation import RFC | ||
from httpolice.parse import (fill_names, many, maybe, pivot, skip, string1, | ||
string_times) | ||
from httpolice.structure import ForwardedParam | ||
from httpolice.syntax.common import ALPHA, DIGIT | ||
from httpolice.syntax.rfc3986 import IPv4address, IPv6address | ||
from httpolice.syntax.rfc7230 import comma_list1, quoted_string, token | ||
|
||
|
||
def _remove_empty(xs): | ||
return [x for x in xs if x is not None] | ||
|
||
|
||
obfnode = '_' + string1(ALPHA | DIGIT | '.' | '_' | '-') > pivot | ||
nodename = (IPv4address | | ||
skip('[') * IPv6address * skip(']') | | ||
'unknown' | obfnode) > pivot | ||
|
||
port = int << string_times(1, 5, DIGIT) > pivot | ||
obfport = '_' + string1(ALPHA | DIGIT | '.' | '_' | '-') > pivot | ||
node_port = port | obfport > pivot | ||
|
||
node = nodename * maybe(skip(':') * node_port) > pivot | ||
|
||
value = token | quoted_string > pivot | ||
forwarded_pair = (ForwardedParam << token) * skip('=') * value > pivot | ||
|
||
forwarded_element = _remove_empty << ( | ||
maybe(forwarded_pair) % many(skip(';') * maybe(forwarded_pair))) > pivot | ||
|
||
Forwarded = comma_list1(forwarded_element) > pivot | ||
|
||
|
||
fill_names(globals(), RFC(7239)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
1000 1000 | ||
|
||
======== BEGIN INBOUND STREAM ======== | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
User-Agent: demo | ||
Forwarded: for=123.45.67.89; proto=https | ||
Forwarded: for=fe80::6eb6:566f:a443:ae95 | ||
|
||
======== BEGIN OUTBOUND STREAM ======== | ||
HTTP/1.1 200 OK | ||
Date: Thu, 31 Dec 2015 18:26:56 GMT | ||
Content-Type: text/plain | ||
Content-Length: 14 | ||
|
||
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
1158 1158 1158 | ||
|
||
======== BEGIN INBOUND STREAM ======== | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
User-Agent: demo | ||
Forwarded: for="fe80::c5cc:dcfa:782a:a232";by="example.net";proto=""; | ||
|
||
======== BEGIN OUTBOUND STREAM ======== | ||
HTTP/1.1 200 OK | ||
Date: Thu, 31 Dec 2015 18:26:56 GMT | ||
Content-Type: text/plain | ||
Content-Length: 14 | ||
|
||
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
1296 1296 1296 | ||
|
||
======== BEGIN INBOUND STREAM ======== | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
User-Agent: demo | ||
Forwarded: for=10.0.4.19;proto=https;for=10.0.4.19 | ||
Forwarded: for=10.129.60.21;proto=https;for=10.129.60.21 | ||
Forwarded: for=unknown;by=_cf56213e;;by=_fb2932cb; | ||
|
||
======== BEGIN OUTBOUND STREAM ======== | ||
HTTP/1.1 200 OK | ||
Date: Thu, 31 Dec 2015 18:26:56 GMT | ||
Content-Type: text/plain | ||
Content-Length: 14 | ||
|
||
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
1297 | ||
|
||
======== BEGIN INBOUND STREAM ======== | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
User-Agent: demo | ||
Forwarded: for=172.16.154.38;proto=https | ||
Forwarded: for=21.0.61.67,proto=https | ||
Via: 1.1 gateway04-eu1 | ||
Forwarded: for="[2a01:ac8::10:1f]:8080";proto=http;by=_gateway04-eu1 | ||
|
||
======== BEGIN OUTBOUND STREAM ======== | ||
HTTP/1.1 200 OK | ||
Date: Thu, 31 Dec 2015 18:26:56 GMT | ||
Content-Type: text/plain | ||
Content-Length: 14 | ||
|
||
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Notice 1297 should only look at one header entry at a time. | ||
|
||
======== BEGIN INBOUND STREAM ======== | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
User-Agent: demo | ||
Forwarded: for=127.0.0.1 | ||
Forwarded: proto=https | ||
Forwarded: by=unknown | ||
|
||
======== BEGIN OUTBOUND STREAM ======== | ||
HTTP/1.1 200 OK | ||
Date: Thu, 31 Dec 2015 18:26:56 GMT | ||
Content-Type: text/plain | ||
Content-Length: 14 | ||
|
||
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
|
||
======== BEGIN INBOUND STREAM ======== | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
User-Agent: demo | ||
Forwarded: for=2.92.0.60, for=2.93.17.180, for=49.141.62.82 | ||
|
||
======== BEGIN OUTBOUND STREAM ======== | ||
HTTP/1.1 200 OK | ||
Date: Thu, 31 Dec 2015 18:26:56 GMT | ||
Content-Type: text/plain | ||
Content-Length: 14 | ||
|
||
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters