nitred / nr-wg-mtu-finder

MIT License
202 stars 22 forks source link

Permission denied (Termux&Python 3.11 support??) #8

Closed MossNotFound closed 1 year ago

MossNotFound commented 1 year ago

I got this error trying to run the script on peer side and now stuck on where to go from here. Android 12 Termux (not running in any virtual environment) Python 3.11

~ $ nr-wg-mtu-finder --mode peer --mtu-min 1280 --mtu-max 1420 --mtu-step 5 --server-ip 10.7.0.1 --interface WireShark2 --conf-file /data/data/com.wireguard.android/files/WireShark2.conf Creating log file: wg_mtu_finder_peer_20221201T122506.csv: SUCCESS Pinging server to establish connection : SUCCESS Send peer ready for next loop to server : SUCCESS Pinging server to establish connection : SUCCESS Waiting for server init and status : FAILED, SERVER_STATUS: NOT_INITIALIZED, Retrying... Waiting for server init and status : FAILED, ConnectTimeout, Retrying... Waiting for server init and status : FAILED, ConnectTimeout, Retrying... Waiting for server init and status : FAILED, ConnectTimeout, Retrying... Waiting for server init and status : SUCCESS, SERVER_MTU: 1280, SERVER_STATUS: INITIALIZED -------------------------------------------------------------------------------- WG Interface Down : SUCCESS Traceback (most recent call last): File "/data/data/com.termux/files/usr/bin/nr-wg-mtu-finder", line 8, in sys.exit(run()) ^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/main.py", line 140, in run MTUFinder(**args.dict()) File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 60, in init self.run_peer_mode() File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 351, in run_peer_mode self.update_mtu_in_conf_file() File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 168, in update_mtu_in_conf_file self.validate_conf_file() File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 151, in validate_conf_file with open(self.conf_file, "r") as f: ^^^^^^^^^^^^^^^^^^^^^^^^^ PermissionError: [Errno 13] Permission denied: `'/data/data/com.wireguard.android/files/WireShark2.conf'

On second run

Creating log file: wg_mtu_finder_peer_20221201T122635.csv: SUCCESS Pinging server to establish connection : FAILED with code 1 **** STDOUT: ------- PING 10.7.0.1 (10.7.0.1) 56(84) bytes of data. \ --- 10.7.0.1 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms \ STDERR: ------- \ **** Traceback (most recent call last): File "/data/data/com.termux/files/usr/bin/nr-wg-mtu-finder", line 8, in sys.exit(run()) ^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/main.py", line 140, in run MTUFinder(**args.dict()) File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 60, in init self.run_peer_mode() File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 316, in run_peer_mode self.peer_mode__ping_server() File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 304, in peer_mode__ping_server self.handle_returncode( File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 95, in handle_returncode raise ReturncodeError() nr_wg_mtu_finder.mtu_finder.ReturncodeError

MossNotFound commented 1 year ago

nvm that i just gave root permission and now i got a diff error

~ $ sudo nr-wg-mtu-finder --mode peer --mtu-min 1280 --mtu-max 1420 --mtu-step 10 --server-ip 10.7.0.1 --interface WireShark2 --conf-file /data/data/com.wireguard.android/files/WireShark2.conf Creating log file: wg_mtu_finder_peer_20221201T143918.csv: SUCCESS Pinging server to establish connection : SUCCESS Send peer ready for next loop to server : SUCCESS Pinging server to establish connection : SUCCESS Waiting for server init and status : FAILED, SERVER_STATUS: NOT_INITIALIZED, Retrying... Waiting for server init and status : FAILED, ConnectTimeout, Retrying... Waiting for server init and status : FAILED, ConnectTimeout, Retrying... Waiting for server init and status : FAILED, ConnectTimeout, Retrying... Waiting for server init and status : SUCCESS, SERVER_MTU: 1280, SERVER_STATUS: INITIALIZED -------------------------------------------------------------------------------- WG Interface Down : SUCCESS Setting MTU to 1280 in /etc/wireguard/wg0.conf : SUCCESS WG Interface Up : FAILED with code 64 **** STDOUT: ------- [#] ip link add WireShark2 type wireguard [#] wg setconf WireShark2 /proc/self/fd/0 [#] ip link set up dev WireShark2 [#] ip link set down dev WireShark2 [#] wg set WireShark2 fwmark 0x20000 [#] iptables -I OUTPUT 1 -m mark --mark 0x20000 -j ACCEPT -m comment --comment "wireguard rule WireShark2" [#] ip6tables -I OUTPUT 1 -m mark --mark 0x20000 -j ACCEPT -m comment --comment "wireguard rule WireShark2" [#] iptables -I INPUT 1 -p udp --dport 40122 -j ACCEPT -m comment --comment "wireguard rule WireShark2" [#] ip6tables -I INPUT 1 -p udp --dport 40122 -j DROP -m comment --comment "wireguard rule WireShark2" [#] ip link set up dev WireShark2 [#] ndc network create 5304 vpn 1 [#] ndc network interface add 5304 WireShark2 [#] ip link del WireShark2 [#] iptables -D INPUT -p udp -m udp --dport 40122 -m comment --comment "wireguard rule WireShark2" -j ACCEPT [#] iptables -D OUTPUT -m mark --mark 0x20000 -m comment --comment "wireguard rule WireShark2" -j ACCEPT [#] ip6tables -D INPUT -p udp -m udp --dport 40122 -m comment --comment "wireguard rule WireShark2" -j DROP [#] ip6tables -D OUTPUT -m mark --mark 0x20000 -m comment --comment "wireguard rule WireShark2" -j ACCEPT \ STDERR: ------- Error: 400 0 addInterfaceToNetwork() failed (Device or resource busy) \ Can't find library for match quota2' Can't find library for matchquota2' \ **** Traceback (most recent call last): File "/data/data/com.termux/files/usr/bin/nr-wg-mtu-finder", line 8, in sys.exit(run()) ^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/main.py", line 140, in run MTUFinder(**args.dict()) File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 60, in init self.run_peer_mode() File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 352, in run_peer_mode self.wg_quick_up() File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 145, in wg_quick_up self.handle_returncode( File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/nr_wg_mtu_finder/mtu_finder.py", line 95, in handle_returncode raise ReturncodeError() nr_wg_mtu_finder.mtu_finder.ReturncodeError

nitred commented 1 year ago

Hi, this seems like something I won't be able to support since you're trying to running it on Android. The development environment I used for this tool is Ubuntu and python3.9 and I have no experience with Android. I googled quota2' Can't find library for match quota2 and the results seem specific to Android and iptables.

I will leave the issue open for a few weeks in case someone else can help you. In case you are able to resolve it on your end, please post your solution here. Sorry, I wasn't able to help.

nitred commented 1 year ago

I found a related github issue elsewhere, maybe it can help: https://github.com/angristan/openvpn-install/issues/145

nitred commented 1 year ago

I won't be able to support 3.11 just yet. Closing issue.