Skip to content

Commit 9cfffa3

Browse files
author
clowwindy
committed
sudo tc setup
1 parent cd07001 commit 9cfffa3

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ before_install:
1515
- pip install m2crypto salsa20 pep8 pyflakes nose coverage
1616
- sudo tests/socksify/install.sh
1717
- sudo tests/libsodium/install.sh
18+
- sudo tests/setup_tc.sh
1819
script:
1920
- ./.jenkins.sh

tests/setup_tc.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
DEV=lo
4+
PORT=8388
5+
DELAY=100ms
6+
7+
type tc 2> /dev/null && (
8+
tc qdisc add dev $DEV root handle 1: htb
9+
tc class add dev $DEV parent 1: classid 1:1 htb rate 2mbps
10+
tc class add dev $DEV parent 1:1 classid 1:6 htb rate 2mbps ceil 1mbps prio 0
11+
tc filter add dev $DEV parent 1:0 prio 0 protocol ip handle 6 fw flowid 1:6
12+
13+
tc filter add dev $DEV parent 1:0 protocol ip u32 match ip dport $PORT 0xffff flowid 1:6
14+
tc filter add dev $DEV parent 1:0 protocol ip u32 match ip sport $PORT 0xffff flowid 1:6
15+
16+
tc qdisc show dev lo
17+
)
18+

tests/test_large_file.sh

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
#!/bin/bash
22

3-
DEV=lo
4-
PORT=8388
5-
DELAY=100ms
6-
73
PYTHON="coverage run -p -a"
84
URL=http://127.0.0.1/file
95

106
mkdir -p tmp
117

12-
type tc 2> /dev/null && (
13-
tc qdisc add dev $DEV root handle 1: htb
14-
tc class add dev $DEV parent 1: classid 1:1 htb rate 2mbps
15-
tc class add dev $DEV parent 1:1 classid 1:6 htb rate 2mbps ceil 1mbps prio 0
16-
tc filter add dev $DEV parent 1:0 prio 0 protocol ip handle 6 fw flowid 1:6
17-
18-
tc filter add dev $DEV parent 1:0 protocol ip u32 match ip dport $PORT 0xffff flowid 1:6
19-
tc filter add dev $DEV parent 1:0 protocol ip u32 match ip sport $PORT 0xffff flowid 1:6
20-
21-
# iptables -D OUTPUT -t mangle -p tcp --sport 8388 -j MARK --set-mark 6
22-
# iptables -A OUTPUT -t mangle -p tcp --sport 8388 -j MARK --set-mark 6
23-
24-
tc qdisc show dev lo
25-
)
26-
278
$PYTHON shadowsocks/local.py -c tests/aes.json &
289
LOCAL=$!
2910

@@ -38,8 +19,6 @@ time curl -o tmp/result --socks5-hostname 127.0.0.1:1081 $URL
3819
kill -s SIGINT $LOCAL
3920
kill -s SIGINT $SERVER
4021

41-
type tc 2> /dev/null && tc qdisc del dev lo root
42-
4322
sleep 2
4423

4524
diff tmp/expected tmp/result || exit 1

0 commit comments

Comments
 (0)