Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS Loopback Address Whitelisting #16

Open
Z-Kris opened this issue Aug 8, 2024 · 5 comments
Open

MacOS Loopback Address Whitelisting #16

Z-Kris opened this issue Aug 8, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@Z-Kris
Copy link
Contributor

Z-Kris commented Aug 8, 2024

MacOS by default only whitelists the 127.0.0.1 loopback address. This is a problem as we use loopback addresses in the range of 127.x.x.2 for the proxy tool, with one IP corresponding to one game world.
Without whitelisting these addresses, the clients will be unable to communicate with the proxy tool after being patched, rendering the entire process non-functional.

In order to remedy this problem, we need to write a script that can whitelist all the loopback addresses from world 301 up to around 600 - effectively every world that exists in Old School RuneScape. Because this process is only done once (until a reboot occurs), we need to secure all the existing worlds and give some headroom for new worlds that might be added as well.

The problem with whitelisting these loopback addresses is that they require sudo privileges - this is likely not something the proxy tool will have. The current best plan forward is to do these steps:

  1. Launch the HTTP server when the proxy tool boots up.
  2. If the operating system is MacOS, attempt to ping the HTTP server on. If the ping is successful, do nothing - the addresses have been whitelisted. If it isn't successful, go to step 3.
  3. Launch a modal window asking the user for the sudo password, with an explanation for why this is necessary.
  4. Once the sudo password has been acquired, run the script with sudo privileges, whitelisting all the loopback addresses that we'll need.
  5. Restart the HTTP server - it is unclear whether this is necessary, but it probably is.

The command to whitelist a loopback address is sudo ifconfig lo0 alias 127.x.x.2.

@Z-Kris Z-Kris added the enhancement New feature or request label Aug 8, 2024
@kylmp
Copy link

kylmp commented Oct 22, 2024

Probably just providing a script to run would work. I think if someone is messing with rsprox they will know how to run a script. Add a line to the setup instructions for mac users.

BTW thanks for the post, this got my rsprox working.

@notmeta
Copy link
Contributor

notmeta commented Oct 22, 2024

Probably just providing a script to run would work. I think if someone is messing with rsprox they will know how to run a script. Add a line to the setup instructions for mac users.

BTW thanks for the post, this got my rsprox working.

I came up with a script that registers all the possible aliases, but in my limited testing it made the general networking of my machine super slow and also doesn't persist across reboots which is far from ideal.

@Hosea-MP
Copy link

Hosea-MP commented Dec 9, 2024

Probably just providing a script to run would work. I think if someone is messing with rsprox they will know how to run a script. Add a line to the setup instructions for mac users.
BTW thanks for the post, this got my rsprox working.

I came up with a script that registers all the possible aliases, but in my limited testing it made the general networking of my machine super slow and also doesn't persist across reboots which is far from ideal.

Can you provide this script?

@notmeta
Copy link
Contributor

notmeta commented Dec 9, 2024

Probably just providing a script to run would work. I think if someone is messing with rsprox they will know how to run a script. Add a line to the setup instructions for mac users.
BTW thanks for the post, this got my rsprox working.

I came up with a script that registers all the possible aliases, but in my limited testing it made the general networking of my machine super slow and also doesn't persist across reboots which is far from ideal.

Can you provide this script?

#!/bin/bash

# Loop for the range 127.1.x.2 where x is 44..255
for ((x=44; x<=255; x++))
do
    sudo ifconfig lo0 alias 127.1.$x.2
done

# Loop for the range 127.2.x.2 where x is 0..88
for ((x=0; x<=88; x++))
do
    sudo ifconfig lo0 alias 127.2.$x.2
done

echo "Alias IPs have been added to lo0 interface."

@CygnixDev
Copy link
Contributor

CygnixDev commented Jan 4, 2025

Some additional context:

  • With 200+ aliases, networking for the whole device comes to pretty much a grinding halt. 10+ seconds of wait time with every DNS lookup/request to services.
  • There's no alternative way on macOS to efficiently alias a range of IP's as one alias.
  • To undo an alias, you can run sudo ifconfig lo0 -alias 127.x.x.2 (note the - bit)

Ideally, you'd only address the current world's IP, as well as the one you're hopping to, but since this requires sudo it likely would lead to loads of disconnects if the rsprox constantly either has to ask or if the alias command / network stack is too slow to execute.

Alternatively, you could inject a custom RuneLite plugin that tracks the current/new world from the client, and that transmits this to rsprot over a socket. That way, you could (in theory) handle most of this using either one or two fixed ip's.

In either case, here's my "disable aliases" script to restore the network stack, which compliments @notmeta's script above that enables said aliases:

 #!/bin/bash

# Loop for the range 127.1.x.2 where x is 44..255
for ((x=44; x<=255; x++))
do
    sudo ifconfig lo0 -alias 127.1.$x.2
done

# Loop for the range 127.2.x.2 where x is 0..88
for ((x=0; x<=88; x++))
do
    sudo ifconfig lo0 -alias 127.2.$x.2
done

echo "Alias IPs have been removed from lo0 interface."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants