feat(gateway): add optional bonjour/mdns discovery
This commit is contained in:
@@ -74,6 +74,34 @@ describe('configSchema — server', () => {
|
||||
expect(result.server.ws_rate_limit.max_violations).toBe(3);
|
||||
expect(result.server.ws_rate_limit.violation_window_ms).toBe(2000);
|
||||
});
|
||||
|
||||
it('defaults discovery settings', () => {
|
||||
const result = configSchema.parse(minimalConfig);
|
||||
expect(result.server.discovery.enabled).toBe(false);
|
||||
expect(result.server.discovery.service_name).toBe('flynn-gateway');
|
||||
expect(result.server.discovery.service_type).toBe('_flynn._tcp');
|
||||
expect(result.server.discovery.txt).toEqual({});
|
||||
});
|
||||
|
||||
it('accepts custom discovery settings', () => {
|
||||
const result = configSchema.parse({
|
||||
...minimalConfig,
|
||||
server: {
|
||||
discovery: {
|
||||
enabled: true,
|
||||
service_name: 'flynn-dev',
|
||||
service_type: '_custom._tcp',
|
||||
txt: {
|
||||
env: 'dev',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(result.server.discovery.enabled).toBe(true);
|
||||
expect(result.server.discovery.service_name).toBe('flynn-dev');
|
||||
expect(result.server.discovery.service_type).toBe('_custom._tcp');
|
||||
expect(result.server.discovery.txt).toEqual({ env: 'dev' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('configSchema — agent_configs', () => {
|
||||
|
||||
@@ -32,6 +32,17 @@ const wsRateLimitSchema = z.object({
|
||||
violation_window_ms: z.number().min(1000).max(60000).default(10000),
|
||||
}).default({});
|
||||
|
||||
const serverDiscoverySchema = z.object({
|
||||
/** Enable local-network service discovery (mDNS/Bonjour advertisement). */
|
||||
enabled: z.boolean().default(false),
|
||||
/** Service instance name advertised on LAN. */
|
||||
service_name: z.string().min(1).default('flynn-gateway'),
|
||||
/** mDNS service type. */
|
||||
service_type: z.string().min(1).default('_flynn._tcp'),
|
||||
/** Additional TXT metadata advertised with the service record. */
|
||||
txt: z.record(z.string(), z.string()).default({}),
|
||||
}).default({});
|
||||
|
||||
const serverSchema = z.object({
|
||||
tailscale: tailscaleSchema,
|
||||
localhost: z.boolean().default(true),
|
||||
@@ -48,6 +59,8 @@ const serverSchema = z.object({
|
||||
max_request_body_bytes: z.number().min(1024).max(10 * 1024 * 1024).default(1_048_576),
|
||||
/** Per-connection WebSocket ingress rate limit settings. */
|
||||
ws_rate_limit: wsRateLimitSchema,
|
||||
/** Optional Bonjour/mDNS advertisement settings. */
|
||||
discovery: serverDiscoverySchema,
|
||||
});
|
||||
|
||||
/** All supported model provider identifiers. Used by the config schema and TUI autocompletion. */
|
||||
|
||||
Reference in New Issue
Block a user