<commit_before>'use strict';

const md5       = require('nyks/crypto/md5');
const ubkClient = require('ubk/client/tcp');
const SSH_Host  = require('./ssh_host.js');
const utils     = require('ssh2').utils;
const debug       = require('debug')('mas4h:slave');

const NS_mas4h = "mas4h";

class Instance extends ubkClient {
  constructor(options) {

    options = Object.assign({
      key : null, //put server private key here
      ssh_port   : 1443,
      ssh_addr   : '0.0.0.0',
      use_socketwrap : false,
    }, options);

    super(options);
    this._localClients = {};

    var key  = utils.parseKey(this.options.key);
    this.client_key = md5(key.getPublicSSH());
  }

  async run() {

    var server = new SSH_Host({
      server_rsa     : this.options.key,
      use_socketwrap : this.options.use_socketwrap
    }, async (client, infos) => {
      client.on('error', (err) => debug('client error', err));<commit_msg>add ips in register parameters<commit_after>'use strict';
const os        = require('os');

const md5       = require('nyks/crypto/md5');
const ubkClient = require('ubk/client/tcp');
const SSH_Host  = require('./ssh_host.js');
const utils     = require('ssh2').utils;
const debug     = require('debug')('mas4h:slave');
const NS_mas4h = "mas4h";

class Instance extends ubkClient {
  constructor(options) {

    options = Object.assign({
      key : null, //put server private key here
      ssh_port   : 1443,
      ssh_addr   : '0.0.0.0',
      use_socketwrap : false,
    }, options);

    super(options);
    this._localClients = {};
    const localIpv4Ips = Object.values(os.networkInterfaces()).reduce((v, c) => [...v, ...c], []).filter(v => v.family === "IPv4" && !v.internal);
    this.options.registration_parameters['ips'] = localIpv4Ips.map(v => v.address);

    var key  = utils.parseKey(this.options.key);
    this.client_key = md5(key.getPublicSSH());
  }

  async run() {

    var server = new SSH_Host({
      server_rsa     : this.options.key,
      use_socketwrap : this.options.use_socketwrap
    }, async (client, infos) => {
      client.on('error', (err) => debug('client error', err));
{'fraction_non_alphanumeric': 0.16151685393258428, 'fraction_numerical': 0.01544943820224719, 'mean_word_length': 3.117533718689788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2828547', 'n_tokens_mistral': 735, 'n_tokens_neox': 711, 'n_words': 151}