<commit_before>/**
 * @author <NAME>
 * @since v1
 */
load('mod/core/processor.js')
load('mod/core/registry_helper.js')
load('mod/core/originate.js')
load('mod/core/context_storage.js')
load('mod/rest/rest.js')

function Server(locationService, registrarService, accountManagerService, resourcesAPI) {
    const contextStorage = new ContextStorage()
    const config = resourcesAPI.getConfig()
    const InetAddress = Packages.java.net.InetAddress
    config.ip = InetAddress.getLocalHost().getHostAddress()

    const SipFactory = Packages.javax.sip.SipFactory
    const Properties = Packages.java.util.Properties
    const LogManager = Packages.org.apache.logging.log4j.LogManager
    const LOG = LogManager.getLogger()
    let restService
    let sipStack

    // Registration with gateways expire in 5 minutes, so we will re-register in 4
    const proRegExp = 4

    this.start = () => {
        LOG.info('Starting Sip I/O')
        LOG.debug('Local IP: ' + config.ip)
        if (config.externalIp != undefined) LOG.debug('External IP: ' + config.externalIp)

        const properties = new Properties()
        const sipFactory = SipFactory.getInstance()

        sipFactory.setPathName('gov.nist')
        properties.setProperty('javax.sip.STACK_NAME', 'sipio')
        properties.setProperty('javax.sip.AUTOMATIC_DIALOG_SUPPORT', 'OFF')
        // Guard against denial of service attack.
        properties.setProperty('gov.nist.javax.sip.MAX_MESSAGE_SIZE', '1048576');
        // Drop the client connection after we are done with the transaction.
        properties.setProperty('gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS', 'false');
        properties.setProperty('gov.nist.javax.sip.TRACE_LEVEL', config.traceLevel);
        // This seems to work with ws but not with udp
        properties.setProperty('gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY', 'gov.nist.javax.sip.stack.NioMessageProcessorFactory')
        properties.setProperty('gov.nist.javax.sip.PATCH_SIP_WEBSOCKETS_HEADERS', 'false')

        sipStack = sipFactory.createSipStack(properties)

        const messageFactory = sipFactory.createMessageFactory()
        const headerFactory = sipFactory.createHeaderFactory()
        const addressFactory = sipFactory.createAddressFactory()
        const tcp = sipStack.createListeningPoint(config.ip, config.tcpPort, 'tcp')
        const udp = sipStack.createListeningPoint(config.ip, config.udpPort, 'udp')
        const ws = sipStack.createListeningPoint(config.ip, config.wsPort, 'ws')

        const sipProvider = sipStack.createSipProvider(tcp)
        sipProvider.addListeningPoint(udp)
        sipProvider.addListeningPoint(ws)

        // Server's contact address and header
        const serverURI = 'sip:' + config.ip
        const contactAddress = addressFactory.createAddress(serverURI)
        const contactHeader = headerFactory.createContactHeader(contactAddress)
<commit_msg>Added default IP address<commit_after>/**
 * @author <NAME>
 * @since v1
 */
load('mod/core/processor.js')
load('mod/core/registry_helper.js')
load('mod/core/originate.js')
load('mod/core/context_storage.js')
load('mod/rest/rest.js')

function Server(locationService, registrarService, accountManagerService, resourcesAPI) {
    const contextStorage = new ContextStorage()
    const config = resourcesAPI.getConfig()
    const InetAddress = Packages.java.net.InetAddress
    config.ip = InetAddress.getLocalHost().getHostAddress()

    const SipFactory = Packages.javax.sip.SipFactory
    const Properties = Packages.java.util.Properties
    const LogManager = Packages.org.apache.logging.log4j.LogManager
    const LOG = LogManager.getLogger()
    let restService
    let sipStack

    // Registration with gateways expire in 5 minutes, so we will re-register in 4
    const proRegExp = 4

    this.start = () => {
        LOG.info('Starting Sip I/O')
        LOG.debug('Local IP: ' + config.ip)
        if (config.externalIp != undefined) LOG.debug('External IP: ' + config.externalIp)

        const properties = new Properties()
        const sipFactory = SipFactory.getInstance()

        sipFactory.setPathName('gov.nist')
        properties.setProperty('javax.sip.STACK_NAME', 'sipio')
        properties.setProperty('javax.sip.IP_ADDRESS', config.ip)
        properties.setProperty('javax.sip.AUTOMATIC_DIALOG_SUPPORT', 'OFF')
        // Guard against denial of service attack.
        properties.setProperty('gov.nist.javax.sip.MAX_MESSAGE_SIZE', '1048576');
        // Drop the client connection after we are done with the transaction.
        properties.setProperty('gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS', 'false');
        properties.setProperty('gov.nist.javax.sip.TRACE_LEVEL', config.traceLevel);
        // This seems to work with ws but not with udp
        properties.setProperty('gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY', 'gov.nist.javax.sip.stack.NioMessageProcessorFactory')
        properties.setProperty('gov.nist.javax.sip.PATCH_SIP_WEBSOCKETS_HEADERS', 'false')

        sipStack = sipFactory.createSipStack(properties)

        const messageFactory = sipFactory.createMessageFactory()
        const headerFactory = sipFactory.createHeaderFactory()
        const addressFactory = sipFactory.createAddressFactory()
        const tcp = sipStack.createListeningPoint(config.tcpPort, 'tcp')
        const udp = sipStack.createListeningPoint(config.udpPort, 'udp')
        const ws = sipStack.createListeningPoint(config.wsPort, 'ws')

        const sipProvider = sipStack.createSipProvider(tcp)
        sipProvider.addListeningPoint(udp)
        sipProvider.addListeningPoint(ws)

        // Server's contact address and header
        const serverURI = 'sip:' + config.ip
        const contactAddress = addressFactory.createAddress(serverURI)
        const contactHeader = headerFactory.createContactHeader(contactAddress)

{'fraction_non_alphanumeric': 0.10681431005110732, 'fraction_numerical': 0.0040885860306643955, 'mean_word_length': 3.6228346456692915, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7347107', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1706, 'n_words': 336}