Skip to content

Commit

Permalink
20191004
Browse files Browse the repository at this point in the history
  • Loading branch information
KloakIT committed Oct 5, 2019
1 parent ac5600c commit b6f2645
Show file tree
Hide file tree
Showing 20 changed files with 590 additions and 922 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Known Vulnerabilities](https://snyk.io/test/github/qtgate/qtgate-desktop-client/badge.svg)](https://snyk.io/test/github/qtgate/qtgate-desktop-client)
[![Telegram](https://img.shields.io/badge/telebot-community%20group-blue.svg)](https://t.me/joinchat/IpX64hGK_95XDTXit42vOg)

![http protocol](/resources/CoPlatform3.png?raw=true)
![http protocol](/resources/CoPlatform4.png?raw=true)

CoNET Platform is cross-platform software, provids a suite of APP that developed for use on [CoNET](https://github.com/QTGate/CoNET).

Expand Down
3 changes: 2 additions & 1 deletion app/CoNET.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ interface QTGateAPIRequestCommand {
fingerprint?: string
dataTransfer?: iTransferData
requestTimes?: number
region?: string
region?: string
CallBack?: any

}

Expand Down
40 changes: 15 additions & 25 deletions app/localWebServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ class localServer {
}
}
};
/**
*
* @param cmd CoNET server command
*
*/
const catchUnSerialCmd = (cmd) => {
return console.log(`catchUnSerialCmd: LocalWebServer catch UnSerialCmd!\n\ncmd`);
};
const makeConnect = (sendMail) => {
if (!this.imapConnectData.sendToQTGate || sendMail) {
Expand All @@ -192,39 +198,22 @@ class localServer {
this.socketServer.emit('systemErr', err);
return socket.emit('tryConnectCoNETStage', imapErrorCallBack(err.message));
}
return this.CoNETConnectCalss = new coNETConnect_1.default(this.imapConnectData, this.socketServer, this.openPgpKeyOption, true, catchUnSerialCmd, _exitFunction);
return this.CoNETConnectCalss = new coNETConnect_1.default(this.imapConnectData, this.socketServer, this.openPgpKeyOption, true, mail => {
return catchUnSerialCmd(mail);
}, _exitFunction);
});
}
console.log(`makeConnect without sendMail`);
return this.CoNETConnectCalss = new coNETConnect_1.default(this.imapConnectData, this.socketServer, this.openPgpKeyOption, false, catchUnSerialCmd, _exitFunction);
return this.CoNETConnectCalss = new coNETConnect_1.default(this.imapConnectData, this.socketServer, this.openPgpKeyOption, false, mail => {
return catchUnSerialCmd(mail);
}, _exitFunction);
};
if (!this.CoNETConnectCalss || this.CoNETConnectCalss.alreadyExit) {
saveLog(`!this.CoNETConnectCalss || this.CoNETConnectCalss.alreadyExit`);
return makeConnect(false);
}
return this.CoNETConnectCalss.tryConnect1();
}
sendRequest(socket, cmd, sessionHash, CallBack) {
if (!this.openPgpKeyOption) {
console.log(`sendrequest keypair error! !this.config [${!this.config}] !this.keyPair[${!this.keyPair}]`);
return CallBack('systemError');
}
if (!this.CoNETConnectCalss) {
console.log(`sendrequest no CoNETConnectCalss`);
this.tryConnectCoNET(socket, sessionHash);
return CallBack('reConnectCoNET');
}
saveLog(`sendRequest send [${cmd.command}]`);
cmd.requestSerial = Crypto.randomBytes(8).toString('hex');
return this.CoNETConnectCalss.requestCoNET(cmd, (err, res) => {
saveLog(`request response [${cmd.command}]`);
if (err) {
CallBack(err);
return saveLog(`QTClass.request error! [${err}]`);
}
return CallBack(null, res);
});
}
listenAfterPassword(socket, sessionHash) {
//console.log (`localServer listenAfterPassword for sessionHash [${ sessionHash }]`)
socket.on('checkImap', (emailAddress, password, timeZone, tLang, CallBack1) => {
Expand Down Expand Up @@ -333,8 +322,9 @@ class localServer {
});
});
});
socket.on('doingRequest', request => {
this.CoNETConnectCalss.trySendToRemote();
socket.on('doingRequest', (uuid, request, CallBack) => {
console.log(`on doingRequest\n[ ${uuid}]\n${request}`);
return this.CoNETConnectCalss.requestCoNET_v1(uuid, request, CallBack);
});
}
doingCheckImap(socket) {
Expand Down
49 changes: 16 additions & 33 deletions app/localWebServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ export default class localServer {


}

const catchUnSerialCmd = ( cmd: QTGateAPIRequestCommand ) => {

/**
*
* @param cmd CoNET server command
*
*/
const catchUnSerialCmd = ( cmd: string ) => {
return console.log (`catchUnSerialCmd: LocalWebServer catch UnSerialCmd!\n\ncmd`)
}

const makeConnect = ( sendMail: boolean ) => {
Expand All @@ -180,12 +184,16 @@ export default class localServer {
return socket.emit ( 'tryConnectCoNETStage', imapErrorCallBack ( err.message ))
}

return this.CoNETConnectCalss = new CoNETConnectCalss ( this.imapConnectData, this.socketServer, this.openPgpKeyOption, true, catchUnSerialCmd, _exitFunction )
return this.CoNETConnectCalss = new CoNETConnectCalss ( this.imapConnectData, this.socketServer, this.openPgpKeyOption, true, mail => {
return catchUnSerialCmd ( mail )
}, _exitFunction )
})

}
console.log ( `makeConnect without sendMail`)
return this.CoNETConnectCalss = new CoNETConnectCalss ( this.imapConnectData, this.socketServer, this.openPgpKeyOption, false, catchUnSerialCmd, _exitFunction )
return this.CoNETConnectCalss = new CoNETConnectCalss ( this.imapConnectData, this.socketServer, this.openPgpKeyOption, false, mail => {
return catchUnSerialCmd ( mail )
}, _exitFunction )

}

Expand All @@ -198,32 +206,6 @@ export default class localServer {

}

public sendRequest ( socket: SocketIO.Socket, cmd: QTGateAPIRequestCommand, sessionHash: string, CallBack ) {
if ( !this.openPgpKeyOption ) {
console.log ( `sendrequest keypair error! !this.config [${ !this.config }] !this.keyPair[${ !this.keyPair }]`)
return CallBack ( 'systemError' )
}
if ( !this.CoNETConnectCalss ) {
console.log (`sendrequest no CoNETConnectCalss`)
this.tryConnectCoNET ( socket, sessionHash )
return CallBack ( 'reConnectCoNET' )
}

saveLog (`sendRequest send [${ cmd.command }]`)

cmd.requestSerial = Crypto.randomBytes(8).toString('hex')

return this.CoNETConnectCalss.requestCoNET ( cmd, ( err, res: QTGateAPIRequestCommand ) => {
saveLog ( `request response [${ cmd.command }]`)
if ( err ) {
CallBack ( err )
return saveLog ( `QTClass.request error! [${ err }]`)
}
return CallBack ( null, res )
})

}


private listenAfterPassword ( socket: SocketIO.Socket, sessionHash: string ) {
//console.log (`localServer listenAfterPassword for sessionHash [${ sessionHash }]`)
Expand Down Expand Up @@ -351,8 +333,9 @@ export default class localServer {
})
})

socket.on ( 'doingRequest', request => {
this.CoNETConnectCalss.trySendToRemote ( )
socket.on ( 'doingRequest', ( uuid, request, CallBack ) => {
console.log (`on doingRequest\n[ ${ uuid }]\n${ request }`)
return this.CoNETConnectCalss.requestCoNET_v1 ( uuid, request, CallBack )
})

}
Expand Down
Loading

0 comments on commit b6f2645

Please sign in to comment.