Agent 1.4.0 + contracts 1.15.0: frp config anywhere, edited from the Hub; ports probed before installs
- The agent finds frps/frpc's config (Hub path, systemd -c, usual places) and reads INI and TOML. - New jobs frp-read, frp-write (secrets kept on the server, verify, backup, restart, roll back) and probe-ports (which ports are free here), on central and church servers. - Stats report frpConfigPath; crosscode gets FRPC_INI on church servers. - Website plan versions move up to contracts 1.16.0 and Hub 2.12.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -240,3 +240,38 @@ describe("env templates", () => {
|
||||
expect(agent.invalidValues({ TRUST_PROXY: "loopback" })).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe("frp config and free ports (1.15.0)", () => {
|
||||
const read = (a: Record<string, unknown>) => agent.jobArgsSchemas["frp-read"].safeParse(a).success;
|
||||
const write = (a: Record<string, unknown>) => agent.jobArgsSchemas["frp-write"].safeParse({ path: "/etc/frp/frps.toml", content: "bindPort = 7000\n", restart: true, ...a }).success;
|
||||
it("read the config the agent finds, or one at a path", () => {
|
||||
expect(read({})).toBe(true);
|
||||
expect(read({ path: "/etc/frp/frps.toml" })).toBe(true);
|
||||
expect(read({ path: "/usr/local/frp/frpc.ini" })).toBe(true);
|
||||
for (const path of ["/etc/shadow", "etc/frp/frps.ini", "/etc/frp/../shadow/frps.ini", "/etc/frp/frps.ini; rm -rf /", "/etc/frp/frps.service", "/etc/frp/server.toml"]) expect(read({ path })).toBe(false);
|
||||
expect(read({ path: "/etc/frp/frps.ini", extra: 1 })).toBe(false);
|
||||
});
|
||||
it("write one, with content and whether to restart", () => {
|
||||
expect(write({})).toBe(true);
|
||||
expect(write({ content: "" })).toBe(false);
|
||||
expect(write({ content: "x".repeat(agent.FRP_CONFIG_MAX + 1) })).toBe(false);
|
||||
expect(write({ path: "/etc/passwd" })).toBe(false);
|
||||
expect(write({ restart: "yes" })).toBe(false);
|
||||
});
|
||||
it("probe ports", () => {
|
||||
expect(agent.jobArgsSchemas["probe-ports"].safeParse({ ports: [20000, 20001] }).success).toBe(true);
|
||||
expect(agent.jobArgsSchemas["probe-ports"].safeParse({ ports: [] }).success).toBe(false);
|
||||
expect(agent.jobArgsSchemas["probe-ports"].safeParse({ ports: [80] }).success).toBe(false);
|
||||
});
|
||||
it("the central agent runs all three", () => {
|
||||
expect(agent.CENTRAL_JOB_TYPES).toEqual(expect.arrayContaining(["frp-read", "frp-write", "probe-ports"]));
|
||||
expect(agent.JOB_TIME_LIMIT_MINUTES["frp-write"]).toBeGreaterThan(0);
|
||||
});
|
||||
it("results", () => {
|
||||
expect(agent.frpReadResultSchema.safeParse({
|
||||
service: "frps", path: "/etc/frp/frps.toml", source: "systemd", found: true, format: "toml", content: `auth.token = "${agent.FRP_HIDDEN}"\n`, hidden: ["auth.token"],
|
||||
proxyBindAddr: "127.0.0.1", allowPorts: "20000-29999", serviceRunning: true, readAt: "2026-11-21T10:00:00.000Z",
|
||||
}).success).toBe(true);
|
||||
expect(agent.probePortsResultSchema.safeParse({ ports: [{ port: 20000, free: false, reason: "in use" }], configPath: null }).success).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user