blob: de049486c26b31394baaba8d8f71390f262f6233 (
plain)
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
44
45
46
|
"""
This module contains all valid messages layers can send to the underlying layers.
"""
from __future__ import (absolute_import, print_function, division)
from netlib.tcp import Address
class _Message(object):
def __eq__(self, other):
# Allow message == Connect checks.
if isinstance(self, other):
return True
return self is other
def __ne__(self, other):
return not self.__eq__(other)
class Connect(_Message):
"""
Connect to the server
"""
class Reconnect(_Message):
"""
Re-establish the server connection
"""
class SetServer(_Message):
"""
Change the upstream server.
"""
def __init__(self, address, server_tls, sni, depth=1):
self.address = Address.wrap(address)
self.server_tls = server_tls
self.sni = sni
# upstream proxy scenario: you may want to change either the final target or the upstream proxy.
# We can express this neatly as the "nth-server-providing-layer"
# ServerConnection could get a `via` attribute.
self.depth = depth
|