mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 01:17:18 +00:00
fix(socket) isContainStr -> isContainStrAtBegin
This commit is contained in:
parent
40c8e6118b
commit
b24a382067
1 changed files with 44 additions and 44 deletions
|
|
@ -55,55 +55,55 @@
|
|||
*/
|
||||
function onMessage(pConnNum, pSocket){
|
||||
return function(pCommand) {
|
||||
Util.log(pCommand);
|
||||
Util.log(pCommand);
|
||||
|
||||
if( Util.isContainStrAtBegin(pCommand, 'cloudcmd') ){
|
||||
pCommand = Util.removeStr(pCommand, 'cloudcmd');
|
||||
|
||||
if( Util.isContainStr(pCommand, 'cloudcmd') ){
|
||||
pCommand = Util.removeStr(pCommand, 'cloudcmd');
|
||||
if( Util.isContainStrAtBegin(pCommand, ' ') ){
|
||||
pCommand = Util.removeStr(pCommand, ' ');
|
||||
|
||||
if( Util.isContainStr(pCommand, ' ') ){
|
||||
pCommand = Util.removeStr(pCommand, ' ');
|
||||
|
||||
if( Util.isContainStr(pCommand, 'update') && update )
|
||||
update.get();
|
||||
|
||||
if( Util.strCmp(pCommand, 'exit') )
|
||||
if(main.WIN32)
|
||||
pCommand = 'taskkill -f /PID ' + process.pid;
|
||||
else
|
||||
pCommand = 'kill -9 ' + process.pid;
|
||||
}
|
||||
else {
|
||||
var lMsg = {
|
||||
stdout : 'cloudcmd exit - for shutdown cloudcmd',
|
||||
stderr : null
|
||||
};
|
||||
|
||||
lMsg = JSON.stringify(lMsg);
|
||||
pSocket.send(lMsg);
|
||||
|
||||
Util.log('received from client: ' + pCommand);
|
||||
Util.log('sended to client: ' + lMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/* if we on windows and command is build in
|
||||
* change code page to unicode becouse
|
||||
* windows use unicode on non English versions
|
||||
*/
|
||||
if(Win32_b){
|
||||
var lWinCommand = pCommand.toUpperCase();
|
||||
if( Util.isContainStrAtBegin(pCommand, 'update') && update )
|
||||
update.get();
|
||||
|
||||
if( Win32Commands.indexOf(lWinCommand) > 0 )
|
||||
pCommand = 'chcp 65001 |' + pCommand;
|
||||
if( Util.strCmp(pCommand, 'exit') )
|
||||
if(main.WIN32)
|
||||
pCommand = 'taskkill -f /PID ' + process.pid;
|
||||
else
|
||||
pCommand = 'kill -9 ' + process.pid;
|
||||
}
|
||||
else {
|
||||
var lMsg = {
|
||||
stdout : 'cloudcmd exit - for shutdown cloudcmd',
|
||||
stderr : null
|
||||
};
|
||||
|
||||
lMsg = JSON.stringify(lMsg);
|
||||
pSocket.send(lMsg);
|
||||
|
||||
Util.log('received from client: ' + pCommand);
|
||||
Util.log('sended to client: ' + lMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/* if we on windows and command is build in
|
||||
* change code page to unicode becouse
|
||||
* windows use unicode on non English versions
|
||||
*/
|
||||
if(Win32_b){
|
||||
var lWinCommand = pCommand.toUpperCase();
|
||||
|
||||
if(!ClientFuncs[pConnNum])
|
||||
ClientFuncs[pConnNum] = getExec(pSocket);
|
||||
|
||||
var lExec_func = ClientFuncs[pConnNum];
|
||||
|
||||
exec(pCommand, lExec_func);
|
||||
};
|
||||
if( Win32Commands.indexOf(lWinCommand) > 0 )
|
||||
pCommand = 'chcp 65001 |' + pCommand;
|
||||
}
|
||||
|
||||
if(!ClientFuncs[pConnNum])
|
||||
ClientFuncs[pConnNum] = getExec(pSocket);
|
||||
|
||||
var lExec_func = ClientFuncs[pConnNum];
|
||||
|
||||
exec(pCommand, lExec_func);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue