Conversation
アプリ起動時に80→8080、443→8443のPort Forwardingルールを 自動で設定する機能を追加。 - PortForwardManagerクラスを新規作成 - 起動時に既存のルールを確認し、未設定の場合のみ設定 - osascriptでmacOSネイティブのパスワードダイアログを表示 - ユーザーがキャンセルした場合は適切にハンドリング Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
init()でloadConfig()をloadHosts()より先に呼び出すように変更。 これにより、ホスト一覧のレンダリング時にcurrentConfigが設定済みとなり、 カスタムドメインが正しく表示される。 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
目的
アプリ起動時にPort Forwardingを自動設定し、ユーザーが毎回手動で
pnpm pf:enableを実行する手間を省く。変更内容
概要
アプリ起動時に80→8080、443→8443のPort Forwardingルールを自動で設定する機能を追加。既に設定済みの場合はスキップし、毎回パスワードを要求しないようにした。
追加
src/main/port-forward-manager.ts- Port Forwarding管理クラスcheckRules(): 現在のpfctl設定を確認enable(): osascriptでパスワードダイアログを表示してルールを設定ensurePortForwarding(): 既存ルールを確認し、必要な場合のみ設定変更
src/main/index.ts- アプリ起動時にPort Forwarding設定を実行影響範囲
直接影響
間接影響
テスト
手動テスト(ユースケース)
🤖 Generated with Claude Code
Greptile Summary
アプリ起動時に80→8080、443→8443のPort Forwardingルールを自動設定する機能を追加。既存ルールがある場合はスキップし、未設定時のみosascriptでパスワードダイアログを表示してpfctlルールを設定する。
PortForwardManagerクラスを追加し、pfctlルールの確認・設定を管理checkRules()で現在のルールを非特権で確認(sudo -nでフォールバック付き)enable()でosascriptによる権限昇格とルール設定ensurePortForwarding()で既存ルール確認後、必要時のみ設定実行app.on('ready'))に自動実行し、エラーはログ出力のみで起動を妨げない実装は堅牢で、ポート値のバリデーション、エラーハンドリング、ユーザーキャンセル処理が適切に行われている。
Confidence Score: 5/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant App as Electronアプリ participant PFM as PortForwardManager participant System as macOS pfctl participant User as ユーザー App->>App: app.on('ready')起動 App->>PFM: new PortForwardManager(config) App->>PFM: ensurePortForwarding() PFM->>PFM: checkRules() PFM->>System: sudo -n pfctl -sr (非対話) alt sudo成功 System-->>PFM: 現在のルール一覧 else sudo失敗 PFM->>System: pfctl -sr (非特権) System-->>PFM: 現在のルール一覧 end PFM->>PFM: ルールが存在するか確認 alt ルール既存 PFM-->>App: 設定済み、スキップ else ルール未設定 PFM->>PFM: enable() PFM->>System: osascript with administrator privileges System->>User: パスワードダイアログ表示 alt ユーザーが認証 User-->>System: パスワード入力 System->>System: pfctlルール設定 System-->>PFM: 成功 PFM-->>App: Port Forwarding有効化完了 else ユーザーがキャンセル User-->>System: キャンセル System-->>PFM: User canceled エラー PFM-->>App: エラー (catchでログ出力) end end App->>App: プロキシサーバー起動