<commit_before>###

Copyright (c) 2011-2012  Voicious

This program is free software: you can redistribute it and/or modify it under the terms of the
GNU Affero General Public License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this
program. If not, see <http://www.gnu.org/licenses/>.

###

Path    = require 'path'

DefaultHostname = (hostname) =>
    h =
        'Internal' : 'localhost',
        'External' : 'localhost'
    if hostname?
        h.Internal = hostname.Internal if hostname.Internal?
        h.External = hostname.External if hostname.External?
    return h

class _Config
    checkCoreConfig : () ->
        @Voicious.Enabled  = 0           if not @Voicious.Enabled?
        @Voicious.Hostname = DefaultHostname @Voicious.Hostname
        @Voicious.Port     = 4242        if not @Voicious.Port?

    checkRestConfig : () ->
        @Restapi.Enabled = 0 if not @Restapi.Enabled?
        if @Restapi.Enabled
            if not @Restapi.Database.Connector?
                throw "Must provice a database connector if enabling REST API."
            @Restapi.Hostname         = DefaultHostname @Restapi.Hostname
            @Restapi.Port             = 4243        if not @Restapi.Port?
            @Restapi['Allowed-hosts'] = [ ]         if not @Restapi['Allowed-hosts']?
            if (typeof @Restapi['Allowed-hosts']) is (typeof "")
                @Restapi['Allowed-hosts'] = [ @Restapi['Allowed-hosts'] ]
            @Restapi['Allowed-hosts'].push "http://#{@Voicious.Hostname.Internal}:#{@Voicious.Port}"
            @Restapi['Allowed-hosts'].push "http://#{@Voicious.Hostname.External}:#{@Voicious.Port}"<commit_msg>[config] can still specify one unique IP address (use it for both internal and external access)<commit_after>###

Copyright (c) 2011-2012  Voicious

This program is free software: you can redistribute it and/or modify it under the terms of the
GNU Affero General Public License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this
program. If not, see <http://www.gnu.org/licenses/>.

###

Path    = require 'path'

DefaultHostname = (hostname) =>
    h =
        'Internal' : 'localhost',
        'External' : 'localhost'
    if hostname?
        if (typeof hostname) is (typeof "")
            h.Internal = hostname
            h.External = hostname
        else
            h.Internal = hostname.Internal if hostname.Internal?
            h.External = hostname.External if hostname.External?
    return h

class _Config
    checkCoreConfig : () ->
        @Voicious.Enabled  = 0           if not @Voicious.Enabled?
        @Voicious.Hostname = DefaultHostname @Voicious.Hostname
        @Voicious.Port     = 4242        if not @Voicious.Port?

    checkRestConfig : () ->
        @Restapi.Enabled = 0 if not @Restapi.Enabled?
        if @Restapi.Enabled
            if not @Restapi.Database.Connector?
                throw "Must provice a database connector if enabling REST API."
            @Restapi.Hostname         = DefaultHostname @Restapi.Hostname
            @Restapi.Port             = 4243        if not @Restapi.Port?
            @Restapi['Allowed-hosts'] = [ ]         if not @Restapi['Allowed-hosts']?
            if (typeof @Restapi['Allowed-hosts']) is (typeof "")
                @Restapi['Allowed-hosts'] = [ @Restapi['Allowed-hosts'] ]
            @Restapi['Allowed-hosts'].push "http://#{@Voicious.Hostname.Internal}:#{@Voicious.Port}"
            @Restapi['Allowed-hosts'].push "http://#{@Voicious.Hostname.External}:#{@Voicious.Port}"
{'fraction_non_alphanumeric': 0.1010477299185099, 'fraction_numerical': 0.008847497089639115, 'mean_word_length': 2.643765903307888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2066488', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1156, 'n_words': 402}