Commit fb92f545 authored by dylan grafmyre's avatar dylan grafmyre
Browse files

idk trying to qui garrysmod, about to go back to the akh solution

parent 0b865026
...@@ -12,9 +12,11 @@ SHLEX_FLAGS?= ...@@ -12,9 +12,11 @@ SHLEX_FLAGS?=
GAME?=hl2.exe GAME?=hl2.exe
CONSOLE_LOG?=garrysmod/console.log 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_PLAY_FLAGS?=+mat_specular 1 +mat_hdr_level 2 $(GAME_TTT_FLAGS)
GAME_FLAGS?=-condebug GAME_FLAGS?=-condebug
# gmod desktop ignores rcon listening
# -usercon +rcon_password runme
GAME_DIR?=C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod\\ GAME_DIR?=C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod\\
MOD_DIR?=$(GAME_DIR)garrysmod\\ MOD_DIR?=$(GAME_DIR)garrysmod\\
...@@ -61,6 +63,10 @@ MOUNT_FLAGS?=--mod-dir "'$(MOD_DIR)'" ...@@ -61,6 +63,10 @@ MOUNT_FLAGS?=--mod-dir "'$(MOD_DIR)'"
%.bspzip-addlist: %.vmf %.bspzip-addlist: %.vmf
"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) %.bsp %.bsp
ifeq ($(GAME),0) ifeq ($(GAME),0)
echo "user disabled run game via GAME=0" echo "user disabled run game via GAME=0"
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
def value(self):
ret = self.value_
self.value_ += 1
return ret
INC = Inc()
rconpacket_header_t = struct.Struct('iii')
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)
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
def size(self):
return 14 + len(cls.msg_bin)
def msg_bin(self):
return codecs.encode(self.msg, 'ascii')
def as_packet(self):
return b''.join([
rconpacket_header_t.pack(self._size, self.id_, self.type_),
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)'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)
packet = RconPacket.new_from_string(value, type_=TYPE_EXEC)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment