From b2b550d47a2f07e2b3bcffa4ad31470ab34f3627 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 26 Dec 2016 16:55:49 +0100 Subject: Move everything to /ss namespace --- client.js | 12 ++++++------ serverstore.js | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client.js b/client.js index 606a331..5108a6b 100755 --- a/client.js +++ b/client.js @@ -8,7 +8,7 @@ var fs=require("fs"), kbd=require("kbd"), toClipboard=require("to-clipboard"); -var HOSTNAME=process.argv[2]||"tomsmeding.com",HTTPPORT=42420; +var HOSTNAME=process.argv[2]||"tomsmeding.com",HTTPPORT=80; console.log("Using server "+HOSTNAME); @@ -126,7 +126,7 @@ function getchallenge(cb){ var req=http.request({ hostname:HOSTNAME, port:HTTPPORT, - path:"/challenge", + path:"/ss/challenge", method:"GET", keepAlive:true //speed up the next request },function(res){ @@ -158,7 +158,7 @@ function sendfile(fname,retries){ var req=http.request({ hostname:HOSTNAME, port:HTTPPORT, - path:"/image/"+userid+"/"+authhash(challenge,password)+"/"+escape(barefname), + path:"/ss/image/"+userid+"/"+authhash(challenge,password)+"/"+escape(barefname), method:"POST", headers:{ "Content-Type":"image/png" @@ -197,7 +197,7 @@ function userExists(userid,cb){ var req=http.request({ hostname:HOSTNAME, port:HTTPPORT, - path:"/exists/"+userid, + path:"/ss/exists/"+userid, method:"GET" },function(res){ if(res.statusCode==200)cb(true); @@ -218,7 +218,7 @@ function checkLogin(userid,password,cb,retries){ var req=http.request({ hostname:HOSTNAME, port:HTTPPORT, - path:"/checklogin/"+userid+"/"+authhash(challenge,password), + path:"/ss/checklogin/"+userid+"/"+authhash(challenge,password), method:"GET" },function(res){ if(res.statusCode==200)cb(true); @@ -240,7 +240,7 @@ function registerUser(userid,password){ var req=http.request({ hostname:HOSTNAME, port:HTTPPORT, - path:"/registerx/"+userid, + path:"/ss/registerx/"+userid, method:"POST", headers:{ "Content-Type":"text/plain" diff --git a/serverstore.js b/serverstore.js index a420c16..21876ee 100755 --- a/serverstore.js +++ b/serverstore.js @@ -54,7 +54,7 @@ app.use(bodyParser.text({ })); -app.get("/challenge",function(req,res){ +app.get("/ss/challenge",function(req,res){ res.end(challenge); }); @@ -86,7 +86,7 @@ app.param("fname",function(req,res,next,fname){ req.ssfname=req.sscode+"_"+fname.replace(/[\x00-\x1F\/]/g,"").replace(/^\.+/,""); next(); }); -app.post("/image/:userid/:authhash/:fname",function(req,res){ +app.post("/ss/image/:userid/:authhash/:fname",function(req,res){ try { if(!fs.statSync("images").isDirectory())throw new Error; } catch(e){ @@ -97,7 +97,7 @@ app.post("/image/:userid/:authhash/:fname",function(req,res){ fs.mkdirSync("images/"+req.ssuser[0]); } fs.writeFileSync("images/"+req.ssuser[0]+"/"+req.ssfname,req.body); - res.end("http://"+req.hostname+"/ssimg/"+req.ssuser[0]+"/"+req.sscode); + res.end("http://"+req.hostname+"/ss/get/"+req.ssuser[0]+"/"+req.sscode); }); @@ -105,7 +105,7 @@ app.param("reguserid",function(req,res,next,reguserid){ req.ssreguserid=reguserid; next(); }); -app.post("/registerx/:reguserid",function(req,res){ //pass password in body +app.post("/ss/registerx/:reguserid",function(req,res){ //pass password in body var password=req.body; if(Persist.getItemSync("user_"+req.ssreguserid)){ res.sendStatus(409); //Conflict @@ -118,12 +118,12 @@ app.post("/registerx/:reguserid",function(req,res){ //pass password in body }); -app.get("/exists/:reguserid",function(req,res){ +app.get("/ss/exists/:reguserid",function(req,res){ res.sendStatus(Persist.getItemSync("user_"+req.ssreguserid)?200:404); res.end(); }); -app.get("/checklogin/:userid/:authhash",function(req,res){ +app.get("/ss/checklogin/:userid/:authhash",function(req,res){ res.sendStatus(200); //login checking is done in the authhash param res.end(); }); @@ -138,7 +138,7 @@ app.param("ssimgcode",function(req,res,next,ssimgcode){ } next(); }); -app.get("/ssimg/:userid/:ssimgcode",function(req,res){ +app.get("/ss/get/:userid/:ssimgcode",function(req,res){ var files=glob.sync(__dirname+"/images/"+req.ssuser[0]+"/"+req.ssimgcode+"*"); if(files.length==0){ res.sendStatus(404); -- cgit v1.2.3-70-g09d2