-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add signal support, forward socket events, add additional docum…
…entation
- Loading branch information
Showing
10 changed files
with
141 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish Package | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Publish package | ||
run: npx jsr publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { LogReceiver } from "@c43721/srcds-log-receiver"; | ||
|
||
const controller = new AbortController(); | ||
const { signal } = controller; | ||
|
||
const receiver = new LogReceiver({ | ||
address: "0.0.0.0", | ||
port: 9871, | ||
signal, | ||
}); | ||
|
||
console.log("Log receiver running.. "); | ||
|
||
receiver.on("event", (message) => console.log(message)); | ||
receiver.on("close", () => console.log("Closed the socket")); | ||
|
||
controller.abort(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"name": "@c43721/srcds-log-receiver", | ||
"version": "1.0.1", | ||
"exports": "./src/index.ts" | ||
"exports": "./src/index.ts", | ||
"publish": { | ||
"exclude": ["./examples"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { LogReceiver, type LogReceiverOptions } from "./logReceiver"; | ||
export { EventData } from "./types"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
import { type RemoteInfo } from "node:dgram"; | ||
|
||
/** | ||
* Object holding the parsed information from the UDP log | ||
* Represents the parsed information from the message data | ||
*/ | ||
export interface ParsedLogMessage { | ||
/** | ||
* The password sent by the server | ||
* The password sent by the server, if present | ||
*/ | ||
password: string | null; | ||
|
||
/** | ||
* The log the server sent | ||
* The message contained in the data | ||
*/ | ||
message: string; | ||
} | ||
|
||
export interface EventData extends ParsedLogMessage { | ||
/** | ||
* The socket information of the server | ||
* The remote address information that sent the packet | ||
*/ | ||
socket: { | ||
/** | ||
* The source IP of the message | ||
*/ | ||
ip: string; | ||
|
||
/** | ||
* The port of the server | ||
*/ | ||
port: number; | ||
}; | ||
socket: RemoteInfo; | ||
} |