1
0
Fork 0

init my glorious creating

This commit is contained in:
nin0dev 2025-02-02 14:45:25 -05:00
commit 6b16aac339
Signed by: nin0
SSH key fingerprint: SHA256:NOoDnFVvZNFvqfXCIhzr6oCTDImZAbTTuyAysZ8Ufk8
5 changed files with 85 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
node_modules/
.pnpm-store
.env

7
.prettierrc.json Normal file
View file

@ -0,0 +1,7 @@
{
"tabWidth": 4,
"useTabs": true,
"singleQuote": false,
"arrowParens": "avoid",
"trailingComma": "none"
}

41
index.mjs Normal file
View file

@ -0,0 +1,41 @@
// @ts-check
import { readFileSync, watch } from "fs";
import { readFile } from "fs/promises";
let lastFlaggedLength = 0;
watch("/opt/endlessh/endlessh.INFO", async (eventType, filename) => {
const fileContent = (await readFile("/opt/endlessh/endlessh.INFO", "utf8"))
.split("\n")
.filter(line => line.includes("ACCEPT"));
if (lastFlaggedLength !== fileContent.length) {
lastFlaggedLength = fileContent.length;
const entry = fileContent[fileContent.length - 1];
// @ts-ignore
const ip = entry.match(/host=(\S+) /)[1];
console.log(ip);
const response = await (
await fetch(`http://ip-api.com/json/${ip}`)
).json();
const t = Math.floor(Date.now() / 1000);
const embed = {
title: "New login",
description: `> **Time:** <t:${t}:D> at <t:${t}:T> (<t:${t}:R>)\n> **IP:** \`${response.query}\``
};
if (response.status === "success") {
embed.description += `\n**Country:** ${response.country}\n**Region:** ${response.regionName}\n**City:** ${response.city}\n**Provider:** ${response.as}`;
}
// @ts-ignore
fetch(process.env.WEBHOOK, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
embeds: [embed]
})
});
}
});

5
package.json Normal file
View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@types/node": "^22.13.0"
}
}

29
pnpm-lock.yaml generated Normal file
View file

@ -0,0 +1,29 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
'@types/node':
specifier: ^22.13.0
version: 22.13.0
packages:
'@types/node@22.13.0':
resolution: {integrity: sha512-ClIbNe36lawluuvq3+YYhnIN2CELi+6q8NpnM7PYp4hBn/TatfboPgVSm2rwKRfnV2M+Ty9GWDFI64KEe+kysA==}
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
snapshots:
'@types/node@22.13.0':
dependencies:
undici-types: 6.20.0
undici-types@6.20.0: {}