# This file is part of the Minecraft Overviewer.
#
# Minecraft Overviewer is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# Minecraft Overviewer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with the Overviewer. If not, see .
import socket
import struct
import select
class RConException(Exception):
def __init__(self, request_id, reason):
self.request_id = request_id
self.reason = reason
def __str__(self):
return ("Failed RCon request with request ID %d, reason %s" %
(self.request_id, self.reason))
class RConConnection():
rid = 0
def __init__(self, target, port):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((target, port))
def send(self, t, payload):
self.rid = self.rid + 1
header = struct.pack("