Initial intranet dashboard app
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set SCRIPT_DIR=%~dp0
|
||||
set PORT=%~1
|
||||
|
||||
if "%PORT%"=="" set PORT=8010
|
||||
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%remove_windows_portproxy.ps1" -Port %PORT%
|
||||
|
||||
endlocal
|
||||
@@ -0,0 +1,16 @@
|
||||
param(
|
||||
[string]$ListenAddress = "0.0.0.0",
|
||||
[int]$Port = 8010,
|
||||
[string]$RuleName = "MyIntranetApp-8010"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
netsh interface portproxy delete v4tov4 listenport=$Port listenaddress=$ListenAddress | Out-Null
|
||||
|
||||
$existingRule = Get-NetFirewallRule -DisplayName $RuleName -ErrorAction SilentlyContinue
|
||||
if ($existingRule) {
|
||||
Remove-NetFirewallRule -DisplayName $RuleName | Out-Null
|
||||
}
|
||||
|
||||
Write-Host "Removed portproxy and firewall rule for port $Port" -ForegroundColor Yellow
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
if [ ! -x ".venv/bin/python" ]; then
|
||||
echo "가상환경이 없습니다. 먼저 아래를 실행하세요."
|
||||
echo "python3 -m venv .venv"
|
||||
echo "source .venv/bin/activate"
|
||||
echo "pip install -r requirements.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec ./.venv/bin/python main.py
|
||||
@@ -0,0 +1,24 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set SCRIPT_DIR=%~dp0
|
||||
set WSL_IP=%~1
|
||||
set PORT=%~2
|
||||
|
||||
if not "%WSL_IP%"=="" (
|
||||
echo %WSL_IP% | findstr /R "^[0-9][0-9]*$" >nul
|
||||
if not errorlevel 1 (
|
||||
set PORT=%WSL_IP%
|
||||
set WSL_IP=
|
||||
)
|
||||
)
|
||||
|
||||
if "%PORT%"=="" set PORT=8010
|
||||
|
||||
if "%WSL_IP%"=="" (
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%setup_windows_portproxy.ps1" -Port %PORT%
|
||||
) else (
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%setup_windows_portproxy.ps1" -WslIp %WSL_IP% -Port %PORT%
|
||||
)
|
||||
|
||||
endlocal
|
||||
@@ -0,0 +1,54 @@
|
||||
param(
|
||||
[string]$ListenAddress = "0.0.0.0",
|
||||
[int]$Port = 8010,
|
||||
[string]$WslIp = "",
|
||||
[string]$RuleName = "MyIntranetApp-8010"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($WslIp)) {
|
||||
$detected = wsl.exe hostname -I 2>$null
|
||||
if (-not $detected) {
|
||||
throw "WSL IP를 자동으로 찾지 못했습니다. -WslIp 옵션으로 직접 지정해 주세요."
|
||||
}
|
||||
|
||||
$WslIp = (($detected -split "\s+") | Where-Object { $_ -match '^\d+\.\d+\.\d+\.\d+$' } | Select-Object -First 1)
|
||||
if (-not $WslIp) {
|
||||
throw "WSL IP를 자동으로 파싱하지 못했습니다. -WslIp 옵션으로 직접 지정해 주세요."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Setting Windows portproxy for WSL app..." -ForegroundColor Cyan
|
||||
Write-Host "ListenAddress: $ListenAddress"
|
||||
Write-Host "Port: $Port"
|
||||
Write-Host "WSL IP: $WslIp"
|
||||
|
||||
netsh interface portproxy delete v4tov4 listenport=$Port listenaddress=$ListenAddress | Out-Null
|
||||
netsh interface portproxy add v4tov4 listenport=$Port listenaddress=$ListenAddress connectport=$Port connectaddress=$WslIp
|
||||
|
||||
$existingRule = Get-NetFirewallRule -DisplayName $RuleName -ErrorAction SilentlyContinue
|
||||
if ($existingRule) {
|
||||
Remove-NetFirewallRule -DisplayName $RuleName | Out-Null
|
||||
}
|
||||
|
||||
New-NetFirewallRule `
|
||||
-DisplayName $RuleName `
|
||||
-Direction Inbound `
|
||||
-Action Allow `
|
||||
-Protocol TCP `
|
||||
-LocalPort $Port | Out-Null
|
||||
|
||||
$windowsIps = Get-NetIPAddress -AddressFamily IPv4 |
|
||||
Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254*' -and $_.IPAddress -notlike '172.*' } |
|
||||
Select-Object -ExpandProperty IPAddress
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Completed." -ForegroundColor Green
|
||||
Write-Host "Now open this from another PC on the intranet:"
|
||||
Write-Host "http://<Windows-IP>:$Port"
|
||||
if ($windowsIps) {
|
||||
Write-Host "Windows IPv4 candidates: $($windowsIps -join ', ')"
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host "Tip: if WSL restarts and its IP changes, run this script again. If you omit -WslIp, the script will detect it automatically."
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
WSL_IP="$(hostname -I | awk '{print $1}')"
|
||||
WSL_HOST_IP="$(awk '/nameserver/ {print $2; exit}' /etc/resolv.conf)"
|
||||
WINDOWS_IPS="$(
|
||||
powershell.exe -NoProfile -Command "(Get-NetIPAddress -AddressFamily IPv4 | Where-Object { \$_.IPAddress -notlike '127.*' -and \$_.IPAddress -notlike '169.254*' } | Select-Object -ExpandProperty IPAddress) -join ','" \
|
||||
2>/dev/null | tr -d '\r'
|
||||
)"
|
||||
|
||||
cat <<EOF
|
||||
WSL 앱 정보
|
||||
- WSL 내부 IP: ${WSL_IP}
|
||||
- Windows 호스트와 연결된 주소 추정값: ${WSL_HOST_IP}
|
||||
- Windows IPv4 후보: ${WINDOWS_IPS:-확인 실패}
|
||||
- 앱 포트: 8010
|
||||
|
||||
중요
|
||||
- WSL2에서는 다른 PC가 WSL 내부 IP(${WSL_IP})로 직접 접속하지 못하는 경우가 많습니다.
|
||||
- 내부망 다른 PC에서는 보통 Windows 호스트 IP:8010 으로 접속해야 합니다.
|
||||
- 따라서 Windows 관리자 PowerShell에서 portproxy + 방화벽 규칙을 설정해야 합니다.
|
||||
|
||||
다음 단계
|
||||
1. WSL에서 서버 실행: ./scripts/run_server.sh
|
||||
2. Windows 관리자 PowerShell 또는 CMD에서 scripts/setup_windows_portproxy 실행
|
||||
3. 다른 PC 브라우저에서 http://Windows호스트IP:8010 접속
|
||||
EOF
|
||||
Reference in New Issue
Block a user