Commit dbc63c7f authored by 神楽坂玲奈's avatar 神楽坂玲奈

not work

parent 1252f233
......@@ -5,6 +5,7 @@ import child_process from 'child_process';
export class RouteWriter {
static input: string[] = [];
static via: Record<number, number> = {};
static plan: Record<number, number> = {};
static reset() {
this.input.push(`route flush table ${config.table} proto ${config.proto}`);
......@@ -17,13 +18,17 @@ export class RouteWriter {
console.log(toId, viaId);
const to = routers.find(r => r.id === toId);
const via = routers.find(r => r.id === viaId);
RouteWriter.via
for (const address of [to.address, ...to.subnets]) {
this.input.push(`route replace ${address} dev ${via.interface} table ${config.table} proto ${config.proto}`);
}
for (const [table, to] of Object.entries(RouteWriter.plan)) {
if (to === toId) {
this.input.push(`route replace default dev ${via.interface} table ${table} proto ${config.proto}`);
}
}
}
static plan(table: number, to: number) {
static setPlan(table: number, toId: number) {
console.log(table, viaId);
const via = routers.find(r => r.id === viaId);
this.input.push(`route replace default dev ${via.interface} table ${table} proto ${config.proto}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment