android - 在不公开服务名称和主机名的情况下使用 Android XMPP Smack
问题描述
正如您在下面的示例代码中看到的,Smack 要求我提供服务名称和主机。我将 Ejabberd 与 Linux 和一个 EC2 实例一起使用。
在检查 XMPP 客户端应用程序时,我看到了使用其他 XMPP 提供商创建帐户的选项。我担心当我向公众发布我的应用程序时,我的 EC2 实例的 DNS 将使人们能够创建大量帐户,而不是直接从我的应用程序而是从任何地方创建。
我应该使用 Firebase Functions 之类的东西吗?或者类似的东西?解决这个问题的最佳方法是什么?我只是不希望主机名公开。
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration
.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setServiceName(serverAddress);
config.setHost(serverAddress);
config.setPort(5222);
config.setResource(context.getResources().getString(R.string.resource_name));
config.setDebuggerEnabled(true);
config.setSendPresence(true);
XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
XMPPTCPConnection.setUseStreamManagementDefault(true);
mConnection = new XMPPTCPConnection(config.build());
XMPPConnectionListener connectionListener = new XMPPConnectionListener(type);
mConnection.addConnectionListener(connectionListener);
解决方案
仅当您在 ejabberd 配置中启用了该选项时,此帐户创建才有效。如果您使用 ProcessOne 和大多数 Linux 发行版提供的标准配置,则应该禁用它。它应该是这样的:
modules:
# other modules stuff
mod_register:
ip_access: trusted_network
您的 acl 应该与此类似:
acl:
# other irrelevant acls
loopback:
ip:
- "127.0.0.0/8"
- "::1/128"
所需的访问规则应如下所示:
access_rules:
trusted_network:
- allow: loopback
这都是根据配置的文档,可以在这里找到:https ://docs.ejabberd.im/admin/configuration/
推荐阅读
- javascript - 如何更新数据变化高图表上的数据表
- javascript - 从客户端接收 JSON 后 Res 无法正常工作
- c# - C# HttpClient 请求无法抓取(在 System.Net 和 Windows.Web http 请求上)
- javascript - 赛普拉斯 - 访问从第 3 方获得的 URL(电子邮件)
- java - 如何使用cardview和适配器将按钮添加到recyclerview布局中?
- javascript - 将数据从页面发送到 chrome 扩展
- c# - AWS Lambda - C# - 环境变量只加载空
- python - 在张量流中加载现有模型时出现问题
- python - ZMQ 上下文套接字在新计算机上的创建速度要慢得多
- javascript - Safari 手机上看不到汉堡菜单