Skip to content

Commit 37d9cb9

Browse files
committedMar 31, 2024·
fix: cidr and dns config not being overwritten
1 parent f7ef640 commit 37d9cb9

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed
 

‎src/GZCTF/Extensions/CaptchaExtension.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public override async Task<bool> VerifyAsync(ModelWithCaptcha model, HttpContext
9999
public static class CaptchaServiceExtension
100100
{
101101
internal static IServiceCollection AddCaptchaService(this IServiceCollection services,
102-
ConfigurationManager configuration)
102+
IConfiguration configuration)
103103
{
104104
CaptchaConfig config = configuration.GetSection(nameof(CaptchaConfig)).Get<CaptchaConfig>() ?? new();
105105

‎src/GZCTF/Models/Internal/Configs.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,8 @@ public class KubernetesConfig
142142
{
143143
public string Namespace { get; set; } = "gzctf-challenges";
144144
public string KubeConfig { get; set; } = "kube-config.yaml";
145-
146-
[JsonObjectCreationHandling(JsonObjectCreationHandling.Replace)]
147-
public List<string> AllowCidr { get; set; } = ["10.0.0.0/8"];
148-
149-
[JsonObjectCreationHandling(JsonObjectCreationHandling.Replace)]
150-
public List<string> Dns { get; set; } = ["8.8.8.8", "223.5.5.5", "114.114.114.114"];
145+
public string[]? AllowCidr { get; set; }
146+
public string[]? Dns { get; set; }
151147
}
152148

153149
public class RegistryConfig

‎src/GZCTF/Services/Container/ContainerServiceExtension.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class ContainerProviderMetadata
2828
public static class ContainerServiceExtension
2929
{
3030
internal static IServiceCollection AddContainerService(this IServiceCollection services,
31-
ConfigurationManager configuration)
31+
IConfiguration configuration)
3232
{
3333
ContainerProvider config = configuration.GetSection(nameof(ContainerProvider)).Get<ContainerProvider>() ??
3434
new();

‎src/GZCTF/Services/Container/Manager/KubernetesManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ authSecretName is null
6363
? Array.Empty<V1LocalObjectReference>()
6464
: new List<V1LocalObjectReference> { new() { Name = authSecretName } },
6565
DnsPolicy = "None",
66-
DnsConfig = new() { Nameservers = options.Dns },
66+
DnsConfig = new() { Nameservers = options.Dns ?? ["8.8.8.8", "223.5.5.5", "114.114.114.114"] },
6767
EnableServiceLinks = false,
6868
Containers =
6969
[

‎src/GZCTF/Services/Container/Provider/KubernetesProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void InitKubernetes(bool withAuth, RegistryConfig? registry)
115115
{
116116
IpBlock = new()
117117
{
118-
Cidr = "0.0.0.0/0", Except = _kubernetesMetadata.Config.AllowCidr
118+
Cidr = "0.0.0.0/0", Except = _kubernetesMetadata.Config.AllowCidr ?? ["10.0.0.0/8"]
119119
}
120120
}
121121
]

0 commit comments

Comments
 (0)
Please sign in to comment.