bend_puzzle/README.md
33333-33333 9d70afb4cc
Some checks failed
BEND FIELD CI / release (push) Has been cancelled
BEND FIELD CI / production-bridge (push) Has been cancelled
t
2026-08-01 22:31:04 +09:00

205 lines
8.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# LinkField v48.0
LinkFieldは、サーバー上の**単一共有ワールド専用**です。ローカル盤面、同期コード、複数ワールド切替はありません。
## 起動
ZIPを展開したプロジェクト直下で実行します。
```bash
npm start
```
`npm start` は次を自動実行し、完了後すぐにコマンド入力へ戻ります。
1. 公開ファイルを一時ディレクトリで完成させ、ディレクトリ単位で切り替え
2. 稼働中の管理済みLinkFieldサーバーと旧版サーバーを安全に停止
3. 古いポート情報を削除
4. 自動再起動・ハートビート付きの監視プロセスをバックグラウンド起動
5. ローカルAPIと、設定済みの場合は公開URLの疎通を確認
6. 実際の使用ポートを `.linkfield-port` へ保存
8080番が使用中の場合は空きポートへ自動的に切り替わります。公開側のPHPブリッジは `.linkfield-port` を参照するため、固定ポートは不要です。
正常時の表示例:
```text
LinkField started in the background. The command prompt is available again.
PID: 12345
Local port: 3000
Public directory: /home/333/public_html/link-field
Log: /home/333/.local/share/LinkField/service/server.log
```
## 公開ディレクトリが異なる場合
Apacheが別のディレクトリを公開している場合だけ指定します。
```bash
LINK_FIELD_PUBLIC_DIR=/実際の公開ディレクトリ npm start
```
例:
```bash
LINK_FIELD_PUBLIC_DIR="$HOME/www/link-field" npm start
```
公開URLも指定すると、起動完了前にページとAPIの外部疎通を検査します。ユーザー名が `333` のホストではREADME記載のURLが自動使用されます。
```bash
LINK_FIELD_PUBLIC_DIR="$HOME/www/link-field" \
LINK_FIELD_PUBLIC_URL="https://example.com/link-field/" \
npm start
```
## 接続確認
```bash
curl 'https://2012r2.nishi.boats/~333/link-field/api-bridge.php?path=/api/cloud/status'
```
正常時は、`available``sharedWorld``singleWorld` がすべて `true` のJSONが返ります。
```json
{"available":true,"sharedWorld":true,"singleWorld":true,"realtime":true}
```
### Windows Apache/PHP host hardening
The public `Server` header must not expose exact Apache or PHP versions. Run the helper once without `-Apply` to preview the change, then run it again with `-Apply`. It creates timestamped backups and runs `httpd.exe -t`; if Apache rejects the configuration, both files are restored automatically.
```powershell
powershell -ExecutionPolicy Bypass -File scripts\harden-windows-host.ps1 `
-ApacheConfig C:\Apache24\conf\httpd.conf `
-PhpIni C:\php\php.ini
powershell -ExecutionPolicy Bypass -File scripts\harden-windows-host.ps1 `
-ApacheConfig C:\Apache24\conf\httpd.conf `
-PhpIni C:\php\php.ini `
-Apply
```
Use the actual configuration paths if Apache or PHP is installed elsewhere. Restart Apache after a successful apply, then verify the public deployment:
```bash
npm run smoke:public -- 'https://2012r2.nishi.boats/~333/link-field/'
```
If the project source is installed directly inside `public_html/link-field`, deploy the current hidden `.htaccess` and `server/apache-bridge.js` before restarting Node. LinkField then maintains a strict Apache allowlist automatically. A private source check must return HTTP 403 (404 is also acceptable when the source and web roots are separated):
```bash
curl -I 'https://2012r2.nishi.boats/~333/link-field/server.js'
curl -I 'https://2012r2.nishi.boats/~333/link-field/package.json'
```
If startup reports `Another LinkField server is already running` or asks for legacy-lock recovery, run the verified one-time recovery command and then start again:
```bash
npm run recover
npm start
npm run status
```
Recovery reads only LinkField's configured world/service lock files and refuses to stop a lock-holder unless it is a running Node process. Normal restarts do not require this command.
404の場合は、Apacheの公開先と自動配置先が一致していません。
```bash
npm run status
ls -l "$HOME/public_html/link-field/api-bridge.php"
```
## 管理コマンド
```bash
npm run status # 状態確認
npm run restart # 再起動
npm stop # 停止
npm run backup # 停止中の手動バックアップ
npm run backups # バックアップ一覧とチェックサム検証
npm run restore -- 2026-08-01T00-00-00-000Z # 停止中に復元
```
ログ確認:
```bash
tail -f "$HOME/.local/share/LinkField/service/server.log"
```
ログは10 MiBで自動ローテーションし、5世代を保持します。監視プロセスは5分間に最大10回までクラッシュしたサーバーを再起動します。
前面起動で直接ログを見る場合:
```bash
npm run start:foreground
```
前面起動中にそのターミナルへ入力できないのは正常です。終了は `Ctrl+C` です。
## データ保存先
共有ワールドの既定保存先は次の1か所です。
```text
/link-field/world
```
起動ユーザーがこのディレクトリへ書き込める必要があります。初回だけ権限を準備する場合は、サーバー管理権限で次を実行します。
```bash
sudo mkdir -p /link-field/world
sudo chown -R "$(id -un):$(id -gn)" /link-field
```
root直下を利用できない環境では、明示した1か所へ変更できます。全リリースで同じ値を設定してください。
```bash
LINK_FIELD_WORLD_DIR="$HOME/.local/share/LinkField/world" npm start
```
自動バックアップは既定で `/link-field/backups`(変更時はワールドディレクトリの隣の `backups`へ1日1回作成され、チェックサム付きで7世代保持されます。保存先は `LINK_FIELD_BACKUP_DIR` で変更できます。
展開フォルダやブラウザごとに別ワールドは作成されません。通常ウィンドウとシークレットウィンドウも同じサーバー正本を取得します。
## 盤面共有
未クリア盤面の線・特殊マス進行もサーバーへ保存されます。盤面を操作する際は専用の共有APIで占有権を即時取得し、利用できない場合だけリアルタイム経路へフォールバックします。占有応答前に指を離しても、ドラッグ軌跡は承認後に適用されます。接続状態は左下のFPS表示直上にある固定サイズの小型インジケーターで確認できます。
## 更新時の起動
`npm start` は、新しい公開ツリーを完成・検証してからアトミックに切り替え、旧LinkFieldサーバーを停止して監視プロセス配下で起動し直します。配置に失敗した場合は旧公開ツリーが維持されます。
```bash
npm start
```
起動エラー画面の「再試行」は共有サーバーへの再接続を行います。ブラウザ内バックアップの復元は実行しません。
## Apache・PHPの要件
- 推奨: `mod_rewrite``mod_proxy``mod_proxy_http``mod_proxy_wstunnel``mod_headers`
- HTTPプロキシが無い場合はPHPブリッジへ自動フォールバックします。
- `ServerTokens Prod``ServerSignature Off` をホスト設定で有効にし、Apache・PHP・OpenSSLをサポート中の版へ更新してください。
- `.htaccess` を有効にする公開ディレクトリには `AllowOverride All`または必要なRewrite/Header権限が必要です。
リリース後の公開確認:
```bash
LINK_FIELD_PUBLIC_URL="https://example.com/link-field/" npm run smoke:public
```
PHP実装を含むブリッジ統合テスト
```bash
npm run test:bridge
```
## v48.0の共有確定ルール
- 盤面の「プレイ中」は、ゲートまたは線端のつまみを押して操作を開始した時だけ発生します。カーソルを重ねただけでは発生しません。
- 占有に関する画面下部の通知は表示しません。
- 盤面がサーバーでクリア確定すると「プレイ中」は即時解除されます。ページ離脱・接続切断時も解除されます。
- クリア表示とジェム加算は、共有サーバーが解答を検証して受理した後に確定します。送信できなかった場合、端末だけがクリア済みになることはありません。
- 新規盤面を生成できるのは、その盤面をクリアしたプレイヤーだけです。生成後はサーバーへ保存され、他プレイヤーと再アクセス後の両方へ同じ盤面が返ります。
- 初回ラインカラーは、プレミアム商品を除いた通常ラインカラーから選ばれます。