<commit_before>// Modified slightly from
// https://github.com/andris9/rai/blob/master/lib/starttls.js
// (This code is MIT licensed.)

//
// Target API:
//
//  var s = require('net').createStream(25, 'smtp.example.com');
//  s.on('connect', function() {
//    require('starttls')(s, options, function() {
//      if (!s.authorized) {
//        s.destroy();
//        return;
//      }
//
//      s.end("hello world\n");
//    });
//  });
//
//

var tls = require('tls'),
    crypto = require('crypto');

// From Node docs for TLS module.
var RECOMMENDED_CIPHERS = 'ECDHE-RSA-AES256-SHA:AES256-SHA:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM';

function starttlsServer(socket, options, callback) {
  return starttls(socket, options, callback, true);
}
function starttlsClient(socket, options, callback) {
  return starttls(socket, options, callback, false);
}

function starttls(socket, options, callback, isServer) {
  var sslcontext, pair, cleartext;

  var opts = { };
  for (k in options) {
    opts[k] = options[k];
  }
  if (!opts.ciphers)
    opts.ciphers = RECOMMENDED_CIPHERS;

  socket.removeAllListeners("data");
  sslcontext = crypto.createCredentials(opts);
  pair = tls.createSecurePair(sslcontext, isServer);
  cleartext = pipe(pair, socket);

  var erroredOut = false;
  pair.on('secure', function() {<commit_msg>Removed use of deprecated createCredentials() method if run under node 0.11+<commit_after>// Modified slightly from
// https://github.com/andris9/rai/blob/master/lib/starttls.js
// (This code is MIT licensed.)

//
// Target API:
//
//  var s = require('net').createStream(25, 'smtp.example.com');
//  s.on('connect', function() {
//    require('starttls')(s, options, function() {
//      if (!s.authorized) {
//        s.destroy();
//        return;
//      }
//
//      s.end("hello world\n");
//    });
//  });
//
//

var tls = require('tls'),
    crypto = require('crypto');

// From Node docs for TLS module.
var RECOMMENDED_CIPHERS = 'ECDHE-RSA-AES256-SHA:AES256-SHA:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM';

function starttlsServer(socket, options, callback) {
  return starttls(socket, options, callback, true);
}
function starttlsClient(socket, options, callback) {
  return starttls(socket, options, callback, false);
}

function starttls(socket, options, callback, isServer) {
  var sslcontext, pair, cleartext;

  var opts = { };
  for (k in options) {
    opts[k] = options[k];
  }
  if (!opts.ciphers)
    opts.ciphers = RECOMMENDED_CIPHERS;

  socket.removeAllListeners("data");
  if (tls.createSecureContext) {
    sslcontext = tls.createSecureContext(opts);
  } else {
    sslcontext = crypto.createCredentials(opts);
  }
  pair = tls.createSecurePair(sslcontext, isServer);
  cleartext = pipe(pair, socket);

  var erroredOut = false;
  pair.on('secure', function() {
{'fraction_non_alphanumeric': 0.1719360568383659, 'fraction_numerical': 0.009591474245115453, 'mean_word_length': 3.5128205128205128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7081005', 'n_tokens_mistral': 1008, 'n_tokens_neox': 978, 'n_words': 203}