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

Add macOS support #96

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Add macOS support #96

wants to merge 17 commits into from

Conversation

deg0nz
Copy link

@deg0nz deg0nz commented Jan 26, 2020

I added the support for macOS for ProxyMan. I created this PR so we can discuss some stuff about the implementation.

For now, the following things are implemented:

  • Determining operation system and sourceing corresponding OS-related file to have the right functions for each OS in place
  • Change system-wide settings in macOS (networksetup as mentioned in Add MacOS networksetup proxy configuration options. #11 )
    • On macOS, proxy settings are set per network device. So I added a second selection prompt to determine for which network devices proxies should be set.
    • Network devices are automatically discovered and shown to the user
  • Terminal's settings work as before, but some adjustments were needed to work on macOS
  • Configurations for npm/yarn and git are untouched since they are identical to Linux
  • non-macOS related configurations (like KDE, apt, docker, ...) are ignored in the macOS-part

What's missing:

  • Printing networksetup proxy configurations. To make this pretty, there is need for some data aggregation to be made, since networksetup is a bit chatty about that. A simple print for all network devices would be too much. So I left that part out for now.
  • I think setting variables other than the ones for the Terminal environment (as mentioned in Set proper configuration files on MacOS. #12) is not necessary, because the configurations via networksetup are system-wide
  • I would like to add auto-discovery for proxies additionally to setting the proxies manually per-device since macOS supports this function later
  • In my experience you only want to change proxy settings for some devices on macOS (most of the time). It could make sense to add the configuration of the affected devices into the profiles that can already be saved by ProxyMan

To be done/discussed before merging:

  • I'm not so happy with the file names of the splitted functions for macOS and Linux (respectively main_macos.sh and main_linux.sh) because they can cause confusion by the user (one could think that those are the main.sh to be executed for the corresponding OS). I will change this to something that makes more sense for this scenario.
  • networksetup throws an error when setting proxy settings with user credentials: networksetup[71185:16035891] error -25299 attempting to create account and password for proxy, but credentials actually get updated in the system and work. Maybe this is a keychain-issue... But I think we can ignore that for the first version.
  • This branch should be testet on Linux to ensure that everything still works as expected

deg0nz added 14 commits January 25, 2020 20:53
Create some kind of interface for different OSes:
Main functions for setting proxies are split into different files for each OS which contain identical function names.
The corresponding file gets sourced at the beginning of the file.
BSD readlink has a different functionality than GNU's readlink. We need to use realpath on macOS.
BSD sed's syntax is different from the GNU one. We check for the OS in the unset function and call the corresponding sed syntax
also removed unnecessary hashtag
also added networksetup entry to do_all function
...because this function is not implemented yet.
in networksetup.sh -> set_proxy()
This was a copy and paste error
macOS does not come with realpath per default, so we need a portable substitute for this
@deg0nz
Copy link
Author

deg0nz commented Jan 27, 2020

I tried the macOS version on another machine today. Turns out, that realpath (readlink -f equivalent for BSD) does not come with macOS per default. It seems that I had installed coreutils a long time ago (and forgot about it), so it worked out of the box on my machine. I added a shell-only substitute that I found on here on GitHub.

@himanshub16
Copy link
Owner

himanshub16 commented Feb 5, 2020

Thanks a lot @deg0nz
Your contribution is really helpful and adds a lot of value by providing support on MacOS.

I'm sorry for not responding. There has been some delay from my end as I had been occupied.
Will definitely have a look at this later this week/during weekend.

@deg0nz
Copy link
Author

deg0nz commented Feb 6, 2020

No problem, take your time :)
I'm currently using my fork at work and found some quirks here and there. I need to do some more testing with the networksetup part. So no need to rush :)

@deg0nz
Copy link
Author

deg0nz commented Feb 26, 2020

Okay, I fixed the problem with the networksetup part and everything seems to work on macOS as far as I tested it.
I also tested the changes on a Linux machine (My LinuxMint VM) and everything works as expected.

From my perspective, this is ready to merge now.
Any tests and suggestions for improvements are appreciated, of course :)

@FatehAK
Copy link

FatehAK commented Jan 15, 2021

Has this feature been merged? Does proxyman support macos now?

@deg0nz
Copy link
Author

deg0nz commented Jan 15, 2021

@FatehAK
Unfortunately it is not merged yet, but you can just use my fork by using the macOS branch until it gets merged.

I'm using this for almost a year now and it seems to be working fine. I would also be happy if someone else could test this :)

@FatehAK
Copy link

FatehAK commented Jan 18, 2021

It works perfectly @deg0nz. I've used it for the past few days haven't faced any issues.

@deg0nz
Copy link
Author

deg0nz commented Nov 12, 2021

Just FYI:

Me and my colleagues are using this for almost 2 years now without any problems. I think it can be considered stable

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

Successfully merging this pull request may close these issues.

3 participants