File: const.py

package info (click to toggle)
python-snitun 0.45.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 640 kB
  • sloc: python: 6,681; sh: 5; makefile: 3
file content (69 lines) | stat: -rw-r--r-- 2,105 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""This file contains the constants used by the multiplexer."""

import os

# When downloading a file, the message size will be
# ~4199990 bytes which is the protocol maximum. Make
# sure we have enough space to store 16 messages
# in the incoming queue before we drop the connection.
DEFAULT_INCOMING_QUEUE_MAX_BYTES_CHANNEL = 1024 * 1024 * 65
DEFAULT_INCOMING_QUEUE_LOW_WATERMARK = 1024 * 512
DEFAULT_INCOMING_QUEUE_HIGH_WATERMARK = 1024 * 1024 * 2

# For protocol version 0, there is no flow control
# and the incoming queue is much larger to accommodate
# the fact we can't tell the client to pause/resume reading.
# This is a temporary solution until we can remove protocol version 0.
DEFAULT_INCOMING_QUEUE_MAX_BYTES_CHANNEL_V0 = 1024 * 1024 * 256


DEFAULT_OUTGOING_QUEUE_MAX_BYTES_CHANNEL = 1024 * 1024 * 12
DEFAULT_OUTGOING_QUEUE_LOW_WATERMARK = 1024 * 512
DEFAULT_OUTGOING_QUEUE_HIGH_WATERMARK = 1024 * 1024 * 1

INCOMING_QUEUE_MAX_BYTES_CHANNEL = int(
    os.getenv(
        "MULTIPLEXER_INCOMING_QUEUE_MAX_BYTES_CHANNEL",
        DEFAULT_INCOMING_QUEUE_MAX_BYTES_CHANNEL,
    ),
)
INCOMING_QUEUE_LOW_WATERMARK = int(
    os.getenv(
        "MULTIPLEXER_INCOMING_QUEUE_LOW_WATERMARK",
        DEFAULT_INCOMING_QUEUE_LOW_WATERMARK,
    ),
)
INCOMING_QUEUE_HIGH_WATERMARK = int(
    os.getenv(
        "MULTIPLEXER_INCOMING_QUEUE_HIGH_WATERMARK",
        DEFAULT_INCOMING_QUEUE_HIGH_WATERMARK,
    ),
)

INCOMING_QUEUE_MAX_BYTES_CHANNEL_V0 = int(
    os.getenv(
        "MULTIPLEXER_INCOMING_QUEUE_MAX_BYTES_CHANNEL_V0",
        DEFAULT_INCOMING_QUEUE_MAX_BYTES_CHANNEL_V0,
    ),
)

OUTGOING_QUEUE_MAX_BYTES_CHANNEL = int(
    os.getenv(
        "MULTIPLEXER_OUTGOING_QUEUE_MAX_BYTES_CHANNEL",
        DEFAULT_OUTGOING_QUEUE_MAX_BYTES_CHANNEL,
    ),
)
OUTGOING_QUEUE_LOW_WATERMARK = int(
    os.getenv(
        "MULTIPLEXER_OUTGOING_QUEUE_LOW_WATERMARK",
        DEFAULT_OUTGOING_QUEUE_LOW_WATERMARK,
    ),
)
OUTGOING_QUEUE_HIGH_WATERMARK = int(
    os.getenv(
        "MULTIPLEXER_OUTGOING_QUEUE_HIGH_WATERMARK",
        DEFAULT_OUTGOING_QUEUE_HIGH_WATERMARK,
    ),
)

PEER_TCP_TIMEOUT = 90