6.2
This commit is contained in:
1 parent
528104fff0
commit
beb498d38b
60 files changed
+3184
-2129
No files matched your search
@@ -1,7 +1,9 @@
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
|
||||
export const BLOG_ROOT = path.resolve(process.cwd(), "..");
|
||||
export const CONTENT_DIR = path.join(BLOG_ROOT, "content", "post");
|
||||
export const STATIC_DIR = path.join(BLOG_ROOT, "static");
|
||||
export const RECYCLE_DIR = path.join(process.cwd(), ".recycle");
|
||||
export const RECYCLE_POSTS_DIR = path.join(RECYCLE_DIR, "posts");
|
||||
export const RECYCLE_META_DIR = path.join(RECYCLE_DIR, "meta");
|
||||
@@ -14,3 +16,33 @@ export const RSS_API_BASE = process.env.RSS_API_BASE || "https://api.usj.cc";
|
||||
export const RSS_API_TOKEN = process.env.RSS_API_TOKEN || "";
|
||||
export const WECHAT_APP_ID = process.env.WECHAT_APP_ID || "";
|
||||
export const WECHAT_APP_SECRET = process.env.WECHAT_APP_SECRET || "";
|
||||
|
||||
// Bot 配置
|
||||
export const TG_BOT_TOKEN = process.env.TG_BOT_TOKEN || "";
|
||||
export const TG_ALLOWED_IDS: number[] = (process.env.TG_ALLOWED_CHAT_IDS || "")
|
||||
.split(",").map((s) => s.trim()).filter(Boolean).map(Number);
|
||||
export const PREFER_IFACE = process.env.PREFER_IFACE || "WLAN";
|
||||
export const DEFAULT_AUTHOR = process.env.DEFAULT_AUTHOR || "小赵";
|
||||
|
||||
export function getLanIP(): string {
|
||||
const ifs = os.networkInterfaces();
|
||||
const candidates: { name: string; address: string }[] = [];
|
||||
for (const [name, addrs] of Object.entries(ifs)) {
|
||||
if (!addrs) continue;
|
||||
for (const a of addrs) {
|
||||
if (a.family !== "IPv4" || a.internal) continue;
|
||||
if (a.address.startsWith("169.254.")) continue;
|
||||
candidates.push({ name, address: a.address });
|
||||
}
|
||||
}
|
||||
const pref = candidates.find((c) =>
|
||||
c.name.toLowerCase().includes(PREFER_IFACE.toLowerCase())
|
||||
);
|
||||
if (pref) return pref.address;
|
||||
const real = candidates.find((c) => {
|
||||
const n = c.name.toLowerCase();
|
||||
return !n.includes("vmware") && !n.includes("virtual") && !n.includes("vethernet");
|
||||
});
|
||||
if (real) return real.address;
|
||||
return candidates[0]?.address || "0.0.0.0";
|
||||
}
|
||||
Reference in new issue
Block a user