<commit_before>var ftpd = require('./');
var fs = require('fs');
var path = require('path');
var multiparter = require("multiparter");
var mime = require("mime");
var url = require("url");
var path = require("path");
var http = require("http");

var keyFile, certFile;
if (process.env.KEY_FILE && process.env.CERT_FILE) {
    console.log("Running as FPTS server");
    if (process.env.KEY_FILE.charAt(0) != '/')
        keyFile = path.join(__dirname, process.env.KEY_FILE);
    if (process.env.CERT_FILE.charAt(0) != '/')
        certFile = path.join(__dirname, process.env.CERT_FILE);
}
else {
    console.log(
        "\n" +
        "*** To run as FTPS server, set 'KEY_FILE', 'CERT_FILE' and (optionally) ***\n" +
        "*** 'CA_FILES' env vars. Set 'PORT' to change port that the server      ***\n" +
        "*** listens on.                                                         ***\n"
    );
}
var listenPort = process.env.PORT || 7002;

var tlsOptions = (process.env.KEY_FILE && process.env.CERT_FILE ? {
    key: fs.readFileSync(keyFile),
    cert: fs.readFileSync(certFile),
    ca: !process.env.CA_FILES ? null : process.env.CA_FILES.split(':').map(function (f) {
        return fs.readFileSync(f);
    })
} : null);

var server = new ftpd.FtpServer(process.env.IP || "127.0.0.1", {
//    getInitialCwd: function () { return "/"; }
    getRoot: function () { return process.cwd(); },
    pasvPortRangeStart: 1025,
    pasvPortRangeEnd: 1050,
    tlsOptions: tlsOptions,
//    tlsOnly: true,
    allowUnauthorizedTls: true,
    useWriteFile: true,
    uploadMaxSlurpSize: 7000
});

server.on('error', function (err) {
    console.log("FTP Server error:", err);
});

server.on("client:connected", function(conn) {
    var username = null;
    console.log("client connected: " + conn.remoteAddress);
    conn.on("command:user", function(user, success, failure) {
        if (user) {
            username = user;
            success();
        } else failure();
    });
    
    conn.on("command:pass", function(pass, success, failure) {
        if (pass) success(username);<commit_msg>Set 'useWriteFile' to 'false' by default in test.js<commit_after>var ftpd = require('./');
var fs = require('fs');
var path = require('path');
var multiparter = require("multiparter");
var mime = require("mime");
var url = require("url");
var path = require("path");
var http = require("http");

var keyFile, certFile;
if (process.env.KEY_FILE && process.env.CERT_FILE) {
    console.log("Running as FPTS server");
    if (process.env.KEY_FILE.charAt(0) != '/')
        keyFile = path.join(__dirname, process.env.KEY_FILE);
    if (process.env.CERT_FILE.charAt(0) != '/')
        certFile = path.join(__dirname, process.env.CERT_FILE);
}
else {
    console.log(
        "\n" +
        "*** To run as FTPS server, set 'KEY_FILE', 'CERT_FILE' and (optionally) ***\n" +
        "*** 'CA_FILES' env vars. Set 'PORT' to change port that the server      ***\n" +
        "*** listens on.                                                         ***\n"
    );
}
var listenPort = process.env.PORT || 7002;

var tlsOptions = (process.env.KEY_FILE && process.env.CERT_FILE ? {
    key: fs.readFileSync(keyFile),
    cert: fs.readFileSync(certFile),
    ca: !process.env.CA_FILES ? null : process.env.CA_FILES.split(':').map(function (f) {
        return fs.readFileSync(f);
    })
} : null);

var server = new ftpd.FtpServer(process.env.IP || "127.0.0.1", {
//    getInitialCwd: function () { return "/"; }
    getRoot: function () { return process.cwd(); },
    pasvPortRangeStart: 1025,
    pasvPortRangeEnd: 1050,
    tlsOptions: tlsOptions,
//    tlsOnly: true,
    allowUnauthorizedTls: true,
    useWriteFile: false,
    uploadMaxSlurpSize: 7000
});

server.on('error', function (err) {
    console.log("FTP Server error:", err);
});

server.on("client:connected", function(conn) {
    var username = null;
    console.log("client connected: " + conn.remoteAddress);
    conn.on("command:user", function(user, success, failure) {
        if (user) {
            username = user;
            success();
        } else failure();
    });
    
    conn.on("command:pass", function(pass, success, failure) {
        if (pass) success(username);
{'fraction_non_alphanumeric': 0.16804537934294492, 'fraction_numerical': 0.011344835736232569, 'mean_word_length': 2.8507734303912646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7066813', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1385, 'n_words': 310}