mirror of
https://github.com/codex-storage/cs-codex-dist-tests.git
synced 2025-02-02 15:23:29 +00:00
Switches to automatic public IP address for codex and geth containers.
This commit is contained in:
parent
485e3cf02e
commit
b90c47a994
@ -5,9 +5,10 @@ namespace CodexPlugin
|
|||||||
public class CodexDebugResponse
|
public class CodexDebugResponse
|
||||||
{
|
{
|
||||||
public string id { get; set; } = string.Empty;
|
public string id { get; set; } = string.Empty;
|
||||||
public string[] addrs { get; set; } = new string[0];
|
public string[] addrs { get; set; } = Array.Empty<string>();
|
||||||
public string repo { get; set; } = string.Empty;
|
public string repo { get; set; } = string.Empty;
|
||||||
public string spr { get; set; } = string.Empty;
|
public string spr { get; set; } = string.Empty;
|
||||||
|
public string[] announceAddresses { get; set; } = Array.Empty<string>();
|
||||||
public EnginePeerResponse[] enginePeers { get; set; } = Array.Empty<EnginePeerResponse>();
|
public EnginePeerResponse[] enginePeers { get; set; } = Array.Empty<EnginePeerResponse>();
|
||||||
public SwitchPeerResponse[] switchPeers { get; set; } = Array.Empty<SwitchPeerResponse>();
|
public SwitchPeerResponse[] switchPeers { get; set; } = Array.Empty<SwitchPeerResponse>();
|
||||||
public CodexDebugVersionResponse codex { get; set; } = new();
|
public CodexDebugVersionResponse codex { get; set; } = new();
|
||||||
|
@ -47,13 +47,15 @@ namespace CodexPlugin
|
|||||||
|
|
||||||
if (config.PublicTestNet != null)
|
if (config.PublicTestNet != null)
|
||||||
{
|
{
|
||||||
AddEnvVar("CODEX_NAT", config.PublicTestNet.PublicNatIP);
|
// This makes the node announce itself to its public IP address.
|
||||||
AddEnvVar("NAT_IP_AUTO", "false");
|
AddEnvVar("NAT_IP_AUTO", "false");
|
||||||
|
AddEnvVar("NAT_PUBLIC_IP_AUTO", "true");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This makes the node announce itself to its local (pod) IP address.
|
// This makes the node announce itself to its local (pod) IP address.
|
||||||
AddEnvVar("NAT_IP_AUTO", "true");
|
AddEnvVar("NAT_IP_AUTO", "true");
|
||||||
|
AddEnvVar("NAT_PUBLIC_IP_AUTO", "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
var listenPort = CreateListenPort(config);
|
var listenPort = CreateListenPort(config);
|
||||||
|
@ -133,7 +133,7 @@ namespace CodexPlugin
|
|||||||
|
|
||||||
private IEnumerable<string> DescribeArgs()
|
private IEnumerable<string> DescribeArgs()
|
||||||
{
|
{
|
||||||
if (PublicTestNet != null) yield return $"<!>Public TestNet at {PublicTestNet.PublicNatIP}:{PublicTestNet.PublicListenPort}<!>";
|
if (PublicTestNet != null) yield return $"<!>Public TestNet with listenPort: {PublicTestNet.PublicListenPort}<!>";
|
||||||
yield return $"LogLevel={LogLevelWithTopics()}";
|
yield return $"LogLevel={LogLevelWithTopics()}";
|
||||||
if (BootstrapSpr != null) yield return $"BootstrapNode={BootstrapSpr}";
|
if (BootstrapSpr != null) yield return $"BootstrapNode={BootstrapSpr}";
|
||||||
if (StorageQuota != null) yield return $"StorageQuota={StorageQuota}";
|
if (StorageQuota != null) yield return $"StorageQuota={StorageQuota}";
|
||||||
|
@ -65,7 +65,6 @@ namespace CodexPlugin
|
|||||||
|
|
||||||
public class CodexTestNetConfig
|
public class CodexTestNetConfig
|
||||||
{
|
{
|
||||||
public string PublicNatIP { get; set; } = string.Empty;
|
|
||||||
public int PublicDiscoveryPort { get; set; }
|
public int PublicDiscoveryPort { get; set; }
|
||||||
public int PublicListenPort { get; set; }
|
public int PublicListenPort { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace GethPlugin
|
|||||||
var authRpc = CreateP2pPort(config, tag: AuthRpcPortTag);
|
var authRpc = CreateP2pPort(config, tag: AuthRpcPortTag);
|
||||||
var wsPort = CreateP2pPort(config, tag: WsPortTag);
|
var wsPort = CreateP2pPort(config, tag: WsPortTag);
|
||||||
|
|
||||||
var args = $"--http.addr 0.0.0.0 --http.port {httpPort.Number} --port {listen.Number} --discovery.port {discovery.Number} {GetTestNetArgs(config)} {defaultArgs}";
|
var args = $"--http.addr 0.0.0.0 --http.port {httpPort.Number} --port {listen.Number} --discovery.port {discovery.Number} {defaultArgs}";
|
||||||
|
|
||||||
if (config.BootstrapNode != null)
|
if (config.BootstrapNode != null)
|
||||||
{
|
{
|
||||||
@ -50,6 +50,14 @@ namespace GethPlugin
|
|||||||
var bootstrapArg = $" --bootnodes enode://{bootPubKey}@{bootIp}:{bootPort} --nat=extip:{bootIp}";
|
var bootstrapArg = $" --bootnodes enode://{bootPubKey}@{bootIp}:{bootPort} --nat=extip:{bootIp}";
|
||||||
args += bootstrapArg;
|
args += bootstrapArg;
|
||||||
}
|
}
|
||||||
|
if (config.IsPublicTestNet != null)
|
||||||
|
{
|
||||||
|
AddEnvVar("NAT_PUBLIC_IP_AUTO", "true");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddEnvVar("NAT_PUBLIC_IP_AUTO", "false");
|
||||||
|
}
|
||||||
|
|
||||||
return args + $" --authrpc.port {authRpc.Number} --ws --ws.addr 0.0.0.0 --ws.port {wsPort.Number}";
|
return args + $" --authrpc.port {authRpc.Number} --ws --ws.addr 0.0.0.0 --ws.port {wsPort.Number}";
|
||||||
}
|
}
|
||||||
@ -64,13 +72,6 @@ namespace GethPlugin
|
|||||||
AddEnvVar("UNLOCK_NUMBER", numberOfAccounts.ToString());
|
AddEnvVar("UNLOCK_NUMBER", numberOfAccounts.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetTestNetArgs(GethStartupConfig config)
|
|
||||||
{
|
|
||||||
if (config.IsPublicTestNet == null) return string.Empty;
|
|
||||||
|
|
||||||
return $"--nat=extip:{config.IsPublicTestNet.PublicIp}";
|
|
||||||
}
|
|
||||||
|
|
||||||
private Port CreateDiscoveryPort(GethStartupConfig config)
|
private Port CreateDiscoveryPort(GethStartupConfig config)
|
||||||
{
|
{
|
||||||
if (config.IsPublicTestNet == null) return AddInternalPort(DiscoveryPortTag);
|
if (config.IsPublicTestNet == null) return AddInternalPort(DiscoveryPortTag);
|
||||||
|
@ -42,14 +42,12 @@
|
|||||||
|
|
||||||
public class GethTestNetConfig
|
public class GethTestNetConfig
|
||||||
{
|
{
|
||||||
public GethTestNetConfig(string publicIp, int discoveryPort, int listenPort)
|
public GethTestNetConfig(int discoveryPort, int listenPort)
|
||||||
{
|
{
|
||||||
PublicIp = publicIp;
|
|
||||||
DiscoveryPort = discoveryPort;
|
DiscoveryPort = discoveryPort;
|
||||||
ListenPort = listenPort;
|
ListenPort = listenPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string PublicIp { get; }
|
|
||||||
public int DiscoveryPort { get; }
|
public int DiscoveryPort { get; }
|
||||||
public int ListenPort { get; }
|
public int ListenPort { get; }
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,6 @@ namespace CodexNetDeployer
|
|||||||
|
|
||||||
return new CodexTestNetConfig
|
return new CodexTestNetConfig
|
||||||
{
|
{
|
||||||
PublicNatIP = config.PublicIP,
|
|
||||||
PublicDiscoveryPort = Convert.ToInt32(discPort),
|
PublicDiscoveryPort = Convert.ToInt32(discPort),
|
||||||
PublicListenPort = Convert.ToInt32(listenPort)
|
PublicListenPort = Convert.ToInt32(listenPort)
|
||||||
};
|
};
|
||||||
|
@ -86,18 +86,12 @@ namespace CodexNetDeployer
|
|||||||
[Uniform("public-testnet", "ptn", "PUBLICTESTNET", false, "If true, deployment is created for public exposure. Default is false.")]
|
[Uniform("public-testnet", "ptn", "PUBLICTESTNET", false, "If true, deployment is created for public exposure. Default is false.")]
|
||||||
public bool IsPublicTestNet { get; set; } = false;
|
public bool IsPublicTestNet { get; set; } = false;
|
||||||
|
|
||||||
[Uniform("public-ip", "pip", "PUBLICIP", false, "Required if public-testnet is true. Public IP address used by nodes for network annoucements.")]
|
|
||||||
public string PublicIP { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Uniform("public-discports", "pdps", "PUBLICDISCPORTS", false, "Required if public-testnet is true. Comma-separated port numbers used for discovery. Number must match number of nodes.")]
|
[Uniform("public-discports", "pdps", "PUBLICDISCPORTS", false, "Required if public-testnet is true. Comma-separated port numbers used for discovery. Number must match number of nodes.")]
|
||||||
public string PublicDiscPorts { get; set; } = string.Empty;
|
public string PublicDiscPorts { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Uniform("public-listenports", "plps", "PUBLICLISTENPORTS", false, "Required if public-testnet is true. Comma-separated port numbers used for listening. Number must match number of nodes.")]
|
[Uniform("public-listenports", "plps", "PUBLICLISTENPORTS", false, "Required if public-testnet is true. Comma-separated port numbers used for listening. Number must match number of nodes.")]
|
||||||
public string PublicListenPorts { get; set; } = string.Empty;
|
public string PublicListenPorts { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Uniform("public-gethip", "pgdp", "PUBLICGETHIP", false, "Required if public-testnet is true. Geth's public IP address.")]
|
|
||||||
public string PublicGethIP { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Uniform("public-gethdiscport", "pgdp", "PUBLICGETHDISCPORT", false, "Required if public-testnet is true. Single port number used for Geth's public discovery port.")]
|
[Uniform("public-gethdiscport", "pgdp", "PUBLICGETHDISCPORT", false, "Required if public-testnet is true. Single port number used for Geth's public discovery port.")]
|
||||||
public int PublicGethDiscPort { get; set; }
|
public int PublicGethDiscPort { get; set; }
|
||||||
|
|
||||||
@ -150,7 +144,6 @@ namespace CodexNetDeployer
|
|||||||
|
|
||||||
if (IsPublicTestNet)
|
if (IsPublicTestNet)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(PublicIP)) errors.Add("Public IP required when deploying public testnet.");
|
|
||||||
if (PublicDiscPorts.Split(",").Length != NumberOfCodexNodes) errors.Add("Number of public discovery-ports provided does not match number of codex nodes.");
|
if (PublicDiscPorts.Split(",").Length != NumberOfCodexNodes) errors.Add("Number of public discovery-ports provided does not match number of codex nodes.");
|
||||||
if (PublicListenPorts.Split(",").Length != NumberOfCodexNodes) errors.Add("Number of public listen-ports provided does not match number of codex nodes.");
|
if (PublicListenPorts.Split(",").Length != NumberOfCodexNodes) errors.Add("Number of public listen-ports provided does not match number of codex nodes.");
|
||||||
if (PublicGethDiscPort == 0) errors.Add("Geth public discovery port is not set.");
|
if (PublicGethDiscPort == 0) errors.Add("Geth public discovery port is not set.");
|
||||||
|
@ -113,7 +113,6 @@ namespace CodexNetDeployer
|
|||||||
if (config.IsPublicTestNet)
|
if (config.IsPublicTestNet)
|
||||||
{
|
{
|
||||||
s.AsPublicTestNet(new GethTestNetConfig(
|
s.AsPublicTestNet(new GethTestNetConfig(
|
||||||
publicIp: config.PublicGethIP,
|
|
||||||
discoveryPort: config.PublicGethDiscPort,
|
discoveryPort: config.PublicGethDiscPort,
|
||||||
listenPort: config.PublicGethListenPort
|
listenPort: config.PublicGethListenPort
|
||||||
));
|
));
|
||||||
|
@ -16,10 +16,8 @@ dotnet run \
|
|||||||
--check-connect=0 \
|
--check-connect=0 \
|
||||||
\
|
\
|
||||||
--public-testnet=1 \
|
--public-testnet=1 \
|
||||||
--public-ip=1.2.3.4 \
|
|
||||||
--public-discports=30010,30020,30030 \
|
--public-discports=30010,30020,30030 \
|
||||||
--public-listenports=30011,30021,30031 \
|
--public-listenports=30011,30021,30031 \
|
||||||
--public-gethip=1.2.3.5 \
|
|
||||||
--public-gethdiscport=30040 \
|
--public-gethdiscport=30040 \
|
||||||
--public-gethlistenport=30041 \
|
--public-gethlistenport=30041 \
|
||||||
\
|
\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user