Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/dceprojects.corals.io/vendor/nesk/rialto/src/node-process/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/dceprojects.corals.io/vendor/nesk/rialto/src/node-process/Server.js
'use strict';

const net = require('net'),
    Connection = require('./Connection');

/**
 * Listen for new socket connections.
 */
class Server
{
    /**
     * Constructor.
     *
     * @param  {ConnectionDelegate} connectionDelegate
     * @param  {Object} options
     */
    constructor(connectionDelegate, options = {})
    {
        this.options = options;

        this.started = this.start(connectionDelegate);

        this.resetIdleTimeout();
    }

    /**
     * Start the server and listen for new connections.
     *
     * @param  {ConnectionDelegate} connectionDelegate
     * @return {Promise}
     */
    start(connectionDelegate)
    {
        this.server = net.createServer(socket => {
            const connection = new Connection(socket, connectionDelegate);

            connection.on('activity', () => this.resetIdleTimeout());

            this.resetIdleTimeout();
        });

        return new Promise(resolve => {
            this.server.listen(() => resolve());
        });
    }

    /**
     * Write the listening port on the process output.
     */
    writePortToOutput()
    {
        process.stdout.write(`${this.server.address().port}\n`);
    }

    /**
     * Reset the idle timeout.
     *
     * @protected
     */
    resetIdleTimeout()
    {
        clearTimeout(this.idleTimer);

        const {idle_timeout: idleTimeout} = this.options;

        if (idleTimeout !== null) {
            this.idleTimer = setTimeout(() => {
                throw new Error('The idle timeout has been reached.');
            }, idleTimeout * 1000);
        }
    }
}

module.exports = Server;

Spamworldpro Mini