Update node config

This commit is contained in:
Sebastian Martinez
2024-06-21 13:24:11 +02:00
parent abcf8f34a1
commit 894ab2e0aa
10 changed files with 77 additions and 26 deletions
+25 -3
View File
@@ -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>;
+1 -1
View File
@@ -3,7 +3,7 @@
import { capitalize } from "lodash";
export let scope: Scope;
export let scope: Scope | undefined = "all";
export let policy: Policy;
</script>
+10 -5
View File
@@ -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") {
+2 -2
View File
@@ -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) {
@@ -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>
+3 -3
View File
@@ -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",
};
+2 -3
View File
@@ -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 }) => {
+4 -1
View File
@@ -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 {
+1 -1
View File
@@ -1 +1 @@
1.0.0-rc.8
1.0.0-rc.11
+24 -3
View File
@@ -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")]),
}),
});