Replace hardcoded IPs with placeholders in templates and services

This commit is contained in:
Reditus committed 2026-05-12 01:55:01 +01:00
1 parent ebff79dbeb
commit 6dab454830
5 files changed
+38 -25

No files matched your search

+1 -1
View File
@@ -266,7 +266,7 @@ class AdminService:
name_match = re.search(r'Name=([^?#]+)', line)
if name_match:
current_player = name_match.group(1).split('#')[0]
if current_player and current_ip and current_ip != '65.21.198.100':
if current_player and current_ip and current_ip != 'YOUR_SERVER_IP':
ip_to_player[current_ip] = current_player
current_ip = None
+34 -21
View File
@@ -164,36 +164,43 @@ $AuthPass = "changeme"
# Try to detect server IP from known_hosts
$KnownHosts = Join-Path $env:USERPROFILE ".ssh\known_hosts"
if (Test-Path $KnownHosts) {
$hosts = Select-String -Path $KnownHosts -Pattern '^\d+\.\d+\.\d+\.\d+' | ForEach-Object {
if ($_ -match '^(\d+\.\d+\.\d+\.\d+)') { $matches[1] }
} | Select-Object -Unique
if ($hosts.Count -gt 0) {
$ServerHost = $hosts[-1]
Write-Host " Detected previous server IP: $ServerHost" -ForegroundColor Green
$content = Get-Content $KnownHosts
$ips = @()
foreach ($line in $content) {
if ($line -match '\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b') {
$ips += $matches[1]
}
}
if ($ips.Count -gt 0) {
$ServerHost = $ips[-1]
Write-Host " Detected server IP from SSH history: $ServerHost" -ForegroundColor Green
}
}
# Test SSH if we have a key and a real IP
if ($FoundKey -and $ServerHost -ne "YOUR_SERVER_IP") {
# Test SSH
$testOut = ssh -i $FoundKey -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 -o BatchMode=yes "dune@$ServerHost" "echo ok" 2>$null
if ($testOut -eq "ok") {
Write-Host " SSH connection OK" -ForegroundColor Green
# Ask for IP first so we can try SSH to detect namespace
Write-Host ""
$val = Read-Host " Server Host [$ServerHost]"
if ($val) { $ServerHost = $val }
# Auto-detect namespace
$nsOut = ssh -i $FoundKey -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 -o BatchMode=yes "dune@$ServerHost" "sudo kubectl get namespaces -o name" 2>$null
# Try SSH with the confirmed IP to auto-detect namespace
if ($FoundKey -and $ServerHost -ne "YOUR_SERVER_IP") {
Write-Host " Testing SSH connection..." -ForegroundColor Yellow
$testOut = cmd /c "ssh -i `"$FoundKey`" -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 -o BatchMode=yes dune@$ServerHost echo ok 2>nul"
if ($testOut -match "ok") {
Write-Host " SSH connection OK" -ForegroundColor Green
$nsOut = cmd /c "ssh -i `"$FoundKey`" -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 -o BatchMode=yes dune@$ServerHost sudo kubectl get namespaces -o name 2>nul"
if ($nsOut) {
foreach ($line in $nsOut -split "`n") {
$ns = $line -replace 'namespace/', ''
if ($ns -match '^funcom-seabass-') {
$K8sNamespace = $ns
Write-Host " Namespace: $K8sNamespace" -ForegroundColor Green
Write-Host " Auto-detected namespace: $K8sNamespace" -ForegroundColor Green
break
}
}
}
} else {
Write-Host " [WARN] SSH failed. Using defaults." -ForegroundColor Yellow
Write-Host " [WARN] SSH failed for $ServerHost. You may need to enter the namespace manually." -ForegroundColor Yellow
}
}
@@ -202,17 +209,23 @@ Write-Host ""
Write-Host " Review settings (press Enter to accept, or type new value):" -ForegroundColor Cyan
Write-Host ""
$val = Read-Host " Server Host [$ServerHost]"
if ($val) { $ServerHost = $val }
Write-Host " Server Host: $ServerHost"
$val = Read-Host " Server User [$ServerUser]"
if ($val) { $ServerUser = $val }
$val = Read-Host " SSH Key Path [$FoundKey]"
if ($val) { $FoundKey = $val }
Write-Host " SSH Key Path: $FoundKey"
$val = Read-Host " K8s Namespace [$K8sNamespace]"
if (-not $K8sNamespace) {
Write-Host " [INFO] To find your namespace, run: ssh dune@YOUR_IP 'sudo kubectl get namespaces'" -ForegroundColor Cyan
$K8sHint = "funcom-seabass-<id>"
} else {
$K8sHint = $K8sNamespace
}
$val = Read-Host " K8s Namespace [$K8sHint]"
if ($val) { $K8sNamespace = $val }
elseif (-not $K8sNamespace) { $K8sNamespace = "" }
$val = Read-Host " Dashboard Port [$DashboardPort]"
if ($val) { $DashboardPort = $val }
+1 -1
View File
@@ -11,7 +11,7 @@
<div class="error-banner danger">
<strong>SSH Tunnel Not Detected</strong><br>
Start the SSH tunnel first, then refresh.
<br><code>ssh -i $env:TEMP\dune-awakening-server-sshKey -L 15433:localhost:15433 -N dune@65.21.198.100</code>
<br><code>ssh -i $env:TEMP\dune-awakening-server-sshKey -L 15433:localhost:15433 -N dune@YOUR_SERVER_IP</code>
</div>
{% elif db_error %}
<div class="error-banner danger"><strong>Database Error:</strong> {{ db_error }}</div>
+1 -1
View File
@@ -13,7 +13,7 @@
The PostgreSQL database is not reachable. Start the SSH tunnel in a separate terminal:
<br><br>
<code>$key = "$env:TEMP\dune-awakening-server-sshKey"</code><br>
<code>ssh -i $key -L 15433:localhost:15433 -N dune@65.21.198.100</code>
<code>ssh -i $key -L 15433:localhost:15433 -N dune@YOUR_SERVER_IP</code>
</div>
{% elif db_error %}
<div class="error-banner danger">
+1 -1
View File
@@ -11,7 +11,7 @@
<div class="error-banner danger">
<strong>SSH Tunnel Not Detected</strong><br>
Start the SSH tunnel first, then refresh.
<br><code>ssh -i $env:TEMP\dune-awakening-server-sshKey -L 15433:localhost:15433 -N dune@65.21.198.100</code>
<br><code>ssh -i $env:TEMP\dune-awakening-server-sshKey -L 15433:localhost:15433 -N dune@YOUR_SERVER_IP</code>
</div>
{% elif db_error %}
<div class="error-banner danger"><strong>Database Error:</strong> {{ db_error }}</div>