Open telnet connection

        Args:
            params (dict), must contain two parameters "ip" - ip address or hostname and "port" - port number

        Example:
            params = {'port': 23, 'ip': 'localhost'}
431675
def open(self, **params):
        
        logger.info('opening telnet')
        self.port = params['port']
        self.ip = params['ip']
        self.tn = None
        self._init()
1177896
def build_url (self):
        
        super(TelnetUrl, self).build_url()
        # default port
        if self.port is None:
            self.port = 23
        # set user/pass
        self.user, self.password = self.get_user_password()
990787
def channel_parameters(parameter_prefix, channel_names, configuration_entry):
    

    if configuration_entry in (True, False):
        return ([], [parameter_prefix])[configuration_entry]

    parameters = []
    if isinstance(configuration_entry, dict):
        for name in set(channel_names).intersection(configuration_entry):
            if configuration_entry[name] is True:
                parameters.append(parameter_prefix + "_" + name)
    else:
        raise TypeError("incorrect type")

    return parameters
273965
def get_network_params(self):
        
        ip = self.__address[0]
        mask = b''
        gate = b''
        cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, b'IPAddress\x00', 1024)
        if cmd_response.get('status'):
            ip = (self.__data.split(b'=', 1)[-1].split(b'\x00')[0])
        cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, b'NetMask\x00', 1024)
        if cmd_response.get('status'):
            mask = (self.__data.split(b'=', 1)[-1].split(b'\x00')[0])
        cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, b'GATEIPAddress\x00', 1024)
        if cmd_response.get('status'):
            gate = (self.__data.split(b'=', 1)[-1].split(b'\x00')[0])
        return {'ip': ip.decode(), 'mask': mask.decode(), 'gateway': gate.decode()}
936796
def open(self, *args, **kwargs):
        
        Telnet.open(self, *args, **kwargs)
        if self.force_ssl:
            self._start_tls()
1218450
def connect_to_tcp(params)
      # check if the path is sufficient
      if params.key?("host") && params.key?("port")
        begin
          # initialize the tcp socket
          @socket = TCPSocket.new(params["host"], params["port"].to_i)
          @socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
          init_connection
          @is_tcp = true
        rescue Exception => e
          puts "Oops:", e
          puts "Error: Could not establish connection to: #{@path}, will now exit."
          exit(1) # a little harsh
        end
      else
        # Danger, Will Robinson: the specified "path" is not usable
        puts "Error: supplied path: #{@path}, unusable! sorry."
      end
    end
125361
def ping(self, params=None):
        
        try:
            return self.transport.perform_request("HEAD", "/", params=params)
        except TransportError:
            return False
88928
def connect_telnet(name, ip_address=None, user='micro', password='python'):
    """"""
    if ip_address is None:
        try:
            ip_address = socket.gethostbyname(name)
        except socket.gaierror:
            ip_address = name
    if not QUIET:
        if name == ip_address:
            print('Connecting to (%s) ...' % ip_address)
        else:
            print('Connecting to %s (%s) ...' % (name, ip_address))
    dev = DeviceNet(name, ip_address, user, password)
    add_device(dev)
321650
def hostname_or_ip_address(blank = false)
      regexp = Regexp.union(hostname, ip_address)
      add_blank_option(regexp, blank)
    end
782338
def _system_parameters(**kwargs):
    
    return {key: value for key, value in kwargs.items()
            if (value is not None or value == {})}
1124017
def ip
      ip = request.remote_ip
      if ip && Ahoy.mask_ips
        Ahoy.mask_ip(ip)
      else
        ip
      end
    end
882014
def _setup_subnet_parameters(self, params, data, is_create=True):
        
        is_update = not is_create
        params['enable_dhcp'] = data['enable_dhcp']
        if int(data['ip_version']) == 6:
            ipv6_modes = utils.get_ipv6_modes_attrs_from_menu(
                data['ipv6_modes'])
            if ipv6_modes[0] and is_create:
                params['ipv6_ra_mode'] = ipv6_modes[0]
            if ipv6_modes[1] and is_create:
                params['ipv6_address_mode'] = ipv6_modes[1]
        if data['allocation_pools']:
            pools = [dict(zip(['start', 'end'], pool.strip().split(',')))
                     for pool in data['allocation_pools'].splitlines()
                     if pool.strip()]
            params['allocation_pools'] = pools
        if data['host_routes'] or is_update:
            routes = [dict(zip(['destination', 'nexthop'],
                               route.strip().split(',')))
                      for route in data['host_routes'].splitlines()
                      if route.strip()]
            params['host_routes'] = routes
        if data['dns_nameservers'] or is_update:
            nameservers = [ns.strip()
                           for ns in data['dns_nameservers'].splitlines()
                           if ns.strip()]
            params['dns_nameservers'] = nameservers
886258
def connect(self, host, port, name=None):
        
        client = self._clients.get(name)
        client.connect_to(host, port)
854681
def _can_connect(ip, port):
    """"""
    cs = socket.socket()
    try:
        cs.connect((ip, port))
        cs.close()
        return True
    except socket.error:
        return False
1291050
def _bindlist(input_str):
    
    try:
        ip_port = input_str.split(':')
        if len(ip_port) == 1:
            _ip = ip_port[0]
            _port = None
        else:
            (_ip, _port) = ip_port
        if not _ip and not _port:
            raise AssertionError
        elif not _port:
            _port = '22'  # default port if not given
        return _ip, int(_port)
    except ValueError:
        raise argparse.ArgumentTypeError(
            'Address tuple must be of type IP_ADDRESS:PORT'
        )
    except AssertionError:
        raise argparse.ArgumentTypeError("Both IP:PORT can't be missing!")
983913
def _parse_allow(allow):
    '''
    
    '''
    # input=> tcp:53,tcp:80,tcp:443,icmp,tcp:4201,udp:53
    # output<= [
    #     {"IPProtocol": "tcp", "ports": ["53","80","443","4201"]},
    #     {"IPProtocol": "icmp"},
    #     {"IPProtocol": "udp", "ports": ["53"]},
    # ]
    seen_protos = {}
    allow_dict = []
    protocols = allow.split(',')
    for p in protocols:
        pairs = p.split(':')
        if pairs[0].lower() not in ['tcp', 'udp', 'icmp']:
            raise SaltCloudSystemExit(
                'Unsupported protocol {0}. Must be tcp, udp, or icmp.'.format(
                    pairs[0]
                )
            )
        if len(pairs) == 1 or pairs[0].lower() == 'icmp':
            seen_protos[pairs[0]] = []
        else:
            if pairs[0] not in seen_protos:
                seen_protos[pairs[0]] = [pairs[1]]
            else:
                seen_protos[pairs[0]].append(pairs[1])
    for k in seen_protos:
        d = {'IPProtocol': k}
        if seen_protos[k]:
            d['ports'] = seen_protos[k]
        allow_dict.append(d)
    log.debug("firewall allowed protocols/ports: %s", allow_dict)
    return allow_dict
1309140
function(req) {
      if (req.connection && req.connection.remoteAddress) {
        return {
          ip: req.connection.remoteAddress,
          port: req.connection.remotePort
        };
      }

      if (req.socket && req.socket.remoteAddress) {
        return {
          ip: req.socket.remoteAddress,
          port: req.socket.remotePort
        };
      }

      return {
        ip: '0.0.0.0',
        port: 'n/a'
      };
    }