rconx 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rconx-0.1.0/LICENSE +165 -0
- rconx-0.1.0/PKG-INFO +93 -0
- rconx-0.1.0/README.md +64 -0
- rconx-0.1.0/pyproject.toml +50 -0
- rconx-0.1.0/pyproject.toml.orig +54 -0
- rconx-0.1.0/src/rconx/__init__.py +68 -0
- rconx-0.1.0/src/rconx/__main__.py +5 -0
- rconx-0.1.0/src/rconx/cli/__init__.py +0 -0
- rconx-0.1.0/src/rconx/cli/arguments.py +128 -0
- rconx-0.1.0/src/rconx/cli/main.py +78 -0
- rconx-0.1.0/src/rconx/client/__init__.py +0 -0
- rconx-0.1.0/src/rconx/client/auth/__init__.py +1 -0
- rconx-0.1.0/src/rconx/client/auth/base.py +13 -0
- rconx-0.1.0/src/rconx/client/auth/source_handler.py +69 -0
- rconx-0.1.0/src/rconx/client/client.py +463 -0
- rconx-0.1.0/src/rconx/client/client_options.py +17 -0
- rconx-0.1.0/src/rconx/client/command/__init__.py +1 -0
- rconx-0.1.0/src/rconx/client/command/base.py +13 -0
- rconx-0.1.0/src/rconx/client/command/common.py +11 -0
- rconx-0.1.0/src/rconx/client/command/cuberite_handler.py +70 -0
- rconx-0.1.0/src/rconx/client/command/idle_timeout_handler.py +50 -0
- rconx-0.1.0/src/rconx/client/command/minecraft_handler.py +65 -0
- rconx-0.1.0/src/rconx/client/command/single_packet_handler.py +35 -0
- rconx-0.1.0/src/rconx/client/command/srcds_handler.py +80 -0
- rconx-0.1.0/src/rconx/client/operation.py +82 -0
- rconx-0.1.0/src/rconx/client/preset.py +22 -0
- rconx-0.1.0/src/rconx/client/raw.py +235 -0
- rconx-0.1.0/src/rconx/common/__init__.py +0 -0
- rconx-0.1.0/src/rconx/common/async_utils.py +26 -0
- rconx-0.1.0/src/rconx/common/connection.py +412 -0
- rconx-0.1.0/src/rconx/common/connection_info.py +21 -0
- rconx-0.1.0/src/rconx/common/connection_options.py +15 -0
- rconx-0.1.0/src/rconx/common/content.py +28 -0
- rconx-0.1.0/src/rconx/common/exceptions.py +26 -0
- rconx-0.1.0/src/rconx/common/protocol.py +66 -0
- rconx-0.1.0/src/rconx/common/thread_pool.py +162 -0
- rconx-0.1.0/src/rconx/common/utils.py +63 -0
- rconx-0.1.0/src/rconx/py.typed +0 -0
- rconx-0.1.0/src/rconx/server/__init__.py +0 -0
- rconx-0.1.0/src/rconx/server/config.py +34 -0
- rconx-0.1.0/src/rconx/server/log.py +5 -0
- rconx-0.1.0/src/rconx/server/raw.py +301 -0
- rconx-0.1.0/src/rconx/server/raw_options.py +12 -0
- rconx-0.1.0/src/rconx/server/server.py +233 -0
- rconx-0.1.0/src/rconx/server/server_connection.py +75 -0
- rconx-0.1.0/src/rconx/server/server_options.py +35 -0
- rconx-0.1.0/src/rconx/server/session.py +173 -0
rconx-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
rconx-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rconx
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python implementation of the Source RCON protocol with client, server, and Minecraft compatibility
|
|
5
|
+
Author: Fallen_Breath
|
|
6
|
+
License-Expression: LGPL-3.0-only
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Requires-Dist: dataclasses>=0.8 ; python_full_version < '3.7'
|
|
21
|
+
Requires-Dist: importlib-metadata>=1.0 ; python_full_version < '3.8'
|
|
22
|
+
Requires-Dist: typing-extensions>=4.1
|
|
23
|
+
Requires-Dist: rconx-cli>=0.1.0 ; extra == 'cli'
|
|
24
|
+
Requires-Python: >=3.6
|
|
25
|
+
Project-URL: Repository, https://github.com/Fallen-Breath/rconx
|
|
26
|
+
Project-URL: Issues, https://github.com/Fallen-Breath/rconx/issues
|
|
27
|
+
Provides-Extra: cli
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# rconx
|
|
31
|
+
|
|
32
|
+
[](LICENSE)
|
|
33
|
+
[](https://pypi.org/project/rconx/)
|
|
34
|
+
[](#installation)
|
|
35
|
+
|
|
36
|
+
rconx is a Python library for communicating with TCP servers [that use the Source RCON packet format](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol). It provides synchronous and asynchronous clients for authentication and command execution, together with servers for exposing an application's own command handlers over RCON.
|
|
37
|
+
|
|
38
|
+
The clients collect command results using selectable presets, including SRCDS, Minecraft, and Cuberite. Low-level clients and servers are available for applications that need to exchange individual RCON packets. The command-line interface executes commands from a terminal or script.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
rconx supports Python 3.8 and later, with best-effort compatibility for Python 3.6 and 3.7. The examples below use Python 3.8 or later.
|
|
43
|
+
|
|
44
|
+
rconx is available on [PyPI](https://pypi.org/project/rconx/):
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
python -m pip install rconx
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Quick start
|
|
51
|
+
|
|
52
|
+
These examples execute `list` on a Minecraft server with RCON enabled.
|
|
53
|
+
|
|
54
|
+
### Synchronous client
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from rconx import RconClient, RconPreset
|
|
58
|
+
|
|
59
|
+
with RconClient.create("127.0.0.1", 25575, RconPreset.minecraft) as client:
|
|
60
|
+
client.connect()
|
|
61
|
+
client.authenticate("your-rcon-password")
|
|
62
|
+
response = client.execute("list")
|
|
63
|
+
print(response.text)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Asynchronous client
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import asyncio
|
|
70
|
+
|
|
71
|
+
from rconx import AsyncRconClient, RconPreset
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
async def main():
|
|
75
|
+
async with AsyncRconClient.create("127.0.0.1", 25575, RconPreset.minecraft) as client:
|
|
76
|
+
await client.connect()
|
|
77
|
+
await client.authenticate("your-rcon-password")
|
|
78
|
+
response = await client.execute("list")
|
|
79
|
+
print(response.text)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
asyncio.run(main())
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Documentation
|
|
86
|
+
|
|
87
|
+
- The [client guide](docs/client.md) describes client usage, presets, command results, and error handling. It also records compatibility and testing status for individual servers.
|
|
88
|
+
- The [server guide](docs/server.md) describes business callbacks, connection handling, and service lifecycle.
|
|
89
|
+
- The [command-line guide](docs/cli.md) describes installation, command execution, interactive mode, and output handling.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
rconx is licensed under [LGPL-3.0-only](LICENSE).
|
rconx-0.1.0/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# rconx
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://pypi.org/project/rconx/)
|
|
5
|
+
[](#installation)
|
|
6
|
+
|
|
7
|
+
rconx is a Python library for communicating with TCP servers [that use the Source RCON packet format](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol). It provides synchronous and asynchronous clients for authentication and command execution, together with servers for exposing an application's own command handlers over RCON.
|
|
8
|
+
|
|
9
|
+
The clients collect command results using selectable presets, including SRCDS, Minecraft, and Cuberite. Low-level clients and servers are available for applications that need to exchange individual RCON packets. The command-line interface executes commands from a terminal or script.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
rconx supports Python 3.8 and later, with best-effort compatibility for Python 3.6 and 3.7. The examples below use Python 3.8 or later.
|
|
14
|
+
|
|
15
|
+
rconx is available on [PyPI](https://pypi.org/project/rconx/):
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
python -m pip install rconx
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
These examples execute `list` on a Minecraft server with RCON enabled.
|
|
24
|
+
|
|
25
|
+
### Synchronous client
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from rconx import RconClient, RconPreset
|
|
29
|
+
|
|
30
|
+
with RconClient.create("127.0.0.1", 25575, RconPreset.minecraft) as client:
|
|
31
|
+
client.connect()
|
|
32
|
+
client.authenticate("your-rcon-password")
|
|
33
|
+
response = client.execute("list")
|
|
34
|
+
print(response.text)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Asynchronous client
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import asyncio
|
|
41
|
+
|
|
42
|
+
from rconx import AsyncRconClient, RconPreset
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async def main():
|
|
46
|
+
async with AsyncRconClient.create("127.0.0.1", 25575, RconPreset.minecraft) as client:
|
|
47
|
+
await client.connect()
|
|
48
|
+
await client.authenticate("your-rcon-password")
|
|
49
|
+
response = await client.execute("list")
|
|
50
|
+
print(response.text)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
asyncio.run(main())
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Documentation
|
|
57
|
+
|
|
58
|
+
- The [client guide](docs/client.md) describes client usage, presets, command results, and error handling. It also records compatibility and testing status for individual servers.
|
|
59
|
+
- The [server guide](docs/server.md) describes business callbacks, connection handling, and service lifecycle.
|
|
60
|
+
- The [command-line guide](docs/cli.md) describes installation, command execution, interactive mode, and output handling.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
rconx is licensed under [LGPL-3.0-only](LICENSE).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "rconx"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A Python implementation of the Source RCON protocol with client, server, and Minecraft compatibility"
|
|
5
|
+
license = "LGPL-3.0-only"
|
|
6
|
+
license-files = ["LICENSE"]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
requires-python = ">=3.6"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Operating System :: OS Independent",
|
|
11
|
+
"Programming Language :: Python",
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Programming Language :: Python :: 3.6",
|
|
14
|
+
"Programming Language :: Python :: 3.7",
|
|
15
|
+
"Programming Language :: Python :: 3.8",
|
|
16
|
+
"Programming Language :: Python :: 3.9",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Programming Language :: Python :: 3.14",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"dataclasses>=0.8 ; python_full_version < '3.7'",
|
|
25
|
+
"importlib-metadata>=1.0 ; python_version < '3.8'",
|
|
26
|
+
"typing-extensions>=4.1",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[[project.authors]]
|
|
30
|
+
name = "Fallen_Breath"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Repository = "https://github.com/Fallen-Breath/rconx"
|
|
34
|
+
Issues = "https://github.com/Fallen-Breath/rconx/issues"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
cli = ["rconx_cli>=0.1.0"]
|
|
38
|
+
|
|
39
|
+
[build-system]
|
|
40
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
41
|
+
build-backend = "uv_build"
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = [
|
|
45
|
+
"mypy>=0.971",
|
|
46
|
+
"pytest>=7.0.1",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.uv.sources.rconx_cli]
|
|
50
|
+
path = "rconx_cli"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "rconx"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A Python implementation of the Source RCON protocol with client, server, and Minecraft compatibility"
|
|
5
|
+
|
|
6
|
+
license = "LGPL-3.0-only"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.6"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Fallen_Breath" }
|
|
12
|
+
]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
"Programming Language :: Python",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.6",
|
|
18
|
+
"Programming Language :: Python :: 3.7",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"dataclasses>=0.8 ; python_full_version < '3.7'",
|
|
29
|
+
"importlib-metadata>=1.0 ; python_version < '3.8'",
|
|
30
|
+
"typing-extensions>=4.1",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Repository = "https://github.com/Fallen-Breath/rconx"
|
|
35
|
+
Issues = "https://github.com/Fallen-Breath/rconx/issues"
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
cli = [
|
|
39
|
+
"rconx_cli>=0.1.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[build-system]
|
|
43
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
44
|
+
build-backend = "uv_build"
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = [
|
|
48
|
+
"mypy>=0.971",
|
|
49
|
+
"pytest>=7.0.1",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
# https://docs.astral.sh/uv/concepts/projects/dependencies/#dependency-sources
|
|
53
|
+
[tool.uv.sources]
|
|
54
|
+
rconx_cli = { path = "rconx_cli" }
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from rconx.client.client import AsyncRconClient, RconClient
|
|
2
|
+
from rconx.client.client_options import RconClientOptions
|
|
3
|
+
from rconx.client.preset import RconPreset
|
|
4
|
+
from rconx.client.raw import AsyncRawRconClient, LocalAddress, RawRconClient
|
|
5
|
+
from rconx.common.connection import AsyncConnection, Connection
|
|
6
|
+
from rconx.common.connection_info import ConnectionAddress, ConnectionInfo
|
|
7
|
+
from rconx.common.connection_options import ConnectionOptions
|
|
8
|
+
from rconx.common.content import RconContent
|
|
9
|
+
from rconx.common.exceptions import (
|
|
10
|
+
RconAuthenticationError,
|
|
11
|
+
RconConnectionError,
|
|
12
|
+
RconError,
|
|
13
|
+
RconPacketDecodeError,
|
|
14
|
+
RconProtocolError,
|
|
15
|
+
RconStateError,
|
|
16
|
+
RconTimeoutError,
|
|
17
|
+
)
|
|
18
|
+
from rconx.common.protocol import Packet, PacketType
|
|
19
|
+
from rconx.server.raw import AsyncRawRconServer, RawRconServer
|
|
20
|
+
from rconx.server.raw_options import RawRconServerOptions
|
|
21
|
+
from rconx.server.server import AsyncRconServer, RconServer
|
|
22
|
+
from rconx.server.server_options import RconServerOptions
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
# High-level clients
|
|
26
|
+
'RconClient',
|
|
27
|
+
'AsyncRconClient',
|
|
28
|
+
'RconPreset',
|
|
29
|
+
'RconClientOptions',
|
|
30
|
+
|
|
31
|
+
# Low-level clients
|
|
32
|
+
'RawRconClient',
|
|
33
|
+
'AsyncRawRconClient',
|
|
34
|
+
'LocalAddress',
|
|
35
|
+
|
|
36
|
+
# High-level servers
|
|
37
|
+
'RconServer',
|
|
38
|
+
'AsyncRconServer',
|
|
39
|
+
'RconServerOptions',
|
|
40
|
+
|
|
41
|
+
# Low-level servers
|
|
42
|
+
'RawRconServer',
|
|
43
|
+
'AsyncRawRconServer',
|
|
44
|
+
'RawRconServerOptions',
|
|
45
|
+
|
|
46
|
+
# Low-level connections
|
|
47
|
+
'Connection',
|
|
48
|
+
'AsyncConnection',
|
|
49
|
+
'ConnectionOptions',
|
|
50
|
+
|
|
51
|
+
# Shared data
|
|
52
|
+
'RconContent',
|
|
53
|
+
'ConnectionInfo',
|
|
54
|
+
'ConnectionAddress',
|
|
55
|
+
|
|
56
|
+
# Protocol
|
|
57
|
+
'Packet',
|
|
58
|
+
'PacketType',
|
|
59
|
+
|
|
60
|
+
# Exceptions
|
|
61
|
+
'RconError',
|
|
62
|
+
'RconConnectionError',
|
|
63
|
+
'RconTimeoutError',
|
|
64
|
+
'RconPacketDecodeError',
|
|
65
|
+
'RconAuthenticationError',
|
|
66
|
+
'RconStateError',
|
|
67
|
+
'RconProtocolError',
|
|
68
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import dataclasses
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
from typing import List, Optional
|
|
6
|
+
|
|
7
|
+
from rconx.client.preset import RconPreset
|
|
8
|
+
from rconx.common.connection_info import ConnectionAddress
|
|
9
|
+
from rconx.common.utils import validate_packet_size_limit, validate_timeout
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def __get_self_version() -> str:
|
|
13
|
+
try:
|
|
14
|
+
if sys.version_info >= (3, 8):
|
|
15
|
+
from importlib.metadata import version
|
|
16
|
+
else:
|
|
17
|
+
from importlib_metadata import version
|
|
18
|
+
return version('rconx')
|
|
19
|
+
except Exception:
|
|
20
|
+
return 'unknown'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclasses.dataclass(frozen=True)
|
|
24
|
+
class SizeLimit:
|
|
25
|
+
value: Optional[int]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclasses.dataclass(frozen=True)
|
|
29
|
+
class CliOptions:
|
|
30
|
+
address: ConnectionAddress
|
|
31
|
+
password: str = dataclasses.field(repr=False)
|
|
32
|
+
commands: List[str]
|
|
33
|
+
preset: RconPreset
|
|
34
|
+
interactive: bool
|
|
35
|
+
timeout: Optional[float]
|
|
36
|
+
idle_window: Optional[float]
|
|
37
|
+
encoding: Optional[str]
|
|
38
|
+
raw: bool
|
|
39
|
+
max_send_packet_size: Optional[SizeLimit]
|
|
40
|
+
max_receive_packet_size: Optional[SizeLimit]
|
|
41
|
+
max_response_size: Optional[SizeLimit]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def compute_address(value: str) -> ConnectionAddress:
|
|
45
|
+
if value.startswith('['):
|
|
46
|
+
closing = value.find(']')
|
|
47
|
+
if closing < 0 or value[closing + 1:closing + 2] != ':':
|
|
48
|
+
raise ValueError('expected HOST:PORT or [IPv6]:PORT')
|
|
49
|
+
host = value[1:closing]
|
|
50
|
+
port_text = value[closing + 2:]
|
|
51
|
+
if ':' not in host or '[' in host:
|
|
52
|
+
raise ValueError('expected [IPv6]:PORT')
|
|
53
|
+
else:
|
|
54
|
+
host, separator, port_text = value.rpartition(':')
|
|
55
|
+
if not separator or ':' in host or '[' in host or ']' in host:
|
|
56
|
+
raise ValueError('expected HOST:PORT or [IPv6]:PORT')
|
|
57
|
+
if not host:
|
|
58
|
+
raise ValueError('host must not be empty')
|
|
59
|
+
if not port_text or any(character < '0' or character > '9' for character in port_text):
|
|
60
|
+
raise ValueError('port must be a decimal integer from 1 to 65535')
|
|
61
|
+
port = int(port_text)
|
|
62
|
+
if not 1 <= port <= 65535:
|
|
63
|
+
raise ValueError('port must be from 1 to 65535')
|
|
64
|
+
return ConnectionAddress(host, port)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def seconds(value: str) -> float:
|
|
68
|
+
seconds = float(value)
|
|
69
|
+
validate_timeout(seconds)
|
|
70
|
+
return seconds
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def timeout(value: str) -> Optional[float]:
|
|
74
|
+
return None if value == 'none' else seconds(value)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def size_limit(value: str) -> SizeLimit:
|
|
78
|
+
size = None if value == 'none' else int(value)
|
|
79
|
+
validate_packet_size_limit(size, 'size limit')
|
|
80
|
+
return SizeLimit(size)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def parse_args() -> CliOptions:
|
|
84
|
+
parser = argparse.ArgumentParser(
|
|
85
|
+
prog='rconx',
|
|
86
|
+
usage='%(prog)s [OPTIONS] HOST:PORT [COMMAND ...]',
|
|
87
|
+
description='Put every local option before HOST:PORT; use [IPv6]:PORT for IPv6 addresses.',
|
|
88
|
+
epilog='Each COMMAND is one complete command string. After HOST:PORT, all arguments are commands, including --help, -i and --. '
|
|
89
|
+
'Without -i, zero commands check the connection and authentication. With -i, interaction follows the startup commands.',
|
|
90
|
+
)
|
|
91
|
+
password_source = parser.add_mutually_exclusive_group(required=True)
|
|
92
|
+
password_source.add_argument('-p', '--password', metavar='PASSWORD', help='password; an explicitly empty value is allowed')
|
|
93
|
+
password_source.add_argument('--password-env', metavar='NAME', help='read the password from environment variable NAME')
|
|
94
|
+
parser.add_argument('-P', '--preset', choices=[preset.name for preset in RconPreset], default='minecraft', help='RCON exchange preset (default: %(default)s)')
|
|
95
|
+
parser.add_argument('-i', '--interactive', action='store_true', help='read commands interactively after the startup commands')
|
|
96
|
+
parser.add_argument('-t', '--timeout', type=timeout, default=10.0, metavar='SECONDS|none', help='timeout for each connect, authentication or command operation (default: 10 seconds)')
|
|
97
|
+
parser.add_argument('--idle-window', type=seconds, metavar='SECONDS', help='response quiet window; required and valid only for the idle_timeout preset')
|
|
98
|
+
parser.add_argument('--encoding', metavar='NAME', help='password, command and response text encoding (default: core utf8)')
|
|
99
|
+
parser.add_argument('--raw', action='store_true', help='write response bytes; incompatible with -i')
|
|
100
|
+
parser.add_argument('--max-send-packet-size', type=size_limit, metavar='BYTES|none', help='send packet size limit; none disables it (default: selected preset)')
|
|
101
|
+
parser.add_argument('--max-receive-packet-size', type=size_limit, metavar='BYTES|none', help='receive packet size limit; none disables it (default: core limit)')
|
|
102
|
+
parser.add_argument('--max-response-size', type=size_limit, metavar='BYTES|none', help='accumulated response size limit; none disables it (default: core limit)')
|
|
103
|
+
parser.add_argument('--version', action='version', version='%(prog)s {}'.format(__get_self_version()))
|
|
104
|
+
parser.add_argument('items', nargs=argparse.REMAINDER, metavar='HOST:PORT [COMMAND ...]', help='target address followed by zero or more complete command strings')
|
|
105
|
+
arguments = parser.parse_args()
|
|
106
|
+
|
|
107
|
+
if not arguments.items:
|
|
108
|
+
raise ValueError('HOST:PORT is required')
|
|
109
|
+
if (arguments.preset == 'idle_timeout') != (arguments.idle_window is not None):
|
|
110
|
+
raise ValueError('--idle-window is required and valid only for idle_timeout')
|
|
111
|
+
if arguments.raw and arguments.interactive:
|
|
112
|
+
raise ValueError('--raw cannot be combined with --interactive')
|
|
113
|
+
password = os.environ[arguments.password_env] if arguments.password_env is not None else arguments.password
|
|
114
|
+
|
|
115
|
+
return CliOptions(
|
|
116
|
+
address=compute_address(arguments.items[0]),
|
|
117
|
+
password=password,
|
|
118
|
+
commands=arguments.items[1:],
|
|
119
|
+
preset=RconPreset[arguments.preset],
|
|
120
|
+
interactive=arguments.interactive,
|
|
121
|
+
timeout=arguments.timeout,
|
|
122
|
+
idle_window=arguments.idle_window,
|
|
123
|
+
encoding=arguments.encoding,
|
|
124
|
+
raw=arguments.raw,
|
|
125
|
+
max_send_packet_size=arguments.max_send_packet_size,
|
|
126
|
+
max_receive_packet_size=arguments.max_receive_packet_size,
|
|
127
|
+
max_response_size=arguments.max_response_size,
|
|
128
|
+
)
|