def update_proxy_settings(self, *args, **kwargs):
        """
        When the network configuration changes, this updates the SOCKS proxy
        settings based the current IP address(es)
        """
        # Open a SystemConfiguration preferences session:
        sc_prefs = SCPreferences()

        # We want to enable the server when our hostname is not on the corporate network:
        # BUG: This does not handle multi-homed systems well:
        current_address = socket.gethostbyname(socket.getfqdn())
        new_state       = not current_address.startswith('10.0.1.')

        logging.info(
            "Current address is now %s: SOCKS proxy will be %s" % (
                current_address,
                "Enabled" if new_state else "Disabled"
            )
        )

        try:
            sc_prefs.set_proxy(
                enable=new_state,
                protocol='SOCKS',
                server=self.socks_server,
                port=self.socks_port
            )
            sc_prefs.save()

            logging.info("Successfully updated SOCKS proxy setting")
        except __HOLE__, e:
            logging.error("Unable to set SOCKS proxy setting: %s" % e.message)
dataset/ETHPy150Open MacSysadmin/pymacadmin/examples/crankd/socks-proxy/ProxyManager.py/ProxyManager.update_proxy_settings