Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thorsummoner
ttt_terrorcon
Commits
fb92f545
Commit
fb92f545
authored
Sep 18, 2021
by
dylan grafmyre
Browse files
idk trying to qui garrysmod, about to go back to the akh solution
parent
0b865026
Changes
2
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
fb92f545
...
...
@@ -12,9 +12,11 @@ SHLEX_FLAGS?=
GAME
?=
hl2.exe
CONSOLE_LOG
?=
garrysmod/console.log
GAME_TTT_FLAGS
?=
+ttt_preptime_seconds 3 +ttt_firstpreptime
_seconds
3 +gamemode terrortown +ttt_debug_preventwin 1
GAME_TTT_FLAGS
?=
+ttt_preptime_seconds 3 +ttt_firstpreptime 3 +gamemode terrortown +ttt_debug_preventwin 1
GAME_PLAY_FLAGS
?=
+mat_specular 1 +mat_hdr_level 2
$(GAME_TTT_FLAGS)
GAME_FLAGS
?=
-condebug
# gmod desktop ignores rcon listening
# -usercon +rcon_password runme
GAME_DIR
?=
C:
\\
Program Files
(
x86
)
\\
Steam
\\
steamapps
\\
common
\\
GarrysMod
\\
VBIN_DIR
?=
$(GAME_DIR)
bin
\\
MOD_DIR
?=
$(GAME_DIR)
garrysmod
\\
...
...
@@ -61,6 +63,10 @@ MOUNT_FLAGS?=--mod-dir "'$(MOD_DIR)'"
%.bspzip-addlist
:
%.vmf
$(GEN_BSPZIP_ADDLIST_BIN)
$(GEN_BSPZIP_ADDLIST_FLAGS)
$^
>
$@
game
:
$(SHLEX_BIN)
$(SHLEX_FLAGS)
$(SHLEX_HL2LOG_FLAGS)
\
"'
$(GAME_DIR)$(GAME)
'"
-allowdebug
$(VBIN_FLAGS)
$(GAME_FLAGS)
$(GAME_PLAY_FLAGS)
%.game
:
%.bsp
ifeq
($(GAME),0)
echo
"user disabled run game via GAME=0"
...
...
pyvmf/rcon.py
0 → 100644
View file @
fb92f545
import
struct
import
logging
import
sys
import
urllib.parse
import
socket
LOGGER
=
logging
.
getLogger
(
'pyvmf:rcon'
)
class
Inc
:
def
__init__
(
self
,
value
=
0
):
self
.
value_
=
value
@
property
def
value
(
self
):
ret
=
self
.
value_
self
.
value_
+=
1
return
ret
INC
=
Inc
()
rconpacket_header_t
=
struct
.
Struct
(
'iii'
)
TYPE_AUTH
=
3
TyPE_EXEC
=
2
class
RconPacket
:
id_
=
None
type_
=
None
msg
=
None
def
__repr__
(
self
):
return
'<{s.__class__.__name__} id:{s.id_} type:{s.type_} {s.msg!r}>'
.
format
(
s
=
self
)
@
classmethod
def
new_from_bin
(
cls
,
bin_
):
obj
=
cls
()
size
,
cls
.
id_
,
cls
.
type_
=
rconpacket_header_t
.
unpack
(
bin_
[:
12
])
cls
.
msg
=
codecs
.
decode
(
bin
[
12
:
-
2
],
'ascii'
)
return
obj
@
property
def
size
(
self
):
return
14
+
len
(
cls
.
msg_bin
)
@
property
def
msg_bin
(
self
):
return
codecs
.
encode
(
self
.
msg
,
'ascii'
)
@
property
def
as_packet
(
self
):
return
b
''
.
join
([
rconpacket_header_t
.
pack
(
self
.
_size
,
self
.
id_
,
self
.
type_
),
self
.
msg_bin
,
b
'
\x00\x00
'
])
@
classmethod
def
new_from_string
(
cls
,
msg
,
id_
=
None
,
type_
=
None
):
if
type_
is
None
:
type_
=
TYPE_EXEC
obj
=
cls
()
obj
.
msg
=
msg
if
id_
is
None
:
id_
=
Inc
.
value
cls
.
id_
=
id_
cls
.
type_
=
type_
return
obj
RCON_PORT
=
27015
def
send_one
(
connstr
,
value
=
None
,
timeout
=
2
):
conn_dat
=
urllib
.
parse
.
urlparse
(
connstr
)
port
=
RCON_PORT
if
'@'
not
in
conn_dat
.
netloc
:
raise
ValueError
(
'password must be provided as "rcon://:pass@host/"'
)
basicauth
,
netloc
=
conn_dat
.
netloc
.
split
(
'@'
,
1
)
if
':'
not
in
basicauth
:
raise
ValueError
(
'username, password must be provided as "rcon://user:pass@host/"'
)
user
,
password
=
basicauth
.
split
(
':'
,
1
)
if
user
:
raise
NotImplementedError
(
'rcon has no username'
)
if
conn_dat
.
path
:
if
conn_dat
.
path
!=
'/'
:
raise
NotImplementedError
(
'uri paths have no mening {!r}'
.
format
(
conn_dat
))
if
conn_dat
.
scheme
!=
'rcon'
:
raise
NotImplementedError
(
'scheme must be "rcon" got {}'
.
format
(
conn_dat
.
scheme
))
if
':'
in
netloc
:
netloc
,
port
=
netloc
.
split
(
':'
,
1
)
conn
=
socket
.
socket
()
conn
.
settimeout
(
timeout
)
LOGGER
.
info
(
'connect %s://%s:%s timeout=%r ...'
,
'tcp'
,
netloc
,
port
,
conn
.
timeout
)
conn
.
connect
((
netloc
,
port
))
if
value
is
None
:
value
=
conn_dat
.
query
if
value
is
None
:
raise
ValueError
(
'value must be provided either as value or as raw uri querystring'
)
packet
=
RconPacket
.
new_from_string
(
password
,
type_
=
TYPE_AUTH
)
print
(
packet
)
packet
=
RconPacket
.
new_from_string
(
value
,
type_
=
TYPE_EXEC
)
print
(
packet
)
logging
.
basicConfig
(
level
=
logging
.
INFO
)
send_one
(
sys
.
argv
[
1
])
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment