项目作者: proger

项目描述 :
ejabberd lightweight HTTP->XMPP trunk
高级语言: Erlang
项目地址: git://github.com/proger/mod_trunk.git
创建时间: 2018-03-14T00:56:05Z
项目社区:https://github.com/proger/mod_trunk

开源协议:ISC License

下载


mod_trunk

Trunk HTTP with XMPP by exposing an HTTP endpoint to forward messages to users routed through a mapping table from string aliases to JIDs.

Prerequisites

  • Erlang/OTP 20 or higher
  • ejabberd 18.01 or higher

Installation and Upgrading

  1. # Substitute ~ for the home directory of the user that runs ejabberd:
  2. cd ~/.ejabberd-modules/sources/
  3. git clone https://github.com/proger/mod_trunk
  4. # ejabberdctl should now list mod_trunk as available:
  5. ejabberdctl modules_available
  6. # Compile and install mod_trunk:
  7. ejabberdctl module_install mod_trunk
  8. # To upgrade, same as uninstall + install:
  9. ejabberdctl module_upgrade mod_trunk

Configuration

Merge the following into your ejabberd.yml. TLS configuration is optional. You may use openssl-make-ca to test with your own CA.

  1. certfiles:
  2. - "/etc/ssl/localhost.crt"
  3. - "/etc/ssl/private/localhost.key"
  4. ca_file: "/etc/ssl/certs/ca-bundle.pem"
  5. listen:
  6. -
  7. port: 5444
  8. ip: "::"
  9. module: ejabberd_http
  10. request_handlers:
  11. # ...
  12. "/trunk": mod_trunk
  13. tls: true
  14. modules:
  15. mod_trunk:
  16. config:
  17. token: "secret"
  18. src_host: "sms.example.com"

Usage

Configure mod_trunk aliases:

  1. % Register aliases in mnesia:
  2. mod_trunk:register_alias(<<"+14085503542">>, <<"john@localhost">>).
  3. % List all registered aliases:
  4. mod_trunk:all_aliases().

Send messages:

  1. curl -v --cacert /etc/ssl/certs/ca-bundle.pem https://localhost:5444/trunk -d '
  2. {"src": "TheMatrix",
  3. "dst": "+14085503542",
  4. "text": "Follow the white rabbit.",
  5. "ts": 1520000000,
  6. "token": "secret"
  7. }
  8. '

Operation Notes

  1. % Module information:
  2. mod_trunk:health().
  3. % Divert logs:
  4. lager:trace_file("/tmp/mod_trunk.log", [{module, mod_trunk}], debug).