README.chromium
1 Name: tsproxy
2 Short Name: tsproxy
3 URL: https://github.com/WPO-Foundation/tsproxy
4 Version: a2f578febcd79b751d948f615bbde8f6189fbeed (commit hash)
5 License: Apache
6 License File: NOT_SHIPPED
7 Security Critical: no
8
9 Local modification: no
10
11 Description:
12 tsproxy provides basic latency, download and upload traffic shaping while only
13 requiring user-level access (no root permissions required)
14
README.md
1 # tsproxy
2 Traffic-shaping SOCKS5 proxy
3
4 tsproxy provides basic latency, download and upload traffic shaping while only requiring user-level access (no root permissions required). It should work for basic browser testing but for protocol-level work it does not provide a suitable replacement for something like dummynet or netem.
5
6 tsproxy is monolithic and all of the functionality is in tsproxy.py. It is written expecting Python 2.7.
7
8 #Usage
9 ```bash
10 $ python tsproxy.py --rtt=<latency> --inkbps=<download bandwidth> --outkbps=<upload bandwidth>
11 ```
12 Hit `ctrl-C` (or send a `SIGINT`) to exit
13
14 #Example
15 ```bash
16 $ python tsproxy.py --rtt=200 --inkbps=1600 --outkbps=768
17 ```
18
19 #Command-line Options
20
21
22 | Option | Alias | Description |
23 | ----------------- | -------- | ---------------------------------------- |
24 | **`--rtt`** | **`-r`** | Latency in milliseconds (full round trip, half of the latency gets applied to each direction). |
25 | **`--inkbps`** | **`-i`** | Download Bandwidth (in 1000 bits/s - Kbps). |
26 | **`--outkbps`** | **`-o`** | Upload Bandwidth (in 1000 bits/s - Kbps). |
27 | **`--window`** | **`-w`** | Emulated TCP initial congestion window (defaults to 10). |
28 | **`--port`** | **`-p`** | SOCKS 5 proxy port (defaults to port 1080). Specifying a port of 0 will use a randomly assigned port. |
29 | **`--bind`** | **`-b`** | Interface address to listen on (defaults to localhost). |
30 | **`--desthost`** | **`-d`** | Redirect all outbound connections to the specified host (name or IP). |
31 | **`--mapports`** | **`-m`** | Remap outbound ports. Comma-separated list of original:new with * as a wildcard. `--mapports '443:8443,*:8080'` |
32 | **`--localhost`** | **`-l`** | Include connections already destined for localhost/127.0.0.1 in the host and port remapping. |
33 | **`--verbose`** | **`-v`** | Increase verbosity (specify multiple times for more). `-vvvv` for full debug output. |
34
35
36 #Runtime Options
37 The traffic shaping configuration can be changed dynamically at runtime by passing commands in through the console (or stdin). Each command is on a line, terminated with an end-of-line (`\n`).
38
39
40 * **`flush`** : Flush queued data out of the pipes. Useful for clearing out any accumulated background data between tests.
41 * **`set rtt <latency>`** : Change the connection latency. i.e. `set rtt 200\n` will change to a 200ms RTT.
42 * **`set inkbps <bandwidth>`** : Change the download bandwidth. i.e. `set inkbps 5000\n` will change to a 5Mbps download connection.
43 * **`set outkbps <bandwidth>`** : Change the upload bandwidth. i.e. `set outkbps 1000\n` will change to a 1Mbps upload connection.
44 * **`set mapports <port mapping string>`** : Change the destination port mapping.
45 * **`reset all`** : Disable all port mapping and traffic shaping
46 * **`reset rtt`** : Set latency to 0
47 * **`reset inkbps`** : Disable download traffic shaping
48 * **`reset outkbps`** : Disable upload traffic shaping
49 * **`reset mapports`** : Disable destination port mapping
50
51 All bandwidth and latency changes also carry an implied flush and clear out any pending data.
52
53
54 #Configuring Chrome to use tsproxy
55 Add a --proxy-server command-line option.
56 ```bash
57 --proxy-server="socks://localhost:1080"
58 ```
59
60 #Known Shortcomings/Issues
61 * DNS lookups on OSX (and FreeBSD) will block each other when it comes to actually resolving. DNS in Python on most platforms is allowed to run concurrently in threads (which tsproxy does) but on OSX and FreeBSD it is not thread-safe and there is a lock around the actual lookups. For most cases this isn't an issue because the latency isn't added on the actual DNS lookup (it is from the browser perspective but it is added outside of the actual lookup). This is also not an issue when desthost is used to override the destination address since dns lookups will be disabled.
62 * QUIC support. Chrome [doesn't currently support QUIC proxies](https://bugs.chromium.org/p/chromium/issues/detail?id=335275), and further work would be neccessary to correctly handle UDP traffic in tsproxy.
63