<commit_before>import net from 'net';
import { EventEmitter } from 'events';
import Connection from './connection';

/**
 * Backend server that listens for proxy connections.
 *
 * @emits connection
 * @extends EventEmitter
 */
class Server extends EventEmitter {
    /**
     * Create a new Server
     *
     * @param {Object} config server configuration
     */
    constructor(config) {
        super();
        this.config = config;
        this.init();
    }

    /**
     * Initialize the server
     *
     * @private
     */
    init() {
        this.server = net.createServer(this.onConnection.bind(this));
        this.server.listen(this.config.getPort(), this.config.getHost());
    }

    /**
     * Handle a new incoming proxy connection.
     *
     * @param {net.Socket} socket remote socket
     * @private
     */
    onConnection(socket) {
        const endpoint = socket.remoteAddress + '/' + socket.remotePort;
        const connection = new Connection(socket, endpoint);
        this.emit('connection', connection);
    }
}

export default Server
<commit_msg>Add protocol field to proxy server<commit_after>import net from 'net';
import { EventEmitter } from 'events';
import Connection from './connection';

/**
 * Backend server that listens for proxy connections.
 *
 * @emits connection
 * @extends EventEmitter
 */
class Server extends EventEmitter {
    /**
     * Create a new Server
     *
     * @param {Object} config server configuration
     * @param {Object} protocol protocol to use for incoming connections
     */
    constructor(config, protocol) {
        super();
        this.config = config;
        this.protocol = protocol;
        this.init();
    }

    /**
     * Initialize the server
     *
     * @private
     */
    init() {
        this.server = net.createServer(this.onConnection.bind(this));
        this.server.listen(this.config.getPort(), this.config.getHost());
    }

    /**
     * Handle a new incoming proxy connection.
     *
     * @param {net.Socket} socket remote socket
     * @private
     */
    onConnection(socket) {
        const endpoint = socket.remoteAddress + '/' + socket.remotePort;
        const connection = new Connection(socket, endpoint, this.protocol);
        this.emit('connection', connection);
    }
}

export default Server

{'fraction_non_alphanumeric': 0.1183585313174946, 'fraction_numerical': 0.0, 'mean_word_length': 2.43620178041543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '2182623', 'n_tokens_mistral': 621, 'n_tokens_neox': 622, 'n_words': 172}