Radish alpha
r
rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5
Radicle web interface
Radicle
Git
Update node config
Sebastian Martinez committed 1 year ago
commit 894ab2e0aab111af3fc585ae9b9253c0088f7cd9
parent abcf8f3
10 files changed +77 -26
modified http-client/lib/shared.ts
@@ -17,11 +17,26 @@ export const nodeConfigSchema = object({
  alias: string(),
  peers: union([
    object({ type: literal("static") }),
-
    object({ type: literal("dynamic"), target: number() }),
+
    object({ type: literal("dynamic") }),
  ]),
  listen: array(string()),
  connect: array(string()),
  externalAddresses: array(string()),
+
  proxy: string().optional(),
+
  onion: union([
+
    object({
+
      mode: literal("proxy"),
+
      address: string(),
+
    }),
+
    object({ mode: literal("forward") }),
+
  ]).optional(),
+
  log: union([
+
    literal("ERROR"),
+
    literal("WARN"),
+
    literal("INFO"),
+
    literal("DEBUG"),
+
    literal("TRACE"),
+
  ]),
  network: union([literal("main"), literal("test")]),
  relay: union([literal("always"), literal("never"), literal("auto")]),
  limits: object({
@@ -40,9 +55,16 @@ export const nodeConfigSchema = object({
        capacity: number(),
      }),
    }),
+
    connection: object({
+
      inbound: number(),
+
      outbound: number(),
+
    }),
+
  }),
+
  workers: number(),
+
  seedingPolicy: object({
+
    default: policySchema,
+
    scope: scopeSchema.optional(),
  }),
-
  policy: policySchema,
-
  scope: scopeSchema,
});

export type Policy = z.infer<typeof policySchema>;
modified src/components/ScopePolicyExplainer.svelte
@@ -3,7 +3,7 @@

  import { capitalize } from "lodash";

-
  export let scope: Scope;
+
  export let scope: Scope | undefined = "all";
  export let policy: Policy;
</script>

modified src/lib/httpd.ts
@@ -83,7 +83,12 @@ export async function authenticate(params: {
          publicKey: params.publicKey,
          alias: sess.alias,
        },
-
        node: { id, state, policy: config?.policy, scope: config?.scope },
+
        node: {
+
          id,
+
          state,
+
          policy: config?.seedingPolicy.default,
+
          scope: config?.seedingPolicy.scope,
+
        },
      });
      return true;
    } catch (error) {
@@ -111,8 +116,8 @@ export async function disconnect() {
          node: {
            id,
            state,
-
            policy: config?.policy,
-
            scope: config?.scope,
+
            policy: config?.seedingPolicy.default,
+
            scope: config?.seedingPolicy.scope,
          },
        });
      } catch (error) {
@@ -150,8 +155,8 @@ async function checkState() {
        const node = {
          id,
          state,
-
          policy: config?.policy,
-
          scope: config?.scope,
+
          policy: config?.seedingPolicy.default,
+
          scope: config?.seedingPolicy.scope,
        };

        if (httpdState && httpdState.state === "authenticated") {
modified src/views/nodes/router.ts
@@ -56,8 +56,8 @@ export async function loadNodeRoute(
        stats,
        externalAddresses: node.config?.externalAddresses ?? [],
        version: node.version,
-
        policy: node.config?.policy,
-
        scope: node.config?.scope,
+
        policy: node.config?.seedingPolicy.default,
+
        scope: node.config?.seedingPolicy.scope,
      },
    };
  } catch (error) {
modified src/views/projects/Sidebar/ContextRepo.svelte
@@ -18,7 +18,8 @@
  let expandedNode = false;

  $: shortSeedingPolicy =
-
    node.config?.scope === "all" && node.config?.policy === "allow"
+
    node.config?.seedingPolicy.scope === "all" &&
+
    node.config?.seedingPolicy.default === "allow"
      ? "permissive"
      : "restrictive";
</script>
@@ -113,11 +114,11 @@
        {capitalize(shortSeedingPolicy)}
      </div>
    </div>
-
    {#if expandedNode && node.config}
+
    {#if expandedNode && node.config?.seedingPolicy}
      <div style:padding-left="2.3rem">
        <ScopePolicyExplainer
-
          scope={node.config.scope}
-
          policy={node.config.policy} />
+
          scope={node.config.seedingPolicy.scope}
+
          policy={node.config.seedingPolicy.default} />
      </div>
    {/if}
  </div>
modified tests/e2e/landingPage.spec.ts
@@ -100,7 +100,6 @@ const nodeInfo = {
    listen: [],
    peers: {
      type: "dynamic",
-
      target: 0,
    },
    connect: [],
    externalAddresses: ["seed.rhizoma.dev:8776"],
@@ -132,8 +131,9 @@ const nodeInfo = {
      },
    },
    workers: 32,
-
    policy: "block",
-
    scope: "all",
+
    seedingPolicy: {
+
      default: "block",
+
    },
  },
  state: "running",
};
modified tests/e2e/node.spec.ts
@@ -6,8 +6,7 @@ test("node metadata", async ({ page, peerManager }) => {
    name: "node-metadata-peer",
  });
  await peer.startNode({
-
    policy: "allow",
-
    scope: "all",
+
    seedingPolicy: { default: "allow", scope: "all" },
    alias: "palm",
    externalAddresses: ["seed.radicle.test:8123"],
  });
@@ -19,7 +18,7 @@ test("node metadata", async ({ page, peerManager }) => {
  await expect(
    page.getByText(`${shortNodeRemote}@seed.radicle.test:8123`),
  ).toBeVisible();
-
  await expect(page.getByText("1.0.0-rc.8-")).toBeVisible();
+
  await expect(page.getByText("1.0.0-rc.11-")).toBeVisible();
});

test("node projects", async ({ page }) => {
modified tests/support/globalSetup.ts
@@ -50,7 +50,10 @@ export default async function globalSetup(): Promise<() => void> {
  });

  if (!process.env.SKIP_FIXTURE_CREATION) {
-
    await palm.startNode({ policy: "allow", scope: "all", alias: "palm" });
+
    await palm.startNode({
+
      seedingPolicy: { default: "allow", scope: "all" },
+
      alias: "palm",
+
    });
    await palm.startHttpd(defaultHttpdPort);

    try {
modified tests/support/heartwood-release
@@ -1 +1 @@
-
1.0.0-rc.8

\ No newline at end of file
+
1.0.0-rc.11

\ No newline at end of file
modified tests/support/peerManager.ts
@@ -124,10 +124,25 @@ export const NodeConfigSchema = object({
    alias: string(),
    peers: union([
      object({ type: literal("static") }),
-
      object({ type: literal("dynamic"), target: number() }),
+
      object({ type: literal("dynamic") }),
    ]),
    connect: array(string()),
    externalAddresses: array(string()),
+
    proxy: string().optional(),
+
    onion: union([
+
      object({
+
        mode: literal("proxy"),
+
        address: string(),
+
      }),
+
      object({ mode: literal("forward") }),
+
    ]).optional(),
+
    log: union([
+
      literal("ERROR"),
+
      literal("WARN"),
+
      literal("INFO"),
+
      literal("DEBUG"),
+
      literal("TRACE"),
+
    ]),
    network: union([literal("main"), literal("test")]),
    relay: union([literal("always"), literal("never"), literal("auto")]),
    limits: object({
@@ -140,9 +155,15 @@ export const NodeConfigSchema = object({
        inbound: object({ fillRate: number(), capacity: number() }),
        outbound: object({ fillRate: number(), capacity: number() }),
      }),
+
      connection: object({
+
        inbound: number(),
+
        outbound: number(),
+
      }),
+
    }),
+
    seedingPolicy: object({
+
      default: union([literal("allow"), literal("block")]),
+
      scope: union([literal("followed"), literal("all")]).optional(),
    }),
-
    policy: union([literal("allow"), literal("block")]),
-
    scope: union([literal("followed"), literal("all")]),
  }),
});