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