繁体   English   中英

在不公开服务名和主机名的情况下使用 Android XMPP Smack

[英]Use Android XMPP Smack without making public the Service Name and the Host name

正如您在下面的示例代码中看到的,Smack 要求我提供服务名称和主机。 我将 Ejabberd 与 Linux 和 EC2 实例一起使用。

在检查 XMPP 客户端应用程序时,我看到了使用其他 XMPP 提供商创建帐户的选项。 我担心当我向公众发布我的应用程序时,我的 EC2 实例的 DNS 会让人们有能力创建大量帐户,而不是直接从我的应用程序而是从任何地方创建。

我应该使用 Firebase 函数之类的东西吗? 或者类似的东西? 解决这个问题的最佳方法是什么? 我只是不希望主机名是公开的。

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/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM