var fs = require('fs');
var splitca = require('split-ca');

module.exports = {
    /* Socket port to listen on */
    port: 5566,

    /* Web UI */
    startWebServer: false,
    webServerPort: 8080,
    webServerPortHttps: 8081,
    /*Log Levels - default is "info"
     *  
     *  This setting controls all logging into
     *  the server.log file - other than the
     *  restart message which will ALWAYS show.
     *
     * "info" -> log info and error events
     * "error" -> log error events only
     * "silent" -> do not log at all
     *
     * debug, warn, fatal, error, http could be 
     * implemented as well, but not done yet*/
    logLevel: "info",

    // Path to log output file
    logFilePath: "./server.log",
    
    /* SSL configurations */
    ssl: {
        port: 5567,
        options: {
            ca: splitca('cert/cabundle.pem'),
            key: fs.readFileSync('cert/server-key.pem'),
            cert: fs.readFileSync('cert/server-cert.pem'),
        }
    },


    /*
    ************************************************************************
    ***   The following options REQUIRE a MySQL database to function !   ***
    ************************************************************************
    */

    // If you want to track how many users are online, set UserList: true.
    Userlist: false,

    /* Controls how many results a request for 'users_online' receives. */
    maxUserResults: 100,

    /* MySQL database connection info for janus-mysql-auth and janus-mysql-userlist */
    MySQL_Hostname: 'localhost',
    MySQL_Database: 'janusvr',
    MySQL_Username: 'janusvr',
    MySQL_Password: 'janusvr',

    /* Authentication mode:
        'none'     - Will not attempt to authenticate users, 
                     anyone can connect with any unused userId.
        'optional' - Anyone can connect, but if userId has been registered
                     a password must be provided.
        'required' - Only users with userids and passwords are allowed to connect.
    */
    authMode: "none",
    
    popularRooms: {
      halfLife: 7 * 24 * 60 * 60 * 1000, // set halflife to 7 days
      updateInterval: 3000,             // interval between weight updates on the popular rooms
      masterToken: "changethis"  
    },

    /*
    ************************************************************************
    ***   The previous options REQUIRE a MySQL database to function !    ***
    ************************************************************************
    */



    /* Plugins must be installed from npm, or manually created in node_module/ to be loaded. */
    /* hookPlugins are called while parsing messages */
    hookPlugins: {  
        logon: { 
            plugins: [ "janus-mysql-auth" ]
        },
        enter_room: {
            plugins: ["janus-mysql-popular"]
        }
      
    },

    /* methodPlugins add new commands to the server */
    methodPlugins: {
        ping: { plugin: "janus-method-ping" }
    },

    /* intervalPlugins are called in intervals specified in seconds. */
    intervalPlugins: [
        { plugin: "janus-mysql-userlist-official", interval: 5 }
    ],
};

@@ -2732,17 +2732,23 @@
 gins: %5B 
-%22
+%0A%09%09//%22 
 janus-my
@@ -2757,16 +2757,18 @@
 l-auth%22 
+%0A%09
 %5D%0A      
@@ -2816,16 +2816,22 @@
 ugins: %5B
+%0A%09%09// 
 %22janus-m
@@ -2843,16 +2843,18 @@
 popular%22
+%0A%09
 %5D%0A      
@@ -2955,16 +2955,19 @@
 %0A       
+ //
  ping: %7B
@@ -3108,17 +3108,20 @@
         
-%7B
+//%7B 
  plugin:
@@ -3168,10 +3168,10 @@
 al: 
-5 
+6%09
 %7D%0A  

Disable plugins by default in config-example.js