ゲームサーバーとしてのみ使用したいejabberdサーバーをセットアップしました。
セキュリティに関して注意しなければならないことと、ゲームサーバーとして使用できるようにするために必要な手順は何ですか?もちろん、ローカルユーザー間の通信のみを有効にしたいので、他のサーバーからJIDへの通信ができない場合があります。
IRCやサーバー間などの機能を無効にするにはどうすればよいですか?これはで行う必要がありejabberd.cfg
ますよね?これらの段落をコメントアウトする必要がありますか、それともオプションとして空の括弧を埋める必要がありますか?
次のアクセス制御リストを定義しました。
[{acl, admin, {user, "admin", "localhost"}},
{acl, admin, {user, "admin", "***.***.***.***"}},
{acl, local, {server, "localhost"}},
{acl, local, {server, "***.***.***.***"}}].
アクセス権に関して、次の定義は問題ありませんか、それともPubSubを除くすべての通信チャネルを無効にする必要がありますか?
[{access, c2s, [{deny, blocked}, {allow, all}]},
{access, pubsub_createnode, [{allow, all}]},
{access, s2s_shaper, [{fast, all}]},
{access, c2s_shaper, [{none, admin}, {normal, all}]},
{access, muc, [{allow, all}]},
{access, max_user_sessions, [{2, all}]},
{access, configure, [{allow, admin}]},
{access, muc_admin, [{allow, admin}]},
{access, max_user_offline_messages,
[{5000, admin}, {100, all}]},
{access, announce, [{allow, admin}]},
{access, register, [{deny, all}]},
{access, local, [{allow, local}]}].
smack
その後、 /などのクライアントライブラリを介してサーバーにアクセスできますasmack
か、それともBOSH、HTTPポーリングなどが必要ですか?通常、XMPPポートはモバイルデバイスで開いていますか?
潜在的なセキュリティリスクのあるゲームサーバーを実行したくないので、上記のセキュリティに関する考慮事項は私にとって最も重要です。しかし、それを除けば、PubSubを実際に実行することはまだできません。
クライアント側では、Androidアプリケーションで、asmackライブラリと次のコードを使用して新しいXMPPセッションを開始し、メッセージを送信します。
private void startXMPP() {
new Thread(new Runnable() {
public void run() {
try {
org.jivesoftware.smackx.ConfigureProviderManager.configureProviderManager();
ConnectionConfiguration xmppConfig = new ConnectionConfiguration("123.123.123.123");
xmppConfig.setDebuggerEnabled(true);
if (Build.VERSION.SDK_INT >= 14) {
xmppConfig.setTruststoreType("AndroidCAStore");
xmppConfig.setTruststorePassword(null);
xmppConfig.setTruststorePath(null);
xmppConfig.setSendPresence(true);
xmppConfig.setSecurityMode(SecurityMode.disabled);
}
else {
xmppConfig.setTruststoreType("BKS");
String path = System.getProperty("javax.net.ssl.trustStore");
if (path == null) {
path = "/system/etc/security/cacerts.bks";
}
xmppConfig.setTruststorePath(path);
}
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
XMPPConnection xmpp = new XMPPConnection(xmppConfig);
xmpp.connect();
xmpp.login("john", "password");
PubSubManager xmppPubsub = new PubSubManager(xmpp);
ConfigureForm form = new ConfigureForm(FormType.submit);
form.setPersistentItems(false);
form.setDeliverPayloads(true);
form.setAccessModel(AccessModel.open);
form.setPublishModel(PublishModel.open);
form.setSubscribe(true);
LeafNode xmppNode;
try {
xmppNode = (LeafNode) xmppPubsub.createNode("TESTNODE", form);
}
catch (XMPPException e) {
xmppNode = (LeafNode) xmppPubsub.getNode("TESTNODE");
}
SimplePayload payload = new SimplePayload("book", "pubsub:test:book", "");
xmppNode.addItemEventListener(new ItemEventCoordinator<Item>());
xmppNode.subscribe("john@123.123.123.123");
xmppNode.publish(new PayloadItem<SimplePayload>(payload));
}
catch (Exception e) {
System.out.println("XMPP Connection failed!");
e.printStackTrace();
}
}
}).start();
}
残念ながら、これは機能しません。理由がわかりますか?デバッグを有効にしているので、LogCatに次のエラーメッセージが表示されます。
<iq from='pubsub.123.123.123.123' to='john@123.123.123.123/Smack' id='Jf****6' type='result'><pubsub xmlns='http://jabber.org/protocol/pubsub'><subscription jid='john@123.123.123.123' subscription='subscribed' subid='53******B2'/></pubsub></iq>
<iq id="Je4Mf-7" to="pubsub.123.123.123.123" type="set"><pubsub xmlns="http://jabber.org/protocol/pubsub"><publish node='TESTNODE'><item></item></publish></pubsub></iq>
<iq from='pubsub.123.123.123.123' to='john@123.123.123.123/Smack' type='error' id='Jf****7'><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='TESTNODE'><item/></publish></pubsub><error code='400' type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><payload-required xmlns='http://jabber.org/protocol/pubsub#errors'/></error></iq>
編集:
ドキュメントで説明されているように、PubSubノード名を設定していませんhome/server/username/whatever
。しかし、少なくともノードの作成は機能していますね。参加しているすべてのユーザーがそのPubSubノードに参加できるように、「game234234」などの名前が必要なため、この形式の名前は必要ありません。
pubsub.***.***.***.***
さらに、私はサブドメインを作成していないので、そこにない連絡の試みがあるようですpubsub
。それが問題の原因ですか?PubSubはそのサブドメイン経由でのみ利用できますか?そのサブドメインに何を設定すればよいかわからないので、サブドメインのないIPでのみPubSubを使用したいと思います。