1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using UnityEngine;
|
---|
4 |
|
---|
5 | namespace AllocsFixes.NetConnections.Servers.Web {
|
---|
6 | public class WebConnection : ConsoleConnectionAbstract {
|
---|
7 | private readonly DateTime login;
|
---|
8 | private readonly List<string> outputLines = new List<string> ();
|
---|
9 | private DateTime lastAction;
|
---|
10 | private readonly string conDescription;
|
---|
11 |
|
---|
12 | public WebConnection (string _sessionId, string _endpoint, ulong _steamId) {
|
---|
13 | SessionID = _sessionId;
|
---|
14 | Endpoint = _endpoint;
|
---|
15 | SteamID = _steamId;
|
---|
16 | login = DateTime.Now;
|
---|
17 | lastAction = login;
|
---|
18 | conDescription = "WebPanel from " + Endpoint;
|
---|
19 | }
|
---|
20 |
|
---|
21 | public string SessionID { get; private set; }
|
---|
22 |
|
---|
23 | public string Endpoint { get; private set; }
|
---|
24 |
|
---|
25 | public ulong SteamID { get; private set; }
|
---|
26 |
|
---|
27 | public TimeSpan Age {
|
---|
28 | get { return DateTime.Now - lastAction; }
|
---|
29 | }
|
---|
30 |
|
---|
31 | public static bool CanViewAllPlayers (int _permissionLevel) {
|
---|
32 | bool val = false;
|
---|
33 |
|
---|
34 | try {
|
---|
35 | const int defaultPermissionLevel = 0;
|
---|
36 |
|
---|
37 | val = _permissionLevel <= defaultPermissionLevel;
|
---|
38 |
|
---|
39 | foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ()) {
|
---|
40 | if (wap.module.Trim ().ToLower () == "webapi.viewallplayers") {
|
---|
41 | val = _permissionLevel <= wap.permissionLevel;
|
---|
42 | }
|
---|
43 | }
|
---|
44 | } catch {
|
---|
45 | }
|
---|
46 |
|
---|
47 | return val;
|
---|
48 | }
|
---|
49 |
|
---|
50 | public static bool CanViewAllClaims (int _permissionLevel) {
|
---|
51 | bool val = false;
|
---|
52 |
|
---|
53 | try {
|
---|
54 | const int defaultPermissionLevel = 0;
|
---|
55 |
|
---|
56 | val = _permissionLevel <= defaultPermissionLevel;
|
---|
57 |
|
---|
58 | foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ()) {
|
---|
59 | if (wap.module.Trim ().ToLower () == "webapi.viewallclaims") {
|
---|
60 | val = _permissionLevel <= wap.permissionLevel;
|
---|
61 | }
|
---|
62 | }
|
---|
63 | } catch {
|
---|
64 | }
|
---|
65 |
|
---|
66 | return val;
|
---|
67 | }
|
---|
68 |
|
---|
69 | public void UpdateUsage () {
|
---|
70 | lastAction = DateTime.Now;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public override string GetDescription () {
|
---|
74 | return conDescription;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public override void SendLine (string _text) {
|
---|
78 | outputLines.Add (_text);
|
---|
79 | }
|
---|
80 |
|
---|
81 | public override void SendLines (List<string> _output) {
|
---|
82 | outputLines.AddRange (_output);
|
---|
83 | }
|
---|
84 |
|
---|
85 | public override void SendLog (string _msg, string _trace, LogType _type) {
|
---|
86 | // Do nothing, handled by LogBuffer
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|