feat(packs): pack types (resourcepack/datapack/modpack), URL /pack/<type>.zip?domain=<domain>
Files move to <NEXTCLOUD_DIR>/<domain>/<type>.zip; packs.json is {domain: {type: meta}}.
Only resourcepack shows the server.properties snippet; datapack/modpack show the URL.
modpack skips the pack.mcmeta check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
19
README.md
19
README.md
@@ -14,7 +14,7 @@
|
||||
- 설정 파일(`data/config.json`) 변경을 프록시가 자동 감지해 hot reload (재시작 불필요)
|
||||
- 모든 연결 시도(허용 / 차단 / 에러)를 SQLite 에 기록
|
||||
- 웹 대시보드 (NPM 스타일): 도메인 관리, 실시간 로그, 통계 카드, 백엔드/포트 설정
|
||||
- **도메인별 리소스팩**: 대시보드에서 zip 업로드 → Nextcloud(share.tkrmagid.kr) 에 저장 → `https://mc.tkrmagid.kr/pack/<도메인>.zip` 로 공개. MC 서버 `server.properties` 에 붙여 넣을 URL/SHA1 을 보여준다
|
||||
- **도메인별 팩 (리소스팩 / 데이터팩 / 모드팩)**: 대시보드에서 zip 업로드 → Nextcloud(share.tkrmagid.kr) 에 저장 → `https://mc.tkrmagid.kr/pack/<종류>.zip?domain=<도메인>` 로 공개. 리소스팩은 MC 서버 `server.properties` 에 붙여 넣을 URL/SHA1 을 보여준다
|
||||
|
||||
## 네트워크 구조
|
||||
|
||||
@@ -76,7 +76,7 @@ mc-filter-proxy 컨테이너 (25565)
|
||||
| `api` | 8000 (내부) | FastAPI, 설정/로그/통계 REST API |
|
||||
| `frontend` | 3000 (내부) | React + Vite SPA |
|
||||
| `nginx` | 8080 (외부) | 대시보드 리버스 프록시 |
|
||||
| `nginx` | 8081 (외부) | 리소스팩 공개 다운로드 (`/pack/` 만) |
|
||||
| `nginx` | 8081 (외부) | 팩 공개 다운로드 (`/pack/` 만) |
|
||||
|
||||
`data/` 디렉터리는 모든 서비스가 공유 볼륨으로 마운트해 `config.json`, `logs.db` 를 공용합니다.
|
||||
|
||||
@@ -94,10 +94,10 @@ mc-filter-proxy 컨테이너 (25565)
|
||||
| DELETE | `/api/logs?from_ts&to_ts` | 접속 로그 삭제 (범위 미지정 시 전체) |
|
||||
| GET | `/api/status` | 프록시 상태 + 통계 |
|
||||
| POST | `/api/proxy/restart` | config 파일 touch (프록시 재로드 트리거) |
|
||||
| GET | `/api/packs` | 도메인별 리소스팩 목록 (URL, SHA1) |
|
||||
| PUT | `/api/packs/{domain}` | 리소스팩 업로드 (multipart `file`, 크기 제한 없음) |
|
||||
| DELETE | `/api/packs/{domain}` | 리소스팩 삭제 |
|
||||
| GET | `/pack/{domain}.zip` | 공개 다운로드 (nginx 81 포트에서만 노출) |
|
||||
| GET | `/api/packs` | 도메인별 팩 목록 (URL, SHA1) |
|
||||
| PUT | `/api/packs/{domain}/{kind}` | 팩 업로드 (`kind`=resourcepack/datapack/modpack, multipart `file`, 크기 제한 없음) |
|
||||
| DELETE | `/api/packs/{domain}/{kind}` | 팩 삭제 |
|
||||
| GET | `/pack/{kind}.zip?domain=` | 공개 다운로드 (nginx 81 포트에서만 노출) |
|
||||
|
||||
## Hot reload 동작
|
||||
|
||||
@@ -108,9 +108,9 @@ mc-filter-proxy 컨테이너 (25565)
|
||||
|
||||
> **리스닝 포트 변경:** `proxy.listen_port` 는 docker-compose 의 `ports` 매핑과 짝이라 대시보드에서 편집할 수 없습니다. 바꾸려면 `data/config.json` 과 `docker-compose.yml` 의 `25565:25565` 매핑을 함께 수정한 뒤 `docker compose up -d --force-recreate proxy` 하세요.
|
||||
|
||||
## 리소스팩
|
||||
## 팩 (리소스팩 / 데이터팩 / 모드팩)
|
||||
|
||||
- 팩 파일은 Nextcloud 의 `NEXTCLOUD_DIR/<도메인>.zip` 에 저장되고, 메타데이터(SHA1, 크기, 업로드 시각)는 `data/packs.json` 에 남는다.
|
||||
- 팩 파일은 Nextcloud 의 `NEXTCLOUD_DIR/<도메인>/<종류>.zip` 에 저장되고, 메타데이터(SHA1, 크기, 업로드 시각)는 `data/packs.json` 에 남는다.
|
||||
- 클라이언트 다운로드는 API 가 Nextcloud 에서 받아 그대로 중계한다. (Nextcloud 공유 링크는 http 로 리다이렉트를 줘서 MC 클라이언트가 못 따라간다.)
|
||||
- nginx 의 81 포트(compose `8081:81`)는 `/pack/` 만 응답하고 나머지는 404 다. 외부 리버스 프록시(NPMplus)에서는 `mc.tkrmagid.kr/pack/` 만 이 포트로 연결한다. 대시보드 포트는 계속 외부 비공개.
|
||||
- Nextcloud 계정은 compose 폴더의 `.env` 에 둔다:
|
||||
@@ -120,7 +120,8 @@ mc-filter-proxy 컨테이너 (25565)
|
||||
NEXTCLOUD_PASSWORD=<앱 비밀번호>
|
||||
```
|
||||
|
||||
- 팩을 교체하면 SHA1 이 바뀌므로 MC 서버의 `resource-pack-sha1` 을 고치고 서버를 재시작해야 한다.
|
||||
- 리소스팩·데이터팩은 zip 최상위에 `pack.mcmeta` 가 있어야 한다. 데이터팩은 클라이언트가 자동으로 받지 않으니 서버 월드의 `datapacks` 폴더에 넣는다. 모드팩은 플레이어에게 주소를 알려 주는 용도다.
|
||||
- 리소스팩을 교체하면 SHA1 이 바뀌므로 MC 서버의 `resource-pack-sha1` 을 고치고 서버를 재시작해야 한다.
|
||||
|
||||
## 보안 권장
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""도메인별 리소스팩: Nextcloud(share.tkrmagid.kr) 에 저장하고 공개 경로로 내려준다.
|
||||
"""도메인별 팩(리소스팩/데이터팩/모드팩): Nextcloud(share.tkrmagid.kr) 에 저장하고 공개 경로로 내려준다.
|
||||
|
||||
- 업로드/삭제/목록은 대시보드용 /api/packs (인증 없음, 내부망 전용)
|
||||
- 클라이언트 다운로드는 /pack/<domain>.zip (외부 공개). Nextcloud 에서 받아 그대로 스트리밍한다.
|
||||
- 다운로드는 /pack/<종류>.zip?domain=<도메인> (외부 공개). Nextcloud 에서 받아 그대로 스트리밍한다.
|
||||
Nextcloud 공유 링크의 /download 는 http:// 로 303 리다이렉트를 주는데,
|
||||
MC 클라이언트(HttpURLConnection)는 https→http 리다이렉트를 따라가지 않아서 직접 중계한다.
|
||||
"""
|
||||
@@ -10,7 +10,6 @@ from __future__ import annotations
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
@@ -34,6 +33,13 @@ NC_PASSWORD = os.environ.get("NEXTCLOUD_PASSWORD", "")
|
||||
NC_DIR = os.environ.get("NEXTCLOUD_DIR", "/claude/mc_domain_proxy/packs").strip("/")
|
||||
PUBLIC_BASE = os.environ.get("PACK_PUBLIC_BASE", "https://mc.tkrmagid.kr/pack").rstrip("/")
|
||||
|
||||
# 종류별 설정. mcmeta=True 면 zip 최상위에 pack.mcmeta 가 있어야 한다.
|
||||
PACK_TYPES = {
|
||||
"resourcepack": {"label": "리소스팩", "mcmeta": True},
|
||||
"datapack": {"label": "데이터팩", "mcmeta": True},
|
||||
"modpack": {"label": "모드팩", "mcmeta": False},
|
||||
}
|
||||
|
||||
_lock = threading.Lock()
|
||||
|
||||
|
||||
@@ -69,9 +75,9 @@ def _require_storage() -> None:
|
||||
)
|
||||
|
||||
|
||||
def _ensure_dir(client: httpx.Client) -> None:
|
||||
# NC_DIR 의 각 단계를 순서대로 MKCOL (이미 있으면 405)
|
||||
parts = NC_DIR.split("/")
|
||||
def _ensure_dir(client: httpx.Client, *extra: str) -> None:
|
||||
# NC_DIR(+extra) 의 각 단계를 순서대로 MKCOL (이미 있으면 405)
|
||||
parts = [*NC_DIR.split("/"), *extra]
|
||||
for i in range(1, len(parts) + 1):
|
||||
url = f"{NC_URL}/remote.php/dav/files/{quote(NC_USER, safe='')}/" + "/".join(
|
||||
quote(p, safe="") for p in parts[:i]
|
||||
@@ -85,8 +91,13 @@ def _domain_names() -> set[str]:
|
||||
return {d["domain"].lower() for d in load_config().get("allowed_domains", [])}
|
||||
|
||||
|
||||
def _pack_url(domain: str) -> str:
|
||||
return f"{PUBLIC_BASE}/{quote(domain, safe='')}.zip"
|
||||
def _pack_url(kind: str, domain: str) -> str:
|
||||
return f"{PUBLIC_BASE}/{kind}.zip?domain={quote(domain, safe='')}"
|
||||
|
||||
|
||||
def _check_kind(kind: str) -> None:
|
||||
if kind not in PACK_TYPES:
|
||||
raise HTTPException(status_code=404, detail="unknown pack type")
|
||||
|
||||
|
||||
@router.get("/packs")
|
||||
@@ -95,17 +106,25 @@ def list_packs() -> dict:
|
||||
items = []
|
||||
for d in load_config().get("allowed_domains", []):
|
||||
name = d["domain"].lower()
|
||||
meta = packs.get(name)
|
||||
stored = packs.get(name, {})
|
||||
items.append({
|
||||
"domain": name,
|
||||
"pack": {**meta, "url": _pack_url(name)} if meta else None,
|
||||
"packs": {
|
||||
kind: {**stored[kind], "url": _pack_url(kind, name)} if kind in stored else None
|
||||
for kind in PACK_TYPES
|
||||
},
|
||||
})
|
||||
return {"storage_configured": bool(NC_USER and NC_PASSWORD), "packs": items}
|
||||
return {
|
||||
"storage_configured": bool(NC_USER and NC_PASSWORD),
|
||||
"types": {k: v["label"] for k, v in PACK_TYPES.items()},
|
||||
"domains": items,
|
||||
}
|
||||
|
||||
|
||||
@router.put("/packs/{domain}")
|
||||
def upload_pack(domain: str, file: UploadFile) -> dict:
|
||||
@router.put("/packs/{domain}/{kind}")
|
||||
def upload_pack(domain: str, kind: str, file: UploadFile) -> dict:
|
||||
_require_storage()
|
||||
_check_kind(kind)
|
||||
name = domain.strip().lower()
|
||||
if name not in _domain_names():
|
||||
raise HTTPException(status_code=404, detail="domain not found")
|
||||
@@ -124,17 +143,17 @@ def upload_pack(domain: str, file: UploadFile) -> dict:
|
||||
has_meta = "pack.mcmeta" in zf.namelist()
|
||||
except zipfile.BadZipFile:
|
||||
raise HTTPException(status_code=400, detail="zip 파일이 아닙니다.")
|
||||
if not has_meta:
|
||||
if PACK_TYPES[kind]["mcmeta"] and not has_meta:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="zip 최상위에 pack.mcmeta 가 없습니다. 폴더째 압축하지 말고 폴더 안의 내용물을 압축해 주세요.",
|
||||
)
|
||||
|
||||
with _client(timeout=None) as client:
|
||||
_ensure_dir(client)
|
||||
_ensure_dir(client, name)
|
||||
tmp.seek(0)
|
||||
r = client.put(
|
||||
_dav_url(f"{name}.zip"),
|
||||
_dav_url(name, f"{kind}.zip"),
|
||||
content=iter(lambda: tmp.read(1024 * 1024), b""),
|
||||
headers={"Content-Length": str(size)},
|
||||
)
|
||||
@@ -144,44 +163,48 @@ def upload_pack(domain: str, file: UploadFile) -> dict:
|
||||
meta = {
|
||||
"sha1": sha1.hexdigest(),
|
||||
"size": size,
|
||||
"original_name": file.filename or f"{name}.zip",
|
||||
"original_name": file.filename or f"{kind}.zip",
|
||||
"uploaded_at": time.time(),
|
||||
}
|
||||
with _lock:
|
||||
packs = _load_packs()
|
||||
packs[name] = meta
|
||||
packs.setdefault(name, {})[kind] = meta
|
||||
_save_packs(packs)
|
||||
return {"domain": name, "pack": {**meta, "url": _pack_url(name)}}
|
||||
return {"domain": name, "kind": kind, "pack": {**meta, "url": _pack_url(kind, name)}}
|
||||
|
||||
|
||||
@router.delete("/packs/{domain}", status_code=204)
|
||||
def delete_pack(domain: str) -> Response:
|
||||
@router.delete("/packs/{domain}/{kind}", status_code=204)
|
||||
def delete_pack(domain: str, kind: str) -> Response:
|
||||
_require_storage()
|
||||
_check_kind(kind)
|
||||
name = domain.strip().lower()
|
||||
with _lock:
|
||||
packs = _load_packs()
|
||||
if name not in packs:
|
||||
if kind not in packs.get(name, {}):
|
||||
raise HTTPException(status_code=404, detail="pack not found")
|
||||
with _client() as client:
|
||||
r = client.delete(_dav_url(f"{name}.zip"))
|
||||
r = client.delete(_dav_url(name, f"{kind}.zip"))
|
||||
if r.status_code not in (204, 404):
|
||||
raise HTTPException(status_code=502, detail=f"Nextcloud 삭제 실패: {r.status_code}")
|
||||
packs.pop(name)
|
||||
packs[name].pop(kind)
|
||||
if not packs[name]:
|
||||
packs.pop(name)
|
||||
_save_packs(packs)
|
||||
return Response(status_code=204)
|
||||
|
||||
|
||||
@public_router.get("/pack/{filename}")
|
||||
def download_pack(filename: str) -> StreamingResponse:
|
||||
def download_pack(filename: str, domain: str = "") -> StreamingResponse:
|
||||
if not filename.endswith(".zip"):
|
||||
raise HTTPException(status_code=404)
|
||||
name = filename[: -len(".zip")].lower()
|
||||
if name not in _load_packs() or not NC_USER:
|
||||
kind = filename[: -len(".zip")]
|
||||
name = domain.strip().lower()
|
||||
if kind not in _load_packs().get(name, {}) or not NC_USER:
|
||||
raise HTTPException(status_code=404)
|
||||
|
||||
client = _client(timeout=httpx.Timeout(30.0, read=None))
|
||||
upstream = client.send(client.build_request(
|
||||
"GET", _dav_url(f"{name}.zip"), headers={"Accept-Encoding": "identity"}
|
||||
"GET", _dav_url(name, f"{kind}.zip"), headers={"Accept-Encoding": "identity"}
|
||||
), stream=True)
|
||||
if upstream.status_code != 200:
|
||||
upstream.close()
|
||||
@@ -195,7 +218,7 @@ def download_pack(filename: str) -> StreamingResponse:
|
||||
upstream.close()
|
||||
client.close()
|
||||
|
||||
headers = {"Content-Disposition": f'attachment; filename="{name}.zip"'}
|
||||
headers = {"Content-Disposition": f'attachment; filename="{kind}.zip"'}
|
||||
if "content-length" in upstream.headers:
|
||||
headers["Content-Length"] = upstream.headers["content-length"]
|
||||
return StreamingResponse(body(), media_type="application/zip", headers=headers)
|
||||
|
||||
@@ -16,7 +16,7 @@ services:
|
||||
expose:
|
||||
- "8000"
|
||||
environment:
|
||||
# 리소스팩 저장소 (share.tkrmagid.kr). 비밀번호는 같은 폴더의 .env 에 둔다.
|
||||
# 팩 저장소 (share.tkrmagid.kr). 비밀번호는 같은 폴더의 .env 에 둔다.
|
||||
NEXTCLOUD_URL: ${NEXTCLOUD_URL:-http://192.168.10.10:8080}
|
||||
NEXTCLOUD_USER: ${NEXTCLOUD_USER:-}
|
||||
NEXTCLOUD_PASSWORD: ${NEXTCLOUD_PASSWORD:-}
|
||||
@@ -42,7 +42,7 @@ services:
|
||||
container_name: mc-filter-nginx
|
||||
ports:
|
||||
- "8080:80" # 대시보드 접근 포트 (외부 포트포워딩 금지 권장)
|
||||
- "8081:81" # 리소스팩 공개 다운로드 전용 (/pack/ 만 응답)
|
||||
- "8081:81" # 팩 공개 다운로드 전용 (/pack/ 만 응답)
|
||||
depends_on:
|
||||
- api
|
||||
- frontend
|
||||
|
||||
@@ -15,7 +15,7 @@ export default function App() {
|
||||
<nav>
|
||||
<NavLink to="/" end>대시보드</NavLink>
|
||||
<NavLink to="/domains">허용 도메인</NavLink>
|
||||
<NavLink to="/packs">리소스팩</NavLink>
|
||||
<NavLink to="/packs">팩</NavLink>
|
||||
<NavLink to="/logs">접속 로그</NavLink>
|
||||
<NavLink to="/settings">설정</NavLink>
|
||||
</nav>
|
||||
|
||||
@@ -39,7 +39,7 @@ export const api = {
|
||||
return req('/logs' + (q ? `?${q}` : ''), { method: 'DELETE' })
|
||||
},
|
||||
packs: () => req('/packs'),
|
||||
deletePack: (name) =>
|
||||
req(`/packs/${encodeURIComponent(name)}`, { method: 'DELETE' }),
|
||||
deletePack: (name, kind) =>
|
||||
req(`/packs/${encodeURIComponent(name)}/${kind}`, { method: 'DELETE' }),
|
||||
restart: () => req('/proxy/restart', { method: 'POST' }),
|
||||
}
|
||||
|
||||
@@ -7,6 +7,17 @@ function fmtSize(n) {
|
||||
return `${n} B`
|
||||
}
|
||||
|
||||
// 종류별로 복사할 텍스트와 안내 문구
|
||||
const HINTS = {
|
||||
resourcepack: '접속하는 클라이언트가 자동으로 받습니다. 아래 줄을 MC 서버 server.properties 에 붙여 넣고 재시작하세요. 팩을 바꾸면 SHA1 도 바뀝니다.',
|
||||
datapack: '클라이언트가 자동으로 받지 않습니다. 받아서 서버 월드의 datapacks 폴더에 넣으세요.',
|
||||
modpack: '플레이어에게 이 주소를 알려 주세요.',
|
||||
}
|
||||
|
||||
function copyText(kind, pack) {
|
||||
return kind === 'resourcepack' ? propsSnippet(pack) : pack.url
|
||||
}
|
||||
|
||||
function propsSnippet(pack) {
|
||||
return [
|
||||
`resource-pack=${pack.url}`,
|
||||
@@ -16,10 +27,10 @@ function propsSnippet(pack) {
|
||||
}
|
||||
|
||||
// fetch 는 업로드 진행률을 못 주므로 XHR 사용
|
||||
function uploadPack(domain, file, onProgress) {
|
||||
function uploadPack(domain, kind, file, onProgress) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest()
|
||||
xhr.open('PUT', `/api/packs/${encodeURIComponent(domain)}`)
|
||||
xhr.open('PUT', `/api/packs/${encodeURIComponent(domain)}/${kind}`)
|
||||
xhr.upload.onprogress = (e) => {
|
||||
if (e.lengthComputable) onProgress(Math.round((e.loaded / e.total) * 100))
|
||||
}
|
||||
@@ -39,7 +50,7 @@ function uploadPack(domain, file, onProgress) {
|
||||
export default function Packs() {
|
||||
const [data, setData] = useState(null)
|
||||
const [error, setError] = useState(null)
|
||||
const [progress, setProgress] = useState({}) // domain -> %
|
||||
const [progress, setProgress] = useState({}) // "domain/kind" -> %
|
||||
const [copied, setCopied] = useState(null)
|
||||
|
||||
async function load() {
|
||||
@@ -53,38 +64,39 @@ export default function Packs() {
|
||||
|
||||
useEffect(() => { load() }, [])
|
||||
|
||||
async function onFile(domain, e) {
|
||||
async function onFile(domain, kind, e) {
|
||||
const file = e.target.files?.[0]
|
||||
e.target.value = ''
|
||||
if (!file) return
|
||||
setProgress((p) => ({ ...p, [domain]: 0 }))
|
||||
const key = `${domain}/${kind}`
|
||||
setProgress((p) => ({ ...p, [key]: 0 }))
|
||||
try {
|
||||
await uploadPack(domain, file, (pct) => setProgress((p) => ({ ...p, [domain]: pct })))
|
||||
await uploadPack(domain, kind, file, (pct) => setProgress((p) => ({ ...p, [key]: pct })))
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setProgress((p) => { const n = { ...p }; delete n[domain]; return n })
|
||||
setProgress((p) => { const n = { ...p }; delete n[key]; return n })
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(domain) {
|
||||
if (!confirm(`${domain} 의 리소스팩을 삭제할까요?`)) return
|
||||
async function remove(domain, kind) {
|
||||
if (!confirm(`${domain} 의 ${data.types[kind]}을(를) 삭제할까요?`)) return
|
||||
try {
|
||||
await api.deletePack(domain)
|
||||
await api.deletePack(domain, kind)
|
||||
await load()
|
||||
} catch (e) { setError(e.message) }
|
||||
}
|
||||
|
||||
async function copy(domain, text) {
|
||||
async function copy(key, text) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
setCopied(domain)
|
||||
setCopied(key)
|
||||
setTimeout(() => setCopied(null), 1500)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>리소스팩</h1>
|
||||
<h1>팩</h1>
|
||||
{error && <div className="error">{error}</div>}
|
||||
{data && !data.storage_configured && (
|
||||
<div className="error">
|
||||
@@ -92,56 +104,69 @@ export default function Packs() {
|
||||
</div>
|
||||
)}
|
||||
<p className="muted">
|
||||
팩은 share.tkrmagid.kr 에 저장되고 아래 URL 로 공개됩니다. 해당 도메인이 연결된 MC 서버의
|
||||
server.properties 에 설정 줄을 붙여 넣고 서버를 재시작하세요. 팩을 바꾸면 SHA1 이 바뀌므로
|
||||
다시 붙여 넣어야 합니다.
|
||||
팩은 share.tkrmagid.kr 에 저장되고 https://mc.tkrmagid.kr/pack/<종류>.zip?domain=<도메인> 주소로 공개됩니다.
|
||||
</p>
|
||||
|
||||
{data && data.packs.length === 0 && (
|
||||
{data && data.domains.length === 0 && (
|
||||
<div className="card muted">등록된 도메인이 없습니다. 허용 도메인 페이지에서 먼저 추가하세요.</div>
|
||||
)}
|
||||
|
||||
{data?.packs.map(({ domain, pack }) => {
|
||||
const busy = domain in progress
|
||||
return (
|
||||
<section className="card" key={domain}>
|
||||
<h2><code>{domain}</code></h2>
|
||||
{pack ? (
|
||||
<>
|
||||
<div className="muted">
|
||||
{pack.original_name} · {fmtSize(pack.size)} ·{' '}
|
||||
{new Date(pack.uploaded_at * 1000).toLocaleString()}
|
||||
{data?.domains.map(({ domain, packs }) => (
|
||||
<section className="card" key={domain}>
|
||||
<h2><code>{domain}</code></h2>
|
||||
{Object.entries(data.types).map(([kind, label]) => {
|
||||
const pack = packs[kind]
|
||||
const key = `${domain}/${kind}`
|
||||
const busy = key in progress
|
||||
return (
|
||||
<div key={kind} style={{ marginTop: 16 }}>
|
||||
<strong>{label}</strong>{' '}
|
||||
{pack ? (
|
||||
<span className="muted">
|
||||
{pack.original_name} · {fmtSize(pack.size)} ·{' '}
|
||||
{new Date(pack.uploaded_at * 1000).toLocaleString()}
|
||||
</span>
|
||||
) : (
|
||||
<span className="muted">없음</span>
|
||||
)}
|
||||
{pack && (
|
||||
<>
|
||||
<div className="muted">{HINTS[kind]}</div>
|
||||
<textarea
|
||||
readOnly
|
||||
rows={kind === 'resourcepack' ? 3 : 1}
|
||||
value={copyText(kind, pack)}
|
||||
style={{ maxWidth: '100%', fontFamily: 'ui-monospace, Consolas, monospace' }}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<div className="actions">
|
||||
<label>
|
||||
<input
|
||||
type="file"
|
||||
accept=".zip,application/zip"
|
||||
disabled={busy || !data.storage_configured}
|
||||
onChange={(e) => onFile(domain, kind, e)}
|
||||
style={{ display: 'none' }}
|
||||
/>
|
||||
<span className={`btn${busy || !data.storage_configured ? ' disabled' : ''}`}>
|
||||
{busy ? `업로드 중… ${progress[key]}%` : pack ? '교체 업로드' : '업로드'}
|
||||
</span>
|
||||
</label>
|
||||
{pack && (
|
||||
<>
|
||||
<button className="ghost" onClick={() => copy(key, copyText(kind, pack))}>
|
||||
{copied === key ? '복사됨' : kind === 'resourcepack' ? '설정 복사' : '주소 복사'}
|
||||
</button>
|
||||
<button className="danger" onClick={() => remove(domain, kind)} disabled={busy}>삭제</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<textarea readOnly rows={3} value={propsSnippet(pack)} style={{ maxWidth: '100%', fontFamily: 'ui-monospace, Consolas, monospace' }} />
|
||||
</>
|
||||
) : (
|
||||
<div className="muted">리소스팩 없음</div>
|
||||
)}
|
||||
<div className="actions">
|
||||
<label>
|
||||
<input
|
||||
type="file"
|
||||
accept=".zip,application/zip"
|
||||
disabled={busy || !data.storage_configured}
|
||||
onChange={(e) => onFile(domain, e)}
|
||||
style={{ display: 'none' }}
|
||||
/>
|
||||
<span className={`btn${busy || !data.storage_configured ? ' disabled' : ''}`}>
|
||||
{busy ? `업로드 중… ${progress[domain]}%` : pack ? '교체 업로드' : '업로드'}
|
||||
</span>
|
||||
</label>
|
||||
{pack && (
|
||||
<>
|
||||
<button className="ghost" onClick={() => copy(domain, propsSnippet(pack))}>
|
||||
{copied === domain ? '복사됨' : '설정 복사'}
|
||||
</button>
|
||||
<button className="danger" onClick={() => remove(domain)} disabled={busy}>삭제</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ http {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# 리소스팩 업로드: 크기 제한 없음 (Nextcloud 로 넘어가므로)
|
||||
# 팩 업로드: 크기 제한 없음 (Nextcloud 로 넘어가므로)
|
||||
# 정규식으로 둔다: prefix "/api/packs/" 면 nginx 가 GET /api/packs 를 301 로 돌려버린다
|
||||
location ~ ^/api/packs/ {
|
||||
client_max_body_size 0;
|
||||
@@ -54,7 +54,7 @@ http {
|
||||
}
|
||||
}
|
||||
|
||||
# 리소스팩 공개 다운로드 전용 (외부 mc.tkrmagid.kr/pack/ 이 이 포트로 연결됨).
|
||||
# 팩 공개 다운로드 전용 (외부 mc.tkrmagid.kr/pack/ 이 이 포트로 연결됨).
|
||||
# 대시보드/API 와 포트를 분리해서, 외부에서는 /pack/ 말고는 아무것도 닿지 않게 한다.
|
||||
server {
|
||||
listen 81;
|
||||
|
||||
Reference in New Issue
Block a user