Skip to content

Commit

Permalink
fix: cidr and dns config not being overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Mar 31, 2024
1 parent f7ef640 commit 37d9cb9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/GZCTF/Extensions/CaptchaExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public sealed class CloudflareTurnstile(IOptions<CaptchaConfig>? options) : Capt
public static class CaptchaServiceExtension
{
internal static IServiceCollection AddCaptchaService(this IServiceCollection services,
ConfigurationManager configuration)
IConfiguration configuration)
{
CaptchaConfig config = configuration.GetSection(nameof(CaptchaConfig)).Get<CaptchaConfig>() ?? new();

Expand Down
8 changes: 2 additions & 6 deletions src/GZCTF/Models/Internal/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,8 @@ public class KubernetesConfig
{
public string Namespace { get; set; } = "gzctf-challenges";
public string KubeConfig { get; set; } = "kube-config.yaml";

[JsonObjectCreationHandling(JsonObjectCreationHandling.Replace)]
public List<string> AllowCidr { get; set; } = ["10.0.0.0/8"];

[JsonObjectCreationHandling(JsonObjectCreationHandling.Replace)]
public List<string> Dns { get; set; } = ["8.8.8.8", "223.5.5.5", "114.114.114.114"];
public string[]? AllowCidr { get; set; }
public string[]? Dns { get; set; }
}

public class RegistryConfig
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/Services/Container/ContainerServiceExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ContainerProviderMetadata
public static class ContainerServiceExtension
{
internal static IServiceCollection AddContainerService(this IServiceCollection services,
ConfigurationManager configuration)
IConfiguration configuration)
{
ContainerProvider config = configuration.GetSection(nameof(ContainerProvider)).Get<ContainerProvider>() ??
new();
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/Services/Container/Manager/KubernetesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class KubernetesManager : IContainerManager
? Array.Empty<V1LocalObjectReference>()
: new List<V1LocalObjectReference> { new() { Name = authSecretName } },
DnsPolicy = "None",
DnsConfig = new() { Nameservers = options.Dns },
DnsConfig = new() { Nameservers = options.Dns ?? ["8.8.8.8", "223.5.5.5", "114.114.114.114"] },
EnableServiceLinks = false,
Containers =
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void InitKubernetes(bool withAuth, RegistryConfig? registry)
{
IpBlock = new()
{
Cidr = "0.0.0.0/0", Except = _kubernetesMetadata.Config.AllowCidr
Cidr = "0.0.0.0/0", Except = _kubernetesMetadata.Config.AllowCidr ?? ["10.0.0.0/8"]
}
}
]
Expand Down

0 comments on commit 37d9cb9

Please sign in to comment.