Generate address for request/response message.

		:param beacon_config: server or client configuration. Client configuration is used for request and \
		server configuration for response
		:return: bytes
357516
def _message_address_generate(self, beacon_config):
		

		address = None

		if beacon_config['wasp-general::network::beacon']['public_address'] != '':
			address = str(WIPV4SocketInfo.parse_address(
				beacon_config['wasp-general::network::beacon']['public_address']
			)).encode('ascii')

		if address is not None:
			address = WBeaconGouverneurMessenger.__message_splitter__ + address

			if beacon_config['wasp-general::network::beacon']['public_port'] != '':
				port = beacon_config.getint('wasp-general::network::beacon', 'public_port')
				address += WBeaconGouverneurMessenger.__message_splitter__ + str(port).encode('ascii')

		return address if address is not None else b''
863980
def _configured_socket(address, options):
    
    sock = _create_connection(address, options)
    ssl_context = options.ssl_context

    if ssl_context is not None:
        host = address[0]
        try:
            # According to RFC6066, section 3, IPv4 and IPv6 literals are
            # not permitted for SNI hostname.
            # Previous to Python 3.7 wrap_socket would blindly pass
            # IP addresses as SNI hostname.
            # https://bugs.python.org/issue32185
            # We have to pass hostname / ip address to wrap_socket
            # to use SSLContext.check_hostname.
            if _HAVE_SNI and (not is_ip_address(host) or _PY37PLUS):
                sock = ssl_context.wrap_socket(sock, server_hostname=host)
            else:
                sock = ssl_context.wrap_socket(sock)
        except _SSLCertificateError:
            sock.close()
            # Raise CertificateError directly like we do after match_hostname
            # below.
            raise
        except IOError as exc:
            sock.close()
            # We raise AutoReconnect for transient and permanent SSL handshake
            # failures alike. Permanent handshake failures, like protocol
            # mismatch, will be turned into ServerSelectionTimeoutErrors later.
            _raise_connection_failure(address, exc, "SSL handshake failed: ")
        if (ssl_context.verify_mode and not
                getattr(ssl_context, "check_hostname", False) and
                options.ssl_match_hostname):
            try:
                match_hostname(sock.getpeercert(), hostname=host)
            except CertificateError:
                sock.close()
                raise

    sock.settimeout(options.socket_timeout)
    return sock
174578
def gen_params_from_config(config_dict):
    

    if config_dict.get("count_bucket"):
        logger.warning("change your endpoint to the count endpoint; this is "
                       "default behavior when the count bucket "
                       "field is defined")
        endpoint = change_to_count_endpoint(config_dict.get("endpoint"))
    else:
        endpoint = config_dict.get("endpoint")


    def intify(arg):
        if not isinstance(arg, int) and arg is not None:
            return int(arg)
        else:
            return arg

    # this parameter comes in as a string when it's parsed
    results_per_call = intify(config_dict.get("results_per_call", None))

    rule = gen_rule_payload(pt_rule=config_dict["pt_rule"],
                            from_date=config_dict.get("from_date", None),
                            to_date=config_dict.get("to_date", None),
                            results_per_call=results_per_call,
                            count_bucket=config_dict.get("count_bucket", None))

    _dict = {"endpoint": endpoint,
             "username": config_dict.get("username"),
             "password": config_dict.get("password"),
             "bearer_token": config_dict.get("bearer_token"),
             "extra_headers_dict": config_dict.get("extra_headers_dict",None),
             "rule_payload": rule,
             "results_per_file": intify(config_dict.get("results_per_file")),
             "max_results": intify(config_dict.get("max_results")),
             "max_pages": intify(config_dict.get("max_pages", None))}
    return _dict
609546
def get_proxy_config(self, headers, path):
        
        self.ofs.conn.add_aws_auth_header(headers, 'PUT', path)
        from pprint import pprint
        pprint(headers)
        host = self.ofs.conn.server_name()
        return host, headers
494030
def get_bitcoind_client(config_path=None, bitcoind_opts=None):
    
    if bitcoind_opts is None and config_path is None:
        raise ValueError("Need bitcoind opts or config path")

    bitcoind_opts = get_bitcoind_config(config_file=config_path)
    log.debug(" at %s:%s (%s)" % (bitcoind_opts['bitcoind_server'], bitcoind_opts['bitcoind_port'], config_path))
    client = connect_bitcoind_impl( bitcoind_opts )

    return client
876360
def get_properties(self, packet, bt_addr):
        """"""
        if is_one_of(packet, [EddystoneTLMFrame, EddystoneURLFrame, \
                              EddystoneEncryptedTLMFrame, EddystoneEIDFrame]):
            # here we retrieve the namespace and instance which corresponds to the
            # eddystone beacon with this bt address
            return self.properties_from_mapping(bt_addr)
        else:
            return packet.properties
1223565
def _determine_beacon_config(self, current_beacon_config, key):
        '''
        
        '''

        interval = False
        if isinstance(current_beacon_config, dict):
            interval = current_beacon_config.get(key, False)

        return interval
949389
def config_server
      file = File.open("#{@project_name}/server.rb", "r+")
      file.each do |line|	   
        while line == "  def response(env)\n" do
          pos = file.pos
          rest = file.read
          file.seek pos
          file.write("\t::") 
          file.write(@module_name)
          file.write("::Base.call(env)\n")
          file.write(rest)
          $stdout.puts "\e[1;35m \tconfig\e[0m\tserver.rb"
          return
        end
      end
    end
247915
def _parse_peer_address(self, config):
        
        match = re.search(r'peer-address ([^\s]+)', config)
        value = match.group(1) if match else None
        return dict(peer_address=value)
205311
def validate(config):
    '''
    
    '''
    valid = True
    messages = []

    if not isinstance(config, list):
        valid = False
        messages.append('[-] Configuration for %s beacon must be a list', config)
    else:
        _config = {}
        list(map(_config.update, config))

    try:
        sites = _config.get('sites', {})
    except AttributeError:
        valid = False
        messages.append('[-] Sites for %s beacon must be a dict', __virtualname__)

    if not sites:
        valid = False
        messages.append('[-] Configuration does not contain sites')

    for site, settings in sites.items():
        if required_site_attributes.isdisjoint(set(settings.keys())):
            valid = False
            messages.append('[-] Sites for {} beacon requires {}'.format(__virtualname__,
                                                                         required_site_attributes))
        log.debug('[+] site: %s', site)
        log.debug('[+] settings: %s', settings)

        for optional_attrs in itertools.chain(settings.get(attr, []) for attr in optional_site_attributes):
            for item in optional_attrs:
                cmp = item.get('comp')
                if cmp and cmp not in comparisons:
                    valid = False
                    messages.append('[-] Invalid comparison operator %s', cmp)

    messages.append('[+] Valid beacon configuration')
    return valid, messages
601167
def _configure_sockets(self, config, with_streamer=False, with_forwarder=False):
        
        rc_port = config.get('rc_port', 5001)

        self.result_collector.set_hwm(0)
        self.result_collector.bind("tcp://*:{}".format(rc_port))

        self.poller.register(self.result_collector, zmq.POLLIN)
944572
def has_response(self, beacon_config, request, client_address):
		
		try:
			groups, address = self._message_hostgroup_parse(request)

			if len(self.__hostgroups) == 0 or len(groups) == 0:
				return True

			for group_name in groups:
				if group_name in self.__hostgroups:
					return True
			return False
		except ValueError:
			pass
		return False
108098
def get(self):
        
        config = self.get_block('^router bgp .*')
        if not config:
            return None

        response = dict()
        response.update(self._parse_bgp_as(config))
        response.update(self._parse_router_id(config))
        response.update(self._parse_max_paths(config))
        response.update(self._parse_shutdown(config))
        response.update(self._parse_networks(config))

        response['neighbors'] = self.neighbors.getall()

        return response
1349368
def beacon(config):
    '''
    
    '''
    ret = []
    pkey = 'sh.vt'
    shells = _get_shells()
    ps_out = __salt__['status.procs']()
    track_pids = []
    for pid in ps_out:
        if any(ps_out[pid].get('cmd', '').lstrip('-') in shell for shell in shells):
            track_pids.append(pid)
    if pkey not in __context__:
        __context__[pkey] = {}
    for pid in track_pids:
        if pid not in __context__[pkey]:
            cmd = ['strace', '-f', '-e', 'execve', '-p', '{0}'.format(pid)]
            __context__[pkey][pid] = {}
            __context__[pkey][pid]['vt'] = salt.utils.vt.Terminal(
                    cmd,
                    log_stdout=True,
                    log_stderr=True,
                    stream_stdout=False,
                    stream_stderr=False)
            __context__[pkey][pid]['user'] = ps_out[pid].get('user')
    for pid in list(__context__[pkey]):
        out = ''
        err = ''
        while __context__[pkey][pid]['vt'].has_unread_data:
            tout, terr = __context__[pkey][pid]['vt'].recv()
            if not terr:
                break
            out += salt.utils.stringutils.to_unicode(tout or '')
            err += terr
        for line in err.split('\n'):
            event = {'args': [],
                     'tag': pid}
            if 'execve' in line:
                comps = line.split('execve')[1].split('"')
                for ind, field in enumerate(comps):
                    if ind == 1:
                        event['cmd'] = field
                        continue
                    if ind % 2 != 0:
                        event['args'].append(field)
                event['user'] = __context__[pkey][pid]['user']
                ret.append(event)
        if not __context__[pkey][pid]['vt'].isalive():
            __context__[pkey][pid]['vt'].close()
            __context__[pkey].pop(pid)
    return ret
252052
def address(self):
        '''
        
        '''
        return self.API.replace(
            'http://{}:{}'.format(
                self._bridge.hostname,
                self._bridge.port
            ), ''
        )
15522
def encode_request(name, uuid, callable, address):
    
    client_message = ClientMessage(payload_size=calculate_size(name, uuid, callable, address))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_str(uuid)
    client_message.append_data(callable)
    AddressCodec.encode(client_message, address)
    client_message.update_frame_length()
    return client_message
420482
def response_address(self, beacon_config, request, client_address):
		
		si = self._message_address_parse(request, invert_hello=self.__invert_hello)
		address = si.address()
		port = si.port()
		return WIPV4SocketInfo(
			address if address is not None else client_address.address(),
			port if port is not None else client_address.port()
		)