This function gets called when the proxy starts up. For
    login the protocol and port are cached.
357109
def init(opts):
    '''
    
    '''
    log.debug('Initting esxvm proxy module in process %s', os.getpid())
    log.debug('Validating esxvm proxy input')
    proxy_conf = merge(opts.get('proxy', {}), __pillar__.get('proxy', {}))
    log.trace('proxy_conf = %s', proxy_conf)
    # TODO json schema validation

    # Save mandatory fields in cache
    for key in ('vcenter', 'datacenter', 'mechanism'):
        DETAILS[key] = proxy_conf[key]

    # Additional validation
    if DETAILS['mechanism'] == 'userpass':
        if 'username' not in proxy_conf:
            raise excs.InvalidProxyInputError(
                'Mechanism is set to \'userpass\' , but no '
                '\'username\' key found in pillar for this proxy.')
        if 'passwords' not in proxy_conf:
            raise excs.InvalidProxyInputError(
                'Mechanism is set to \'userpass\' , but no '
                '\'passwords\' key found in pillar for this proxy.')
        for key in ('username', 'passwords'):
            DETAILS[key] = proxy_conf[key]
    else:
        if 'domain' not in proxy_conf:
            raise excs.InvalidProxyInputError(
                'Mechanism is set to \'sspi\' , but no '
                '\'domain\' key found in pillar for this proxy.')
        if 'principal' not in proxy_conf:
            raise excs.InvalidProxyInputError(
                'Mechanism is set to \'sspi\' , but no '
                '\'principal\' key found in pillar for this proxy.')
        for key in ('domain', 'principal'):
            DETAILS[key] = proxy_conf[key]

    # Save optional
    DETAILS['protocol'] = proxy_conf.get('protocol')
    DETAILS['port'] = proxy_conf.get('port')

    # Test connection
    if DETAILS['mechanism'] == 'userpass':
        # Get the correct login details
        log.debug('Retrieving credentials and testing vCenter connection for '
                  'mehchanism \'userpass\'')
        try:
            username, password = find_credentials()
            DETAILS['password'] = password
        except excs.SaltSystemExit as err:
            log.critical('Error: %s', err)
            return False
    return True
291676
protected Object activateProxy()
    {
        if ( settings == null )
        {
            return null;
        }
        final Proxy proxy = settings.getActiveProxy();
        if ( proxy == null )
        {
            return null;
        }

        final List<String> properties = new ArrayList<String>();
        final String protocol = proxy.getProtocol();
        final String prefix = isEmpty( protocol ) ? "" : ( protocol + "." );

        final String host = proxy.getHost();
        final String hostProperty = prefix + "proxyHost";
        final String hostValue = isEmpty( host ) ? null : host;
        setProperty( properties, hostProperty, hostValue );
        final int port = proxy.getPort();
        final String portProperty = prefix + "proxyPort";
        final String portValue = ( port == 0 || port == -1 ) ? null : String.valueOf( port );
        setProperty( properties, portProperty, portValue );
        final String username = proxy.getUsername();
        final String userProperty = prefix + "proxyUser";
        final String userValue = isEmpty( username ) ? null : username;
        setProperty( properties, userProperty, userValue );
        final String password = proxy.getPassword();
        final String passwordProperty = prefix + "proxyPassword";
        final String passwordValue = isEmpty( password ) ? null : password;
        setProperty( properties, passwordProperty, passwordValue );
        final String nonProxyHosts = proxy.getNonProxyHosts();
        final String nonProxyHostsProperty = prefix + "nonProxyHosts";
        final String nonProxyHostsValue = isEmpty( nonProxyHosts ) ? null : nonProxyHosts.replace( ',', '|' );
        setProperty( properties, nonProxyHostsProperty, nonProxyHostsValue );
        getLog().debug( "Proxy settings: " + hostProperty + "=" + hostValue + ", " + portProperty + "=" + portValue
            + ", " + userProperty + "=" + userValue + ", " + passwordProperty + "="
            + ( passwordValue == null ? "null" : "<PasswordNotLogged>" ) + ", " + nonProxyHostsProperty + "="
            + nonProxyHostsValue );
        return properties;
    }
1323725
private void configureProxyServer(ChannelPipeline clientPipeline) {
        if (proxyServerConfiguration != null && sslConfig != null) {
            if (proxyServerConfiguration.getProxyUsername() != null
                    && proxyServerConfiguration.getProxyPassword() != null) {
                clientPipeline.addLast(Constants.PROXY_HANDLER,
                        new HttpProxyHandler(proxyServerConfiguration.getInetSocketAddress(),
                                proxyServerConfiguration.getProxyUsername(),
                                proxyServerConfiguration.getProxyPassword()));
            } else {
                clientPipeline.addLast(Constants.PROXY_HANDLER,
                        new HttpProxyHandler(proxyServerConfiguration.getInetSocketAddress()));
            }
        }
    }
708915
def start_proxy(self, port=None):
        

        self.runner.info_log("Starting proxy...")

        # Get a random port that is available
        if not port:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.bind(('0.0.0.0', 0))
            sock.listen(5)
            self.proxy_port = sock.getsockname()[1]
            sock.close()

        network_data_path = os.path.join(
            self.runner.runner_dir,
            'network_capture'
        )
        create_dir_if_doesnt_exist(network_data_path)

        self.proxy_output_path = os.path.join(
            network_data_path,
            string_to_filename('%s.data' % self.test_name)
        )

        path_to_mitmproxy = BROME_CONFIG['mitmproxy']['path']

        if not path_to_mitmproxy:
            raise Exception("""
                You need to set the mitmproxy:path config to be able
                to the use the proxy with this browser
            """)

        filter_ = BROME_CONFIG['mitmproxy']['filter']
        command = [
            path_to_mitmproxy,
            "-p",
            "%s" % self.proxy_port,
            "-w",
            self.proxy_output_path
        ]

        if filter_:
            command.append(filter_)

        process = self.execute_command(command)

        self.proxy_pid = process.pid

        self.runner.info_log("Proxy pid: %s" % self.proxy_pid)
1248831
def start_proxy(self):
        

        self.runner.info_log("Starting proxy...")

        self.proxy_port = self.browser_config.get('proxy_port', 8080)

        self.network_data_path = os.path.join(
            self.runner.runner_dir,
            'network_capture'
        )
        create_dir_if_doesnt_exist(self.network_data_path)

        self.local_proxy_output_path = os.path.join(
            self.network_data_path,
            string_to_filename('%s.data' % self.testname)
        )
        self.local_proxy_log_path = os.path.join(
            self.network_data_path,
            string_to_filename('%s.mitm' % self.testname)
        )

        self.remote_proxy_output_path = string_to_filename(
            '%s.data' % self.testname
        )
        self.remote_proxy_log_path = string_to_filename(
            '%s.mitm' % self.testname
        )

        path_to_mitmproxy = self.browser_config.get(
            "mitmproxy:path",
            'mitmdump'
        )

        filter_ = self.browser_config.get("mitmproxy:filter")
        command = [
            'DISPLAY=:0',
            'nohup',
            path_to_mitmproxy,
            "-p",
            "%s" % str(self.proxy_port),
            "-w",
            "'%s'" % self.remote_proxy_output_path
        ]

        if filter_:
            command.append(filter_)

        command.extend(['>', "'%s'" % self.remote_proxy_log_path, '2>&1'])
        command.append('&')

        self.execute_command(' '.join(command))
106312
def connection_made(self, address):
        """"""
        self._proxy = PickleProxy(self.loop, self)
        for d in self._proxy_deferreds:
            d.callback(self._proxy)
512400
def init(opts=None):
    '''
    
    '''
    if opts is None:
        opts = __opts__
    try:
        DETAILS[_worker_name()] = SSHConnection(
            host=opts['proxy']['host'],
            username=opts['proxy']['username'],
            password=opts['proxy']['password'],
            key_accept=opts['proxy'].get('key_accept', False),
            ssh_args=opts['proxy'].get('ssh_args', ''),
            prompt='{0}.*(#|>) '.format(opts['proxy']['prompt_name']))
        DETAILS[_worker_name()].sendline('no cli session paging enable')

    except TerminalException as e:
        log.error(e)
        return False
    DETAILS['initialized'] = True
974610
private function initConnection() {
		if($this->isCliMode()) {
			return;
		}

		$this->initServerCookie();
		$this->client = $this->initClient();

		if($this->client) {
			ob_start();
			$this->isActiveClient = true;
			$this->registerFlushOnShutDown();
			$this->setHeadersLimit(isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false
				? 4096 // default headers limit for Nginx
				: 8192 // default headers limit for all other web-servers
			);
			$this->listenGetPostponedResponse();
			$this->postponeResponseId = $this->setPostponeHeader();
		}
	}
854067
@Override
	protected synchronized void beforeStart()
	{
		super.beforeStart();

		((SipStandardContext)context).setJ2EEServer("MSS-Arquillian-7-" + UUID.randomUUID().toString());
		Tomcat.initWebappDefaults(context);
	}
969347
def enable_proxy(self, host, port):
        """"""

        self.proxy = [host, _number(port)]
        self.proxy_enabled = True
1134693
def startup(self):
        
        self.runner.info_log("Startup")

        if self.browser_config.config.get('enable_proxy'):
            self.start_proxy()
692457
public void start() {
    	if(logger.isDebugEnabled()) {
            logger.debug("start");
        }
        started.set(true);
        if(logger.isDebugEnabled()) {
            logger.debug("Started proxy timer service "+ this);
        }
    }
1347884
def ServerLoggingStartupInit():
  """"""
  global LOGGER
  if local_log:
    logging.debug("Using local LogInit from %s", local_log)
    local_log.LogInit()
    logging.debug("Using local AppLogInit from %s", local_log)
    LOGGER = local_log.AppLogInit()
  else:
    LogInit()
    LOGGER = AppLogInit()
374885
private void onOK() {
		host = host_text.getText().trim();
		user = user_text.getText();
		password = password_text.getText();

		if (host.length() == 0) {
			warn("Proxy host is not set!");
			return;
		}
		if (socks_group.getSelectedCheckbox() == socks4radio) {
			if (user.length() == 0) {
				warn("User name is not set");
				return;
			}

		} else {
			if (up_check.getState()) {
				if (user.length() == 0) {
					warn("User name is not set.");
					return;
				}
				if (password.length() == 0) {
					warn("Password is not set.");
					return;
				}
			} else if (!none_check.getState()) {
				warn("Please select at least one Authentication Method.");
				return;
			}
		}

		try {
			port = Integer.parseInt(port_text.getText());
		} catch (NumberFormatException nfe) {
			warn("Proxy port is invalid!");
			return;
		}

		mode = OK_MODE;

		if (useThreads) {
			net_thread = new Thread(this);
			net_thread.start();

			info("Looking up host: " + host);
			// System.out.println("Info returned.");
		} else if (!initProxy()) {
			warn("Proxy host is invalid.");
			mode = COMMAND_MODE;
		}

		if (mode == OK_MODE)
			dispose();
	}
956104
def init(opts):
    '''
    
    '''
    proxy_dict = opts.get('proxy', {})
    conn_args = proxy_dict.copy()
    conn_args.pop('proxytype', None)
    opts['multiprocessing'] = conn_args.get('multiprocessing', True)
    # This is not a SSH-based proxy, so it should be safe to enable
    # multiprocessing.
    try:
        conn = pyeapi.client.connect(**conn_args)
        node = pyeapi.client.Node(conn, enablepwd=conn_args.get('enablepwd'))
        pyeapi_device['connection'] = node
        pyeapi_device['initialized'] = True
        pyeapi_device['up'] = True
    except pyeapi.eapilib.ConnectionError as cerr:
        log.error('Unable to connect to %s', conn_args['host'], exc_info=True)
        return False
    return True
153171
def set_proxy (self, proxy):
        
        self.proxy = proxy
        self.proxytype = "http"
        self.proxyauth = None
        if not self.proxy:
            return
        proxyurl = urlparse.urlparse(self.proxy)
        self.proxytype = proxyurl.scheme
        if self.proxytype not in ('http', 'https'):
            # Note that invalid proxies might raise TypeError in urllib2,
            # so make sure to stop checking at this point, not later.
            msg = _("Proxy value `%(proxy)s' must start with 'http:' or 'https:'.") \
                 % dict(proxy=proxy)
            raise LinkCheckerError(msg)
        if self.ignore_proxy_host():
            # log proxy without auth info
            log.debug(LOG_CHECK, "ignoring proxy %r", self.proxy)
            self.add_info(_("Ignoring proxy setting `%(proxy)s'.") %
                dict(proxy=proxy))
            self.proxy = None
            return
        log.debug(LOG_CHECK, "using proxy %r", self.proxy)
        self.add_info(_("Using proxy `%(proxy)s'.") % dict(proxy=self.proxy))
        self.proxyhost = proxyurl.hostname
        self.proxyport = proxyurl.port
        if proxyurl.username is not None:
            username = proxyurl.username
            password = proxyurl.password if proxy.password is not None else ""
            auth = "%s:%s" % (username, password)
            self.proxyauth = "Basic "+httputil.encode_base64(auth)
456464
private void initializePort() throws ChannelException {
        try {
            this.endPoint.initServerSocket();
        } catch (IOException ioe) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "TCP Channel: " + getExternalName() + "- Problem occurred while initializing TCP Channel: " + ioe.getMessage());
            }
            throw new ChannelException("TCP Channel: " + getExternalName() + "- Problem occurred while starting channel: " + ioe.getMessage());
        } catch (RetryableChannelException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "TCP Channel: " + getExternalName() + "- Problem occurred while starting TCP Channel: " + e.getMessage());
            }
            throw e;
        }

        // add property to config to provide actual port used (could be ephemeral
        // port if '0' passed in)
        this.channelData.getPropertyBag().put(TCPConfigConstants.LISTENING_PORT, String.valueOf(this.endPoint.getListenPort()));
    }