<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>ブログ on EBIOS GAMES</title><link>https://ebios-games.com/civ4/blog/</link><description>Recent content in ブログ on EBIOS GAMES</description><generator>Hugo</generator><language>ja</language><lastBuildDate>Sat, 19 Sep 2026 17:04:00 +0900</lastBuildDate><atom:link href="https://ebios-games.com/civ4/blog/index.xml" rel="self" type="application/rss+xml"/><item><title>このブログについて</title><link>https://ebios-games.com/civ4/blog/welcome-post/</link><pubDate>Fri, 11 Sep 2026 00:00:00 +0900</pubDate><guid>https://ebios-games.com/civ4/blog/welcome-post/</guid><description>Civ4 Internet Lobbyプロジェクトの技術記録を始めます</description><content:encoded><![CDATA[<p>Civilization IV のマルチプレイは、GameSpyのサービス終了後、有志によるロビーサーバーの実装によって続けられています。このブログでは、その一つとなる Civ4 Internet Lobbyプロジェクトに取り組む中で分かったことや直したこと等を記録していきます。</p>
<p>扱う予定のテーマ:</p>
<ul>
<li>GameSpyプロトコルの構造</li>
<li>NAT越え（NATNEG）の仕組み</li>
<li>運用上気づいた点</li>
</ul>
]]></content:encoded></item><item><title>Civ4 Internet Lobbyの成り立ち</title><link>https://ebios-games.com/civ4/blog/pylobby-origins/</link><pubDate>Sat, 19 Sep 2026 17:04:00 +0900</pubDate><guid>https://ebios-games.com/civ4/blog/pylobby-origins/</guid><description>Civ4 Internet Lobbyの成り立ち</description><content:encoded><![CDATA[<h2 id="gamespy終了後の仕組み">GameSpy終了後の仕組み</h2>
<p>オープンソースプロジェクトである <code>pylobby</code> は、<strong>Civilization IV のマルチプレイ・ロビー機能が依存していた GameSpy SDK のマスターサーバー群を、ゼロから再実装したもの</strong>である。GameSpy は2010年代にオンラインサービス事業を終了しており、公式のロビーサーバー（<code>gpcm.gamespy.com</code> 等）はすでに存在しない。Civ4 クライアント側のプロトコル実装は変更できないため、<strong>クライアントが「GameSpy のサーバーだ」と信じて話しかけてくる相手を、自前サーバー上に用意する</strong>というアプローチを取っている。具体的には、Civ4 クライアントの <code>hosts</code> ファイルで <code>gpcm.gamespy.com</code> 等のホスト名を自前サーバーの IP に向け、そこで <code>pylobby</code> をベースにしたサーバー実装(本プロジェクト「Civ4 Internet Lobby」)を稼働させている。</p>
<figure><svg viewBox="0 0 680 300" role="img" aria-labelledby="fig1-title fig1-desc" xmlns="http://www.w3.org/2000/svg" style="width:100%;height:auto;font-family:sans-serif;"><title id="fig1-title">GameSpy終了後のなりすまし構成</title><desc id="fig1-desc">かつてCiv4クライアントは実在するGameSpyのマスターサーバー群と通信していたが、GameSpyサービス終了後はhostsファイルでホスト名を自前サーバーのIPに向けることで、クライアントを改造せずにCiv4 Internet Lobbyへ通信させている。</desc><defs><marker id="arrow-hist" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="currentColor"/></marker></defs><text x="170" y="26" font-size="15" font-weight="600" text-anchor="middle" fill="currentColor">かつて</text><text x="510" y="26" font-size="15" font-weight="600" text-anchor="middle" fill="currentColor">現在(Civ4 Internet Lobby)</text><rect x="60" y="45" width="220" height="50" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="170" y="75" font-size="13" text-anchor="middle" fill="currentColor">Civ4 クライアント</text><line x1="170" y1="95" x2="170" y2="150" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-hist)"/><rect x="40" y="152" width="260" height="80" rx="6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="6 4" opacity="0.55"/><text x="170" y="182" font-size="13" text-anchor="middle" fill="currentColor" opacity="0.55">GameSpy マスターサーバー群</text><text x="170" y="200" font-size="11" text-anchor="middle" fill="currentColor" opacity="0.55">(gpcm.gamespy.com 等)</text><text x="170" y="252" font-size="11" text-anchor="middle" fill="currentColor" font-style="italic" opacity="0.7">2010年代にサービス終了・現存せず</text><rect x="400" y="45" width="220" height="50" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="510" y="75" font-size="13" text-anchor="middle" fill="currentColor">Civ4 クライアント(無改造)</text><line x1="510" y1="95" x2="510" y2="132" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-hist)"/><rect x="400" y="134" width="220" height="52" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="510" y="156" font-size="12" text-anchor="middle" fill="currentColor">hosts ファイルで書き換え</text><text x="510" y="174" font-size="11" text-anchor="middle" fill="currentColor">gpcm.gamespy.com → 自前サーバー</text><line x1="510" y1="186" x2="510" y2="222" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-hist)"/><rect x="400" y="224" width="220" height="56" rx="6" fill="none" stroke="currentColor" stroke-width="2.5"/><text x="510" y="248" font-size="13" font-weight="600" text-anchor="middle" fill="currentColor">Civ4 Internet Lobby</text><text x="510" y="266" font-size="11" text-anchor="middle" fill="currentColor">GameSpyになりすまして応答</text></svg><figcaption>クライアント側の実装は変更せず、通信先だけをhostsファイルで自前サーバーへ差し替えている。</figcaption></figure>
<h2 id="civ4-internet-lobbyの構成">Civ4 Internet Lobbyの構成</h2>
<p><code>pylobby</code> は GameSpy Presence（ログイン）とサーバーブラウザ（部屋一覧）を実装したものだが、<strong>NAT 越え（NATNEG）機能は含まれていなかった</strong>。Civ4 Internet Lobbyでは <code>pylobby</code> のコードをベースに、NATNEG サーバーを新規実装として追加し、実機検証を通じてプロトコルの確定仕様に合わせ込んだ。</p>
<figure><svg viewBox="0 0 680 300" role="img" aria-labelledby="fig2-title fig2-desc" xmlns="http://www.w3.org/2000/svg" style="width:100%;height:auto;font-family:sans-serif;"><title id="fig2-title">pylobbyの構成(既存部分と新規追加部分)</title><desc id="fig2-desc">上流のpylobbyが実装していたGameSpy PresenceとServerBrowserに、Civ4 Internet Lobbyが新規実装したNATNEGを組み合わせて構成している。</desc><defs><marker id="arrow-compose" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="currentColor"/></marker></defs><text x="210" y="50" font-size="14" font-weight="600" text-anchor="middle" fill="currentColor">既存(pylobbyベース)</text><rect x="40" y="60" width="340" height="140" rx="8" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="6 4"/><rect x="60" y="95" width="140" height="80" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="130" y="130" font-size="12" text-anchor="middle" fill="currentColor">GameSpy Presence</text><text x="130" y="148" font-size="11" text-anchor="middle" fill="currentColor">(ログイン)</text><rect x="220" y="95" width="140" height="80" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="290" y="130" font-size="12" text-anchor="middle" fill="currentColor">ServerBrowser</text><text x="290" y="148" font-size="11" text-anchor="middle" fill="currentColor">(部屋一覧)</text><text x="405" y="140" font-size="28" text-anchor="middle" fill="currentColor">+</text><rect x="430" y="75" width="210" height="110" rx="8" fill="none" stroke="currentColor" stroke-width="2.5"/><text x="535" y="115" font-size="15" font-weight="600" text-anchor="middle" fill="currentColor">NATNEG</text><text x="535" y="134" font-size="12" text-anchor="middle" fill="currentColor">(NAT越え)</text><text x="535" y="162" font-size="10.5" text-anchor="middle" fill="currentColor">Civ4 Internet Lobbyで新規実装</text><line x1="210" y1="200" x2="260" y2="236" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-compose)"/><line x1="535" y1="185" x2="460" y2="236" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-compose)"/><rect x="140" y="240" width="400" height="50" rx="6" fill="none" stroke="currentColor" stroke-width="2"/><text x="340" y="262" font-size="13" font-weight="600" text-anchor="middle" fill="currentColor">Civ4 Internet Lobby</text><text x="340" y="280" font-size="11" text-anchor="middle" fill="currentColor">(ログイン + 部屋一覧 + NAT越え)</text></svg><figcaption>ログインと部屋一覧はpylobbyの流れを汲み、NAT越え(NATNEG)をCiv4 Internet Lobbyが新規実装して組み合わせている。</figcaption></figure>
]]></content:encoded></item><item><title>システム全体像と通信シーケンス</title><link>https://ebios-games.com/civ4/blog/system-overview/</link><pubDate>Fri, 18 Sep 2026 15:43:00 +0900</pubDate><guid>https://ebios-games.com/civ4/blog/system-overview/</guid><description>3つの独立したサーバープロセスの役割と、部屋参加からNAT越えを経て直接通信が始まるまでの流れ</description><content:encoded><![CDATA[<p>システムは独立した2つのプロセス(<code>civgs-login</code>・<code>civgs-gamebrowser</code>)と、別途起動が必要なIRCサーバー(<code>civgs-ircd</code>)から成ります。2つのプロセスは互いに独立して動作しており、共有しているのはコードだけで、プロセス間通信は一切行いません。<code>civgs-ircd</code>が起動していないと、Civ4クライアントはログイン処理を完了できずフリーズしてしまいます。</p>
<h2 id="サーバー構成">サーバー構成</h2>
<figure>
<svg viewBox="0 0 680 300" role="img" aria-label="Civ4 Internet Lobbyのサーバー構成図。Civ4クライアントは civgs-login・civgs-gamebrowser・civgs-ircd という3つの独立したプロセスにそれぞれ接続する。civgs-loginとcivgs-gamebrowserはプロセス間通信を持たない。" style="max-width:100%;height:auto;">
  <defs>
    <marker id="arrow-overview" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto">
      <path d="M0,0 L10,5 L0,10 z" fill="currentColor"/>
    </marker>
  </defs>
  <rect x="250" y="20" width="180" height="48" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/>
  <text x="340" y="49" text-anchor="middle" font-size="13" fill="currentColor">Civ4クライアント</text>
  <rect x="20" y="150" width="180" height="70" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/>
  <rect x="250" y="150" width="180" height="70" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/>
  <rect x="480" y="150" width="180" height="70" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/>
  <text x="110" y="178" text-anchor="middle" font-size="13" fill="currentColor">civgs-login</text>
  <text x="110" y="198" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.75">TCP 29900・29901</text>
  <text x="340" y="178" text-anchor="middle" font-size="13" fill="currentColor">civgs-gamebrowser</text>
  <text x="340" y="198" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.75">TCP 28910</text>
  <text x="340" y="212" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.75">UDP 27900・27901</text>
  <text x="570" y="178" text-anchor="middle" font-size="13" fill="currentColor">civgs-ircd</text>
  <text x="570" y="198" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.75">TCP 6667</text>
  <line x1="300" y1="68" x2="130" y2="150" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-overview)"/>
  <line x1="340" y1="68" x2="340" y2="150" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-overview)"/>
  <line x1="380" y1="68" x2="550" y2="150" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-overview)"/>
  <text x="200" y="100" text-anchor="middle" font-size="11" fill="currentColor">ログイン・検索</text>
  <text x="362" y="100" text-anchor="start" font-size="11" fill="currentColor">部屋一覧・NAT越え</text>
  <text x="480" y="100" text-anchor="middle" font-size="11" fill="currentColor">在席確認</text>
  <line x1="200" y1="185" x2="250" y2="185" stroke="currentColor" stroke-width="1.2" stroke-dasharray="3,3"/>
  <text x="225" y="238" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.75">プロセス間通信なし</text>
  <text x="225" y="251" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.75">(コードのみ共有)</text>
</svg>
<figcaption>Civ4クライアントは civgs-login・civgs-gamebrowser・civgs-ircd という3つの独立したプロセスにそれぞれ接続する。civgs-loginとcivgs-gamebrowserはコードを共有するだけで、プロセス間通信は行わない。</figcaption>
</figure>
<table>
	<thead>
			<tr>
					<th>プロセス</th>
					<th>ポート</th>
					<th>役割</th>
					<th>対応するGameSpyドメイン</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td><code>civgs-login</code></td>
					<td>TCP 29900</td>
					<td>ログイン(GP presence)</td>
					<td><code>gpcm.gamespy.com</code></td>
			</tr>
			<tr>
					<td><code>civgs-login</code></td>
					<td>TCP 29901</td>
					<td>ユーザー検索(GP search)</td>
					<td><code>gpsp.gamespy.com</code></td>
			</tr>
			<tr>
					<td><code>civgs-gamebrowser</code></td>
					<td>TCP 28910</td>
					<td>部屋一覧(ServerBrowser)</td>
					<td><code>&lt;エディション&gt;.ms*.gamespy.com</code> 等</td>
			</tr>
			<tr>
					<td><code>civgs-gamebrowser</code></td>
					<td>UDP 27900</td>
					<td>ホストのハートビート(QR)</td>
					<td>同上</td>
			</tr>
			<tr>
					<td><code>civgs-gamebrowser</code></td>
					<td>UDP 27901</td>
					<td>NAT越え(NATNEG)</td>
					<td><code>natneg1〜3.gamespy.com</code></td>
			</tr>
			<tr>
					<td><code>civgs-ircd</code></td>
					<td>TCP 6667</td>
					<td>在席確認・チャット(peerchat)</td>
					<td><code>peerchat.gamespy.com</code></td>
			</tr>
	</tbody>
</table>
<h2 id="通信シーケンス部屋参加nat越え">通信シーケンス(部屋参加〜NAT越え)</h2>
<p>ホストが部屋を作成してから、参加者が直接通信を始めるまでの流れは次の通りです。</p>
<figure>
<svg viewBox="0 0 680 470" role="img" aria-label="部屋参加からNAT越え(NATNEG)を経て、ホストと参加者が直接通信を始めるまでの通信シーケンス図。" style="max-width:100%;height:auto;">
  <defs>
    <marker id="arrow-seq" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
      <path d="M0,0 L10,5 L0,10 z" fill="currentColor"/>
    </marker>
  </defs>
  <rect x="20" y="20" width="140" height="36" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/>
  <text x="90" y="43" text-anchor="middle" font-size="13" fill="currentColor">ホスト</text>
  <rect x="270" y="20" width="140" height="36" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/>
  <text x="340" y="35" text-anchor="middle" font-size="12" fill="currentColor">サーバー</text>
  <text x="340" y="49" text-anchor="middle" font-size="10" fill="currentColor" opacity="0.75">(civgs-gamebrowser)</text>
  <rect x="520" y="20" width="140" height="36" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/>
  <text x="590" y="43" text-anchor="middle" font-size="13" fill="currentColor">参加者</text>
  <line x1="90" y1="56" x2="90" y2="440" stroke="currentColor" stroke-width="1" stroke-dasharray="4,4" opacity="0.5"/>
  <line x1="340" y1="56" x2="340" y2="400" stroke="currentColor" stroke-width="1" stroke-dasharray="4,4" opacity="0.5"/>
  <line x1="590" y1="56" x2="590" y2="440" stroke="currentColor" stroke-width="1" stroke-dasharray="4,4" opacity="0.5"/>
  <line x1="90" y1="90" x2="340" y2="90" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <text x="215" y="82" text-anchor="middle" font-size="11" fill="currentColor">部屋を作成(QR開始・UDP 27900)</text>
  <line x1="590" y1="130" x2="340" y2="130" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <text x="465" y="122" text-anchor="middle" font-size="11" fill="currentColor">部屋一覧取得(TCP 28910)</text>
  <line x1="340" y1="170" x2="590" y2="170" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <text x="465" y="162" text-anchor="middle" font-size="11" fill="currentColor">一覧を返す</text>
  <line x1="590" y1="210" x2="340" y2="210" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <text x="465" y="202" text-anchor="middle" font-size="11" fill="currentColor">参加を選択→NATNEG開始</text>
  <line x1="90" y1="250" x2="340" y2="250" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <line x1="590" y1="250" x2="340" y2="250" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <text x="340" y="242" text-anchor="middle" font-size="11" fill="currentColor">INIT(UDP 27901)</text>
  <line x1="340" y1="290" x2="90" y2="290" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <line x1="340" y1="290" x2="590" y2="290" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <text x="340" y="282" text-anchor="middle" font-size="11" fill="currentColor">CONNECT ×2</text>
  <line x1="90" y1="330" x2="340" y2="330" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <line x1="590" y1="330" x2="340" y2="330" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <text x="340" y="322" text-anchor="middle" font-size="11" fill="currentColor">CONNECT_ACK</text>
  <line x1="90" y1="370" x2="340" y2="370" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <line x1="590" y1="370" x2="340" y2="370" stroke="currentColor" stroke-width="1.3" marker-end="url(#arrow-seq)"/>
  <text x="340" y="362" text-anchor="middle" font-size="11" fill="currentColor">REPORT / REPORT_ACK</text>
  <line x1="90" y1="420" x2="590" y2="420" stroke="currentColor" stroke-width="2.5" marker-start="url(#arrow-seq)" marker-end="url(#arrow-seq)"/>
  <text x="340" y="410" text-anchor="middle" font-size="11" fill="currentColor">直接通信開始(UDP 2056・サーバーを介さない)</text>
</svg>
<figcaption>部屋参加からNAT越え(NATNEG)の4回のやり取りを経て、ホストと参加者が直接通信を始めるまでの流れ。NATNEG成立後はサーバーを経由しない。</figcaption>
</figure>
<ol>
<li>ホストが部屋を作成すると、<code>civgs-gamebrowser</code>へのハートビート(QR、UDP 27900)が始まる</li>
<li>参加者が部屋一覧を取得する(TCP 28910)</li>
<li>参加者が部屋への参加を選ぶと、NAT越え(NATNEG)処理が始まる</li>
<li>ホスト・参加者の双方から<code>civgs-gamebrowser</code>へ<code>INIT</code>を送る(UDP 27901)</li>
<li>サーバーは両者の通信先アドレスへ<code>CONNECT</code>を能動的に送信する(それぞれ2回ずつ)</li>
<li>両者がサーバーへ<code>CONNECT_ACK</code>を返す</li>
<li><code>REPORT</code>・<code>REPORT_ACK</code>のやり取りが完了する</li>
<li>ホストと参加者の間で直接通信が始まる(ゲームポート、UDP 2056。以降サーバーは経由しない)</li>
</ol>
<p>各プレイヤー側でのポート開放が不要なのは、このNAT越え処理のおかげです。</p>
]]></content:encoded></item><item><title>ログイン時のpeerchat/IRC通信(TCP 6667)について</title><link>https://ebios-games.com/civ4/blog/peerchat-irc/</link><pubDate>Sat, 19 Sep 2026 12:00:00 +0900</pubDate><guid>https://ebios-games.com/civ4/blog/peerchat-irc/</guid><description>ロビーへのログイン時に必須のIRCハンドシェイク(TCP 6667)が何のためにあるのか、なぜフリーズの原因になり得るのか、部屋への参加処理とは無関係であることを解説</description><content:encoded><![CDATA[<h2 id="この通信は何のためにあるのか">この通信は何のためにあるのか</h2>
<p>Civ4のマルチプレイでロビーにログインする際、クライアントは裏側で複数のGameSpy系サーバーと順番に通信している。その中の1つが<code>peerchat.gamespy.com</code>(TCP 6667)で、これは目に見えるチャット機能ではなく、<strong>ログイン処理の一部として必須のハンドシェイク</strong>である。クライアントは接続直後に<code>CRYPT</code>という拡張コマンドを送り、サーバーからの暗号チャレンジ応答(<code>705</code>)を待つ。この一往復が成立しないと、クライアントはロビー画面にたどり着けない。</p>
<figure><svg viewBox="0 0 680 400" role="img" aria-labelledby="fig1-title fig1-desc" xmlns="http://www.w3.org/2000/svg" style="width:100%;height:auto;font-family:sans-serif;"><title id="fig1-title">ログイン処理内でのIRCハンドシェイクの位置づけ</title><desc id="fig1-desc">Civ4クライアントはGameSpy Presence認証に続けてpeerchat/IRC(TCP 6667)へ接続しCRYPTコマンドを送る。705応答が返ればロビー画面へ進み、応答がなければ無応答のままフリーズする。</desc><defs><marker id="arrow-login" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="currentColor"/></marker></defs><rect x="250" y="15" width="180" height="45" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="340" y="43" font-size="13" text-anchor="middle" fill="currentColor">Civ4 クライアント</text><line x1="340" y1="60" x2="340" y2="93" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-login)"/><rect x="190" y="97" width="300" height="55" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="340" y="122" font-size="13" text-anchor="middle" fill="currentColor">GameSpy Presence認証</text><text x="340" y="140" font-size="11" text-anchor="middle" fill="currentColor">(TCP 29900・ログイン)</text><line x1="340" y1="152" x2="340" y2="185" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-login)"/><rect x="170" y="189" width="340" height="68" rx="6" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="340" y="214" font-size="14" font-weight="600" text-anchor="middle" fill="currentColor">IRCハンドシェイク</text><text x="340" y="232" font-size="11" text-anchor="middle" fill="currentColor">(peerchat, TCP 6667)</text><text x="340" y="250" font-size="11" text-anchor="middle" fill="currentColor">CRYPTコマンド → 705応答を待つ</text><line x1="340" y1="257" x2="150" y2="298" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-login)"/><line x1="340" y1="257" x2="530" y2="298" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-login)"/><rect x="40" y="302" width="220" height="70" rx="6" fill="none" stroke="currentColor" stroke-width="2.5"/><text x="150" y="326" font-size="13" font-weight="600" text-anchor="middle" fill="currentColor">705応答あり</text><text x="150" y="344" font-size="11" text-anchor="middle" fill="currentColor">→ ロビー画面へ</text><text x="150" y="362" font-size="11" text-anchor="middle" fill="currentColor">(civgs-ircdが正常稼働)</text><rect x="420" y="302" width="220" height="70" rx="6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="6 4" opacity="0.6"/><text x="530" y="326" font-size="13" font-weight="600" text-anchor="middle" fill="currentColor" opacity="0.75">705応答なし</text><text x="530" y="344" font-size="11" text-anchor="middle" fill="currentColor" opacity="0.75">→ 無応答のままフリーズ</text><text x="530" y="362" font-size="11" text-anchor="middle" fill="currentColor" opacity="0.75">(標準IRCサーバー等)</text></svg><figcaption>peerchat(TCP 6667)でのCRYPTハンドシェイクが成立しないと、クライアントはエラーも出さずに無応答のままフリーズする。</figcaption></figure>
<h2 id="なぜ普通のircサーバーでは動かないのか">なぜ普通のIRCサーバーでは動かないのか</h2>
<p>一般的なIRCサーバー実装(標準の<code>miniircd</code>本家など)は、GameSpy独自の<code>CRYPT</code>コマンドを理解しない。この場合に起きることは2通りある。</p>
<ul>
<li>そもそも接続できない場合: クライアントはログイン自体を取り消し、「サーバー接続不能: ゲーム検索サーバーと接続できませんでした」という分かりやすいエラーを表示する。</li>
<li>接続はできるが<code>CRYPT</code>に応答が返らない場合: <strong>エラーメッセージが一切出ないまま、クライアントが無応答でフリーズする。</strong></li>
</ul>
<p>後者が厄介なのは、原因がひと目で分からないことである。Civ4 Internet Lobbyでは、<code>CRYPT</code>/<code>705</code>応答と<code>civ4</code>/<code>civ4bts</code>/<code>civ4btsjp</code>用の暗号レイヤーを実装した<a href="https://github.com/Zulan/miniircd"><code>Zulan/miniircd</code></a>フォークを<code>civgs-ircd</code>として稼働させることで、この問題を解決している。</p>
<figure><svg viewBox="0 0 680 300" role="img" aria-labelledby="fig3-title fig3-desc" xmlns="http://www.w3.org/2000/svg" style="width:100%;height:auto;font-family:sans-serif;"><title id="fig3-title">標準IRCサーバーとcivgs-ircdでのCRYPTハンドシェイクの違い</title><desc id="fig3-desc">標準のIRCサーバーはGameSpy独自のCRYPTコマンドに応答できず無応答のままフリーズするが、civgs-ircd(Zulanフォーク)はCRYPTコマンドに705応答を返しログイン処理が続行する。</desc><defs><marker id="arrow-crypt" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="currentColor"/></marker></defs><text x="180" y="15" font-size="13" font-weight="600" text-anchor="middle" fill="currentColor">標準IRCサーバーの場合</text><text x="520" y="15" font-size="13" font-weight="600" text-anchor="middle" fill="currentColor">civgs-ircd(対応フォーク)の場合</text><text x="100" y="38" font-size="12" text-anchor="middle" fill="currentColor">Civ4 クライアント</text><text x="260" y="38" font-size="12" text-anchor="middle" fill="currentColor" opacity="0.7">標準IRCサーバー</text><line x1="100" y1="48" x2="100" y2="260" stroke="currentColor" stroke-width="1.5" stroke-dasharray="5 4" opacity="0.6"/><line x1="260" y1="48" x2="260" y2="260" stroke="currentColor" stroke-width="1.5" stroke-dasharray="5 4" opacity="0.6"/><line x1="100" y1="95" x2="260" y2="95" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-crypt)"/><text x="180" y="85" font-size="10" text-anchor="middle" fill="currentColor">CRYPT des 1 civ4bts</text><text x="260" y="120" font-size="11" text-anchor="middle" fill="currentColor" opacity="0.6">CRYPTを理解できない</text><text x="180" y="158" font-size="20" text-anchor="middle" fill="currentColor" opacity="0.6">&#10005;</text><text x="180" y="180" font-size="11" text-anchor="middle" fill="currentColor" opacity="0.6">応答なし(705が返らない)</text><text x="100" y="230" font-size="12" font-weight="600" text-anchor="middle" fill="currentColor">無応答のまま</text><text x="100" y="248" font-size="12" font-weight="600" text-anchor="middle" fill="currentColor">フリーズ</text><text x="440" y="38" font-size="12" text-anchor="middle" fill="currentColor">Civ4 クライアント</text><text x="600" y="38" font-size="12" text-anchor="middle" fill="currentColor">civgs-ircd</text><line x1="440" y1="48" x2="440" y2="260" stroke="currentColor" stroke-width="1.5"/><line x1="600" y1="48" x2="600" y2="260" stroke="currentColor" stroke-width="1.5"/><line x1="440" y1="95" x2="600" y2="95" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-crypt)"/><text x="520" y="85" font-size="10" text-anchor="middle" fill="currentColor">CRYPT des 1 civ4bts</text><line x1="600" y1="150" x2="440" y2="150" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-crypt)"/><text x="520" y="140" font-size="10" text-anchor="middle" fill="currentColor">705(暗号チャレンジ応答)</text><text x="440" y="230" font-size="12" font-weight="600" text-anchor="middle" fill="currentColor">ログイン処理を続行</text><text x="440" y="248" font-size="11" text-anchor="middle" fill="currentColor">→ ロビー画面へ</text></svg><figcaption>標準のIRCサーバーはGameSpy独自のCRYPTコマンドに応答できずフリーズの原因になるが、civgs-ircd(Zulanフォーク)はこれに対応しているため正常にログインできる。</figcaption></figure>
<h2 id="部屋に参加できない原因ではない">「部屋に参加できない」原因ではない</h2>
<p>もう一つ、誤解されやすい点がある。<strong>このTCP 6667通信は、部屋への参加処理そのものとは無関係</strong>である。実際のパケットキャプチャでは、参加時のUDP 2056ハンドシェイクが完了してから38秒も経ってから、ようやく6667の通信が発生していることが確認できている。6667は参加とは独立した、buddy/chat presenceのための定期的なバックグラウンド処理である。</p>
<figure><svg viewBox="0 0 680 220" role="img" aria-labelledby="fig2-title fig2-desc" xmlns="http://www.w3.org/2000/svg" style="width:100%;height:auto;font-family:sans-serif;"><title id="fig2-title">UDP 2056の参加ハンドシェイクとTCP 6667の時間差</title><desc id="fig2-desc">実測では、部屋参加時のUDP 2056ハンドシェイク完了から約38秒後にTCP 6667のIRC通信が発生しており、両者は独立した処理であることを示している。</desc><defs><marker id="arrow-timeline" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="currentColor"/></marker></defs><line x1="60" y1="140" x2="620" y2="140" stroke="currentColor" stroke-width="1.5" marker-end="url(#arrow-timeline)"/><text x="600" y="128" font-size="11" text-anchor="middle" fill="currentColor" opacity="0.75">時間</text><line x1="150" y1="120" x2="150" y2="148" stroke="currentColor" stroke-width="1.5"/><text x="150" y="95" font-size="12" font-weight="600" text-anchor="middle" fill="currentColor">UDP 2056</text><text x="150" y="113" font-size="11" text-anchor="middle" fill="currentColor">参加ハンドシェイク完了</text><line x1="480" y1="120" x2="480" y2="148" stroke="currentColor" stroke-width="1.5"/><text x="480" y="95" font-size="12" font-weight="600" text-anchor="middle" fill="currentColor">TCP 6667</text><text x="480" y="113" font-size="11" text-anchor="middle" fill="currentColor">IRC通信開始</text><line x1="150" y1="165" x2="150" y2="171" stroke="currentColor" stroke-width="1.5"/><line x1="480" y1="165" x2="480" y2="171" stroke="currentColor" stroke-width="1.5"/><line x1="150" y1="165" x2="480" y2="165" stroke="currentColor" stroke-width="1.5"/><text x="315" y="185" font-size="12" font-weight="600" text-anchor="middle" fill="currentColor">約38秒後(実測)</text><text x="340" y="208" font-size="12" text-anchor="middle" fill="currentColor" font-style="italic" opacity="0.85">6667の通信は参加のトリガーではない</text></svg><figcaption>6667のIRC通信は参加のトリガーではなく、独立したバックグラウンド処理であることが実測で確認できている。</figcaption></figure>
<p>つまり、部屋に参加できない・NAT越えがうまくいかないといった症状の原因を探すときは、この6667通信は切り分けて考えてよい(NAT越えの仕組みについては<a href="/civ4/blog/system-overview/">システム全体像と通信シーケンス</a>を参照)。逆に、ロビー画面に<strong>そもそも入れない・ログイン中にフリーズする</strong>という症状であれば、この6667のハンドシェイクが疑わしい候補になる。</p>
<p>そのようなときは、<a href="/civ4/guide/status/">稼働状況・お知らせ</a>ページを確認してほしい。ログイン(civgs-login)・ゲームブラウザ(civgs-gamebrowser)と並んで「IRC(civgs-ircd)」の行があり、緑色の「● 稼働中」であれば、このハンドシェイクを処理するサーバー側の準備はできている。ここが赤色の「● 停止中」になっている場合は、サーバー側の問題(このページで解説したcivgs-ircdの停止)が原因である可能性が高い。「● 稼働中」なのにフリーズする場合は、別の原因を疑う必要がある。</p>
]]></content:encoded></item></channel></rss>