-
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.
- Loading branch information
Showing
10 changed files
with
294 additions
and
164 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,12 @@ | ||
# Contributing | ||
|
||
Please make a Github issue before making any pull requests. | ||
|
||
# Bugs | ||
|
||
Any bugs should be attached to a Github issue. | ||
|
||
# Style | ||
|
||
Please follow the existing styling of the repository, and include documentation | ||
on new code. |
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,3 +1,28 @@ | ||
# rcon | ||
# Deno Source RCON Protocol | ||
|
||
Complete implementation of the | ||
[Source RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol). | ||
|
||
## Install | ||
|
||
Checkout the [jsr page](https://jsr.io/@c43721/rcon) for more details. | ||
|
||
### Examples | ||
|
||
For more examples, see the [documentation on jsr](https://jsr.io/@c43721/rcon/doc). | ||
|
||
## Contributing | ||
|
||
If there's a feature or bug, please raise a github issue first alongside your PR | ||
(if you're kind enough to make a PR.) | ||
|
||
## Acknowledgements | ||
|
||
- EnriqCG's [rcon-srcds](https://github.com/EnriqCG/rcon-srcds) | ||
- ribizli's [deno_rcon](https://github.com/ribizli/deno_rcon) | ||
|
||
Both of these repositories I've contributed to in the past and am super thankful for their work. | ||
|
||
## License | ||
|
||
Distributed under the MIT License. See [LICENSE](LICENSE) for more information. |
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,34 @@ | ||
import { parseArgs } from "@std/cli"; | ||
import Rcon from "./src/rcon.ts"; | ||
|
||
const args = parseArgs(Deno.args, { | ||
string: ["password", "ip", "port", "command"], | ||
boolean: ["console", "file"], | ||
}); | ||
|
||
if (!args.password || !args.ip || !args.command) { | ||
console.error("Must specify a password, ip and command"); | ||
} else { | ||
const port = parseInt(args.port ?? "27015", 10); | ||
|
||
using rcon = new Rcon({ | ||
host: args.ip, | ||
port, | ||
}); | ||
|
||
const didAuthenticate = await rcon.authenticate(args.password!); | ||
|
||
if (didAuthenticate) { | ||
const result = await rcon.execute(args.command!); | ||
|
||
if (args.file) { | ||
Deno.writeTextFile(`${Deno.cwd()}/rcon-result.txt`, result.toString(), { | ||
append: true, | ||
}); | ||
} else if (args.console) { | ||
console.log(result); | ||
} | ||
} else { | ||
console.error("RCON password incorrect"); | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,36 +1,44 @@ | ||
/** | ||
* RCON Packet Types | ||
* Reference: https://developer.valvesoftware.com/wiki/Source_RCON#Requests_and_Responses | ||
* The list of [RCON Packet Types](https://developer.valvesoftware.com/wiki/Source_RCON#Requests_and_Responses) | ||
* | ||
* @readonly | ||
*/ | ||
const protocol = { | ||
/** | ||
* First packet for authentication | ||
* Used for authenticating the connection with the server | ||
*/ | ||
SERVERDATA_AUTH: 0x03, | ||
|
||
/** | ||
* Command issued to the server | ||
* Represents a command issue to the server by a client | ||
*/ | ||
SERVERDATA_EXECCOMMAND: 0x02, | ||
|
||
/** | ||
* Response of SERVERDATA_AUTH | ||
* @remarks If body is -1, the auth failed | ||
* Notifies the connection's current authentication status | ||
* | ||
* @remarks When sent, the server will respond with an empty {@link SERVERDATA_RESPONSE_VALUE} followed by a {@link SERVERDATA_AUTH_RESPONSE} indicating if the authentication was successful. A value of -1 for the packet id will be set if the authentication failed | ||
*/ | ||
SERVERDATA_AUTH_RESPONSE: 0x02, | ||
|
||
/** | ||
* Response of SERVERDATA_EXECCOMMAND | ||
* Response to a {@link SERVERDATA_EXECCOMMAND} | ||
*/ | ||
SERVERDATA_RESPONSE_VALUE: 0x00, | ||
|
||
/** | ||
* The packet id used when issuing {@link SERVERDATA_AUTH} commands | ||
* | ||
* @internal | ||
*/ | ||
ID_AUTH: 0x999, | ||
|
||
ID_REQUEST: 0x123, | ||
|
||
ID_TERM: 0x777, | ||
/** | ||
* The packet id used when working with multipacket responses | ||
* | ||
* @internal | ||
*/ | ||
ID_TERM: 0x888, | ||
} as const; | ||
|
||
export default protocol; |
Oops, something went wrong.