Launches a new Telnet client session on the server taken from the `self.options` dict.

        :param my_ip: IP of this Client itself
353461
def start(self):
        

        login = self.options['username']
        password = self.options['password']
        server_host = self.options['server']
        server_port = self.options['port']
        honeypot_id = self.options['honeypot_id']
        command_limit = random.randint(6, 11)

        session = self.create_session(server_host, server_port, honeypot_id)
        self.sessions[session.id] = session
        logger.debug(
            'Sending telnet bait session to {0}:{1}. (bait id: {2})'.format(server_host, server_port, session.id))

        try:
            self.connect()
            self.login(login, password)

            session.add_auth_attempt('plaintext', True, username=login, password=password)

            session.did_connect = True
            session.source_port = self.client.sock.getsockname()[1]
            session.did_login = True
        except InvalidLogin:
            logger.debug('Telnet session could not login. ({0})'.format(session.id))
            session.did_login = False
        except Exception as err:
            logger.debug('Caught exception: {0} {1}'.format(err, str(err), exc_info=True))
        else:
            command_count = 0
            while command_count < command_limit:
                command_count += 1
                self.sense()
                comm, param = self.decide()
                self.act(comm, param)
                gevent.sleep(random.uniform(0.4, 5.6))
            self.act('logout')
            session.did_complete = True
        finally:
            session.alldone = True
            session.end_session()
            if self.client:
                self.client.close()
1180408
def assign_global_ip(self, global_ip_id, target):
        
        return self.client['Network_Subnet_IpAddress_Global'].route(
            target, id=global_ip_id)
1338561
def __telnet_event_listener(self, ip, callback):
        """"""

        tn = telnetlib.Telnet(ip, 2708)
        self._last_event = ""
        self._telnet_running = True
        while self._telnet_running:
            try:
                raw_string = tn.read_until(b'.\n', 5)

                if len(raw_string) >= 2 and raw_string[-2:] == b'.\n':
                    # lightpad sends ".\n" at the end that we need to chop off
                    json_string = raw_string.decode('ascii')[0:-2]
                    if json_string != self._last_event:
                        callback(json.loads(json_string))

                    self._last_event = json_string

            except:
                pass
        tn.close()
677018
def launch(self, callback_function=None):
        
        self._check_registered()

        self._socket_client.receiver_controller.launch_app(
            self.supporting_app_id, callback_function=callback_function)
578293
def create_telnet_shell(shell, loop=None):
    

    if loop is None:
        loop = asyncio.get_event_loop()

    def factory(reader, writer):
        return ShellConnection(reader, writer, shell, loop)

    return AsyncioTelnetServer(binary=True, echo=True, naws=True, connection_factory=factory)
535246
def post_init(*args)
      logger.info "got connection from #{remote_ip}"

      # initialize the line-based protocol: IRC is \r\n
      @lt2_delimiter = "\r\n"

      # start up the IRCD for this connection
      @ircd = IRCD.new(self, options)

      if options[:ssl]
        logger.info "starting TLS for #{remote_ip}"
        start_tls(:cert_chain_file => options[:ssl_cert], :private_key_file => options[:ssl_private_key], :verify_peer => options[:ssl_verify_peer])
      end
    end
477062
def open(self):
        
        print 'Connection opened.'
        
        # retrieve user_id if specified
        user_id = self.get_argument("user_id", None)
        # add client to list of connected clients
        self.add_client(user_id)
        # welcome message
        self.send_message("Welcome to nodeshot websocket server.")
        # new client connected message
        client_count = len(self.get_clients().keys())
        new_client_message = 'New client connected, now we have %d %s!' % (client_count, 'client' if client_count <= 1 else 'clients')
        # broadcast new client connected message to all connected clients
        self.broadcast(new_client_message)
        
        print self.channels['private']
955697
def _send(self, ip, port, data):
        
        return self._listen_socket.sendto(data, (ip, port))
576848
async def main():
    
    # Create Client from endpoint string in Duniter format
    client = Client(ES_CORE_ENDPOINT)

    # Get the current node (direct REST GET request)
    print("\nGET g1-test/block/current/_source:")
    response = await client.get('g1-test/block/current/_source')
    print(response)

    # Get the node number 2 with only selected fields (direct REST GET request)
    print("\nGET g1-test/block/2/_source:")
    response = await client.get('g1-test/block/2/_source', {'_source': 'number,hash,dividend,membersCount'})
    print(response)

    # Close client aiohttp session
    await client.close()

    # Create Client from endpoint string in Duniter format
    client = Client(ES_USER_ENDPOINT)

    # prompt entry
    pubkey = input("\nEnter a public key to get the user profile: ")

    # Get the profil of a public key (direct REST GET request)
    print("\nGET user/profile/{0}/_source:".format(pubkey))
    response = await client.get('user/profile/{0}/_source'.format(pubkey.strip(' \n')))
    print(response)

    # Close client aiohttp session
    await client.close()
565110
def start(self):
        
        self.log.info("Starting SSL Session for Monitor %s."
                      % self.monitor_id)
        if self.socket is not None:
            raise Exception("Socket already established for %s." % self)

        try:
            # Create socket, wrap in SSL and connect.
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            # Validate that certificate server uses matches what we expect.
            if self.ca_certs is not None:
                self.socket = ssl.wrap_socket(self.socket,
                                              cert_reqs=ssl.CERT_REQUIRED,
                                              ca_certs=self.ca_certs)
            else:
                self.socket = ssl.wrap_socket(self.socket)

            self.socket.connect((self.client.hostname, PUSH_SECURE_PORT))
            self.socket.setblocking(0)
        except Exception as exception:
            self.socket.close()
            self.socket = None
            raise exception

        self.send_connection_request()
530563
def _create_websession(self):
        """"""
        from socket import AF_INET
        from aiohttp import ClientTimeout, TCPConnector

        _LOGGER.debug('Creating web session')
        conn = TCPConnector(
            family=AF_INET,
            limit_per_host=5,
            enable_cleanup_closed=True,
        )

        # Create session object.
        session_timeout = ClientTimeout(connect=10)
        self._websession = ClientSession(connector=conn,
                                         timeout=session_timeout)
        self._supplied_websession = False
810355
def _connect(self, endpoint: str):
        
        if self._socket:
            raise RuntimeError('Cannot run multiple Servers on the same socket')

        context = zmq.asyncio.Context()
        self._socket = context.socket(zmq.ROUTER)
        self._socket.bind(endpoint)

        _log.info("Starting server, listening on endpoint {}".format(endpoint))
1212444
def launch_server(message_handler, options):
    
    logger = logging.getLogger(__name__)
    if (options.debug):
        logger.setLevel(logging.DEBUG)

    if not options.monitor_port:
        logger.warning(
            "Monitoring not enabled. No monitor-port option defined.")
    else:
        threading.Thread(target=launch_monitor_server, args=(options.host, options.monitor_port, logger)).start()

    # Create the server, binding to specified host on configured port

    logger.info(
        'Starting server on host %s port %d Python version %s.%s.%s' % ((options.host, options.port) + sys.version_info[:3]))
    server = ThreadedTCPServer((options.host, options.port),
                       StreamHandler.create_handler(message_handler,
                                                    options.buffer_size,
                                                    logger))

    # Activate the server; this will keep running until you
    # interrupt the program with Ctrl-C
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        logger.info("Ctrl-C, exiting...")
        os._exit(142)
877857
def run
      if PryDebugger.current_remote_server
        raise 'Already running a pry-remote session!'
      else
        PryDebugger.current_remote_server = self
      end

      setup
      Pry.start @object, {
        :input  => client.input_proxy,
        :output => client.output
      }
    end
903784
def start(self):
        '''
        
        '''
        log.debug('Creating the TCP server')
        if ':' in self.address:
            self.skt = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
        else:
            self.skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        if self.reuse_port:
            self.skt.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            if hasattr(socket, 'SO_REUSEPORT'):
                self.skt.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
            else:
                log.error('SO_REUSEPORT not supported')
        try:
            self.skt.bind((self.address, int(self.port)))
        except socket.error as msg:
            error_string = 'Unable to bind to port {} on {}: {}'.format(self.port, self.address, msg)
            log.error(error_string, exc_info=True)
            raise BindException(error_string)
        log.debug('Accepting max %d parallel connections', self.max_clients)
        self.skt.listen(self.max_clients)
        self.thread_serve = threading.Thread(target=self._serve_clients)
        self.thread_serve.start()
1267538
def create_ip(self):
        """"""
        return Ip(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
328893
def start_to(self, ip, tcpport=102):
        
        if tcpport != 102:
            logger.info("setting server TCP port to %s" % tcpport)
            self.set_param(snap7.snap7types.LocalPort, tcpport)
        assert re.match(ipv4, ip), '%s is invalid ipv4' % ip
        logger.info("starting server to %s:102" % ip)
        return self.library.Srv_Start(self.pointer, ip)