Ejemplo n.º 1
0
def rcon(ip):
    try:
        if not request.cookies.get('rconpwd'):
            res = make_response("")
            res.set_cookie('rconpwd', 'NotSet', max_age=60 * 60)
        else:
            res = make_response("{}".format(request.cookies.get('rconpwd')))

        server_addr = next(gs.query_master(r'\appid\581320\gameaddr\%s' % ip))
        serverInfo = gs.a2s_info(server_addr)
        serverRules = gs.a2s_rules(server_addr)
        serverPlayers = gs.a2s_players(server_addr)
        return render_template('rcon.html',
                               addr=server_addr[0],
                               ip=ip,
                               data=serverInfo,
                               players=serverPlayers,
                               rules=serverRules,
                               quote=randomQuote(),
                               maplist=mapList)
    except StopIteration as e:
        e = "Unable to resolve server ip."
        return render_template('error.html', error=e)
    except socket.timeout as e:
        e = "Unable to resolve server ip."
        return render_template('error.html', error=e)
    except:  # noqa
        e = "Unknown error."
        return render_template('error.html', error=e)
Ejemplo n.º 2
0
def home():
    try:
        if "0.0.0.0" in os.environ["SERVERIP"]:
            return render_template('homedefault.html', version=__version__)

        server_addr = next(
            gs.query_master(r'\appid\581320\gameaddr\%s' %
                            os.environ["SERVERIP"]))
        serverInfo = gs.a2s_info(server_addr)
        serverRules = gs.a2s_rules(server_addr)
        serverPlayers = gs.a2s_players(server_addr)
        return render_template('home.html',
                               addr=server_addr,
                               ip=os.environ["SERVERIP"],
                               data=serverInfo,
                               players=serverPlayers,
                               rules=serverRules,
                               quote=randomQuote())
    except StopIteration as e:
        e = "Unable to resolve server ip."
        return render_template('error.html', error=e)
    except socket.timeout as e:
        e = "Unable to resolve server ip."
        return render_template('error.html', error=e)
    except:  # noqa
        e = "Unknown error."
        return render_template('error.html', error=e)
Ejemplo n.º 3
0
    def run_query(args):
        try:
            for ip, port in gs.query_master(args.filter, max_servers=args.num_servers):
                if args.ip_only:
                    print("%s:%s" % (ip, port))
                else:
                    results.put(task_pool.spawn(get_info_short, ip, port))
        except Exception as exp:
            _LOG.error("query_master: Error: %s", str(exp))

        results.put(StopIteration)
Ejemplo n.º 4
0
def dashboard():
    if request.remote_addr != '142.93.124.24':
        abort(403)  # Forbidden
    players = 0
    try:
        for server_addr in gs.query_master(
                r'\app_id\107410\gameaddr\51.89.155.186'):
            players += gs.a2s_info(server_addr)["players"]
    except:
        print("No servers online")
    return jsonify(cpu=psutil.cpu_percent(),
                   players=players,
                   ram=psutil.virtual_memory().percent)
Ejemplo n.º 5
0
def banner(ip):
    try:
        server_addr = next(gs.query_master(r'\appid\581320\gameaddr\%s' % ip))
        serverInfo = gs.a2s_info(server_addr)
        serverRules = gs.a2s_rules(server_addr)
        serverPlayers = gs.a2s_players(server_addr)
        return render_template('banner.html',
                               addr=server_addr,
                               ip=ip,
                               data=serverInfo,
                               rules=serverRules,
                               players=serverPlayers)
    except:  # noqa
        e = "Unknown error."
        return render_template('bannererror.html', error=e)
Ejemplo n.º 6
0
    def status(self, request, pk=None):
        server = self.get_object()

        ip_port = '{}:{}'.format(server.ip, server.port)
        server_address = next(
            gs.query_master(r'\appid\{}\gameaddr\{}'.format(
                server.game.app_id, ip_port)))
        server_info = gs.a2s_info(server_address)
        server_data = {
            'name': server_info['name'],
            'ip': ip_port,
            'players': server_info['players'],
            'max_players': server_info['max_players'],
            'map': server_info['map'],
            'game': server.game.tag
        }

        serializer = ServerStatusSerializer(server_data)
        return Response(serializer.data)
Ejemplo n.º 7
0
def serverInfo(port):
    if request.remote_addr != '142.93.124.24':
        abort(403)  # Forbidden
    x = ""
    try:
        x = subprocess.check_output(['screen', '-list'])
    except:
        print("Wrong")
    if "arma_" + str(port) in str(x):
        for server_addr in gs.query_master(
                r'\app_id\107410\gameaddr\51.89.155.186:' + str(port)):
            serverinfo = gs.a2s_info(server_addr)
            return jsonify(running=2,
                           maxplayers=serverinfo["max_players"],
                           players=serverinfo["players"],
                           version=serverinfo["version"],
                           map=serverinfo["map"],
                           mission=serverinfo["game"],
                           hostname=serverinfo["name"])
        return jsonify(running=1)
    return jsonify(running=0)
Ejemplo n.º 8
0
def remote(ip):
    try:
        server_addr = next(gs.query_master(r'\appid\581320\gameaddr\%s' % ip))
        serverInfo = gs.a2s_info(server_addr)
        serverRules = gs.a2s_rules(server_addr)
        serverPlayers = gs.a2s_players(server_addr)
        return render_template('remote.html',
                               addr=server_addr,
                               ip=ip,
                               data=serverInfo,
                               players=serverPlayers,
                               rules=serverRules,
                               quote=randomQuote())
    except StopIteration as e:
        e = "Unable to resolve server ip."
        return render_template('error.html', error=e)
    except socket.timeout as e:
        e = "Unable to resolve server ip."
        return render_template('error.html', error=e)
    except:  # noqa
        e = "Unknown error."
        return render_template('error.html', error=e)
Ejemplo n.º 9
0
    def get(self, request, format=None):
        queryset = Server.objects.all()
        servers = []

        for server in queryset:
            ip_port = '{}:{}'.format(server.ip, server.port)
            server_address = next(
                gs.query_master(r'\appid\{}\gameaddr\{}'.format(
                    server.game.app_id, ip_port)))
            server_info = gs.a2s_info(server_address)

            server_data = {
                'name': server_info['name'],
                'ip': ip_port,
                'players': server_info['players'],
                'max_players': server_info['max_players'],
                'map': server_info['map'],
                'game': server.game.tag
            }
            servers.append(server_data)

        serializer = ServerStatusSerializer(servers, many=True)
        return Response(serializer.data)
Ejemplo n.º 10
0
async def status(ctx):
    try:
        server = next(gs.query_master(ADDR))
        if not (info := gs.a2s_info(server)):
            raise RuntimeError

        embed_dict = {
            "title":
            f'Status of __{info["name"]}__ ',
            "fields": [
                {
                    "name": "Map:",
                    "value": info["map"],
                    "inline": True
                },
                {
                    "name": "Players:",
                    "value": f"{info['players']}/{info['max_players']}",
                    "inline": True,
                },
            ],
            "color":
            COLORS[min(info["players"], 64)],  # 64 is max players
        }
Ejemplo n.º 11
0
import time
import random

i = open('/home/gamed/inssa/Insurgency/Config/Server/pvemaps.txt', 'r')
o = open('/home/gamed/inssa/Insurgency/Config/Server/MapCycle.txt', 'w')


def randomly(seq):
    shuffled = list(seq)
    random.shuffle(shuffled)
    return iter(shuffled)


try:
    # next(gs.query_master(r'\appid\581320\gameaddr\83.96.176.32'))
    server_addr = next(gs.query_master(r'\appid\581320\name_match\Dutch Recon*'))
    # print(server_addr)
    playerList = gs.a2s_players(server_addr)
    if len(playerList) == 0:
        print "Could now execute a restart"

        for item in randomly(i):
            o.write(item)

    subprocess.call(["/usr/bin/supervisorctl", "stop", "insurgency"], cwd='.')
    print "sleeping 5 seconds"
    time.sleep(5)
    subprocess.call(["/usr/bin/supervisorctl", "start", "insurgency"], cwd='.')
    else:
        print("Process active, no action")