README.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. Introduction
  2. ============
  3. Matrix is an ambitious new ecosystem for open federated Instant Messaging and
  4. VoIP. The basics you need to know to get up and running are:
  5. - Chatrooms are distributed and do not exist on any single server. Rooms
  6. can be found using aliases like ``#matrix:matrix.org`` or
  7. ``#test:localhost:8008`` or they can be ephemeral.
  8. - Matrix user IDs look like ``@matthew:matrix.org`` (although in the future
  9. you will normally refer to yourself and others using a 3PID: email
  10. address, phone number, etc rather than manipulating Matrix user IDs)
  11. The overall architecture is::
  12. client <----> homeserver <=====================> homeserver <----> client
  13. https://somewhere.org/_matrix https://elsewhere.net/_matrix
  14. WARNING
  15. =======
  16. **Synapse is currently in a state of rapid development, and not all features
  17. are yet functional. Critically, some security features are still in
  18. development, which means Synapse can *not* be considered secure or reliable at
  19. this point.** For instance:
  20. - **SSL Certificates used by server-server federation are not yet validated.**
  21. - **Room permissions are not yet enforced on traffic received via federation.**
  22. - **Homeservers do not yet cryptographically sign their events to avoid
  23. tampering**
  24. - Default configuration provides open signup to the service from the internet
  25. Despite this, we believe Synapse is more than useful as a way for experimenting
  26. and exploring Synapse, and the missing features will land shortly. **Until
  27. then, please do *NOT* use Synapse for any remotely important or secure
  28. communication.**
  29. Quick Start
  30. ===========
  31. System requirements:
  32. - POSIX-compliant system (tested on Linux & OSX)
  33. - Python 2.7
  34. To get up and running:
  35. - To simply play with an **existing** homeserver you can
  36. just go straight to http://matrix.org/alpha.
  37. - To run your own **private** homeserver on localhost:8008, generate a basic
  38. config file: ``./synctl start`` will give you instructions on how to do this.
  39. For this purpose, you can use 'localhost' or your hostname as a server name.
  40. Once you've done so, running ``./synctl start`` again will start your private
  41. home sserver. You will find a webclient running at http://localhost:8008.
  42. Please use a recent Chrome or Firefox for now (or Safari if you don't need
  43. VoIP support).
  44. - To run a **public** homeserver and let it exchange messages with other
  45. homeservers and participate in the global Matrix federation, you must expose
  46. port 8448 to the internet and edit homeserver.yaml to specify server_name
  47. (the public DNS entry for this server) and then run ``synctl start``. If you
  48. changed the server_name, you may need to move the old database
  49. (homeserver.db) out of the way first. Then come join ``#matrix:matrix.org``
  50. and say hi! :)
  51. For more detailed setup instructions, please see further down this document.
  52. About Matrix
  53. ============
  54. Matrix specifies a set of pragmatic RESTful HTTP JSON APIs as an open standard,
  55. which handle:
  56. - Creating and managing fully distributed chat rooms with no
  57. single points of control or failure
  58. - Eventually-consistent cryptographically secure[1] synchronisation of room
  59. state across a global open network of federated servers and services
  60. - Sending and receiving extensible messages in a room with (optional)
  61. end-to-end encryption[2]
  62. - Inviting, joining, leaving, kicking, banning room members
  63. - Managing user accounts (registration, login, logout)
  64. - Using 3rd Party IDs (3PIDs) such as email addresses, phone numbers,
  65. Facebook accounts to authenticate, identify and discover users on Matrix.
  66. - Placing 1:1 VoIP and Video calls
  67. These APIs are intended to be implemented on a wide range of servers, services
  68. and clients, letting developers build messaging and VoIP functionality on top
  69. of the entirely open Matrix ecosystem rather than using closed or proprietary
  70. solutions. The hope is for Matrix to act as the building blocks for a new
  71. generation of fully open and interoperable messaging and VoIP apps for the
  72. internet.
  73. Synapse is a reference "homeserver" implementation of Matrix from the core
  74. development team at matrix.org, written in Python/Twisted for clarity and
  75. simplicity. It is intended to showcase the concept of Matrix and let folks see
  76. the spec in the context of a codebase and let you run your own homeserver and
  77. generally help bootstrap the ecosystem.
  78. In Matrix, every user runs one or more Matrix clients, which connect through to
  79. a Matrix homeserver which stores all their personal chat history and user
  80. account information - much as a mail client connects through to an IMAP/SMTP
  81. server. Just like email, you can either run your own Matrix homeserver and
  82. control and own your own communications and history or use one hosted by
  83. someone else (e.g. matrix.org) - there is no single point of control or
  84. mandatory service provider in Matrix, unlike WhatsApp, Facebook, Hangouts, etc.
  85. Synapse ships with two basic demo Matrix clients: webclient (a basic group chat
  86. web client demo implemented in AngularJS) and cmdclient (a basic Python
  87. command line utility which lets you easily see what the JSON APIs are up to).
  88. We'd like to invite you to take a look at the Matrix spec, try to run a
  89. homeserver, and join the existing Matrix chatrooms already out there,
  90. experiment with the APIs and the demo clients, and let us know your thoughts at
  91. https://github.com/matrix-org/synapse/issues or at matrix@matrix.org.
  92. Thanks for trying Matrix!
  93. [1] Cryptographic signing of messages isn't turned on yet
  94. [2] End-to-end encryption is currently in development
  95. Homeserver Installation
  96. =======================
  97. First, the dependencies need to be installed. Start by installing
  98. 'python2.7-dev' and the various tools of the compiler toolchain.
  99. Installing prerequisites on Ubuntu::
  100. $ sudo apt-get install build-essential python2.7-dev libffi-dev
  101. Installing prerequisites on Mac OS X::
  102. $ xcode-select --install
  103. The homeserver has a number of external dependencies, that are easiest
  104. to install by making setup.py do so, in --user mode::
  105. $ python setup.py develop --user
  106. You'll need a version of setuptools new enough to know about git, so you
  107. may need to also run::
  108. $ sudo apt-get install python-pip
  109. $ sudo pip install --upgrade setuptools
  110. If you don't have access to github, then you may need to install ``syutil``
  111. manually by checking it out and running ``python setup.py develop --user`` on
  112. it too.
  113. If you get errors about ``sodium.h`` being missing, you may also need to
  114. manually install a newer PyNaCl via pip as setuptools installs an old one. Or
  115. you can check PyNaCl out of git directly (https://github.com/pyca/pynacl) and
  116. installing it. Installing PyNaCl using pip may also work (remember to remove
  117. any other versions installed by setuputils in, for example, ~/.local/lib).
  118. On OSX, if you encounter ``clang: error: unknown argument: '-mno-fused-madd'``
  119. you will need to ``export CFLAGS=-Qunused-arguments``.
  120. This will run a process of downloading and installing into your
  121. user's .local/lib directory all of the required dependencies that are
  122. missing.
  123. Once this is done, you may wish to run the homeserver's unit tests, to
  124. check that everything is installed as it should be::
  125. $ python setup.py test
  126. This should end with a 'PASSED' result::
  127. Ran 143 tests in 0.601s
  128. PASSED (successes=143)
  129. Upgrading an existing homeserver
  130. ================================
  131. Before upgrading an existing homeserver to a new version, please refer to
  132. UPGRADE.rst for any additional instructions.
  133. Setting up Federation
  134. =====================
  135. In order for other homeservers to send messages to your server, it will need to
  136. be publicly visible on the internet, and they will need to know its host name.
  137. You have two choices here, which will influence the form of your Matrix user
  138. IDs:
  139. 1) Use the machine's own hostname as available on public DNS in the form of
  140. its A or AAAA records. This is easier to set up initially, perhaps for
  141. testing, but lacks the flexibility of SRV.
  142. 2) Set up a SRV record for your domain name. This requires you create a SRV
  143. record in DNS, but gives the flexibility to run the server on your own
  144. choice of TCP port, on a machine that might not be the same name as the
  145. domain name.
  146. For the first form, simply pass the required hostname (of the machine) as the
  147. --host parameter::
  148. $ python synapse/app/homeserver.py \
  149. --server-name machine.my.domain.name \
  150. --config-path homeserver.config \
  151. --generate-config
  152. $ python synapse/app/homeserver.py --config-path homeserver.config
  153. Alternatively, you can run synapse via synctl - running ``synctl start`` to
  154. generate a homeserver.yaml config file, where you can then edit server-name to
  155. specify machine.my.domain.name, and then set the actual server running again
  156. with synctl start.
  157. For the second form, first create your SRV record and publish it in DNS. This
  158. needs to be named _matrix._tcp.YOURDOMAIN, and point at at least one hostname
  159. and port where the server is running. (At the current time synapse does not
  160. support clustering multiple servers into a single logical homeserver). The DNS
  161. record would then look something like::
  162. _matrix._tcp IN SRV 10 0 8448 machine.my.domain.name.
  163. At this point, you should then run the homeserver with the hostname of this
  164. SRV record, as that is the name other machines will expect it to have::
  165. $ python synapse/app/homeserver.py \
  166. --server-name YOURDOMAIN \
  167. --bind-port 8448 \
  168. --config-path homeserver.config \
  169. --generate-config
  170. $ python synapse/app/homeserver.py --config-path homeserver.config
  171. You may additionally want to pass one or more "-v" options, in order to
  172. increase the verbosity of logging output; at least for initial testing.
  173. For the initial alpha release, the homeserver is not speaking TLS for
  174. either client-server or server-server traffic for ease of debugging. We have
  175. also not spent any time yet getting the homeserver to run behind loadbalancers.
  176. Running a Demo Federation of Homeservers
  177. ----------------------------------------
  178. If you want to get up and running quickly with a trio of homeservers in a
  179. private federation (``localhost:8080``, ``localhost:8081`` and
  180. ``localhost:8082``) which you can then access through the webclient running at
  181. http://localhost:8080. Simply run::
  182. $ demo/start.sh
  183. Running The Demo Web Client
  184. ===========================
  185. The homeserver runs a web client by default at https://localhost:8448/.
  186. If this is the first time you have used the client from that browser (it uses
  187. HTML5 local storage to remember its config), you will need to log in to your
  188. account. If you don't yet have an account, because you've just started the
  189. homeserver for the first time, then you'll need to register one.
  190. Registering A New Account
  191. -------------------------
  192. Your new user name will be formed partly from the hostname your server is
  193. running as, and partly from a localpart you specify when you create the
  194. account. Your name will take the form of::
  195. @localpart:my.domain.here
  196. (pronounced "at localpart on my dot domain dot here")
  197. Specify your desired localpart in the topmost box of the "Register for an
  198. account" form, and click the "Register" button. Hostnames can contain ports if
  199. required due to lack of SRV records (e.g. @matthew:localhost:8448 on an
  200. internal synapse sandbox running on localhost)
  201. Logging In To An Existing Account
  202. ---------------------------------
  203. Just enter the ``@localpart:my.domain.here`` Matrix user ID and password into
  204. the form and click the Login button.
  205. Identity Servers
  206. ================
  207. The job of authenticating 3PIDs and tracking which 3PIDs are associated with a
  208. given Matrix user is very security-sensitive, as there is obvious risk of spam
  209. if it is too easy to sign up for Matrix accounts or harvest 3PID data.
  210. Meanwhile the job of publishing the end-to-end encryption public keys for
  211. Matrix users is also very security-sensitive for similar reasons.
  212. Therefore the role of managing trusted identity in the Matrix ecosystem is
  213. farmed out to a cluster of known trusted ecosystem partners, who run 'Matrix
  214. Identity Servers' such as ``sydent``, whose role is purely to authenticate and
  215. track 3PID logins and publish end-user public keys.
  216. It's currently early days for identity servers as Matrix is not yet using 3PIDs
  217. as the primary means of identity and E2E encryption is not complete. As such,
  218. we are running a single identity server (http://matrix.org:8090) at the current
  219. time.
  220. Where's the spec?!
  221. ==================
  222. For now, please go spelunking in the ``docs/`` directory to find out.
  223. Building Internal API Documentation
  224. ===================================
  225. Before building internal API documentation install spinx and
  226. sphinxcontrib-napoleon::
  227. $ pip install sphinx
  228. $ pip install sphinxcontrib-napoleon
  229. Building internal API documentation::
  230. $ python setup.py build_sphinx