Handle existing HTB qdisc and class gracefully in traffic control setup
This commit is contained in:
@@ -8,8 +8,25 @@ class TrafficControlService {
|
|||||||
try {
|
try {
|
||||||
// Ensure HTB qdisc exists on wg0
|
// Ensure HTB qdisc exists on wg0
|
||||||
print('Setting up HTB qdisc on wg0...');
|
print('Setting up HTB qdisc on wg0...');
|
||||||
await _runTcCommand(['qdisc', 'add', 'dev', 'wg0', 'root', 'handle', '1:', 'htb', 'default', '30']);
|
try {
|
||||||
await _runTcCommand(['class', 'add', 'dev', 'wg0', 'parent', '1:', 'classid', '1:1', 'htb', 'rate', '1000mbit']);
|
await _runTcCommand(['qdisc', 'add', 'dev', 'wg0', 'root', 'handle', '1:', 'htb', 'default', '30']);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.toString().contains('File exists') || e.toString().contains('Exclusivity flag')) {
|
||||||
|
print('HTB qdisc already exists, continuing...');
|
||||||
|
} else {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await _runTcCommand(['class', 'add', 'dev', 'wg0', 'parent', '1:', 'classid', '1:1', 'htb', 'rate', '1000mbit']);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.toString().contains('File exists')) {
|
||||||
|
print('HTB root class already exists, continuing...');
|
||||||
|
} else {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print('Running iptables MARK commands for $peerIP...');
|
print('Running iptables MARK commands for $peerIP...');
|
||||||
await _runIptablesCommand(['-I', 'FORWARD', '-s', peerIP, '-j', 'MARK', '--set-mark', mark.toString()]);
|
await _runIptablesCommand(['-I', 'FORWARD', '-s', peerIP, '-j', 'MARK', '--set-mark', mark.toString()]);
|
||||||
|
|||||||
Reference in New Issue
Block a user