log all disconnects
This commit is contained in:
parent
8d809c66ba
commit
d62c8ca564
|
@ -91,6 +91,7 @@ public class User
|
||||||
{
|
{
|
||||||
if (msgArr.Length < 1)
|
if (msgArr.Length < 1)
|
||||||
{
|
{
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicking {_username ?? _ip.ToString()} for sending an empty message");
|
||||||
await Close();
|
await Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -209,6 +210,7 @@ public class User
|
||||||
if (msgArr.Length != 4 || this.vm == null || (!HasTurn() && _rank != Rank.Admin)) return;
|
if (msgArr.Length != 4 || this.vm == null || (!HasTurn() && _rank != Rank.Admin)) return;
|
||||||
if (KitLimiter != null && !KitLimiter.Limit())
|
if (KitLimiter != null && !KitLimiter.Limit())
|
||||||
{
|
{
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicking {_username ?? _ip.ToString()} for kitting the VM");
|
||||||
await Close();
|
await Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -224,6 +226,7 @@ public class User
|
||||||
if (this.vm == null || msgArr.Length != 3 || (!HasTurn() && _rank != Rank.Admin)) return;
|
if (this.vm == null || msgArr.Length != 3 || (!HasTurn() && _rank != Rank.Admin)) return;
|
||||||
if (KitLimiter != null && !KitLimiter.Limit())
|
if (KitLimiter != null && !KitLimiter.Limit())
|
||||||
{
|
{
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicking {_username ?? _ip.ToString()} for kitting the VM");
|
||||||
await Close();
|
await Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -349,6 +352,7 @@ public class User
|
||||||
if (_rank != Rank.Admin && (_rank != Rank.Moderator || !Program.Config.ModPermissions.Ban) || msgArr.Length < 3 || vm == null) return;
|
if (_rank != Rank.Admin && (_rank != Rank.Moderator || !Program.Config.ModPermissions.Ban) || msgArr.Length < 3 || vm == null) return;
|
||||||
var user = vm.Users.First(u => u.Username == msgArr[2]);
|
var user = vm.Users.First(u => u.Username == msgArr[2]);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
Utilities.Log(LogLevel.INFO, $"{_username ?? _ip.ToString()} banned {user.Username!}");
|
||||||
await user.Ban(msgArr.Length == 4 ? msgArr[3] : null);
|
await user.Ban(msgArr.Length == 4 ? msgArr[3] : null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -383,6 +387,7 @@ public class User
|
||||||
if (_rank != Rank.Admin && (_rank != Rank.Moderator || !Program.Config.ModPermissions.Kick) || msgArr.Length != 3 || vm == null) return;
|
if (_rank != Rank.Admin && (_rank != Rank.Moderator || !Program.Config.ModPermissions.Kick) || msgArr.Length != 3 || vm == null) return;
|
||||||
var user = vm.Users.First(u => u.Username == msgArr[2]);
|
var user = vm.Users.First(u => u.Username == msgArr[2]);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicked {user.Username!} by {_username}");
|
||||||
await user.Close();
|
await user.Close();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -488,6 +493,7 @@ public class User
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicking {_username ?? _ip.ToString()} for not responding to NOP");
|
||||||
await Close();
|
await Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -507,6 +513,7 @@ public class User
|
||||||
}
|
}
|
||||||
catch (WebSocketException ex)
|
catch (WebSocketException ex)
|
||||||
{
|
{
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicking {_username ?? _ip.ToString()} due to websocket exception: {ex.Message}");
|
||||||
await Close(false);
|
await Close(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -518,6 +525,7 @@ public class User
|
||||||
|
|
||||||
if (result.MessageType == WebSocketMessageType.Binary)
|
if (result.MessageType == WebSocketMessageType.Binary)
|
||||||
{
|
{
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicking {_username ?? _ip.ToString()} for sending a binary message");
|
||||||
await Close();
|
await Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,6 +538,7 @@ public class User
|
||||||
} catch (Exception ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
Utilities.Log(LogLevel.DEBUG, "Failed to decode websocket message");
|
Utilities.Log(LogLevel.DEBUG, "Failed to decode websocket message");
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicking {_username ?? _ip.ToString()} for sending an invalid message");
|
||||||
await Close();
|
await Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -540,6 +549,7 @@ public class User
|
||||||
} catch (Exception ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
Utilities.Log(LogLevel.DEBUG, "Failed to decode guacamole message " + msg);
|
Utilities.Log(LogLevel.DEBUG, "Failed to decode guacamole message " + msg);
|
||||||
|
Utilities.Log(LogLevel.INFO, $"Kicking {_username ?? _ip.ToString()} for sending an invalid guacamole string");
|
||||||
await Close();
|
await Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@ public class VM
|
||||||
};
|
};
|
||||||
user.Disconnected += async (_, _) =>
|
user.Disconnected += async (_, _) =>
|
||||||
{
|
{
|
||||||
|
Utilities.Log(LogLevel.INFO, $"User {user.Username!} disconnected");
|
||||||
this.Users.Remove(user);
|
this.Users.Remove(user);
|
||||||
this.TurnQueue.RemoveUser(user);
|
this.TurnQueue.RemoveUser(user);
|
||||||
user.IPData.Reset();
|
user.IPData.Reset();
|
||||||
|
|
Loading…
Reference in a new issue