forked from seth/ipv4.army
Update Lanyard socket URL, enhance IP logging in postAnalytics, and refactor App component structure
This commit is contained in:
parent
281e34bbd9
commit
a8d8f7014a
7 changed files with 49 additions and 183 deletions
|
@ -7,7 +7,7 @@ export default class {
|
|||
|
||||
constructor(callback: (data: LanyardData) => void) {
|
||||
this._socket = new ReconnectingWebSocket(
|
||||
"wss://lanyard.creations.works/socket",
|
||||
"wss://lanyard.atums.world/socket",
|
||||
);
|
||||
this._keepAlive = null;
|
||||
this._callback = callback;
|
||||
|
@ -55,7 +55,7 @@ export default class {
|
|||
}
|
||||
};
|
||||
|
||||
this._socket.onclose = () => {
|
||||
this._socket.onclose = (e) => {
|
||||
console.log("Lanyard socket closed");
|
||||
if (this._keepAlive) {
|
||||
clearInterval(this._keepAlive);
|
||||
|
|
|
@ -10,7 +10,7 @@ const build = async () => {
|
|||
minify: !development,
|
||||
sourcemap: development ? "inline" : "none",
|
||||
splitting: true,
|
||||
publicPath: "/assets/",
|
||||
publicPath: "/assets/"
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -47,18 +47,28 @@ const postAnalytics = async (
|
|||
req: Request | Bun.BunRequest,
|
||||
server: Bun.Server,
|
||||
) => {
|
||||
const cfIp = req.headers.get("CF-Connecting-IP");
|
||||
const realIp = req.headers.get("X-Real-IP");
|
||||
const forwardedIp = req.headers.get("X-Forwarded-For");
|
||||
const serverIp = server.requestIP(req)?.address;
|
||||
|
||||
console.log({
|
||||
cfIp,
|
||||
realIp,
|
||||
forwardedIp,
|
||||
serverIp,
|
||||
});
|
||||
|
||||
return await fetch("https://plausible.creations.works/api/event", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": req.headers.get("user-agent") || "",
|
||||
"X-Forwarded-For": String(
|
||||
req.headers.get("CF-Connecting-IP") ||
|
||||
req.headers.get("X-Real-IP") ||
|
||||
req.headers.get("X-Forwarded-For")?.split(",")[0] ||
|
||||
(typeof server.requestIP(req) === "string"
|
||||
? server.requestIP(req)
|
||||
: server.requestIP(req)?.address || ""),
|
||||
cfIp ||
|
||||
realIp ||
|
||||
forwardedIp?.split(",")[0] ||
|
||||
serverIp,
|
||||
),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue