Permalink
Browse files

Reference Matrix Home Server

  • Loading branch information...
0 parents commit 4f475c7697722e946e39e42f38f3dd03a95d8765 matrix.org committed Aug 12, 2014
Showing with 48,447 additions and 0 deletions.
  1. +177 −0 LICENSE
  2. +3 −0 MANIFEST.in
  3. +126 −0 README.rst
  4. +699 −0 cmdclient/console.py
  5. +203 −0 cmdclient/http.py
  6. +16 −0 database-save.sh
  7. +22 −0 demo/README
  8. +16 −0 demo/clean.sh
  9. +24 −0 demo/start.sh
  10. +14 −0 demo/stop.sh
  11. +39 −0 demo/webserver.py
  12. +1,264 −0 docs/client-server/specification
  13. +92 −0 docs/client-server/urls
  14. +18 −0 docs/code_style
  15. +43 −0 docs/documentation_style
  16. +249 −0 docs/model/presence
  17. +232 −0 docs/model/profiles
  18. +113 −0 docs/model/room-join-workflow
  19. +274 −0 docs/model/rooms
  20. +108 −0 docs/model/third-party-id
  21. +64 −0 docs/protocol_examples
  22. +53 −0 docs/python_architecture
  23. +59 −0 docs/server-server/protocol-format
  24. +141 −0 docs/server-server/security-threat-model
  25. +177 −0 docs/server-server/specification
  26. +271 −0 docs/sphinx/conf.py
  27. +20 −0 docs/sphinx/index.rst
  28. +7 −0 docs/sphinx/modules.rst
  29. +7 −0 docs/sphinx/synapse.api.auth.rst
  30. +7 −0 docs/sphinx/synapse.api.constants.rst
  31. +7 −0 docs/sphinx/synapse.api.dbobjects.rst
  32. +7 −0 docs/sphinx/synapse.api.errors.rst
  33. +7 −0 docs/sphinx/synapse.api.event_stream.rst
  34. +7 −0 docs/sphinx/synapse.api.events.factory.rst
  35. +7 −0 docs/sphinx/synapse.api.events.room.rst
  36. +18 −0 docs/sphinx/synapse.api.events.rst
  37. +7 −0 docs/sphinx/synapse.api.handlers.events.rst
  38. +7 −0 docs/sphinx/synapse.api.handlers.factory.rst
  39. +7 −0 docs/sphinx/synapse.api.handlers.federation.rst
  40. +7 −0 docs/sphinx/synapse.api.handlers.register.rst
  41. +7 −0 docs/sphinx/synapse.api.handlers.room.rst
  42. +21 −0 docs/sphinx/synapse.api.handlers.rst
  43. +7 −0 docs/sphinx/synapse.api.notifier.rst
  44. +7 −0 docs/sphinx/synapse.api.register_events.rst
  45. +7 −0 docs/sphinx/synapse.api.room_events.rst
  46. +30 −0 docs/sphinx/synapse.api.rst
  47. +7 −0 docs/sphinx/synapse.api.server.rst
  48. +7 −0 docs/sphinx/synapse.api.storage.rst
  49. +7 −0 docs/sphinx/synapse.api.stream.rst
  50. +7 −0 docs/sphinx/synapse.api.streams.event.rst
  51. +17 −0 docs/sphinx/synapse.api.streams.rst
  52. +7 −0 docs/sphinx/synapse.app.homeserver.rst
  53. +17 −0 docs/sphinx/synapse.app.rst
  54. +10 −0 docs/sphinx/synapse.db.rst
  55. +7 −0 docs/sphinx/synapse.federation.handler.rst
  56. +7 −0 docs/sphinx/synapse.federation.messaging.rst
  57. +7 −0 docs/sphinx/synapse.federation.pdu_codec.rst
  58. +7 −0 docs/sphinx/synapse.federation.persistence.rst
  59. +7 −0 docs/sphinx/synapse.federation.replication.rst
  60. +22 −0 docs/sphinx/synapse.federation.rst
  61. +7 −0 docs/sphinx/synapse.federation.transport.rst
  62. +7 −0 docs/sphinx/synapse.federation.units.rst
  63. +19 −0 docs/sphinx/synapse.persistence.rst
  64. +7 −0 docs/sphinx/synapse.persistence.service.rst
  65. +7 −0 docs/sphinx/synapse.persistence.tables.rst
  66. +7 −0 docs/sphinx/synapse.persistence.transactions.rst
  67. +7 −0 docs/sphinx/synapse.rest.base.rst
  68. +7 −0 docs/sphinx/synapse.rest.events.rst
  69. +7 −0 docs/sphinx/synapse.rest.register.rst
  70. +7 −0 docs/sphinx/synapse.rest.room.rst
  71. +20 −0 docs/sphinx/synapse.rest.rst
  72. +30 −0 docs/sphinx/synapse.rst
  73. +7 −0 docs/sphinx/synapse.server.rst
  74. +7 −0 docs/sphinx/synapse.state.rst
  75. +7 −0 docs/sphinx/synapse.util.async.rst
  76. +7 −0 docs/sphinx/synapse.util.dbutils.rst
  77. +7 −0 docs/sphinx/synapse.util.http.rst
  78. +7 −0 docs/sphinx/synapse.util.lockutils.rst
  79. +7 −0 docs/sphinx/synapse.util.logutils.rst
  80. +21 −0 docs/sphinx/synapse.util.rst
  81. +7 −0 docs/sphinx/synapse.util.stringutils.rst
  82. +86 −0 docs/terminology
  83. +11 −0 docs/versioning
  84. +154 −0 example/cursesio.py
  85. +380 −0 example/test_messaging.py
  86. +137 −0 graph/graph.py
  87. +10 −0 setup.cfg
  88. +40 −0 setup.py
  89. +1 −0 sphinx_api_docs.sh
  90. +16 −0 synapse/__init__.py
  91. +14 −0 synapse/api/__init__.py
  92. +164 −0 synapse/api/auth.py
  93. +42 −0 synapse/api/constants.py
  94. +114 −0 synapse/api/errors.py
  95. +152 −0 synapse/api/events/__init__.py
  96. +50 −0 synapse/api/events/factory.py
  97. +99 −0 synapse/api/events/room.py
  98. +186 −0 synapse/api/notifier.py
  99. +96 −0 synapse/api/streams/__init__.py
  100. +247 −0 synapse/api/streams/event.py
  101. +14 −0 synapse/app/__init__.py
  102. +172 −0 synapse/app/homeserver.py
  103. +14 −0 synapse/crypto/__init__.py
  104. +159 −0 synapse/crypto/config.py
  105. +118 −0 synapse/crypto/keyclient.py
  106. +110 −0 synapse/crypto/keyserver.py
  107. +14 −0 synapse/crypto/resource/__init__.py
  108. +160 −0 synapse/crypto/resource/key.py
  109. +29 −0 synapse/federation/__init__.py
  110. +148 −0 synapse/federation/handler.py
  111. +101 −0 synapse/federation/pdu_codec.py
  112. +240 −0 synapse/federation/persistence.py
  113. +582 −0 synapse/federation/replication.py
  114. +454 −0 synapse/federation/transport.py
  115. +236 −0 synapse/federation/units.py
  116. +46 −0 synapse/handlers/__init__.py
  117. +26 −0 synapse/handlers/_base.py
  118. +100 −0 synapse/handlers/directory.py
  119. +149 −0 synapse/handlers/events.py
  120. +74 −0 synapse/handlers/federation.py
  121. +64 −0 synapse/handlers/login.py
  122. +697 −0 synapse/handlers/presence.py
  123. +169 −0 synapse/handlers/profile.py
  124. +100 −0 synapse/handlers/register.py
  125. +808 −0 synapse/handlers/room.py
  126. +14 −0 synapse/http/__init__.py
  127. +246 −0 synapse/http/client.py
  128. +171 −0 synapse/http/endpoint.py
  129. +181 −0 synapse/http/server.py
  130. +44 −0 synapse/rest/__init__.py
  131. +113 −0 synapse/rest/base.py
  132. +82 −0 synapse/rest/directory.py
  133. +50 −0 synapse/rest/events.py
  134. +39 −0 synapse/rest/im.py
  135. +80 −0 synapse/rest/login.py
  136. +134 −0 synapse/rest/presence.py
  137. +93 −0 synapse/rest/profile.py
  138. +32 −0 synapse/rest/public.py
  139. +68 −0 synapse/rest/register.py
  140. +394 −0 synapse/rest/room.py
  141. +176 −0 synapse/server.py
  142. +223 −0 synapse/state.py
  143. +117 −0 synapse/storage/__init__.py
  144. +405 −0 synapse/storage/_base.py
  145. +93 −0 synapse/storage/directory.py
  146. +74 −0 synapse/storage/feedback.py
  147. +80 −0 synapse/storage/message.py
  148. +993 −0 synapse/storage/pdu.py
  149. +103 −0 synapse/storage/presence.py
  150. +51 −0 synapse/storage/profile.py
  151. +113 −0 synapse/storage/registration.py
  152. +129 −0 synapse/storage/room.py
  153. +84 −0 synapse/storage/roomdata.py
  154. +171 −0 synapse/storage/roommember.py
  155. +31 −0 synapse/storage/schema/edge_pdus.sql
  156. +54 −0 synapse/storage/schema/im.sql
  157. +106 −0 synapse/storage/schema/pdu.sql
  158. +37 −0 synapse/storage/schema/presence.sql
  159. +20 −0 synapse/storage/schema/profiles.sql
  160. +12 −0 synapse/storage/schema/room_aliases.sql
  161. +61 −0 synapse/storage/schema/transactions.sql
  162. +31 −0 synapse/storage/schema/users.sql
  163. +282 −0 synapse/storage/stream.py
  164. +287 −0 synapse/storage/transactions.py
  165. +79 −0 synapse/types.py
  166. +40 −0 synapse/util/__init__.py
  167. +22 −0 synapse/util/async.py
  168. +108 −0 synapse/util/distributor.py
  169. +98 −0 synapse/util/jsonobject.py
  170. +67 −0 synapse/util/lockutils.py
  171. +65 −0 synapse/util/logutils.py
  172. +24 −0 synapse/util/stringutils.py
  173. +1 −0 tests/__init__.py
  174. +1 −0 tests/events/__init__.py
  175. +172 −0 tests/events/test_events.py
  176. 0 tests/federation/__init__.py
  177. +240 −0 tests/federation/test_federation.py
  178. +146 −0 tests/federation/test_pdu_codec.py
  179. 0 tests/handlers/__init__.py
  180. +107 −0 tests/handlers/test_federation.py
  181. +884 −0 tests/handlers/test_presence.py
  182. +250 −0 tests/handlers/test_presencelike.py
  183. +112 −0 tests/handlers/test_profile.py
  184. +363 −0 tests/handlers/test_room.py
  185. +1 −0 tests/rest/__init__.py
  186. +202 −0 tests/rest/test_events.py
  187. +241 −0 tests/rest/test_presence.py
  188. +130 −0 tests/rest/test_profile.py
  189. +924 −0 tests/rest/test_rooms.py
  190. +112 −0 tests/rest/utils.py
  191. 0 tests/storage/__init__.py
  192. +191 −0 tests/storage/test_base.py
  193. +74 −0 tests/test_distributor.py
  194. +271 −0 tests/test_state.py
  195. +49 −0 tests/test_types.py
  196. +1 −0 tests/util/__init__.py
  197. +94 −0 tests/util/test_lock.py
  198. +252 −0 tests/utils.py
  199. +12 −0 webclient/README
  200. +46 −0 webclient/app-controller.js
  201. +228 −0 webclient/app.css
  202. +57 −0 webclient/app.js
  203. +307 −0 webclient/components/matrix/matrix-service.js
  204. BIN webclient/favicon.ico
  205. BIN webclient/img/default-profile.jpg
  206. BIN webclient/img/default-profile.png
  207. BIN webclient/img/gradient.png
  208. +41 −0 webclient/index.html
  209. +1,689 −0 webclient/js/angular-animate.js
  210. +927 −0 webclient/js/angular-route.js
  211. +21,822 −0 webclient/js/angular.js
  212. +81 −0 webclient/login/login-controller.js
  213. +51 −0 webclient/login/login.html
  214. +214 −0 webclient/room/room-controller.js
  215. +76 −0 webclient/room/room.html
  216. +195 −0 webclient/rooms/rooms-controller.js
  217. +80 −0 webclient/rooms/rooms.html
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,3 @@
+recursive-include docs *
+recursive-include tests *.py
+recursive-include synapse/persistence/schema *.sql
@@ -0,0 +1,126 @@
+Installation
+============
+
+[TODO(kegan): I also needed libffi-dev, which I don't think is included in build-essential.]
+
+First, the dependencies need to be installed. Start by installing 'python-dev'
+and the various tools of the compiler toolchain:
+
+ Installing prerequisites on ubuntu::
+
+ $ sudo apt-get install build-essential python-dev
+
+ Installing prerequisites on Mac OS X::
+
+ $ xcode-select --install
+
+The homeserver has a number of external dependencies, that are easiest
+to install by making setup.py do so, in --user mode::
+
+ $ python setup.py develop --user
+
+This will run a process of downloading and installing into your
+user's .local/lib directory all of the required dependencies that are
+missing.
+
+Once this is done, you may wish to run the homeserver's unit tests, to
+check that everything is installed as it should be::
+
+ $ python setup.py test
+
+This should end with a 'PASSED' result::
+
+ Ran 143 tests in 0.601s
+
+ PASSED (successes=143)
+
+
+Running The Home Server
+=======================
+
+In order for other home servers to send messages to your server, they will need
+to know its host name. You have two choices here, which will influence the form
+of your user IDs:
+
+ 1) Use the machine's own hostname as available on public DNS in the form of its
+ A or AAAA records. This is easier to set up initially, perhaps for testing,
+ but lacks the flexibility of SRV.
+
+ 2) Set up a SRV record for your domain name. This requires you create a SRV
+ record in DNS, but gives the flexibility to run the server on your own
+ choice of TCP port, on a machine that might not be the same name as the
+ domain name.
+
+For the first form, simply pass the required hostname (of the machine) as the
+--host parameter::
+
+ $ python synapse/app/homeserver.py --host machine.my.domain.name
+
+For the second form, first create your SRV record and publish it in DNS. This
+needs to be named _matrix._tcp.YOURDOMAIN, and point at at least one hostname
+and port where the server is running. (At the current time we only support a
+single server, but we may at some future point support multiple servers, for
+backup failover or load-balancing purposes). The DNS record would then look
+something like::
+
+ _matrix._tcp IN SRV 10 0 8448 machine.my.domain.name.
+
+At this point, you should then run the homeserver with the hostname of this
+SRV record, as that is the name other machines will expect it to have::
+
+ $ python synapse/app/homeserver.py --host my.domain.name --port 8448
+
+You may additionally want to pass one or more "-v" options, in order to
+increase the verbosity of logging output; at least for initial testing.
+
+
+Running The Web Client
+======================
+
+At the present time, the web client is not directly served by the homeserver's
+HTTP server. To serve this in a form the web browser can reach, arrange for the
+'webclient' sub-directory to be made available by any sort of HTTP server that
+can serve static files. For example, python's SimpleHTTPServer will suffice::
+
+ $ cd webclient
+ $ python -m SimpleHTTPServer
+
+You can now point your browser at http://localhost:8000/ to find the client.
+
+If this is the first time you have used the client from that browser (it uses
+HTML5 local storage to remember its config), you will need to log in to your
+account. If you don't yet have an account, because you've just started the
+homeserver for the first time, then you'll need to register one.
+
+Registering A New Account
+-------------------------
+
+Your new user name will be formed partly from the hostname your server is
+running as, and partly from a localpart you specify when you create the
+account. Your name will take the form of::
+
+ @localpart:my.domain.here
+ (pronounced "at localpart on my dot domain dot here")
+
+Specify your desired localpart in the topmost box of the "Register for an
+account" form, and click the "Register" button.
+
+Logging In To An Existing Account
+---------------------------------
+
+[[TODO(paul): It seems the current web client still requests an access_token -
+ I suspect this part will need updating before we can point people at how to
+ perform e.g. user+password or 3PID authenticated login]]
+
+
+Building Documentation
+======================
+
+Before building documentation install spinx and sphinxcontrib-napoleon::
+
+ $ pip install sphinx
+ $ pip install sphinxcontrib-napoleon
+
+Building documentation::
+
+ $ python setup.py build_sphinx
Oops, something went wrong.

0 comments on commit 4f475c7

Please sign in to comment.