feat: add boss key
This commit is contained in:
1 parent
e7087bc4b1
commit
bc775d4fd6
10 files changed
+168
-6
No files matched your search
@@ -10,6 +10,7 @@ import { gatewayRouter } from './gateway/router';
|
||||
import { os } from '@orpc/server';
|
||||
import { z } from 'zod';
|
||||
import { isProcessRunning, closeAntigravity, startAntigravity } from './process/handler';
|
||||
import { systemHandler } from './system/handler';
|
||||
|
||||
// Log middleware setup
|
||||
const logMiddleware = os.middleware(async (opts: any) => {
|
||||
@@ -51,4 +52,5 @@ export const router = os.use(logMiddleware).router({
|
||||
cloud: cloudRouter,
|
||||
config: configRouter,
|
||||
gateway: gatewayRouter,
|
||||
system: systemHandler,
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { os } from '@orpc/server';
|
||||
import { z } from 'zod';
|
||||
import { networkInterfaces } from 'os';
|
||||
|
||||
export const systemHandler = os.route({
|
||||
get_local_ip: os.handler(async () => {
|
||||
const nets = networkInterfaces();
|
||||
const results: string[] = [];
|
||||
|
||||
for (const name of Object.keys(nets)) {
|
||||
for (const net of nets[name] || []) {
|
||||
// Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
|
||||
if (net.family === 'IPv4' && !net.internal) {
|
||||
results.push(net.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results.length > 0 ? results[0] : '127.0.0.1';
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user