Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.145.116.239
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/3/task/3/root/proc/3/root/lib/node_modules/pm2/node_modules/needle/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/3/task/3/root/proc/3/root/lib/node_modules/pm2/node_modules/needle/test/helpers.js
var fs = require('fs');

var protocols = {
  http  : require('http'),
  https : require('https')
}

var keys = {
  cert : fs.readFileSync(__dirname + '/keys/ssl.cert'),
  key  : fs.readFileSync(__dirname + '/keys/ssl.key')
}

var helpers = {};

helpers.server = function(opts, cb) {

  var defaults = {
    code    : 200,
    headers : {'Content-Type': 'application/json'}
  }

  var mirror_response = function(req) {
    return JSON.stringify({
      headers: req.headers,
      body: req.body
    })
  }

  var get = function(what) {
    if (!opts[what])
      return defaults[what];
  
    if (typeof opts[what] == 'function')
      return opts[what](); // set them at runtime
    else
      return opts[what];
  }

  var finish = function(req, res) {
    res.writeHead(get('code'), get('headers'));
    res.end(opts.response || mirror_response(req));
  }

  var handler = function(req, res) {

    req.setEncoding('utf8'); // get as string
    req.body = '';
    req.on('data', function(str) { req.body += str })
    req.socket.on('error', function(e) { 
      // res.writeHead(500, {'Content-Type': 'text/plain'});
      // res.end('Error: ' + e.message);
    })

    setTimeout(function(){
      finish(req, res);
    }, opts.wait || 0);

  };

  var protocol = opts.protocol || 'http';
  var server;

  if (protocol == 'https')
    server = protocols[protocol].createServer(keys, handler);
  else
    server = protocols[protocol].createServer(handler);

  server.listen(opts.port, cb);
  return server;
}

module.exports = helpers;

Anon7 - 2022
AnonSec Team