hide info

This commit is contained in:
2019-09-18 02:24:40 +02:00
parent 2f32d7c9cd
commit 17dc58c5b3
4 changed files with 23 additions and 47 deletions
+8 -19
View File
@@ -132,7 +132,10 @@ export const rpcToRpcinfo = (rpc : socketioRPC, owner: string):RpcInfo => {
}
}
export const rpcHooker = (socket: Socket, owner:string, RPCs: socketioRPC[], makeUnique = true):ExtendedRpcInfo[] => {
function rpcHooker(socket: Socket, exporter:RPCExporter, makeUnique = true):ExtendedRpcInfo[]{
const owner = exporter.name
const RPCs = [...exporter.exportPublicRPCs(), ...exporter.exportRPCs()]
const suffix = makeUnique?"-"+uuid().substr(0,4):""
return RPCs.map(rpc => rpcToRpcinfo(rpc, owner))
.map(info => {
@@ -236,32 +239,18 @@ export class RPCSocketServer{
}
protected initRPCs(socket:Socket){
const infoRPC:socketioRPC[] = [
{
name: 'info',
type: 'call',
func: async () => rpcInfos
}
]
socket.hook('info', () => rpcInfos)
const rpcInfos:ExtendedRpcInfo[] = [
...rpcHooker(socket, "RPC", infoRPC, false),
...this.rpcExporters.flatMap(exporter => rpcHooker(socket, exporter.name, [...exporter.exportPublicRPCs(), ...exporter.exportRPCs()]))
...this.rpcExporters.flatMap(exporter => rpcHooker(socket, exporter))
]
}
protected initPublicRPCs(socket:Socket){
const adminRPCs:socketioRPC[] = [
{
name: 'info',
type: 'call',
func: async () => rpcInfos
}
]
socket.hook('info', () => rpcInfos)
const rpcInfos:ExtendedRpcInfo[] = [
...rpcHooker(socket, "Admin", adminRPCs, false),
...this.rpcExporters.flatMap(exporter => rpcHooker(socket, exporter.name, exporter.exportPublicRPCs()))
...this.rpcExporters.flatMap(exporter => rpcHooker(socket, exporter))
]
}
}