Closed ghost closed 1 year ago
In fact, if mitigate.py has been run via pipe, then __file__
would be empty, and this oodle_helper_path
would end up becoming /oodle_helper
. This path probably can just be os.path.join(os.getcwd(), "oodle_helper")
instead.
I replaced os.path.join()
both for cleanup.sh
and oodle_helper
and they are correctly placed in the working directory but the PREROUTING
rules are still there after the service stops meaning the cleanup script isn't being run
root@0:~# iptables -t nat -F PREROUTING
root@0:~# iptables -t nat -L PREROUTING
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
root@0:~# service xivalexander start
root@0:~# ls -A xivalexander/
.cleanup.sh definitions.json ffxiv.exe oodle_helper run.sh
root@0:~# service xivalexander stop
root@0:~# iptables -t nat -L PREROUTING
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- anywhere 27.221.0.0/16 multiport dports tcpmux:65535 redir ports 45244
REDIRECT tcp -- anywhere 202.67.52.0/24 multiport dports 1025:65535 redir ports 45244
REDIRECT tcp -- anywhere 162.14.0.0/16 multiport dports tcpmux:65535 redir ports 45244
REDIRECT tcp -- anywhere 80-239-145-0.teliacarrier-cust.com/24 multiport dports 1025:65535 redir ports 45244
REDIRECT tcp -- anywhere 153.254.80.0/24 multiport dports 1025:65535 redir ports 45244
REDIRECT tcp -- anywhere 204.2.229.0/24 multiport dports 1025:65535 redir ports 45244
REDIRECT tcp -- anywhere 124.150.157.0/24 multiport dports 1025:65535 redir ports 45244
REDIRECT tcp -- anywhere 109.244.0.0/16 multiport dports tcpmux:65535 redir ports 45244
REDIRECT tcp -- anywhere 183.111.189.0/24 multiport dports 1025:65535 redir ports 45244
REDIRECT tcp -- anywhere 119.97.0.0/16 multiport dports tcpmux:65535 redir ports 45244
As a workaround I added ExecStop=/bin/bash .cleanup.sh
to my service but the file keeps staying in the working directory even when mitigate.py
isn't running
The journalctl logs for the xivalexander service
Oct 22 13:10:48 finnix systemd[1]: Started XivAlexander script.
Oct 22 13:10:48 finnix bash[5795]: % Total % Received % Xferd Average Speed Time Time Time Current
Oct 22 13:10:48 finnix bash[5795]: Dload Upload Total Spent Left Speed
Oct 22 13:10:48 finnix bash[5795]: [158B blob data]
Oct 22 13:10:48 finnix bash[5796]: 2022-10-22 13:10:48,544 5796(main) INFO Region filter: (None)
Oct 22 13:10:48 finnix bash[5796]: 2022-10-22 13:10:48,544 5796(main) INFO Extra delay: 0.075s
Oct 22 13:10:48 finnix bash[5796]: 2022-10-22 13:10:48,544 5796(main) INFO Use measured socket latency: no
Oct 22 13:10:49 finnix bash[5803]: Base: 0xf3d40000
Oct 22 13:10:49 finnix bash[5803]: Oodle encode test: 256 -> 100
Oct 22 13:10:49 finnix bash[5803]: Oodle helper running: state=2eb400 shared=400018 window=8000
Oct 22 13:10:49 finnix bash[5806]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5807]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5808]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5809]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5810]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5811]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5812]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5813]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5814]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5815]: iptables: Bad rule (does a matching rule exist in that chain?).
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,592 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1025:65535 -d 202.67.52.0/24 -j REDIRECT --t>
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,596 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1025:65535 -d 204.2.229.0/24 -j REDIRECT --t>
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,599 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1025:65535 -d 124.150.157.0/24 -j REDIRECT ->
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,603 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1025:65535 -d 183.111.189.0/24 -j REDIRECT ->
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,607 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1:65535 -d 162.14.0.0/16 -j REDIRECT --to 24>
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,611 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1:65535 -d 109.244.0.0/16 -j REDIRECT --to 2>
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,615 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1025:65535 -d 80.239.145.0/24 -j REDIRECT -->
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,619 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1:65535 -d 27.221.0.0/16 -j REDIRECT --to 24>
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,623 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1:65535 -d 119.97.0.0/16 -j REDIRECT --to 24>
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,627 5796(main) INFO Running: iptables -t nat -I PREROUTING -p tcp -m multiport --dports 1025:65535 -d 153.254.80.0/24 -j REDIRECT -->
Oct 22 13:10:49 finnix bash[5837]: net.ipv4.ip_forward = 1
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,634 5796(main) INFO Listening on ('0.0.0.0', 24121)...
Oct 22 13:10:49 finnix bash[5796]: 2022-10-22 13:10:49,634 5796(main) INFO Press Ctrl+C to quit.
The iptables: Bad rule (does a matching rule exist in that chain?).
error was caused by me running with nftables active. Switching to legacy mode solved that error
update-alternatives --set iptables /usr/sbin/iptables-legacy
but the rules yet remain in the iptables
Running the run.sh
script manually correctly removes the iptables rules and the cleanup script. I basically never touched python before but I think it's due to is_child
boolean not being True
This issue has been resolved thanks to https://github.com/Soreepeong/XivMitmLatencyMitigator/issues/66#issuecomment-1287760129 since .cleanup.sh
is being now named properly and oodle_helper
is being placed in the working directory so I'll just close this issue and maybe open a new one for the systemd problem.
When I manually execute
run.sh
the cleanup happens without problems onCtrl+C
. When started as a systemd service, the following happens:<stdin>.cleanup.sh
/
instead ofWorkingDirectory
I can only assume the lack of cleanup is due to a name mismatch but I don't quite get why
oodle_helper
is placed in/
. This happens if I manually execute run.sh and if I manually pipe the curl output in python. It should be mentioned that I'm running this in a live CD, similarly to how Arch is run the documentation example. I did install and use this script on a normal Debian installation in the past so I know that it works for sure on Debian.