OSDN Git Service

テストケースを追加した
[webchat/WebChat.git] / chat.js
diff --git a/chat.js b/chat.js
index 0b7e68e..5388d6f 100644 (file)
--- a/chat.js
+++ b/chat.js
@@ -29,15 +29,16 @@ module.exports = function(app,server,express,session){
        app.get("/chat", chat_proc);\r
        app.all("/log/*",express.basicAuth(auth_proc));\r
        app.get("/log/*",log_proc);\r
-       app.all("/admin",express.basicAuth(auth_proc));\r
-       app.get("/admin", admin_proc);\r
-       app.post("/admin",admin_postproc);\r
+       app.all("/chat/admin",express.basicAuth(auth_proc));\r
+       app.get("/chat/admin", admin_proc);\r
+       app.post("/chat/admin",admin_postproc);\r
 \r
        var io = require("socket.io").listen(server);\r
        io.configure("production", function(){\r
+               io.set("transports", config.transports);\r
                io.enable("browser client minification");  // minified されたクライアントファイルを送信する\r
-       io.enable("browser client etag");          // バージョンによって etag によるキャッシングを有効にする\r
-       io.set("log level", 1);                    // ログレベルを設定(デフォルトより下げている)\r
+               io.enable("browser client etag");          // バージョンによって etag によるキャッシングを有効にする\r
+               io.set("log level", 1);                    // ログレベルを設定(デフォルトより下げている)\r
        });\r
 \r
        for(var i = 0; i < config.max_room_number; i++)\r
@@ -71,19 +72,19 @@ function admin_postproc(req,res){
        if(typeof(req.body.erase) != "undefined")\r
        {\r
                removeLog(req.body.file,function(){\r
-                       res.redirect("/admin");\r
+                       res.redirect("/chat/admin");\r
                });\r
        }\r
        if(typeof(req.body.registor) != "undefined")\r
        {\r
                ipbanlist.Update(req.body.newbanlist,function(){\r
-                       res.redirect("/admin");\r
+                       res.redirect("/chat/admin");\r
                });\r
        }\r
        if(typeof(req.body.updateroom) != "undefined")\r
        {\r
                $rooms.Update(req.body,function(){\r
-                       res.redirect("/admin");\r
+                       res.redirect("/chat/admin");\r
                });\r
        }\r
 }\r
@@ -134,7 +135,7 @@ function RoomInfomationCollection()
                                user     : config.db_user,\r
                                password : config.db_password,\r
                                port     : config.db_port,\r
-                               database : "webchat",\r
+                               database : config.db_name,\r
                        });\r
        var collection = {};\r
        this.Get = function(rno){\r
@@ -351,7 +352,7 @@ function IpBanCollecion()
                                user     : config.db_user,\r
                                password : config.db_password,\r
                                port     : config.db_port,\r
-                               database : "webchat",\r
+                               database : config.db_name,\r
                        });\r
        var collection = {};\r
        this.IsBaned = function(ip){\r
@@ -477,9 +478,11 @@ function ParseAuthorization(handshakeData, callback)
                                result = "failed get from session store";\r
                        else if(err)\r
                                result = err;\r
+                       else if(typeof(session) == "undefined" || typeof(session._csrf) == "undefined")\r
+                               result = "session is undefined";\r
                        else if(handshakeData.query.token != session._csrf)\r
                                result = "invaild token";\r
-                       if(typeof(session) != "undefined" && result == null)\r
+                       if(result == null)\r
                                handshakeData.sessionID = sessionID;\r
                        callback(result,result == null && !err);\r
                });\r