-
-
Notifications
You must be signed in to change notification settings - Fork 591
/
Copy pathgrout_client.py
43 lines (36 loc) · 1.3 KB
/
grout_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
proxy.py
~~~~~~~~
⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on
Network monitoring, controls & Application development, testing, debugging.
:copyright: (c) 2013-present by Abhinav Singh and contributors.
:license: BSD, see LICENSE for more details.
"""
from typing import Tuple, Optional
from proxy.proxy import GroutClientBasePlugin
from proxy.common.types import HostPort
from proxy.http.parser.parser import HttpParser
class GroutClientPlugin(GroutClientBasePlugin):
def resolve_route(
self,
route: str,
request: HttpParser,
origin: HostPort,
server: HostPort,
) -> Tuple[Optional[str], HttpParser]:
# print(request, origin, server, '->', route)
# print(request.header(b'host'), request.path)
#
# Send to localhost:7001 irrespective of the
# original "route" value provided to the grout client
# OR any custom host:upstream mapping provided through the
# --tunnel-route flags.
#
# Optionally, you can also strip path like this:
# request.path = b"/"
#
# Return None for route to drop the request
# return None, request
#
return 'http://localhost:7001', request