minor stylefixes
This commit is contained in:
@@ -61,7 +61,7 @@ public class JwtController : Controller
|
|||||||
_mareDbContext.BannedUsers.Add(new Banned()
|
_mareDbContext.BannedUsers.Add(new Banned()
|
||||||
{
|
{
|
||||||
CharacterIdentification = charaIdent,
|
CharacterIdentification = charaIdent,
|
||||||
Reason = "Autobanned CharacterIdent (" + authResult.Uid + ")"
|
Reason = "Autobanned CharacterIdent (" + authResult.Uid + ")",
|
||||||
});
|
});
|
||||||
|
|
||||||
await _mareDbContext.SaveChangesAsync();
|
await _mareDbContext.SaveChangesAsync();
|
||||||
@@ -75,14 +75,14 @@ public class JwtController : Controller
|
|||||||
{
|
{
|
||||||
_mareDbContext.BannedRegistrations.Add(new BannedRegistrations()
|
_mareDbContext.BannedRegistrations.Add(new BannedRegistrations()
|
||||||
{
|
{
|
||||||
DiscordIdOrLodestoneAuth = lodestone.HashedLodestoneId
|
DiscordIdOrLodestoneAuth = lodestone.HashedLodestoneId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!_mareDbContext.BannedRegistrations.Any(c => c.DiscordIdOrLodestoneAuth == lodestone.DiscordId.ToString()))
|
if (!_mareDbContext.BannedRegistrations.Any(c => c.DiscordIdOrLodestoneAuth == lodestone.DiscordId.ToString()))
|
||||||
{
|
{
|
||||||
_mareDbContext.BannedRegistrations.Add(new BannedRegistrations()
|
_mareDbContext.BannedRegistrations.Add(new BannedRegistrations()
|
||||||
{
|
{
|
||||||
DiscordIdOrLodestoneAuth = lodestone.DiscordId.ToString()
|
DiscordIdOrLodestoneAuth = lodestone.DiscordId.ToString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public class JwtController : Controller
|
|||||||
var token = CreateToken(new List<Claim>()
|
var token = CreateToken(new List<Claim>()
|
||||||
{
|
{
|
||||||
new Claim(MareClaimTypes.Uid, authResult.Uid),
|
new Claim(MareClaimTypes.Uid, authResult.Uid),
|
||||||
new Claim(MareClaimTypes.CharaIdent, charaIdent)
|
new Claim(MareClaimTypes.CharaIdent, charaIdent),
|
||||||
});
|
});
|
||||||
|
|
||||||
return Content(token.RawData);
|
return Content(token.RawData);
|
||||||
@@ -111,7 +111,7 @@ public class JwtController : Controller
|
|||||||
var token = new SecurityTokenDescriptor()
|
var token = new SecurityTokenDescriptor()
|
||||||
{
|
{
|
||||||
Subject = new ClaimsIdentity(authClaims),
|
Subject = new ClaimsIdentity(authClaims),
|
||||||
SigningCredentials = new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256Signature)
|
SigningCredentials = new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256Signature),
|
||||||
};
|
};
|
||||||
|
|
||||||
var handler = new JwtSecurityTokenHandler();
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public partial class MareHub
|
|||||||
return await _dbContext.BannedUsers.AsNoTracking().Select(b => new BannedUserDto()
|
return await _dbContext.BannedUsers.AsNoTracking().Select(b => new BannedUserDto()
|
||||||
{
|
{
|
||||||
CharacterHash = b.CharacterIdentification,
|
CharacterHash = b.CharacterIdentification,
|
||||||
Reason = b.Reason
|
Reason = b.Reason,
|
||||||
}).ToListAsync().ConfigureAwait(false);
|
}).ToListAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public partial class MareHub
|
|||||||
return await _dbContext.ForbiddenUploadEntries.AsNoTracking().Select(b => new ForbiddenFileDto()
|
return await _dbContext.ForbiddenUploadEntries.AsNoTracking().Select(b => new ForbiddenFileDto()
|
||||||
{
|
{
|
||||||
Hash = b.Hash,
|
Hash = b.Hash,
|
||||||
ForbiddenBy = b.ForbiddenBy
|
ForbiddenBy = b.ForbiddenBy,
|
||||||
}).ToListAsync().ConfigureAwait(false);
|
}).ToListAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public partial class MareHub
|
|||||||
CharacterNameHash = b.Ident,
|
CharacterNameHash = b.Ident,
|
||||||
UID = b.User.UID,
|
UID = b.User.UID,
|
||||||
IsModerator = b.User.IsModerator,
|
IsModerator = b.User.IsModerator,
|
||||||
IsAdmin = b.User.IsAdmin
|
IsAdmin = b.User.IsAdmin,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ public partial class MareHub
|
|||||||
await _dbContext.BannedUsers.AddAsync(new Banned
|
await _dbContext.BannedUsers.AddAsync(new Banned
|
||||||
{
|
{
|
||||||
CharacterIdentification = dto.CharacterHash,
|
CharacterIdentification = dto.CharacterHash,
|
||||||
Reason = dto.Reason
|
Reason = dto.Reason,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ public partial class MareHub
|
|||||||
await _dbContext.ForbiddenUploadEntries.AddAsync(new ForbiddenUploadEntry
|
await _dbContext.ForbiddenUploadEntries.AddAsync(new ForbiddenUploadEntry
|
||||||
{
|
{
|
||||||
Hash = dto.Hash,
|
Hash = dto.Hash,
|
||||||
ForbiddenBy = dto.ForbiddenBy
|
ForbiddenBy = dto.ForbiddenBy,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public partial class MareHub
|
|||||||
request.Hash.AddRange(ownFiles.Select(f => f.Hash));
|
request.Hash.AddRange(ownFiles.Select(f => f.Hash));
|
||||||
Metadata headers = new Metadata()
|
Metadata headers = new Metadata()
|
||||||
{
|
{
|
||||||
{ "Authorization", "Bearer " + _generator.Token }
|
{ "Authorization", "Bearer " + _generator.Token },
|
||||||
};
|
};
|
||||||
_ = await _fileServiceClient.DeleteFilesAsync(request, headers).ConfigureAwait(false);
|
_ = await _fileServiceClient.DeleteFilesAsync(request, headers).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public partial class MareHub
|
|||||||
IsForbidden = forbiddenFile != null,
|
IsForbidden = forbiddenFile != null,
|
||||||
Hash = file.Hash,
|
Hash = file.Hash,
|
||||||
Size = file.Size,
|
Size = file.Size,
|
||||||
Url = baseUrl.ToString()
|
Url = baseUrl.ToString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
ForbiddenBy = forbiddenFiles[file].ForbiddenBy,
|
ForbiddenBy = forbiddenFiles[file].ForbiddenBy,
|
||||||
Hash = file,
|
Hash = file,
|
||||||
IsForbidden = true
|
IsForbidden = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -119,7 +119,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
Hash = file,
|
Hash = file,
|
||||||
Uploaded = false,
|
Uploaded = false,
|
||||||
Uploader = uploader
|
Uploader = uploader,
|
||||||
});
|
});
|
||||||
|
|
||||||
notCoveredFiles[file] = new UploadFileDto()
|
notCoveredFiles[file] = new UploadFileDto()
|
||||||
@@ -210,7 +210,7 @@ public partial class MareHub
|
|||||||
|
|
||||||
Metadata headers = new Metadata()
|
Metadata headers = new Metadata()
|
||||||
{
|
{
|
||||||
{ "Authorization", "Bearer " + _generator.Token }
|
{ "Authorization", "Bearer " + _generator.Token },
|
||||||
};
|
};
|
||||||
var streamingCall = _fileServiceClient.UploadFile(headers);
|
var streamingCall = _fileServiceClient.UploadFile(headers);
|
||||||
using var tempFileStream = new FileStream(tempFileName, FileMode.Open, FileAccess.Read);
|
using var tempFileStream = new FileStream(tempFileName, FileMode.Open, FileAccess.Read);
|
||||||
@@ -223,7 +223,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
FileData = ByteString.CopyFrom(data, 0, readBytes),
|
FileData = ByteString.CopyFrom(data, 0, readBytes),
|
||||||
Hash = computedHashString,
|
Hash = computedHashString,
|
||||||
Uploader = UserUID
|
Uploader = UserUID,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await streamingCall.RequestStream.CompleteAsync().ConfigureAwait(false);
|
await streamingCall.RequestStream.CompleteAsync().ConfigureAwait(false);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public partial class MareHub
|
|||||||
UID = Convert.ToString(userPair.OtherUserUID),
|
UID = Convert.ToString(userPair.OtherUserUID),
|
||||||
GID = "DIRECT",
|
GID = "DIRECT",
|
||||||
PauseStateSelf = userPair.IsPaused,
|
PauseStateSelf = userPair.IsPaused,
|
||||||
PauseStateOther = otherUserPair.IsPaused
|
PauseStateOther = otherUserPair.IsPaused,
|
||||||
})
|
})
|
||||||
.Union(
|
.Union(
|
||||||
(from userGroupPair in _dbContext.GroupPairs
|
(from userGroupPair in _dbContext.GroupPairs
|
||||||
@@ -69,7 +69,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
UID = key,
|
UID = key,
|
||||||
PauseStates = g.Select(p => new PauseState() { GID = string.Equals(p.GID, "DIRECT", StringComparison.Ordinal) ? null : p.GID, IsSelfPaused = p.PauseStateSelf, IsOtherPaused = p.PauseStateOther })
|
PauseStates = g.Select(p => new PauseState() { GID = string.Equals(p.GID, "DIRECT", StringComparison.Ordinal) ? null : p.GID, IsSelfPaused = p.PauseStateSelf, IsOtherPaused = p.PauseStateOther })
|
||||||
.ToList()
|
.ToList(),
|
||||||
}, StringComparer.Ordinal).ToList();
|
}, StringComparer.Ordinal).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public partial class MareHub
|
|||||||
GID = gid,
|
GID = gid,
|
||||||
HashedPassword = hashedPw,
|
HashedPassword = hashedPw,
|
||||||
InvitesEnabled = true,
|
InvitesEnabled = true,
|
||||||
OwnerUID = UserUID
|
OwnerUID = UserUID,
|
||||||
};
|
};
|
||||||
|
|
||||||
GroupPair initialPair = new()
|
GroupPair initialPair = new()
|
||||||
@@ -46,7 +46,7 @@ public partial class MareHub
|
|||||||
GroupGID = newGroup.GID,
|
GroupGID = newGroup.GID,
|
||||||
GroupUserUID = UserUID,
|
GroupUserUID = UserUID,
|
||||||
IsPaused = false,
|
IsPaused = false,
|
||||||
IsPinned = true
|
IsPinned = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
await _dbContext.Groups.AddAsync(newGroup).ConfigureAwait(false);
|
await _dbContext.Groups.AddAsync(newGroup).ConfigureAwait(false);
|
||||||
@@ -61,7 +61,7 @@ public partial class MareHub
|
|||||||
OwnedBy = string.IsNullOrEmpty(self.Alias) ? self.UID : self.Alias,
|
OwnedBy = string.IsNullOrEmpty(self.Alias) ? self.UID : self.Alias,
|
||||||
IsDeleted = false,
|
IsDeleted = false,
|
||||||
IsPaused = false,
|
IsPaused = false,
|
||||||
InvitesEnabled = true
|
InvitesEnabled = true,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
_logger.LogCallInfo(MareHubLogger.Args(gid));
|
_logger.LogCallInfo(MareHubLogger.Args(gid));
|
||||||
@@ -69,7 +69,7 @@ public partial class MareHub
|
|||||||
return new GroupCreatedDto()
|
return new GroupCreatedDto()
|
||||||
{
|
{
|
||||||
GID = newGroup.GID,
|
GID = newGroup.GID,
|
||||||
Password = passwd
|
Password = passwd,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ public partial class MareHub
|
|||||||
GroupPair newPair = new()
|
GroupPair newPair = new()
|
||||||
{
|
{
|
||||||
GroupGID = group.GID,
|
GroupGID = group.GID,
|
||||||
GroupUserUID = UserUID
|
GroupUserUID = UserUID,
|
||||||
};
|
};
|
||||||
|
|
||||||
await _dbContext.GroupPairs.AddAsync(newPair).ConfigureAwait(false);
|
await _dbContext.GroupPairs.AddAsync(newPair).ConfigureAwait(false);
|
||||||
@@ -206,7 +206,7 @@ public partial class MareHub
|
|||||||
IsDeleted = false,
|
IsDeleted = false,
|
||||||
IsPaused = false,
|
IsPaused = false,
|
||||||
Alias = group.Alias,
|
Alias = group.Alias,
|
||||||
InvitesEnabled = true
|
InvitesEnabled = true,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
var self = _dbContext.Users.Single(u => u.UID == UserUID);
|
var self = _dbContext.Users.Single(u => u.UID == UserUID);
|
||||||
@@ -272,7 +272,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
ExpirationDate = DateTime.UtcNow.AddDays(1),
|
ExpirationDate = DateTime.UtcNow.AddDays(1),
|
||||||
GroupGID = group.GID,
|
GroupGID = group.GID,
|
||||||
Invite = hashedInvite
|
Invite = hashedInvite,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ public partial class MareHub
|
|||||||
await Clients.User(UserUID).Client_GroupChange(new GroupDto()
|
await Clients.User(UserUID).Client_GroupChange(new GroupDto()
|
||||||
{
|
{
|
||||||
GID = group.GID,
|
GID = group.GID,
|
||||||
IsDeleted = true
|
IsDeleted = true,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
bool ownerHasLeft = string.Equals(group.OwnerUID, UserUID, StringComparison.Ordinal);
|
bool ownerHasLeft = string.Equals(group.OwnerUID, UserUID, StringComparison.Ordinal);
|
||||||
@@ -325,7 +325,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
GID = group.GID,
|
GID = group.GID,
|
||||||
OwnedBy = groupHasMigrated.Item2,
|
OwnedBy = groupHasMigrated.Item2,
|
||||||
Alias = null
|
Alias = null,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -335,7 +335,7 @@ public partial class MareHub
|
|||||||
await Clients.Users(groupPairsWithoutSelf.Select(p => p.GroupUserUID)).Client_GroupChange(new GroupDto()
|
await Clients.Users(groupPairsWithoutSelf.Select(p => p.GroupUserUID)).Client_GroupChange(new GroupDto()
|
||||||
{
|
{
|
||||||
GID = group.GID,
|
GID = group.GID,
|
||||||
IsDeleted = true
|
IsDeleted = true,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
await SendGroupDeletedToAll(groupPairs).ConfigureAwait(false);
|
await SendGroupDeletedToAll(groupPairs).ConfigureAwait(false);
|
||||||
@@ -388,7 +388,7 @@ public partial class MareHub
|
|||||||
await Clients.User(UserUID).Client_GroupChange(new GroupDto
|
await Clients.User(UserUID).Client_GroupChange(new GroupDto
|
||||||
{
|
{
|
||||||
GID = gid,
|
GID = gid,
|
||||||
IsPaused = isPaused
|
IsPaused = isPaused,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
var allUserPairs = await GetAllPairedClientsWithPauseState().ConfigureAwait(false);
|
var allUserPairs = await GetAllPairedClientsWithPauseState().ConfigureAwait(false);
|
||||||
@@ -545,7 +545,7 @@ public partial class MareHub
|
|||||||
await Clients.User(uid).Client_GroupChange(new GroupDto()
|
await Clients.User(uid).Client_GroupChange(new GroupDto()
|
||||||
{
|
{
|
||||||
GID = gid,
|
GID = gid,
|
||||||
IsModerator = isGroupModerator
|
IsModerator = isGroupModerator,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
await Clients.Users(groupPairs.Where(p => !string.Equals(p.GroupUserUID, uid, StringComparison.Ordinal))
|
await Clients.Users(groupPairs.Where(p => !string.Equals(p.GroupUserUID, uid, StringComparison.Ordinal))
|
||||||
@@ -553,7 +553,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
GroupGID = gid,
|
GroupGID = gid,
|
||||||
IsModerator = isGroupModerator,
|
IsModerator = isGroupModerator,
|
||||||
UserUID = uid
|
UserUID = uid,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
_logger.LogCallInfo(MareHubLogger.Args(gid, uid, isGroupModerator, "Success"));
|
_logger.LogCallInfo(MareHubLogger.Args(gid, uid, isGroupModerator, "Success"));
|
||||||
@@ -590,14 +590,14 @@ public partial class MareHub
|
|||||||
GID = gid,
|
GID = gid,
|
||||||
OwnedBy = string.IsNullOrEmpty(group.Owner.Alias) ? group.Owner.UID : group.Owner.Alias,
|
OwnedBy = string.IsNullOrEmpty(group.Owner.Alias) ? group.Owner.UID : group.Owner.Alias,
|
||||||
IsModerator = false,
|
IsModerator = false,
|
||||||
Alias = null
|
Alias = null,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
await Clients.Users(groupPairs).Client_GroupChange(new GroupDto()
|
await Clients.Users(groupPairs).Client_GroupChange(new GroupDto()
|
||||||
{
|
{
|
||||||
GID = gid,
|
GID = gid,
|
||||||
OwnedBy = string.IsNullOrEmpty(group.Owner.Alias) ? group.Owner.UID : group.Owner.Alias,
|
OwnedBy = string.IsNullOrEmpty(group.Owner.Alias) ? group.Owner.UID : group.Owner.Alias,
|
||||||
Alias = null
|
Alias = null,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
await Clients.Users(groupPairs.Where(p => !string.Equals(p, uid, StringComparison.Ordinal))).Client_GroupUserChange(new GroupPairDto()
|
await Clients.Users(groupPairs.Where(p => !string.Equals(p, uid, StringComparison.Ordinal))).Client_GroupUserChange(new GroupPairDto()
|
||||||
@@ -605,7 +605,7 @@ public partial class MareHub
|
|||||||
GroupGID = gid,
|
GroupGID = gid,
|
||||||
UserUID = uid,
|
UserUID = uid,
|
||||||
IsPinned = true,
|
IsPinned = true,
|
||||||
IsModerator = false
|
IsModerator = false,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
GroupGID = gid,
|
GroupGID = gid,
|
||||||
UserUID = uid,
|
UserUID = uid,
|
||||||
IsPinned = isPinned
|
IsPinned = isPinned,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,7 +680,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
GroupGID = pair.GroupGID,
|
GroupGID = pair.GroupGID,
|
||||||
IsRemoved = true,
|
IsRemoved = true,
|
||||||
UserUID = pair.GroupUserUID
|
UserUID = pair.GroupUserUID,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
var pairIdent = await GetIdentFromUidFromRedis(pair.GroupUserUID).ConfigureAwait(false);
|
var pairIdent = await GetIdentFromUidFromRedis(pair.GroupUserUID).ConfigureAwait(false);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public partial class MareHub
|
|||||||
await Clients.User(pair.User.UID).Client_UserUpdateClientPairs(new ClientPairDto()
|
await Clients.User(pair.User.UID).Client_UserUpdateClientPairs(new ClientPairDto()
|
||||||
{
|
{
|
||||||
OtherUID = UserUID,
|
OtherUID = UserUID,
|
||||||
IsRemoved = true
|
IsRemoved = true,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,12 +79,12 @@ public partial class MareHub
|
|||||||
on new
|
on new
|
||||||
{
|
{
|
||||||
user = userToOther.UserUID,
|
user = userToOther.UserUID,
|
||||||
other = userToOther.OtherUserUID
|
other = userToOther.OtherUserUID,
|
||||||
|
|
||||||
} equals new
|
} equals new
|
||||||
{
|
{
|
||||||
user = otherToUser.OtherUserUID,
|
user = otherToUser.OtherUserUID,
|
||||||
other = otherToUser.UserUID
|
other = otherToUser.UserUID,
|
||||||
} into leftJoin
|
} into leftJoin
|
||||||
from otherEntry in leftJoin.DefaultIfEmpty()
|
from otherEntry in leftJoin.DefaultIfEmpty()
|
||||||
where
|
where
|
||||||
@@ -95,7 +95,7 @@ public partial class MareHub
|
|||||||
userToOther.IsPaused,
|
userToOther.IsPaused,
|
||||||
OtherIsPaused = otherEntry != null && otherEntry.IsPaused,
|
OtherIsPaused = otherEntry != null && otherEntry.IsPaused,
|
||||||
userToOther.OtherUserUID,
|
userToOther.OtherUserUID,
|
||||||
IsSynced = otherEntry != null
|
IsSynced = otherEntry != null,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (await query.AsNoTracking().ToListAsync().ConfigureAwait(false)).Select(f => new ClientPairDto()
|
return (await query.AsNoTracking().ToListAsync().ConfigureAwait(false)).Select(f => new ClientPairDto()
|
||||||
@@ -104,7 +104,7 @@ public partial class MareHub
|
|||||||
IsPaused = f.IsPaused,
|
IsPaused = f.IsPaused,
|
||||||
OtherUID = f.OtherUserUID,
|
OtherUID = f.OtherUserUID,
|
||||||
IsSynced = f.IsSynced,
|
IsSynced = f.IsSynced,
|
||||||
IsPausedFromOthers = f.OtherIsPaused
|
IsPausedFromOthers = f.OtherIsPaused,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
IsPaused = false,
|
IsPaused = false,
|
||||||
OtherUser = otherUser,
|
OtherUser = otherUser,
|
||||||
User = user
|
User = user,
|
||||||
};
|
};
|
||||||
await _dbContext.ClientPairs.AddAsync(wl).ConfigureAwait(false);
|
await _dbContext.ClientPairs.AddAsync(wl).ConfigureAwait(false);
|
||||||
await _dbContext.SaveChangesAsync().ConfigureAwait(false);
|
await _dbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||||
@@ -204,7 +204,7 @@ public partial class MareHub
|
|||||||
OtherUID = otherUser.UID,
|
OtherUID = otherUser.UID,
|
||||||
IsPaused = false,
|
IsPaused = false,
|
||||||
IsPausedFromOthers = otherEntry?.IsPaused ?? false,
|
IsPausedFromOthers = otherEntry?.IsPaused ?? false,
|
||||||
IsSynced = otherEntry != null
|
IsSynced = otherEntry != null,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
// if there's no opposite entry do nothing
|
// if there's no opposite entry do nothing
|
||||||
@@ -222,7 +222,7 @@ public partial class MareHub
|
|||||||
OtherUID = user.UID,
|
OtherUID = user.UID,
|
||||||
IsPaused = otherEntry.IsPaused,
|
IsPaused = otherEntry.IsPaused,
|
||||||
IsPausedFromOthers = false,
|
IsPausedFromOthers = false,
|
||||||
IsSynced = true
|
IsSynced = true,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
// get own ident and all pairs
|
// get own ident and all pairs
|
||||||
@@ -260,7 +260,7 @@ public partial class MareHub
|
|||||||
OtherUID = otherUserUid,
|
OtherUID = otherUserUid,
|
||||||
IsPaused = isPaused,
|
IsPaused = isPaused,
|
||||||
IsPausedFromOthers = otherEntry?.IsPaused ?? false,
|
IsPausedFromOthers = otherEntry?.IsPaused ?? false,
|
||||||
IsSynced = otherEntry != null
|
IsSynced = otherEntry != null,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
if (otherEntry != null)
|
if (otherEntry != null)
|
||||||
{
|
{
|
||||||
@@ -269,7 +269,7 @@ public partial class MareHub
|
|||||||
OtherUID = UserUID,
|
OtherUID = UserUID,
|
||||||
IsPaused = otherEntry.IsPaused,
|
IsPaused = otherEntry.IsPaused,
|
||||||
IsPausedFromOthers = isPaused,
|
IsPausedFromOthers = isPaused,
|
||||||
IsSynced = true
|
IsSynced = true,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
var otherCharaIdent = await GetIdentFromUidFromRedis(pair.OtherUserUID).ConfigureAwait(false);
|
var otherCharaIdent = await GetIdentFromUidFromRedis(pair.OtherUserUID).ConfigureAwait(false);
|
||||||
@@ -304,7 +304,7 @@ public partial class MareHub
|
|||||||
.Client_UserUpdateClientPairs(new ClientPairDto()
|
.Client_UserUpdateClientPairs(new ClientPairDto()
|
||||||
{
|
{
|
||||||
OtherUID = otherUserUid,
|
OtherUID = otherUserUid,
|
||||||
IsRemoved = true
|
IsRemoved = true,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
// check if opposite entry exists
|
// check if opposite entry exists
|
||||||
@@ -321,7 +321,7 @@ public partial class MareHub
|
|||||||
{
|
{
|
||||||
OtherUID = UserUID,
|
OtherUID = UserUID,
|
||||||
IsPausedFromOthers = false,
|
IsPausedFromOthers = false,
|
||||||
IsSynced = false
|
IsSynced = false,
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
// if the other user had paused the user the state will be offline for either, do nothing
|
// if the other user had paused the user the state will be offline for either, do nothing
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ public partial class MareHub : Hub<IMareHub>, IMareHub
|
|||||||
MaxGroupsCreatedByUser = _maxExistingGroupsByUser,
|
MaxGroupsCreatedByUser = _maxExistingGroupsByUser,
|
||||||
ShardName = _shardName,
|
ShardName = _shardName,
|
||||||
MaxGroupsJoinedByUser = _maxJoinedGroupsByUser,
|
MaxGroupsJoinedByUser = _maxJoinedGroupsByUser,
|
||||||
MaxGroupUserCount = _maxGroupUserCount
|
MaxGroupUserCount = _maxGroupUserCount,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public partial class MareHub : Hub<IMareHub>, IMareHub
|
|||||||
{
|
{
|
||||||
return new ConnectionDto()
|
return new ConnectionDto()
|
||||||
{
|
{
|
||||||
ServerVersion = IMareHub.ApiVersion
|
ServerVersion = IMareHub.ApiVersion,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class SignalRLimitFilter : IHubFilter
|
|||||||
ClientIp = ip,
|
ClientIp = ip,
|
||||||
Path = invocationContext.HubMethodName,
|
Path = invocationContext.HubMethodName,
|
||||||
HttpVerb = "ws",
|
HttpVerb = "ws",
|
||||||
ClientId = invocationContext.Context.UserIdentifier
|
ClientId = invocationContext.Context.UserIdentifier,
|
||||||
};
|
};
|
||||||
foreach (var rule in await _processor.GetMatchingRulesAsync(client).ConfigureAwait(false))
|
foreach (var rule in await _processor.GetMatchingRulesAsync(client).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ public enum UserRequirements
|
|||||||
{
|
{
|
||||||
Identified = 0b00000001,
|
Identified = 0b00000001,
|
||||||
Moderator = 0b00000010,
|
Moderator = 0b00000010,
|
||||||
Administrator = 0b00000100
|
Administrator = 0b00000100,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class Startup
|
|||||||
ConfigureMetrics(services);
|
ConfigureMetrics(services);
|
||||||
|
|
||||||
// configure file service grpc connection
|
// configure file service grpc connection
|
||||||
ConfigureFileServiceGrpcClient(services, mareConfig);
|
ConfigureFileServiceGrpcClient(services);
|
||||||
|
|
||||||
// configure database
|
// configure database
|
||||||
ConfigureDatabase(services, mareConfig);
|
ConfigureDatabase(services, mareConfig);
|
||||||
@@ -105,29 +105,29 @@ public class Startup
|
|||||||
});
|
});
|
||||||
|
|
||||||
// configure redis for SignalR
|
// configure redis for SignalR
|
||||||
var redis = mareConfig.GetValue(nameof(ServerConfiguration.RedisConnectionString), string.Empty);
|
var redisConnection = mareConfig.GetValue(nameof(ServerConfiguration.RedisConnectionString), string.Empty);
|
||||||
if (!string.IsNullOrEmpty(redis))
|
if (!string.IsNullOrEmpty(redisConnection))
|
||||||
{
|
{
|
||||||
signalRServiceBuilder.AddStackExchangeRedis(redis, options =>
|
signalRServiceBuilder.AddStackExchangeRedis(redisConnection, options =>
|
||||||
{
|
{
|
||||||
options.Configuration.ChannelPrefix = "MareSynchronos";
|
options.Configuration.ChannelPrefix = "MareSynchronos";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = ConfigurationOptions.Parse(redis);
|
var options = ConfigurationOptions.Parse(redisConnection);
|
||||||
|
|
||||||
var endpoint = options.EndPoints.First();
|
var endpoint = options.EndPoints[0];
|
||||||
string address = "";
|
string address = "";
|
||||||
int port = 0;
|
int port = 0;
|
||||||
if (endpoint is DnsEndPoint) { address = ((DnsEndPoint)endpoint).Host; port = ((DnsEndPoint)endpoint).Port; }
|
if (endpoint is DnsEndPoint dnsEndPoint) { address = dnsEndPoint.Host; port = dnsEndPoint.Port; }
|
||||||
if (endpoint is IPEndPoint) { address = ((IPEndPoint)endpoint).Address.ToString(); port = ((IPEndPoint)endpoint).Port; }
|
if (endpoint is IPEndPoint ipEndPoint) { address = ipEndPoint.Address.ToString(); port = ipEndPoint.Port; }
|
||||||
var redisConfiguration = new RedisConfiguration()
|
var redisConfiguration = new RedisConfiguration()
|
||||||
{
|
{
|
||||||
AbortOnConnectFail = true,
|
AbortOnConnectFail = true,
|
||||||
KeyPrefix = "",
|
KeyPrefix = "",
|
||||||
Hosts = new RedisHost[]
|
Hosts = new RedisHost[]
|
||||||
{
|
{
|
||||||
new RedisHost(){ Host = address, Port = port }
|
new RedisHost(){ Host = address, Port = port },
|
||||||
},
|
},
|
||||||
AllowAdmin = true,
|
AllowAdmin = true,
|
||||||
ConnectTimeout = 3000,
|
ConnectTimeout = 3000,
|
||||||
@@ -138,10 +138,10 @@ public class Startup
|
|||||||
{
|
{
|
||||||
Mode = ServerEnumerationStrategy.ModeOptions.All,
|
Mode = ServerEnumerationStrategy.ModeOptions.All,
|
||||||
TargetRole = ServerEnumerationStrategy.TargetRoleOptions.Any,
|
TargetRole = ServerEnumerationStrategy.TargetRoleOptions.Any,
|
||||||
UnreachableServerAction = ServerEnumerationStrategy.UnreachableServerActionOptions.Throw
|
UnreachableServerAction = ServerEnumerationStrategy.UnreachableServerActionOptions.Throw,
|
||||||
},
|
},
|
||||||
MaxValueLength = 1024,
|
MaxValueLength = 1024,
|
||||||
PoolSize = 50
|
PoolSize = 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
services.AddStackExchangeRedisExtensions<SystemTextJsonSerializer>(redisConfiguration);
|
services.AddStackExchangeRedisExtensions<SystemTextJsonSerializer>(redisConfiguration);
|
||||||
@@ -162,15 +162,15 @@ public class Startup
|
|||||||
services.AddTransient<IAuthorizationHandler, UserRequirementHandler>();
|
services.AddTransient<IAuthorizationHandler, UserRequirementHandler>();
|
||||||
|
|
||||||
services.AddOptions<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme)
|
services.AddOptions<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme)
|
||||||
.Configure<IConfigurationService<MareConfigurationAuthBase>>((o, s) =>
|
.Configure<IConfigurationService<MareConfigurationAuthBase>>((options, config) =>
|
||||||
{
|
{
|
||||||
o.TokenValidationParameters = new()
|
options.TokenValidationParameters = new()
|
||||||
{
|
{
|
||||||
ValidateIssuer = false,
|
ValidateIssuer = false,
|
||||||
ValidateLifetime = false,
|
ValidateLifetime = false,
|
||||||
ValidateAudience = false,
|
ValidateAudience = false,
|
||||||
ValidateIssuerSigningKey = true,
|
ValidateIssuerSigningKey = true,
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(s.GetValue<string>(nameof(MareConfigurationAuthBase.Jwt))))
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(config.GetValue<string>(nameof(MareConfigurationAuthBase.Jwt)))),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ public class Startup
|
|||||||
MetricsAPI.GaugeGroups,
|
MetricsAPI.GaugeGroups,
|
||||||
MetricsAPI.GaugeGroupPairs,
|
MetricsAPI.GaugeGroupPairs,
|
||||||
MetricsAPI.GaugeGroupPairsPaused,
|
MetricsAPI.GaugeGroupPairsPaused,
|
||||||
MetricsAPI.GaugeUsersRegistered
|
MetricsAPI.GaugeUsersRegistered,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ public class Startup
|
|||||||
var noRetryConfig = new MethodConfig
|
var noRetryConfig = new MethodConfig
|
||||||
{
|
{
|
||||||
Names = { MethodName.Default },
|
Names = { MethodName.Default },
|
||||||
RetryPolicy = null
|
RetryPolicy = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
services.AddGrpcClient<ConfigurationService.ConfigurationServiceClient>("MainServer", c =>
|
services.AddGrpcClient<ConfigurationService.ConfigurationServiceClient>("MainServer", c =>
|
||||||
@@ -264,7 +264,7 @@ public class Startup
|
|||||||
c.ServiceConfig = new ServiceConfig { MethodConfigs = { noRetryConfig } };
|
c.ServiceConfig = new ServiceConfig { MethodConfigs = { noRetryConfig } };
|
||||||
c.HttpHandler = new SocketsHttpHandler()
|
c.HttpHandler = new SocketsHttpHandler()
|
||||||
{
|
{
|
||||||
EnableMultipleHttp2Connections = true
|
EnableMultipleHttp2Connections = true,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ public class Startup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureFileServiceGrpcClient(IServiceCollection services, IConfigurationSection mareConfig)
|
private static void ConfigureFileServiceGrpcClient(IServiceCollection services)
|
||||||
{
|
{
|
||||||
var defaultMethodConfig = new MethodConfig
|
var defaultMethodConfig = new MethodConfig
|
||||||
{
|
{
|
||||||
@@ -301,8 +301,8 @@ public class Startup
|
|||||||
InitialBackoff = TimeSpan.FromSeconds(1),
|
InitialBackoff = TimeSpan.FromSeconds(1),
|
||||||
MaxBackoff = TimeSpan.FromSeconds(5),
|
MaxBackoff = TimeSpan.FromSeconds(5),
|
||||||
BackoffMultiplier = 1.5,
|
BackoffMultiplier = 1.5,
|
||||||
RetryableStatusCodes = { Grpc.Core.StatusCode.Unavailable }
|
RetryableStatusCodes = { Grpc.Core.StatusCode.Unavailable },
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
services.AddGrpcClient<FileService.FileServiceClient>((serviceProvider, c) =>
|
services.AddGrpcClient<FileService.FileServiceClient>((serviceProvider, c) =>
|
||||||
{
|
{
|
||||||
@@ -325,6 +325,7 @@ public class Startup
|
|||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
app.UseWebSockets();
|
app.UseWebSockets();
|
||||||
|
app.UseHttpMetrics();
|
||||||
|
|
||||||
var metricServer = new KestrelMetricServer(config.GetValueOrDefault<int>(nameof(MareConfigurationBase.MetricsPort), 4980));
|
var metricServer = new KestrelMetricServer(config.GetValueOrDefault<int>(nameof(MareConfigurationBase.MetricsPort), 4980));
|
||||||
metricServer.Start();
|
metricServer.Start();
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ public enum PauseInfo
|
|||||||
{
|
{
|
||||||
NoConnection,
|
NoConnection,
|
||||||
Paused,
|
Paused,
|
||||||
Unpaused
|
Unpaused,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ public class ServerTokenGenerator
|
|||||||
Subject = new ClaimsIdentity(new List<Claim>()
|
Subject = new ClaimsIdentity(new List<Claim>()
|
||||||
{
|
{
|
||||||
new Claim(MareClaimTypes.Uid, _configuration.GetValue<string>(nameof(MareConfigurationBase.ShardName))),
|
new Claim(MareClaimTypes.Uid, _configuration.GetValue<string>(nameof(MareConfigurationBase.ShardName))),
|
||||||
new Claim(MareClaimTypes.Internal, "true")
|
new Claim(MareClaimTypes.Internal, "true"),
|
||||||
}),
|
}),
|
||||||
SigningCredentials = new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256Signature)
|
SigningCredentials = new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256Signature),
|
||||||
};
|
};
|
||||||
|
|
||||||
var handler = new JwtSecurityTokenHandler();
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class Startup
|
|||||||
var noRetryConfig = new MethodConfig
|
var noRetryConfig = new MethodConfig
|
||||||
{
|
{
|
||||||
Names = { MethodName.Default },
|
Names = { MethodName.Default },
|
||||||
RetryPolicy = null
|
RetryPolicy = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
services.AddGrpcClient<ConfigurationService.ConfigurationServiceClient>("FileServer", c =>
|
services.AddGrpcClient<ConfigurationService.ConfigurationServiceClient>("FileServer", c =>
|
||||||
@@ -86,7 +86,7 @@ public class Startup
|
|||||||
c.ServiceConfig = new ServiceConfig { MethodConfigs = { noRetryConfig } };
|
c.ServiceConfig = new ServiceConfig { MethodConfigs = { noRetryConfig } };
|
||||||
c.HttpHandler = new SocketsHttpHandler()
|
c.HttpHandler = new SocketsHttpHandler()
|
||||||
{
|
{
|
||||||
EnableMultipleHttp2Connections = true
|
EnableMultipleHttp2Connections = true,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public class Startup
|
|||||||
c.ServiceConfig = new ServiceConfig { MethodConfigs = { noRetryConfig } };
|
c.ServiceConfig = new ServiceConfig { MethodConfigs = { noRetryConfig } };
|
||||||
c.HttpHandler = new SocketsHttpHandler()
|
c.HttpHandler = new SocketsHttpHandler()
|
||||||
{
|
{
|
||||||
EnableMultipleHttp2Connections = true
|
EnableMultipleHttp2Connections = true,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ public class Startup
|
|||||||
ValidateLifetime = false,
|
ValidateLifetime = false,
|
||||||
ValidateAudience = false,
|
ValidateAudience = false,
|
||||||
ValidateIssuerSigningKey = true,
|
ValidateIssuerSigningKey = true,
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(s.GetValue<string>(nameof(MareConfigurationAuthBase.Jwt))))
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(s.GetValue<string>(nameof(MareConfigurationAuthBase.Jwt)))),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user