Ejemplo n.º 1
0
def players(ip):
    ip = ip.split(':')
    try:
        player_data = gs.a2s_players((ip[0], int(ip[1])))
        return jsonify({"players": player_data})
    except:
        abort(404)
Ejemplo n.º 2
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.º 3
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.º 4
0
def getServerInfoSteam(ip, port):
    #print("getServerInfoSteam()")
    server = (ip, int(port))
    return {
        "info": gs.a2s_info(server),
        "players": gs.a2s_players(server),
        "rules": gs.a2s_rules(server)
    }
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 cmd_hlmaster_info(args):
    host, port = parse_host(args.server)

    flags = [args.info, args.players, args.rules].count(True)

    if args.info or flags == 0:
        if flags > 1:
            print('--- {:-<60}'.format("Server Info "))

        if args.short:
            print(get_info_short(host, port))
        else:
            try:
                data = gs.a2s_info((host, port))
            except Exception as exp:
                print("Error: {}".format(exp))
            else:
                for pair in sorted(data.items()):
                    print("{} = {}".format(*pair))

    if args.players:
        if flags > 1:
            print('--- {:-<60}'.format("Players "))

        try:
            plist = gs.a2s_players((host, port))
        except Exception as exp:
            print("Error: {}".format(exp))
        else:
            print_table([[
                player['name'],
                str(player['score']),
                fmt_duration(player['duration']),
                ] for player in plist],
                ['Name', '>Score', '>Duration'],
                )

    if args.rules:
        if flags > 1:
            print('--- {:-<60}'.format("Rules "))

        try:
            rules = gs.a2s_rules((host, port))
        except Exception as exp:
            print("Error: {}".format(exp))
        else:
            for rule in rules.items():
                print("{} = {}".format(*rule))
Ejemplo n.º 7
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.º 8
0
async def steamserver(ctx, arg1, arg2: int):
    server = gs.a2s_info((arg1, arg2))
    players = gs.a2s_players((arg1, arg2))

    embed = discord.Embed(color=discord.Color.green())
    embed.set_author(
        name='Game Info',
        icon_url=
        'https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Steam_icon_logo.svg/64px-Steam_icon_logo.svg.png'
    )
    if server['app_id'] == 440:
        embed.set_thumbnail(
            url=
            'https://res.cloudinary.com/teepublic/image/private/s--ec3A9OxT--/t_Preview/b_rgb:191919,c_limit,f_jpg,h_630,q_90,w_630/v1539296609/production/designs/3303784_0.jpg'
        )
    embed.add_field(name='Name: `{}`'.format(server['name']),
                    value='\u200b',
                    inline=False)
    embed.add_field(name='IP Address: `{}:{}`'.format(arg1, arg2),
                    value='\u200b',
                    inline=False)
    embed.add_field(name='Game: `{}`'.format(server['game']),
                    value='\u200b',
                    inline=False)
    embed.add_field(name='Map: `{}`'.format(server['map']),
                    value='\u200b',
                    inline=False)
    embed.add_field(name='Players: `{}/{}`'.format(server['players'],
                                                   server['max_players']),
                    value='\u200b',
                    inline=False)
    embed.add_field(name='Latency: `{}`'.format(server['_ping']),
                    value='\u200b',
                    inline=False)

    await ctx.send(embed=embed)
Ejemplo n.º 9
0
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")

except StopIteration as e:
    print("Error occurred.")