$ErrorActionPreference = "Continue" Get-Content "E:\wwwroot\.env" | ForEach-Object { $line = $_.Trim() if (-not $line -or $line.StartsWith("#")) { return } $i = $line.IndexOf("=") if ($i -lt 1) { return } Set-Item -Path ("Env:" + $line.Substring(0, $i).Trim()) -Value $line.Substring($i + 1).Trim().Trim('"') } if ($env:REDIS_URL -match "redis://([^:/@]+):([^@]+)@([^:/]+)(?::(\d+))?(?:/(\d+))?") { $user = $Matches[1]; $pass = $Matches[2]; $rh = $Matches[3]; $port = $Matches[4]; if (-not $port) { $port = "6379" } } else { Write-Host "parse_fail"; exit 1 } Write-Host ("user=" + $user + " pw_len=" + $pass.Length + " rh=" + $rh + " port=" + $port) function Send-Redis([string]$rh,[int]$port,[byte[]]$payload) { $tcp = New-Object Net.Sockets.TcpClient $tcp.ReceiveTimeout = 3000; $tcp.SendTimeout = 3000 $tcp.Connect($rh, $port) $stream = $tcp.GetStream() $stream.Write($payload, 0, $payload.Length) $buf = New-Object byte[] 256 $n = $stream.Read($buf, 0, $buf.Length) $tcp.Close() return [Text.Encoding]::ASCII.GetString($buf, 0, $n) } function Resp-Auth([string[]]$parts) { $ms = New-Object IO.MemoryStream $sw = New-Object IO.StreamWriter($ms, [Text.Encoding]::UTF8) $sw.NewLine = "`r`n" $sw.WriteLine("*" + $parts.Count) foreach ($p in $parts) { $b = [Text.Encoding]::UTF8.GetBytes($p) $sw.WriteLine("$" + $b.Length) $sw.Flush() $ms.Write($b, 0, $b.Length) $cr = [Text.Encoding]::ASCII.GetBytes("`r`n"); $ms.Write($cr, 0, 2) } $sw.Flush() return $ms.ToArray() } foreach ($label in @("pw_only","user_pw","ping")) { try { if ($label -eq "pw_only") { $payload = Resp-Auth @("AUTH", $pass) } elseif ($label -eq "user_pw") { $payload = Resp-Auth @("AUTH", $user, $pass) } else { $payload = Resp-Auth @("PING") } $resp = Send-Redis $rh ([int]$port) $payload $respOne = ($resp -split "`r`n")[0] Write-Host ("AUTH " + $label + " => " + $respOne) } catch { Write-Host ("AUTH " + $label + " ERR " + $_.Exception.Message) } } # prod redis config snippet (mask password values) $prodCfgCandidates = @( "C:\yutongda\releases\admin-rel26-local-source-20260911d\backend\config\application-prod.yml", "C:\yutongda\releases\admin-rel26-local-source-20260911d\backend\application-prod.yml" ) Get-ChildItem "C:\yutongda\releases\admin-rel26-local-source-20260911d\backend" -Recurse -Filter "*prod*.yml" -ErrorAction SilentlyContinue | Select-Object -First 5 | ForEach-Object { Write-Host ("prod_yml=" + $_.FullName) Select-String -Path $_.FullName -Pattern "redis|password|username|host" | Select-Object -First 20 | ForEach-Object { $line = $_.Line $line = $line -replace "(password\s*:\s*).+","`$1***" Write-Host (" " + $line.Trim()) } } # also check if YTD_REDIS_PASSWORD exists separately in any env used by prod Write-Host ("env_YTD_REDIS_PASSWORD_len=" + ($(if($env:YTD_REDIS_PASSWORD){$env:YTD_REDIS_PASSWORD.Length}else{0}))) Write-Host ("env_YTD_REDIS_USERNAME=" + $env:YTD_REDIS_USERNAME) Write-Host "AUTH_PROBE2_DONE"