Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Sudo and echo with ofSystem()

$
0
0

@fresla wrote:

I want to turn on and off port forwarding when I open and close my application.

I can do this with terminal with the following commands, I need it to be autonomous and not need user input.

echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
" | sudo pfctl -ef -

I am trying to build this command to work with ofSystem and have got this far

ofSystem(echo -ne ”rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080 /n rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443 " \n | echo -ne “password” | sudo -S pfctl -ef -)

but alas it does not work.

I did not try the disabling function yet, but it is simpler:

sudo pfctl -F all -f /etc/pf.conf

Any clues on how I can do this? I dont want to do this permanently, I would like to start and stop it with my application.

I am on OSX and need this to run form 10.10 to 10.14.

Cheers

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles