aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deno/base/config.ts2
-rw-r--r--deno/base/deno.json3
-rw-r--r--deno/base/lib.ts (renamed from deno/base/date.ts)4
-rw-r--r--deno/base/log.ts66
-rw-r--r--deno/base/text.ts3
-rw-r--r--deno/deno.json10
-rw-r--r--deno/deno.lock92
-rw-r--r--deno/mail-relay/app.ts27
-rw-r--r--deno/mail-relay/aws/app.ts147
-rw-r--r--deno/mail-relay/aws/deliver.ts17
-rw-r--r--deno/mail-relay/aws/fetch.ts37
-rw-r--r--deno/mail-relay/aws/mail.ts22
-rw-r--r--deno/mail-relay/db.ts2
-rw-r--r--deno/mail-relay/dovecot.ts18
-rw-r--r--deno/mail-relay/dumb-smtp-server.ts37
-rw-r--r--deno/mail-relay/mail.test.ts4
-rw-r--r--deno/mail-relay/mail.ts63
-rw-r--r--deno/service-manager/deno.json12
-rw-r--r--deno/service-manager/main.ts39
-rw-r--r--deno/tools/deno.json1
-rw-r--r--deno/tools/generate-geosite-rules.ts (renamed from deno/tools/gen-geosite-rules.ts)75
-rw-r--r--deno/tools/manage-service.ts42
-rw-r--r--deno/tools/manage-vm.ts144
-rw-r--r--deno/tools/template.ts (renamed from deno/service-manager/template.ts)0
-rw-r--r--dictionary.txt74
-rwxr-xr-xservices/docker/mail-server/app/main.bash2
-rwxr-xr-xservices/manage2
-rw-r--r--store/config/etc/fonts/local.conf60
-rw-r--r--store/config/home/bashrc7
-rw-r--r--store/config/mihomo/config.yaml85
-rw-r--r--store/config/mihomo/need-rule4
-rw-r--r--store/config/nvim/lua/setup/init.lua2
-rw-r--r--store/config/nvim/lua/setup/lsp.lua2
-rw-r--r--store/config/nvim/lua/setup/plugins/lint.lua2
-rw-r--r--store/config/nvim/lua/setup/win.lua1
-rw-r--r--www/content/notes/cheat-sheet.md50
-rw-r--r--www/content/notes/hurd/todos.md2
-rw-r--r--www/content/posts/c-func-ext.md2
38 files changed, 648 insertions, 514 deletions
diff --git a/deno/base/config.ts b/deno/base/config.ts
index 8fce1d8..a5f5d86 100644
--- a/deno/base/config.ts
+++ b/deno/base/config.ts
@@ -1,4 +1,4 @@
-import { camelCaseToKebabCase } from "./text.ts";
+import { camelCaseToKebabCase } from "./lib.ts";
export interface ConfigDefinitionItem {
readonly description: string;
diff --git a/deno/base/deno.json b/deno/base/deno.json
index 2c2d550..dabc02a 100644
--- a/deno/base/deno.json
+++ b/deno/base/deno.json
@@ -2,10 +2,9 @@
"name": "@crupest/base",
"version": "0.1.0",
"exports": {
+ ".": "./lib.ts",
"./config": "./config.ts",
"./cron": "./cron.ts",
- "./date": "./date.ts",
- "./text": "./text.ts",
"./log": "./log.ts"
}
}
diff --git a/deno/base/date.ts b/deno/base/lib.ts
index e65691e..a5e4a6a 100644
--- a/deno/base/date.ts
+++ b/deno/base/lib.ts
@@ -1,3 +1,7 @@
+export function camelCaseToKebabCase(str: string): string {
+ return str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
+}
+
export function toFileNameString(date: Date, dateOnly?: boolean): string {
const str = date.toISOString();
return dateOnly === true
diff --git a/deno/base/log.ts b/deno/base/log.ts
index cc71dfa..940f569 100644
--- a/deno/base/log.ts
+++ b/deno/base/log.ts
@@ -1,66 +1,17 @@
import { join } from "@std/path";
-import { toFileNameString } from "./date.ts";
-
-export type LogLevel = "error" | "warn" | "info";
-
-export interface LogOptions {
- level?: LogLevel;
- cause?: unknown;
-}
+import { toFileNameString } from "./lib.ts";
export interface ExternalLogStream extends Disposable {
stream: WritableStream;
}
-export class Logger {
- #defaultLevel = "info" as const;
- #externalLogDir?: string;
-
- get externalLogDir() {
- return this.#externalLogDir;
- }
-
- set externalLogDir(value: string | undefined) {
- this.#externalLogDir = value;
- if (value != null) {
- Deno.mkdirSync(value, {
- recursive: true,
- });
- }
- }
-
- write(message: string, options?: LogOptions): void {
- const logFunction = console[options?.level ?? this.#defaultLevel];
- if (options?.cause != null) {
- logFunction.call(console, message, options.cause);
- } else {
- logFunction.call(console, message);
- }
- }
-
- info(message: string) {
- this.write(message, { level: "info" });
- }
-
- tagInfo(tag: string, message: string) {
- this.info(tag + " " + message);
- }
-
- warn(message: string) {
- this.write(message, { level: "warn" });
- }
+export class LogFileProvider {
+ #directory: string;
- tagWarn(tag: string, message: string) {
- this.warn(tag + " " + message);
- }
-
- error(message: string, cause?: unknown) {
- this.write(message, { level: "info", cause });
- }
-
- tagError(tag: string, message: string, cause?: unknown) {
- this.error(tag + " " + message, cause);
+ constructor(directory: string) {
+ this.#directory = directory;
+ Deno.mkdirSync(directory, { recursive: true });
}
async createExternalLogStream(
@@ -72,12 +23,9 @@ export class Logger {
if (name.includes("/")) {
throw new Error(`External log stream's name (${name}) contains '/'.`);
}
- if (this.#externalLogDir == null) {
- throw new Error("External log directory is not set.");
- }
const logPath = join(
- this.#externalLogDir,
+ this.#directory,
options?.noTime === true
? name
: `${name}-${toFileNameString(new Date())}`,
diff --git a/deno/base/text.ts b/deno/base/text.ts
deleted file mode 100644
index f3e4020..0000000
--- a/deno/base/text.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export function camelCaseToKebabCase(str: string): string {
- return str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
-}
diff --git a/deno/deno.json b/deno/deno.json
index 55ffcb8..f4859d1 100644
--- a/deno/deno.json
+++ b/deno/deno.json
@@ -1,17 +1,19 @@
{
- "workspace": ["./base", "./service-manager", "./mail-relay", "./tools" ],
+ "workspace": ["./base", "./mail-relay", "./tools" ],
"tasks": {
"compile:mail-relay": "deno task --cwd=mail-relay compile",
- "compile:service-manager": "deno task --cwd=service-manager compile"
},
"imports": {
- "@std/cli": "jsr:@std/cli@^1.0.19",
"@std/collections": "jsr:@std/collections@^1.1.1",
"@std/csv": "jsr:@std/csv@^1.0.6",
"@std/encoding": "jsr:@std/encoding@^1.0.10",
"@std/expect": "jsr:@std/expect@^1.0.16",
"@std/io": "jsr:@std/io@^0.225.2",
"@std/path": "jsr:@std/path@^1.1.0",
- "@std/testing": "jsr:@std/testing@^1.0.13"
+ "@std/testing": "jsr:@std/testing@^1.0.13",
+ "@std/dotenv": "jsr:@std/dotenv@^0.225.5",
+ "@std/fs": "jsr:@std/fs@^1.0.18",
+ "yargs": "npm:yargs@^18.0.0"
+ "@types/yargs": "npm:@types/yargs@^17.0.33"
}
}
diff --git a/deno/deno.lock b/deno/deno.lock
index 357b31f..871a9ae 100644
--- a/deno/deno.lock
+++ b/deno/deno.lock
@@ -7,7 +7,6 @@
"jsr:@std/assert@^1.0.13": "1.0.13",
"jsr:@std/async@^1.0.13": "1.0.13",
"jsr:@std/bytes@^1.0.5": "1.0.6",
- "jsr:@std/cli@^1.0.19": "1.0.19",
"jsr:@std/collections@^1.1.1": "1.1.1",
"jsr:@std/csv@^1.0.6": "1.0.6",
"jsr:@std/data-structures@^1.0.8": "1.0.8",
@@ -36,10 +35,13 @@
"npm:@types/lodash@*": "4.17.17",
"npm:@types/mustache@*": "4.2.6",
"npm:@types/node@*": "22.15.15",
+ "npm:@types/yargs@*": "17.0.33",
+ "npm:@types/yargs@^17.0.33": "17.0.33",
"npm:email-addresses@5": "5.0.0",
"npm:hono@^4.7.11": "4.7.11",
"npm:kysely@~0.28.2": "0.28.2",
"npm:mustache@^4.2.0": "4.2.0",
+ "npm:yargs@18": "18.0.0",
"npm:zod@^3.25.48": "3.25.51"
},
"jsr": {
@@ -74,9 +76,6 @@
"@std/bytes@1.0.6": {
"integrity": "f6ac6adbd8ccd99314045f5703e23af0a68d7f7e58364b47d2c7f408aeb5820a"
},
- "@std/cli@1.0.19": {
- "integrity": "b3601a54891f89f3f738023af11960c4e6f7a45dc76cde39a6861124cba79e88"
- },
"@std/collections@1.1.1": {
"integrity": "eff6443fbd9d5a6697018fb39c5d13d5f662f0045f21392d640693d0008ab2af"
},
@@ -1183,12 +1182,41 @@
"undici-types"
]
},
+ "@types/yargs-parser@21.0.3": {
+ "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ=="
+ },
+ "@types/yargs@17.0.33": {
+ "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==",
+ "dependencies": [
+ "@types/yargs-parser"
+ ]
+ },
+ "ansi-regex@6.1.0": {
+ "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA=="
+ },
+ "ansi-styles@6.2.1": {
+ "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug=="
+ },
"bowser@2.11.0": {
"integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA=="
},
+ "cliui@9.0.1": {
+ "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
+ "dependencies": [
+ "string-width",
+ "strip-ansi",
+ "wrap-ansi"
+ ]
+ },
"email-addresses@5.0.0": {
"integrity": "sha512-4OIPYlA6JXqtVn8zpHpGiI7vE6EQOAg16aGnDMIAlZVinnoZ8208tW1hAbjWydgN/4PLTT9q+O1K6AH/vALJGw=="
},
+ "emoji-regex@10.4.0": {
+ "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw=="
+ },
+ "escalade@3.2.0": {
+ "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="
+ },
"fast-xml-parser@4.4.1": {
"integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==",
"dependencies": [
@@ -1196,6 +1224,12 @@
],
"bin": true
},
+ "get-caller-file@2.0.5": {
+ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="
+ },
+ "get-east-asian-width@1.3.0": {
+ "integrity": "sha512-vpeMIQKxczTD/0s2CdEWHcb0eeJe6TFjxb+J5xgX7hScxqrGuyjmv4c1D4A/gelKfyox0gJJwIHF+fLjeaM8kQ=="
+ },
"hono@4.7.11": {
"integrity": "sha512-rv0JMwC0KALbbmwJDEnxvQCeJh+xbS3KEWW5PC9cMJ08Ur9xgatI0HmtgYZfOdOSOeYsp5LO2cOhdI8cLEbDEQ=="
},
@@ -1206,6 +1240,20 @@
"integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==",
"bin": true
},
+ "string-width@7.2.0": {
+ "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
+ "dependencies": [
+ "emoji-regex",
+ "get-east-asian-width",
+ "strip-ansi"
+ ]
+ },
+ "strip-ansi@7.1.0": {
+ "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
+ "dependencies": [
+ "ansi-regex"
+ ]
+ },
"strnum@1.1.2": {
"integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA=="
},
@@ -1219,20 +1267,48 @@
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
"bin": true
},
+ "wrap-ansi@9.0.0": {
+ "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==",
+ "dependencies": [
+ "ansi-styles",
+ "string-width",
+ "strip-ansi"
+ ]
+ },
+ "y18n@5.0.8": {
+ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="
+ },
+ "yargs-parser@22.0.0": {
+ "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw=="
+ },
+ "yargs@18.0.0": {
+ "integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==",
+ "dependencies": [
+ "cliui",
+ "escalade",
+ "get-caller-file",
+ "string-width",
+ "y18n",
+ "yargs-parser"
+ ]
+ },
"zod@3.25.51": {
"integrity": "sha512-TQSnBldh+XSGL+opiSIq0575wvDPqu09AqWe1F7JhUMKY+M91/aGlK4MhpVNO7MgYfHcVCB1ffwAUTJzllKJqg=="
}
},
"workspace": {
"dependencies": [
- "jsr:@std/cli@^1.0.19",
"jsr:@std/collections@^1.1.1",
"jsr:@std/csv@^1.0.6",
+ "jsr:@std/dotenv@~0.225.5",
"jsr:@std/encoding@^1.0.10",
"jsr:@std/expect@^1.0.16",
+ "jsr:@std/fs@^1.0.18",
"jsr:@std/io@~0.225.2",
"jsr:@std/path@^1.1.0",
- "jsr:@std/testing@^1.0.13"
+ "jsr:@std/testing@^1.0.13",
+ "npm:@types/yargs@^17.0.33",
+ "npm:yargs@18"
],
"members": {
"mail-relay": {
@@ -1248,10 +1324,8 @@
"npm:zod@^3.25.48"
]
},
- "service-manager": {
+ "tools": {
"dependencies": [
- "jsr:@std/dotenv@~0.225.5",
- "jsr:@std/fs@^1.0.18",
"npm:mustache@^4.2.0"
]
}
diff --git a/deno/mail-relay/app.ts b/deno/mail-relay/app.ts
index d96fa1d..eeffc12 100644
--- a/deno/mail-relay/app.ts
+++ b/deno/mail-relay/app.ts
@@ -1,7 +1,7 @@
import { Hono } from "hono";
import { logger as honoLogger } from "hono/logger";
-import { Logger } from "@crupest/base/log";
+import { LogFileProvider } from "@crupest/base/log";
import {
AliasRecipientMailHook,
@@ -13,7 +13,7 @@ import { DovecotMailDeliverer } from "./dovecot.ts";
import { DumbSmtpServer } from "./dumb-smtp-server.ts";
export function createInbound(
- logger: Logger,
+ logFileProvider: LogFileProvider,
{
fallback,
mailDomain,
@@ -26,7 +26,7 @@ export function createInbound(
ldaPath: string;
},
) {
- const deliverer = new DovecotMailDeliverer(logger, ldaPath);
+ const deliverer = new DovecotMailDeliverer(logFileProvider, ldaPath);
deliverer.preHooks.push(
new RecipientFromHeadersHook(mailDomain),
new FallbackRecipientHook(new Set(fallback)),
@@ -35,15 +35,11 @@ export function createInbound(
return deliverer;
}
-export function createHono(
- logger: Logger,
- outbound: MailDeliverer,
- inbound: MailDeliverer,
-) {
+export function createHono(outbound: MailDeliverer, inbound: MailDeliverer) {
const hono = new Hono();
hono.onError((err, c) => {
- logger.error("Hono handler throws an error.", err);
+ console.error("Hono handler throws an error.", err);
return c.json({ msg: "Server error, check its log." }, 500);
});
hono.use(honoLogger());
@@ -66,11 +62,11 @@ export function createHono(
return hono;
}
-export function createSmtp(logger: Logger, outbound: MailDeliverer) {
- return new DumbSmtpServer(logger, outbound);
+export function createSmtp(outbound: MailDeliverer) {
+ return new DumbSmtpServer(outbound);
}
-export async function sendMail(logger: Logger, port: number) {
+export async function sendMail(port: number) {
const decoder = new TextDecoder();
let text = "";
for await (const chunk of Deno.stdin.readable) {
@@ -81,9 +77,8 @@ export async function sendMail(logger: Logger, port: number) {
method: "post",
body: text,
});
- logger.write(Deno.inspect(res), { level: res.ok ? "info" : "error" });
- logger.write(Deno.inspect(await res.text()), {
- level: res.ok ? "info" : "error",
- });
+ const fn = res.ok ? "info" : "error";
+ console[fn](res);
+ console[fn](await res.text());
if (!res.ok) Deno.exit(-1);
}
diff --git a/deno/mail-relay/aws/app.ts b/deno/mail-relay/aws/app.ts
index 685d7a9..13db351 100644
--- a/deno/mail-relay/aws/app.ts
+++ b/deno/mail-relay/aws/app.ts
@@ -1,11 +1,12 @@
import { join } from "@std/path";
-import { parseArgs } from "@std/cli";
import { z } from "zod";
import { Hono } from "hono";
import { zValidator } from "@hono/zod-validator";
import { FetchHttpHandler } from "@smithy/fetch-http-handler";
+// @ts-types="npm:@types/yargs"
+import yargs from "yargs";
-import { Logger } from "@crupest/base/log";
+import { LogFileProvider } from "@crupest/base/log";
import { ConfigDefinition, ConfigProvider } from "@crupest/base/config";
import { CronTask } from "@crupest/base/cron";
@@ -93,11 +94,10 @@ function createAwsOptions({
}
function createOutbound(
- logger: Logger,
awsOptions: ReturnType<typeof createAwsOptions>,
db: DbService,
) {
- const deliverer = new AwsMailDeliverer(logger, awsOptions);
+ const deliverer = new AwsMailDeliverer(awsOptions);
deliverer.preHooks.push(
new AwsMailMessageIdRewriteHook(db.messageIdToAws.bind(db)),
);
@@ -155,65 +155,57 @@ function createCron(fetcher: AwsMailFetcher, consumer: AwsS3MailConsumer) {
function createBaseServices() {
const config = new ConfigProvider(PREFIX, CONFIG_DEFINITIONS);
Deno.mkdirSync(config.get("dataPath"), { recursive: true });
- const logger = new Logger();
- logger.externalLogDir = join(config.get("dataPath"), "log");
- return { config, logger };
+ const logFileProvider = new LogFileProvider(
+ join(config.get("dataPath"), "log"),
+ );
+ return { config, logFileProvider };
}
function createAwsFetchOnlyServices() {
- const { config, logger } = createBaseServices();
+ const services = createBaseServices();
+ const { config } = services;
+
const awsOptions = createAwsOptions({
user: config.get("awsUser"),
password: config.get("awsPassword"),
region: config.get("awsRegion"),
});
- const fetcher = new AwsMailFetcher(
- logger,
- awsOptions,
- config.get("awsMailBucket"),
- );
- return { config, logger, awsOptions, fetcher };
+ const fetcher = new AwsMailFetcher(awsOptions, config.get("awsMailBucket"));
+
+ return { ...services, awsOptions, fetcher };
}
function createAwsRecycleOnlyServices() {
- const { config, logger, awsOptions, fetcher } = createAwsFetchOnlyServices();
+ const services = createAwsFetchOnlyServices();
+ const { config, logFileProvider } = services;
- const inbound = createInbound(logger, {
+ const inbound = createInbound(logFileProvider, {
fallback: config.getList("inboundFallback"),
ldaPath: config.get("ldaPath"),
aliasFile: join(config.get("dataPath"), "aliases.csv"),
mailDomain: config.get("mailDomain"),
});
-
const recycler = (rawMail: string, _: unknown): Promise<void> =>
inbound.deliver({ mail: new Mail(rawMail) }).then();
- return { config, logger, awsOptions, fetcher, inbound, recycler };
+ return { ...services, inbound, recycler };
}
function createAwsServices() {
- const { config, logger, inbound, awsOptions, fetcher, recycler } =
- createAwsRecycleOnlyServices();
+ const services = createAwsRecycleOnlyServices();
+ const { config, awsOptions } = services;
+
const dbService = new DbService(join(config.get("dataPath"), "db.sqlite"));
- const outbound = createOutbound(logger, awsOptions, dbService);
+ const outbound = createOutbound(awsOptions, dbService);
- return {
- config,
- logger,
- inbound,
- dbService,
- awsOptions,
- fetcher,
- recycler,
- outbound,
- };
+ return { ...services, dbService, outbound };
}
function createServerServices() {
const services = createAwsServices();
- const { logger, config, outbound, inbound, fetcher } = services;
- const smtp = createSmtp(logger, outbound);
+ const { config, outbound, inbound, fetcher } = services;
- const hono = createHono(logger, outbound, inbound);
+ const smtp = createSmtp(outbound);
+ const hono = createHono(outbound, inbound);
setupAwsHono(hono, {
path: config.get("awsInboundPath"),
auth: config.get("awsInboundKey"),
@@ -224,11 +216,7 @@ function createServerServices() {
},
});
- return {
- ...services,
- smtp,
- hono,
- };
+ return { ...services, smtp, hono };
}
function serve(cron: boolean = false) {
@@ -251,10 +239,12 @@ function serve(cron: boolean = false) {
}
async function listLives() {
- const { logger, fetcher } = createAwsFetchOnlyServices();
+ const { fetcher } = createAwsFetchOnlyServices();
const liveMails = await fetcher.listLiveMails();
- logger.info(`Total ${liveMails.length}:`);
- logger.info(liveMails.join("\n"));
+ console.info(`Total ${liveMails.length}:`);
+ if (liveMails.length !== 0) {
+ console.info(liveMails.join("\n"));
+ }
}
async function recycleLives() {
@@ -263,38 +253,43 @@ async function recycleLives() {
}
if (import.meta.main) {
- const args = parseArgs(Deno.args);
-
- if (args._.length === 0) {
- throw new Error("You must specify a command.");
- }
-
- const command = String(args._[0]);
-
- switch (command) {
- case "sendmail": {
- const { logger, config } = createBaseServices();
- await sendMail(logger, config.getInt("httpPort"));
- break;
- }
- case "list-lives": {
- await listLives();
- break;
- }
- case "recycle-lives": {
- await recycleLives();
- break;
- }
- case "serve": {
- serve();
- break;
- }
- case "real-serve": {
- serve(true);
- break;
- }
- default: {
- throw new Error(command + " is not a valid command.");
- }
- }
+ await yargs(Deno.args)
+ .scriptName("mail-relay")
+ .command({
+ command: "sendmail",
+ describe: "send mail via this server's endpoint",
+ handler: async (_argv) => {
+ const { config } = createBaseServices();
+ await sendMail(config.getInt("httpPort"));
+ },
+ })
+ .command({
+ command: "live",
+ describe: "work with live mails",
+ builder: (builder) => {
+ return builder
+ .command({
+ command: "list",
+ describe: "list live mails",
+ handler: listLives,
+ })
+ .command({
+ command: "recycle",
+ describe: "recycle all live mails",
+ handler: recycleLives,
+ })
+ .demandCommand(1, "One command must be specified.");
+ },
+ handler: () => {},
+ })
+ .command({
+ command: "serve",
+ describe: "start the http and smtp servers",
+ builder: (builder) => builder.option("real", { type: "boolean" }),
+ handler: (argv) => serve(argv.real),
+ })
+ .demandCommand(1, "One command must be specified.")
+ .help()
+ .strict()
+ .parse();
}
diff --git a/deno/mail-relay/aws/deliver.ts b/deno/mail-relay/aws/deliver.ts
index 9950e37..a002eda 100644
--- a/deno/mail-relay/aws/deliver.ts
+++ b/deno/mail-relay/aws/deliver.ts
@@ -1,12 +1,9 @@
-// spellchecker:words sesv2 amazonses
-
import {
SendEmailCommand,
SESv2Client,
SESv2ClientConfig,
} from "@aws-sdk/client-sesv2";
-import { Logger } from "@crupest/base/log";
import { Mail, MailDeliverContext, SyncMailDeliverer } from "../mail.ts";
declare module "../mail.ts" {
@@ -17,13 +14,11 @@ declare module "../mail.ts" {
export class AwsMailDeliverer extends SyncMailDeliverer {
readonly name = "aws";
- readonly #logger;
readonly #aws;
readonly #ses;
- constructor(logger: Logger, aws: SESv2ClientConfig) {
- super(logger);
- this.#logger = logger;
+ constructor(aws: SESv2ClientConfig) {
+ super();
this.#aws = aws;
this.#ses = new SESv2Client(aws);
}
@@ -32,7 +27,7 @@ export class AwsMailDeliverer extends SyncMailDeliverer {
mail: Mail,
context: MailDeliverContext,
): Promise<void> {
- this.#logger.info("Begin to call aws send-email api...");
+ console.info("Begin to call aws send-email api...");
try {
const sendCommand = new SendEmailCommand({
@@ -43,9 +38,11 @@ export class AwsMailDeliverer extends SyncMailDeliverer {
const res = await this.#ses.send(sendCommand);
if (res.MessageId == null) {
- this.#logger.warn("Aws send-email returns no message id.");
+ console.warn("Aws send-email returns no message id.");
} else {
- context.result.awsMessageId = `${res.MessageId}@${this.#aws.region}.amazonses.com`;
+ context.result.awsMessageId = `${res.MessageId}@${
+ this.#aws.region
+ }.amazonses.com`;
}
context.result.recipients.set("*", {
diff --git a/deno/mail-relay/aws/fetch.ts b/deno/mail-relay/aws/fetch.ts
index ef1ba5f..68e02e6 100644
--- a/deno/mail-relay/aws/fetch.ts
+++ b/deno/mail-relay/aws/fetch.ts
@@ -7,8 +7,7 @@ import {
S3ClientConfig,
} from "@aws-sdk/client-s3";
-import { toFileNameString } from "@crupest/base/date";
-import { Logger } from "@crupest/base/log";
+import { toFileNameString } from "@crupest/base";
import { Mail } from "../mail.ts";
@@ -42,18 +41,16 @@ export type AwsS3MailConsumer = (
export class AwsMailFetcher {
readonly #livePrefix = "mail/live/";
readonly #archivePrefix = "mail/archive/";
- readonly #logger;
readonly #s3;
readonly #bucket;
- constructor(logger: Logger, aws: S3ClientConfig, bucket: string) {
- this.#logger = logger;
+ constructor(aws: S3ClientConfig, bucket: string) {
this.#s3 = new S3Client(aws);
this.#bucket = bucket;
}
async listLiveMails(): Promise<string[]> {
- this.#logger.info("Begin to retrieve live mails.");
+ console.info("Begin to retrieve live mails.");
const listCommand = new ListObjectsV2Command({
Bucket: this.#bucket,
@@ -62,16 +59,14 @@ export class AwsMailFetcher {
const res = await this.#s3.send(listCommand);
if (res.Contents == null) {
- this.#logger.warn("Listing live mails in S3 returns null Content.");
+ console.warn("Listing live mails in S3 returns null Content.");
return [];
}
const result: string[] = [];
for (const object of res.Contents) {
if (object.Key == null) {
- this.#logger.warn(
- "Listing live mails in S3 returns an object with no Key.",
- );
+ console.warn("Listing live mails in S3 returns an object with no Key.");
continue;
}
@@ -83,9 +78,9 @@ export class AwsMailFetcher {
}
async consumeS3Mail(s3Key: string, consumer: AwsS3MailConsumer) {
- this.#logger.info(`Begin to consume s3 mail ${s3Key} ...`);
+ console.info(`Begin to consume s3 mail ${s3Key} ...`);
- this.#logger.info(`Fetching s3 mail ${s3Key}...`);
+ console.info(`Fetching s3 mail ${s3Key}...`);
const mailPath = `${this.#livePrefix}${s3Key}`;
const command = new GetObjectCommand({
Bucket: this.#bucket,
@@ -98,14 +93,14 @@ export class AwsMailFetcher {
}
const rawMail = await res.Body.transformToString();
- this.#logger.info(`Done fetching s3 mail ${s3Key}.`);
+ console.info(`Done fetching s3 mail ${s3Key}.`);
- this.#logger.info(`Calling consumer...`);
+ console.info(`Calling consumer...`);
await consumer(rawMail, s3Key);
- this.#logger.info(`Done consuming s3 mail ${s3Key}.`);
+ console.info(`Done consuming s3 mail ${s3Key}.`);
const date = new Mail(rawMail)
- .startSimpleParse(this.#logger)
+ .startSimpleParse()
.sections()
.headers()
.date();
@@ -113,17 +108,17 @@ export class AwsMailFetcher {
date != null ? toFileNameString(date, true) : "invalid-date";
const newPath = `${this.#archivePrefix}${dateString}/${s3Key}`;
- this.#logger.info(`Archiving s3 mail ${s3Key} to ${newPath}...`);
+ console.info(`Archiving s3 mail ${s3Key} to ${newPath}...`);
await s3MoveObject(this.#s3, this.#bucket, mailPath, newPath);
- this.#logger.info(`Done archiving s3 mail ${s3Key}.`);
+ console.info(`Done archiving s3 mail ${s3Key}.`);
- this.#logger.info(`Done consuming s3 mail ${s3Key}.`);
+ console.info(`Done consuming s3 mail ${s3Key}.`);
}
async recycleLiveMails(consumer: AwsS3MailConsumer) {
- this.#logger.info("Begin to recycle live mails...");
+ console.info("Begin to recycle live mails...");
const mails = await this.listLiveMails();
- this.#logger.info(`Found ${mails.length} live mails`);
+ console.info(`Found ${mails.length} live mails`);
for (const s3Key of mails) {
await this.consumeS3Mail(s3Key, consumer);
}
diff --git a/deno/mail-relay/aws/mail.ts b/deno/mail-relay/aws/mail.ts
index d2cfad1..cc05d23 100644
--- a/deno/mail-relay/aws/mail.ts
+++ b/deno/mail-relay/aws/mail.ts
@@ -8,17 +8,17 @@ export class AwsMailMessageIdRewriteHook implements MailDeliverHook {
}
async callback(context: MailDeliverContext): Promise<void> {
- context.logger.info("Rewrite message ids...");
+ console.info("Rewrite message ids...");
const addresses = context.mail.simpleFindAllAddresses();
- context.logger.info(`Addresses found in mail: ${addresses.join(", ")}.`);
+ console.info(`Addresses found in mail: ${addresses.join(", ")}.`);
for (const address of addresses) {
const awsMessageId = await this.#lookup(address);
if (awsMessageId != null && awsMessageId.length !== 0) {
- context.logger.info(`Rewrite ${address} to ${awsMessageId}.`);
+ console.info(`Rewrite ${address} to ${awsMessageId}.`);
context.mail.raw = context.mail.raw.replaceAll(address, awsMessageId);
}
}
- context.logger.info("Done rewrite message ids.");
+ console.info("Done rewrite message ids.");
}
}
@@ -30,24 +30,20 @@ export class AwsMailMessageIdSaveHook implements MailDeliverHook {
}
async callback(context: MailDeliverContext): Promise<void> {
- context.logger.info("Save aws message ids...");
+ console.info("Save aws message ids...");
const messageId = context.mail
- .startSimpleParse(context.logger)
+ .startSimpleParse()
.sections()
.headers()
.messageId();
if (messageId == null) {
- context.logger.info(
- "Original mail does not have message id. Skip saving.",
- );
+ console.info("Original mail does not have message id. Skip saving.");
return;
}
if (context.result.awsMessageId != null) {
- context.logger.info(
- `Saving ${messageId} => ${context.result.awsMessageId}.`,
- );
+ console.info(`Saving ${messageId} => ${context.result.awsMessageId}.`);
await this.#record(messageId, context.result.awsMessageId);
}
- context.logger.info("Done save message ids.");
+ console.info("Done save message ids.");
}
}
diff --git a/deno/mail-relay/db.ts b/deno/mail-relay/db.ts
index 807ecf6..062700b 100644
--- a/deno/mail-relay/db.ts
+++ b/deno/mail-relay/db.ts
@@ -1,5 +1,3 @@
-// spellchecker: words kysely insertable updateable introspector
-
import {
Generated,
Insertable,
diff --git a/deno/mail-relay/dovecot.ts b/deno/mail-relay/dovecot.ts
index 124a82b..333b803 100644
--- a/deno/mail-relay/dovecot.ts
+++ b/deno/mail-relay/dovecot.ts
@@ -1,15 +1,17 @@
import { basename } from "@std/path";
-import { Logger } from "@crupest/base/log";
+import { LogFileProvider } from "@crupest/base/log";
import { Mail, MailDeliverContext, MailDeliverer } from "./mail.ts";
export class DovecotMailDeliverer extends MailDeliverer {
readonly name = "dovecot";
+ readonly #logFileProvider;
readonly #ldaPath;
- constructor(logger: Logger, ldaPath: string) {
- super(logger);
+ constructor(logFileProvider: LogFileProvider, ldaPath: string) {
+ super();
+ this.#logFileProvider = logFileProvider;
this.#ldaPath = ldaPath;
}
@@ -29,12 +31,12 @@ export class DovecotMailDeliverer extends MailDeliverer {
return;
}
- this.logger.info(`Deliver to dovecot users: ${recipients.join(", ")}.`);
+ console.info(`Deliver to dovecot users: ${recipients.join(", ")}.`);
for (const recipient of recipients) {
try {
const commandArgs = ["-d", recipient];
- this.logger.info(`Run ${ldaBinName} ${commandArgs.join(" ")}...`);
+ console.info(`Run ${ldaBinName} ${commandArgs.join(" ")}...`);
const ldaCommand = new Deno.Command(ldaPath, {
args: commandArgs,
@@ -45,7 +47,9 @@ export class DovecotMailDeliverer extends MailDeliverer {
const ldaProcess = ldaCommand.spawn();
using logFiles =
- await this.logger.createExternalLogStreamsForProgram(ldaBinName);
+ await this.#logFileProvider.createExternalLogStreamsForProgram(
+ ldaBinName,
+ );
ldaProcess.stdout.pipeTo(logFiles.stdout);
ldaProcess.stderr.pipeTo(logFiles.stderr);
@@ -90,6 +94,6 @@ export class DovecotMailDeliverer extends MailDeliverer {
}
}
- this.logger.info("Done handling all recipients.");
+ console.info("Done handling all recipients.");
}
}
diff --git a/deno/mail-relay/dumb-smtp-server.ts b/deno/mail-relay/dumb-smtp-server.ts
index 1a1090a..ac7069c 100644
--- a/deno/mail-relay/dumb-smtp-server.ts
+++ b/deno/mail-relay/dumb-smtp-server.ts
@@ -1,4 +1,3 @@
-import { Logger } from "@crupest/base/log";
import { MailDeliverer } from "./mail.ts";
const CRLF = "\r\n";
@@ -20,26 +19,24 @@ function createResponses(host: string, port: number | string) {
const LOG_TAG = "[dumb-smtp]";
export class DumbSmtpServer {
- #logger;
#deliverer;
#responses: ReturnType<typeof createResponses> = createResponses(
"invalid",
"invalid",
);
- constructor(logger: Logger, deliverer: MailDeliverer) {
- this.#logger = logger;
+ constructor(deliverer: MailDeliverer) {
this.#deliverer = deliverer;
}
async #handleConnection(conn: Deno.Conn) {
using disposeStack = new DisposableStack();
disposeStack.defer(() => {
- this.#logger.tagInfo(LOG_TAG, "Close session's tcp connection.");
+ console.info(LOG_TAG, "Close session's tcp connection.");
conn.close();
});
- this.#logger.tagInfo(LOG_TAG, "New session's tcp connection established.");
+ console.info(LOG_TAG, "New session's tcp connection established.");
const writer = conn.writable.getWriter();
disposeStack.defer(() => writer.releaseLock());
@@ -49,7 +46,7 @@ export class DumbSmtpServer {
const [decoder, encoder] = [new TextDecoder(), new TextEncoder()];
const decode = (data: Uint8Array) => decoder.decode(data);
const send = async (s: string) => {
- this.#logger.tagInfo(LOG_TAG, "Send line: " + s);
+ console.info(LOG_TAG, "Send line: " + s);
await writer.write(encoder.encode(s + CRLF));
};
@@ -72,7 +69,7 @@ export class DumbSmtpServer {
buffer = buffer.slice(eolPos + CRLF.length);
if (rawMail == null) {
- this.#logger.tagInfo(LOG_TAG, "Received line: " + line);
+ console.info(LOG_TAG, "Received line: " + line);
const upperLine = line.toUpperCase();
if (upperLine.startsWith("EHLO") || upperLine.startsWith("HELO")) {
await send(this.#responses["EHLO"]);
@@ -82,32 +79,26 @@ export class DumbSmtpServer {
await send(this.#responses["RCPT"]);
} else if (upperLine === "DATA") {
await send(this.#responses["DATA"]);
- this.#logger.tagInfo(LOG_TAG, "Begin to receive mail data...");
+ console.info(LOG_TAG, "Begin to receive mail data...");
rawMail = "";
} else if (upperLine === "QUIT") {
await send(this.#responses["QUIT"]);
return;
} else {
- this.#logger.tagWarn(
- LOG_TAG,
- "Unrecognized command from client: " + line,
- );
+ console.warn(LOG_TAG, "Unrecognized command from client: " + line);
await send(this.#responses["INVALID"]);
return;
}
} else {
if (line === ".") {
try {
- this.#logger.tagInfo(
- LOG_TAG,
- "Mail data Received, begin to relay...",
- );
+ console.info(LOG_TAG, "Mail data Received, begin to relay...");
const { message } = await this.#deliverer.deliverRaw(rawMail);
await send(`250 2.6.0 ${message}`);
rawMail = null;
- this.#logger.tagInfo(LOG_TAG, "Relay succeeded.");
+ console.info(LOG_TAG, "Relay succeeded.");
} catch (err) {
- this.#logger.tagError(LOG_TAG, "Relay failed.", err);
+ console.error(LOG_TAG, "Relay failed.", err);
await send("554 5.3.0 Error: check server log");
return;
}
@@ -123,7 +114,7 @@ export class DumbSmtpServer {
async serve(options: { hostname: string; port: number }) {
const listener = Deno.listen(options);
this.#responses = createResponses(options.hostname, options.port);
- this.#logger.tagInfo(
+ console.info(
LOG_TAG,
`Dumb SMTP server starts to listen on ${this.#responses.serverName}.`,
);
@@ -132,11 +123,7 @@ export class DumbSmtpServer {
try {
await this.#handleConnection(conn);
} catch (cause) {
- this.#logger.tagError(
- LOG_TAG,
- "Tcp connection throws an error.",
- cause,
- );
+ console.error(LOG_TAG, "Tcp connection throws an error.", cause);
}
}
}
diff --git a/deno/mail-relay/mail.test.ts b/deno/mail-relay/mail.test.ts
index 09cf8eb..6abb7d7 100644
--- a/deno/mail-relay/mail.test.ts
+++ b/deno/mail-relay/mail.test.ts
@@ -1,8 +1,6 @@
import { describe, it } from "@std/testing/bdd";
import { expect, fn } from "@std/expect";
-import { Logger } from "@crupest/base/log";
-
import { Mail, MailDeliverContext, MailDeliverer } from "./mail.ts";
const mockDate = "Fri, 02 May 2025 08:33:02 +0000";
@@ -119,7 +117,7 @@ describe("MailDeliverer", () => {
return Promise.resolve();
}) as MailDeliverer["doDeliver"];
}
- const mockDeliverer = new MockMailDeliverer(new Logger());
+ const mockDeliverer = new MockMailDeliverer();
it("deliver success", async () => {
await mockDeliverer.deliverRaw(mockMailStr);
diff --git a/deno/mail-relay/mail.ts b/deno/mail-relay/mail.ts
index 12d5972..d6dfe65 100644
--- a/deno/mail-relay/mail.ts
+++ b/deno/mail-relay/mail.ts
@@ -2,19 +2,10 @@ import { encodeBase64 } from "@std/encoding/base64";
import { parse } from "@std/csv/parse";
import emailAddresses from "email-addresses";
-import { Logger } from "@crupest/base/log";
-
class MailSimpleParseError extends Error {}
class MailSimpleParsedHeaders {
- #logger;
-
- constructor(
- logger: Logger | undefined,
- public fields: [key: string, value: string][],
- ) {
- this.#logger = logger;
- }
+ constructor(public fields: [key: string, value: string][]) {}
getFirst(fieldKey: string): string | undefined {
for (const [key, value] of this.fields) {
@@ -31,9 +22,7 @@ class MailSimpleParsedHeaders {
if (match != null) {
return match[1];
} else {
- this.#logger?.warn(
- "Invalid message-id header of mail: " + messageIdField,
- );
+ console.warn("Invalid message-id header of mail: " + messageIdField);
return undefined;
}
}
@@ -44,7 +33,7 @@ class MailSimpleParsedHeaders {
const date = new Date(dateField);
if (invalidToUndefined && isNaN(date.getTime())) {
- this.#logger?.warn(`Invalid date string (${dateField}) found in header.`);
+ console.warn(`Invalid date string (${dateField}) found in header.`);
return undefined;
}
return date;
@@ -76,11 +65,7 @@ class MailSimpleParsedSections {
eol: string;
sep: string;
- #logger;
-
- constructor(logger: Logger | undefined, raw: string) {
- this.#logger = logger;
-
+ constructor(raw: string) {
const twoEolMatch = raw.match(/(\r?\n)(\r?\n)/);
if (twoEolMatch == null) {
throw new MailSimpleParseError(
@@ -91,7 +76,7 @@ class MailSimpleParsedSections {
const [eol, sep] = [twoEolMatch[1], twoEolMatch[2]];
if (eol !== sep) {
- logger?.warn("Different EOLs (\\r\\n, \\n) found.");
+ console.warn("Different EOLs (\\r\\n, \\n) found.");
}
this.header = raw.slice(0, twoEolMatch.index!);
@@ -131,7 +116,7 @@ class MailSimpleParsedSections {
handleField();
- return new MailSimpleParsedHeaders(this.#logger, headers);
+ return new MailSimpleParsedHeaders(headers);
}
}
@@ -147,8 +132,8 @@ export class Mail {
return encodeBase64(this.raw);
}
- startSimpleParse(logger?: Logger) {
- return { sections: () => new MailSimpleParsedSections(logger, this.raw) };
+ startSimpleParse() {
+ return { sections: () => new MailSimpleParsedSections(this.raw) };
}
simpleFindAllAddresses(): string[] {
@@ -195,10 +180,7 @@ export class MailDeliverContext {
readonly recipients: Set<string> = new Set();
readonly result;
- constructor(
- public readonly logger: Logger,
- public mail: Mail,
- ) {
+ constructor(public mail: Mail) {
this.result = new MailDeliverResult(this.mail);
}
}
@@ -212,8 +194,6 @@ export abstract class MailDeliverer {
preHooks: MailDeliverHook[] = [];
postHooks: MailDeliverHook[] = [];
- constructor(protected readonly logger: Logger) {}
-
protected abstract doDeliver(
mail: Mail,
context: MailDeliverContext,
@@ -227,9 +207,9 @@ export abstract class MailDeliverer {
mail: Mail;
recipients?: string[];
}): Promise<MailDeliverResult> {
- this.logger.info(`Begin to deliver mail via ${this.name}...`);
+ console.info(`Begin to deliver mail via ${this.name}...`);
- const context = new MailDeliverContext(this.logger, options.mail);
+ const context = new MailDeliverContext(options.mail);
options.recipients?.forEach((r) => context.recipients.add(r));
for (const hook of this.preHooks) {
@@ -242,7 +222,8 @@ export abstract class MailDeliverer {
await hook.callback(context);
}
- context.logger.info("Deliver result:\n" + Deno.inspect(context.result));
+ console.info("Deliver result:");
+ console.info(context.result);
if (context.result.hasError()) {
throw new Error("Mail failed to deliver.");
@@ -259,7 +240,7 @@ export abstract class SyncMailDeliverer extends MailDeliverer {
mail: Mail;
recipients?: string[];
}): Promise<MailDeliverResult> {
- this.logger.info(
+ console.info(
"The mail deliverer is sync. Wait for last delivering done...",
);
await this.#last;
@@ -277,12 +258,12 @@ export class RecipientFromHeadersHook implements MailDeliverHook {
callback(context: MailDeliverContext) {
if (context.recipients.size !== 0) {
- context.logger.warn(
+ console.warn(
"Recipients are already filled. Won't set them with ones in headers.",
);
} else {
context.mail
- .startSimpleParse(context.logger)
+ .startSimpleParse()
.sections()
.headers()
.recipients({
@@ -290,7 +271,7 @@ export class RecipientFromHeadersHook implements MailDeliverHook {
})
.forEach((r) => context.recipients.add(r));
- context.logger.info(
+ console.info(
"Recipients found from mail headers: " +
[...context.recipients].join(", "),
);
@@ -304,7 +285,7 @@ export class FallbackRecipientHook implements MailDeliverHook {
callback(context: MailDeliverContext) {
if (context.recipients.size === 0) {
- context.logger.info(
+ console.info(
"No recipients, fill with fallback: " + [...this.fallback].join(", "),
);
this.fallback.forEach((a) => context.recipients.add(a));
@@ -320,10 +301,10 @@ export class AliasRecipientMailHook implements MailDeliverHook {
this.#aliasFile = aliasFile;
}
- async #parseAliasFile(logger: Logger): Promise<Map<string, string>> {
+ async #parseAliasFile(): Promise<Map<string, string>> {
const result = new Map();
if ((await Deno.stat(this.#aliasFile)).isFile) {
- logger.info(`Found recipients alias file: ${this.#aliasFile}.`);
+ console.info(`Found recipients alias file: ${this.#aliasFile}.`);
const text = await Deno.readTextFile(this.#aliasFile);
const csv = parse(text);
for (const [real, ...aliases] of csv) {
@@ -334,11 +315,11 @@ export class AliasRecipientMailHook implements MailDeliverHook {
}
async callback(context: MailDeliverContext) {
- const aliases = await this.#parseAliasFile(context.logger);
+ const aliases = await this.#parseAliasFile();
for (const recipient of [...context.recipients]) {
const realRecipients = aliases.get(recipient);
if (realRecipients != null) {
- context.logger.info(
+ console.info(
`Recipient alias resolved: ${recipient} => ${realRecipients}.`,
);
context.recipients.delete(recipient);
diff --git a/deno/service-manager/deno.json b/deno/service-manager/deno.json
deleted file mode 100644
index 9f30853..0000000
--- a/deno/service-manager/deno.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "version": "0.1.0",
- "tasks": {
- "run": "deno run -A main.ts",
- "compile": "deno compile -o out/manage -A main.ts"
- },
- "imports": {
- "@std/dotenv": "jsr:@std/dotenv@^0.225.5",
- "@std/fs": "jsr:@std/fs@^1.0.18",
- "mustache": "npm:mustache@^4.2.0"
- }
-}
diff --git a/deno/service-manager/main.ts b/deno/service-manager/main.ts
deleted file mode 100644
index 93f4c1b..0000000
--- a/deno/service-manager/main.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { parseArgs } from "@std/cli";
-import { loadVariables, TemplateDir } from "./template.ts";
-import { join } from "@std/path";
-
-if (import.meta.main) {
- const args = parseArgs(Deno.args, {
- string: ["project-dir"],
- boolean: ["no-dry-run"],
- });
-
- if (args._.length === 0) {
- throw new Error("You must specify a command.");
- }
-
- const projectDir = args["project-dir"];
- if (projectDir == null) {
- throw new Error("You must specify project-dir.");
- }
-
- const command = String(args._[0]);
-
- switch (command) {
- case "gen-tmpl":
- new TemplateDir(
- join(projectDir, "services/templates"),
- ).generateWithVariableFiles(
- [
- join(projectDir, "data/config"),
- join(projectDir, "services/config.template"),
- ],
- args["no-dry-run"] === true
- ? join(projectDir, "services/generated")
- : undefined,
- );
- break;
- default:
- throw new Error(command + " is not a valid command.");
- }
-}
diff --git a/deno/tools/deno.json b/deno/tools/deno.json
index 3597182..1b2cf32 100644
--- a/deno/tools/deno.json
+++ b/deno/tools/deno.json
@@ -3,5 +3,6 @@
"tasks": {
},
"imports": {
+ "mustache": "npm:mustache@^4.2.0",
}
}
diff --git a/deno/tools/gen-geosite-rules.ts b/deno/tools/generate-geosite-rules.ts
index c59d34f..bfa53ba 100644
--- a/deno/tools/gen-geosite-rules.ts
+++ b/deno/tools/generate-geosite-rules.ts
@@ -1,7 +1,8 @@
-const PROXY_NAME = "node-select"
-const ATTR = "cn"
+const PROXY_NAME = "node-select";
+const ATTR = "cn";
const REPO_NAME = "domain-list-community";
-const URL = "https://github.com/v2fly/domain-list-community/archive/refs/heads/master.zip"
+const URL =
+ "https://github.com/v2fly/domain-list-community/archive/refs/heads/master.zip";
const SITES = [
"github",
"google",
@@ -39,9 +40,9 @@ const SITES = [
"ieee",
"sci-hub",
"libgen",
-]
+];
-const prefixes = ["include", "domain", "keyword", "full", "regexp"] as const
+const prefixes = ["include", "domain", "keyword", "full", "regexp"] as const;
interface Rule {
kind: (typeof prefixes)[number];
@@ -52,20 +53,20 @@ interface Rule {
type FileProvider = (name: string) => string;
function extract(starts: string[], provider: FileProvider): Rule[] {
-function parseLine(line: string): Rule {
- let kind = prefixes.find((p) => line.startsWith(p + ":"));
- if (kind != null) {
- line = line.slice(line.indexOf(":") + 1);
- } else {
- kind = "domain";
+ function parseLine(line: string): Rule {
+ let kind = prefixes.find((p) => line.startsWith(p + ":"));
+ if (kind != null) {
+ line = line.slice(line.indexOf(":") + 1);
+ } else {
+ kind = "domain";
+ }
+ const segs = line.split("@");
+ return {
+ kind,
+ value: segs[0].trim(),
+ attrs: [...segs.slice(1)].map((s) => s.trim()),
+ };
}
- const segs = line.split("@");
- return {
- kind,
- value: segs[0].trim(),
- attrs: [...segs.slice(1)].map((s) => s.trim()),
- };
-}
function parse(text: string): Rule[] {
return text
@@ -76,10 +77,10 @@ function parseLine(line: string): Rule {
.map((l) => parseLine(l));
}
- const visited = [] as string[]
- const rules = [] as Rule[]
+ const visited = [] as string[];
+ const rules = [] as Rule[];
- function add(name :string) {
+ function add(name: string) {
const text = provider(name);
for (const rule of parse(text)) {
if (rule.kind === "include") {
@@ -100,25 +101,25 @@ function parseLine(line: string): Rule {
add(start);
}
- return rules
+ return rules;
}
function toNewFormat(rules: Rule[], attr: string): [string, string] {
function toLine(rule: Rule) {
const prefixMap = {
- "domain": "DOMAIN-SUFFIX",
- "full": "DOMAIN",
- "keyword": "DOMAIN-KEYWORD",
- "regexp": "DOMAIN-REGEX",
+ domain: "DOMAIN-SUFFIX",
+ full: "DOMAIN",
+ keyword: "DOMAIN-KEYWORD",
+ regexp: "DOMAIN-REGEX",
} as const;
if (rule.kind === "include") {
- throw new Error("Include rule not parsed.")
+ throw new Error("Include rule not parsed.");
}
- return `${prefixMap[rule.kind]},${rule.value}`
+ return `${prefixMap[rule.kind]},${rule.value}`;
}
function toLines(rules: Rule[]) {
- return rules.map(r => toLine(r)).join("\n")
+ return rules.map((r) => toLine(r)).join("\n");
}
const has: Rule[] = [];
@@ -128,7 +129,6 @@ function toNewFormat(rules: Rule[], attr: string): [string, string] {
return [toLines(has), toLines(notHas)];
}
-
if (import.meta.main) {
const tmpDir = Deno.makeTempDirSync({ prefix: "geosite-rules-" });
console.log("Work dir is ", tmpDir);
@@ -150,12 +150,11 @@ if (import.meta.main) {
const provider = (name: string) =>
Deno.readTextFileSync(dataDir + "/" + name);
- const rules = extract(SITES, provider)
- const [has, notHas] = toNewFormat(rules, ATTR)
- const hasFile = tmpDir + "/has-rule"
- const notHasFile = tmpDir + "/not-has-rule"
- console.log("Write result to: " + hasFile + " , " + notHasFile)
- Deno.writeTextFileSync(hasFile, has)
- Deno.writeTextFileSync(notHasFile, notHas)
+ const rules = extract(SITES, provider);
+ const [has, notHas] = toNewFormat(rules, ATTR);
+ const hasFile = tmpDir + "/has-rule";
+ const notHasFile = tmpDir + "/not-has-rule";
+ console.log("Write result to: " + hasFile + " , " + notHasFile);
+ Deno.writeTextFileSync(hasFile, has);
+ Deno.writeTextFileSync(notHasFile, notHas);
}
-
diff --git a/deno/tools/manage-service.ts b/deno/tools/manage-service.ts
new file mode 100644
index 0000000..148f55a
--- /dev/null
+++ b/deno/tools/manage-service.ts
@@ -0,0 +1,42 @@
+import { join } from "@std/path";
+// @ts-types="npm:@types/yargs"
+import yargs from "yargs";
+
+import { TemplateDir } from "./template.ts";
+
+if (import.meta.main) {
+ await yargs(Deno.args)
+ .scriptName("manage-service")
+ .option("project-dir", {
+ type: "string",
+ })
+ .demandOption("project-dir")
+ .command({
+ command: "gen-tmpl",
+ describe: "generate files for templates",
+ builder: (builder) => {
+ return builder
+ .option("dry-run", {
+ type: "boolean",
+ default: true,
+ })
+ .strict();
+ },
+ handler: (argv) => {
+ const { projectDir, dryRun } = argv;
+ new TemplateDir(
+ join(projectDir, "services/templates"),
+ ).generateWithVariableFiles(
+ [
+ join(projectDir, "data/config"),
+ join(projectDir, "services/config.template"),
+ ],
+ dryRun ? undefined : join(projectDir, "services/generated"),
+ );
+ },
+ })
+ .demandCommand(1, "One command must be specified.")
+ .help()
+ .strict()
+ .parse();
+}
diff --git a/deno/tools/manage-vm.ts b/deno/tools/manage-vm.ts
new file mode 100644
index 0000000..bb985ce
--- /dev/null
+++ b/deno/tools/manage-vm.ts
@@ -0,0 +1,144 @@
+import os from "node:os";
+import { join } from "@std/path";
+// @ts-types="npm:@types/yargs"
+import yargs from "yargs";
+
+type ArchAliasMap = { [name: string]: string[] };
+const arches = {
+ x86_64: ["x86_64", "amd64"],
+ i386: ["i386", "x86", "i686"],
+} as const satisfies ArchAliasMap;
+type Arch = keyof typeof arches;
+type GeneralArch = (typeof arches)[Arch][number];
+
+function normalizeArch(generalName: GeneralArch): Arch {
+ for (const [name, aliases] of Object.entries(arches as ArchAliasMap)) {
+ if (aliases.includes(generalName)) return name as Arch;
+ }
+ throw Error("Unknown architecture name.");
+}
+
+interface GeneralVmSetup {
+ name?: string[];
+ arch: GeneralArch;
+ disk: string;
+ sshForwardPort: number;
+ kvm?: boolean;
+}
+
+interface VmSetup {
+ arch: Arch;
+ disk: string;
+ sshForwardPort: number;
+ kvm: boolean;
+}
+
+const MY_VMS: GeneralVmSetup[] = [
+ {
+ name: ["hurd", ...arches.i386.map((a) => `hurd-${a}`)],
+ arch: "i386",
+ disk: join(os.homedir(), "vms/hurd-i386.qcow2"),
+ sshForwardPort: 3222,
+ },
+ {
+ name: [...arches.x86_64.map((a) => `hurd-${a}`)],
+ arch: "x86_64",
+ disk: join(os.homedir(), "vms/hurd-x86_64.qcow2"),
+ sshForwardPort: 3223,
+ },
+];
+
+function normalizeVmSetup(generalSetup: GeneralVmSetup): VmSetup {
+ const { arch, disk, sshForwardPort, kvm } = generalSetup;
+ return {
+ arch: normalizeArch(arch),
+ disk,
+ sshForwardPort,
+ kvm: kvm ?? Deno.build.os === "linux",
+ };
+}
+
+function resolveVmSetup(
+ name: string,
+ vms: GeneralVmSetup[],
+): VmSetup | undefined {
+ const setup = vms.find((vm) => vm.name?.includes(name));
+ return setup == null ? undefined : normalizeVmSetup(setup);
+}
+
+const qemuBinPrefix = "qemu-system" as const;
+
+const qemuBinSuffix = {
+ x86_64: "x86_64",
+ i386: "x86_64",
+} as const;
+
+function getQemuBin(arch: Arch): string {
+ return `${qemuBinPrefix}-${qemuBinSuffix[arch]}`;
+}
+
+function getLinuxHostArgs(kvm: boolean): string[] {
+ return kvm ? ["-enable-kvm"] : [];
+}
+
+function getMachineArgs(arch: Arch): string[] {
+ const is64 = arch === "x86_64";
+ const machineArgs = is64 ? ["-machine", "q35"] : [];
+ const memory = is64 ? 8 : 4;
+ return [...machineArgs, "-m", `${memory}G`];
+}
+
+function getNetworkArgs(sshForwardPort: number): string[] {
+ return ["-net", "nic", "-net", `user,hostfwd=tcp::${sshForwardPort}-:22`];
+}
+
+function getDisplayArgs(): string[] {
+ return ["-vga", "vmware"];
+}
+
+function getDiskArgs(disk: string): string[] {
+ return ["-drive", `cache=writeback,file=${disk}`];
+}
+
+function createQemuArgs(setup: VmSetup): string[] {
+ const { arch, disk, sshForwardPort } = setup;
+ return [
+ getQemuBin(arch),
+ ...getLinuxHostArgs(setup.kvm),
+ ...getMachineArgs(arch),
+ ...getDisplayArgs(),
+ ...getNetworkArgs(sshForwardPort),
+ ...getDiskArgs(disk),
+ ];
+}
+
+if (import.meta.main) {
+ await yargs(Deno.args)
+ .scriptName("manage-vm")
+ .command({
+ command: "gen <name>",
+ describe: "generate cli command to run the vm",
+ builder: (builder) => {
+ return builder
+ .positional("name", {
+ describe: "name of the vm to run",
+ type: "string",
+ })
+ .demandOption("name")
+ .strict();
+ },
+ handler: (argv) => {
+ const vm = resolveVmSetup(argv.name, MY_VMS);
+ if (vm == null) {
+ console.error(`No vm called ${argv.name} is found.`);
+ Deno.exit(-1);
+ }
+ const cli = createQemuArgs(vm);
+ console.log(`${cli.join(" ")}`);
+ },
+ })
+ .demandCommand(1, "One command must be specified.")
+ .help()
+ .strict()
+ .parse();
+}
diff --git a/deno/service-manager/template.ts b/deno/tools/template.ts
index 0b043a1..0b043a1 100644
--- a/deno/service-manager/template.ts
+++ b/deno/tools/template.ts
diff --git a/dictionary.txt b/dictionary.txt
index 03a5f54..e2894d9 100644
--- a/dictionary.txt
+++ b/dictionary.txt
@@ -4,40 +4,68 @@ Yuqian
Yang
fxxking
-# self-hosted services
+# general
+aarch64
+esmtp
+healthcheck
+
2fauth
-rspamd
certbot
roundcube
roundcubemail
+gerrit
gohugoio
+pwsh
+rclone
+
+kmod
+btrfs
+chroot
+nproc
+zstd
+cpio
+pacman
+fontconfig
-# general
-catppuccin
-macchiato
-cheatsheet
-aarch64
-pythonpath
-gerrit
-esmtp
-tini
-healthcheck
nspawn
+tini
containerd
buildx
-fontconfig
+qcow2
+hostfwd
+
+# languages
+pythonpath
+denoland
+kysely
+insertable
+
+ustc
+sourceware
+sesv2
+amazonses
+
+geodata
+geoip
+geosite
+vmess
+vnext
+
+catppuccin
+macchiato
# vim/nvim
nvim
neovide
vimruntime
-
+termguicolors
autobrief
autopairs
bashls
bufhidden
bufnr
clangd
+denols
devicons
exepath
gitsigns
@@ -45,16 +73,6 @@ lspconfig
lualine
luasnip
-# unix
-cpio
-kmod
-nproc
-sourceware
-zstd
-btrfs
-pacman
-rclone
-
# hurd
gnumach
settrans
@@ -69,7 +87,6 @@ dquilt
buildpackage
quiltrc
nocheck
-chroot
indep
confdir
createchroot
@@ -77,10 +94,3 @@ sbuild
sbuildrc
schroot
-# misc
-geodata
-geoip
-geosite
-vmess
-vnext
-ustc
diff --git a/services/docker/mail-server/app/main.bash b/services/docker/mail-server/app/main.bash
index 14900d7..70c9b75 100755
--- a/services/docker/mail-server/app/main.bash
+++ b/services/docker/mail-server/app/main.bash
@@ -7,5 +7,5 @@ die() {
exit 1
}
-/app/crupest-relay real-serve &
+/app/crupest-relay serve --real &
/dovecot/sbin/dovecot -F
diff --git a/services/manage b/services/manage
index c81e6dc..9248945 100755
--- a/services/manage
+++ b/services/manage
@@ -14,4 +14,4 @@ export CRUPEST_PROJECT_DIR
echo "Project Dir: $CRUPEST_PROJECT_DIR"
-exec deno run -A "$CRUPEST_PROJECT_DIR/deno/service-manager/main.ts" --project-dir "$CRUPEST_PROJECT_DIR" "$@"
+exec deno run -A "$CRUPEST_PROJECT_DIR/deno/tools/manage-service.ts" --project-dir "$CRUPEST_PROJECT_DIR" "$@"
diff --git a/store/config/etc/fonts/local.conf b/store/config/etc/fonts/local.conf
new file mode 100644
index 0000000..a8dbe2b
--- /dev/null
+++ b/store/config/etc/fonts/local.conf
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
+<fontconfig>
+
+ <alias>
+ <family>sans-serif</family>
+ <prefer>
+ <family>MiSans</family>
+ </prefer>
+ </alias>
+
+ <alias>
+ <family>serif</family>
+ <prefer>
+ <family>MiSans</family>
+ </prefer>
+ </alias>
+
+ <alias>
+ <family>monospace</family>
+ <prefer>
+ <family>Maple Mono</family>
+ </prefer>
+ </alias>
+
+ <alias>
+ <family>MiSans</family>
+ <prefer>
+ <family>MiSans</family>
+ <family>Noto Color Emoji</family>
+ </prefer>
+ </alias>
+
+ <alias>
+ <family>Maple Mono</family>
+ <prefer>
+ <family>Maple Mono</family>
+ <family>Maple Mono NF</family>
+ <family>Maple Mono NF CN</family>
+ <family>Noto Color Emoji</family>
+ </prefer>
+ </alias>
+
+ <alias>
+ <family>Noto Sans</family>
+ <prefer>
+ <family>Noto Sans</family>
+ <family>Noto Sans CJK SC</family>
+ </prefer>
+ </alias>
+
+ <alias>
+ <family>Noto Serif</family>
+ <prefer>
+ <family>Noto Serif</family>
+ <family>Noto Serif CJK SC</family>
+ </prefer>
+ </alias>
+
+</fontconfig> \ No newline at end of file
diff --git a/store/config/home/bashrc b/store/config/home/bashrc
index 1ab3b08..e59b2a4 100644
--- a/store/config/home/bashrc
+++ b/store/config/home/bashrc
@@ -1,8 +1,13 @@
set-proxy() {
+ export http_proxy="http://127.0.0.1:7897"
+ export https_proxy="http://127.0.0.1:7897"
export HTTP_PROXY="http://127.0.0.1:7897"
export HTTPS_PROXY="http://127.0.0.1:7897"
}
unset-proxy() {
- unset HTTP_PROXY HTTPS_PROXY
+ unset http_proxy
+ unset https_proxy
+ unset HTTP_PROXY
+ unset HTTPS_PROXY
}
diff --git a/store/config/mihomo/config.yaml b/store/config/mihomo/config.yaml
index cd2c3a3..c455409 100644
--- a/store/config/mihomo/config.yaml
+++ b/store/config/mihomo/config.yaml
@@ -26,56 +26,61 @@ dns:
ipv6: true
default-nameserver:
- 223.5.5.5
+ - 119.29.29.29
nameserver:
+# - 9.9.9.11
+# - tls://1.1.1.1
+ - https://doh.pub/dns-query
- https://dns.alidns.com/dns-query
- 223.5.5.5
- - 8.8.8.8
- - 1.1.1.1
+ - 119.29.29.29
+
+sniffer:
+ enable: true
+ sniff:
+ HTTP:
+ ports: [80]
+ TLS:
+ ports: [443]
+ QUIC:
+ ports: [443]
+ skip-domain:
+ - "Mijia Cloud"
+
+rule-providers:
+ cn:
+ type: file
+ path: has-rule
+ behavior: classical
+ format: text
+
+ non-cn:
+ type: file
+ path: not-has-rule
+ behavior: classical
+ format: text
+
+ need:
+ type: file
+ path: need-rule
+ behavior: classical
+ format: text
rules:
- - GEOSITE,github,node-select
- - GEOSITE,google,node-select
- - GEOSITE,youtube,node-select
- - GEOSITE,twitter,node-select
- - GEOSITE,facebook,node-select
- - GEOSITE,discord,node-select
- - GEOSITE,reddit,node-select
- - GEOSITE,twitch,node-select
- - GEOSITE,quora,node-select
- - GEOSITE,telegram,node-select
- - GEOSITE,imgur,node-select
- - GEOSITE,stackexchange,node-select
- - GEOSITE,onedrive,node-select
- - GEOSITE,duckduckgo,node-select
- - GEOSITE,wikimedia,node-select
- - GEOSITE,gitbook,node-select
- - GEOSITE,gitlab,node-select
- - GEOSITE,creativecommons,node-select
- - GEOSITE,archive,node-select
- - GEOSITE,matrix,node-select
- - GEOSITE,tor,node-select
- - GEOSITE,python,node-select
- - GEOSITE,ruby,node-select
- - GEOSITE,rust,node-select
- - GEOSITE,nodejs,node-select
- - GEOSITE,npmjs,node-select
- - GEOSITE,qt,node-select
- - GEOSITE,docker,node-select
- - GEOSITE,v2ray,node-select
- - GEOSITE,homebrew,node-select
- - GEOSITE,bootstrap,node-select
- - GEOSITE,heroku,node-select
- - GEOSITE,vercel,node-select
- - GEOSITE,ieee,node-select
- - GEOSITE,sci-hub,node-select
- - GEOSITE,libgen,node-select
+ - RULE-SET,cn,DIRECT
+ - RULE-SET,non-cn,node-select
+ - RULE-SET,need,node-select
+# - NOT,((GEOIP,CN)),node-select
- DOMAIN-SUFFIX,gnu.org,node-select
- DOMAIN-SUFFIX,nongnu.org,node-select
- DOMAIN-SUFFIX,ietf.org,node-select
- - DOMAIN-SUFFIX,packagist.org,node-select
- DOMAIN-SUFFIX,metacubex.one,node-select
- DOMAIN-SUFFIX,winehq.org,node-select
- - DOMAIN-SUFFIX,postfix.org,node-select
+ - DOMAIN-SUFFIX,freedesktop.org,node-select
+ - DOMAIN-SUFFIX,eff.org,node-select
+ - DOMAIN-SUFFIX,typescriptlang.org,node-select
+ - DOMAIN-SUFFIX,arxiv.org,node-select
+# - MATCH,node-select
- MATCH,DIRECT
proxy-groups:
diff --git a/store/config/mihomo/need-rule b/store/config/mihomo/need-rule
new file mode 100644
index 0000000..b785f0f
--- /dev/null
+++ b/store/config/mihomo/need-rule
@@ -0,0 +1,4 @@
+IP-CIDR,185.199.108.153/32,node-select
+IP-CIDR,185.199.109.153/32,node-select
+IP-CIDR,185.199.110.153/32,node-select
+IP-CIDR,185.199.111.153/32,node-select \ No newline at end of file
diff --git a/store/config/nvim/lua/setup/init.lua b/store/config/nvim/lua/setup/init.lua
index ec8c8d4..bbce01c 100644
--- a/store/config/nvim/lua/setup/init.lua
+++ b/store/config/nvim/lua/setup/init.lua
@@ -1,5 +1,3 @@
--- spellchecker: words termguicolors
-
local function close_float()
local wins = vim.api.nvim_list_wins()
for _, v in ipairs(wins) do
diff --git a/store/config/nvim/lua/setup/lsp.lua b/store/config/nvim/lua/setup/lsp.lua
index a11ad34..6a58759 100644
--- a/store/config/nvim/lua/setup/lsp.lua
+++ b/store/config/nvim/lua/setup/lsp.lua
@@ -1,5 +1,3 @@
--- spellchecker: words denols luals
-
vim.lsp.config("*", {
capabilities = vim.tbl_extend("force",
vim.lsp.protocol.make_client_capabilities(),
diff --git a/store/config/nvim/lua/setup/plugins/lint.lua b/store/config/nvim/lua/setup/plugins/lint.lua
index b33db22..d03f539 100644
--- a/store/config/nvim/lua/setup/plugins/lint.lua
+++ b/store/config/nvim/lua/setup/plugins/lint.lua
@@ -1,4 +1,4 @@
---- spellchecker: words markdownlintrc
+--- spellchecker: ignore markdownlintrc
---@alias CruLinter { name: string, config_patterns: string[], filetypes: string[] | nil, fast: boolean }
diff --git a/store/config/nvim/lua/setup/win.lua b/store/config/nvim/lua/setup/win.lua
index 90e168a..9aa979d 100644
--- a/store/config/nvim/lua/setup/win.lua
+++ b/store/config/nvim/lua/setup/win.lua
@@ -1,4 +1,3 @@
--- spellchecker: words pwsh
-- spellchecker: ignore shellcmdflag shellredir shellpipe shellquote shellxquote
local function setup()
vim.cmd([[
diff --git a/www/content/notes/cheat-sheet.md b/www/content/notes/cheat-sheet.md
index c37c1e3..56bc92a 100644
--- a/www/content/notes/cheat-sheet.md
+++ b/www/content/notes/cheat-sheet.md
@@ -130,53 +130,3 @@ systemctl start docker
groupadd -f docker
usermod -aG docker $USER
```
-
-### Font Config
-
-```xml
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
-<fontconfig>
-
- <alias>
- <family>sans-serif</family>
- <prefer>
- <family>MiSans</family>
- <family>Noto Color Emoji</family>
- </prefer>
- </alias>
-
- <alias>
- <family>serif</family>
- <prefer>
- <family>MiSans</family>
- <family>Noto Color Emoji</family>
- </prefer>
- </alias>
-
- <alias>
- <family>Maple Mono</family>
- <prefer>
- <family>Maple Mono NF</family>
- <family>Maple Mono</family>
- </prefer>
- </alias>
-
- <alias>
- <family>Noto Sans</family>
- <prefer>
- <family>Noto Sans</family>
- <family>Noto Sans CJK SC</family>
- </prefer>
- </alias>
-
- <alias>
- <family>Noto Serif</family>
- <prefer>
- <family>Noto Serif</family>
- <family>Noto Serif CJK SC</family>
- </prefer>
- </alias>
-
-</fontconfig>
-```
diff --git a/www/content/notes/hurd/todos.md b/www/content/notes/hurd/todos.md
index cd93f01..8fe068b 100644
--- a/www/content/notes/hurd/todos.md
+++ b/www/content/notes/hurd/todos.md
@@ -58,5 +58,3 @@ gerrit: <https://chromium-review.googlesource.com/c/codecs/libgav1/+/6239812>
{{< /link-group >}}
{{< /todo >}}
-
-
diff --git a/www/content/posts/c-func-ext.md b/www/content/posts/c-func-ext.md
index 7106fad..1f5f822 100644
--- a/www/content/posts/c-func-ext.md
+++ b/www/content/posts/c-func-ext.md
@@ -8,6 +8,8 @@ tags:
- posix
---
+(I've given up on this, at least for linux pam.)
+
Recently, I’ve been working on porting some libraries to GNU/Hurd. Many (old)
libraries use [`*_MAX` constants on POSIX system
interfaces](https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/nframe.html)