hide info
This commit is contained in:
@@ -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))
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user