Advertisement
Tuh_Rev

Real An0n Encrypted Net Matrix.org+Riot.to inc #IRC#Twitter

Feb 15th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.12 KB | None | 0 0
  1. AN0NYM0US 2018
  2.  
  3. Matrix & Riot
  4.  
  5. #https://matrix.org/
  6.  
  7. How does it work?
  8. oK three Matrix homeservers, each with one client connected.
  9.  
  10. The clients are all participating in the same Matrix room, which is synchronised across the three participating servers.
  11. Alice sends a JSON message to a room on her homeserver.
  12.  
  13. Alice's homeserver adds the JSON to its graph of history, linking it to the most recent unlinked object(s) in the graph.
  14. The server then signs the JSON including the signatures of the parent objects to calculate a tamper-resistent signature for the history.
  15.  
  16. The server then sends the signed JSON over HTTPS to any other servers which are participating in the room.
  17. #https://matrix.bob.com:8448/_matrix/federation/v1/send/916d...
  18.  
  19. The destination servers perform a series of checks on the message:
  20.  
  21. Validate the message signature to protect against tampering with history
  22. Validate the HTTP request's auth signature to protect against identity spoofing
  23. Validate whether Alice's historical permissions allow her to send this particular message
  24. If these checks pass, the JSON is added to the destination servers' graphs.
  25. Destination clients receive Alice's message with a long-lived GET request. (Clients are free to implement more efficient transports than polling as desired).
  26.  
  27. #curl "https://matrix.bob.com/_matrix/client
  28.  
  29. Open Standard
  30.  
  31. Simple pragmatic RESTful HTTP/JSON APIs
  32. Open specification of the Matrix standard
  33. Create and manage fully distributed (eventually consistent) conversations with no single points of control or failure
  34.  
  35. Send and receive extensible messages with optional end-to-end encryption
  36. WebRTC VoIP/Video calling using Matrix signalling
  37. Real-time synchronised history and state across all clients
  38. Group conversation by default
  39.  
  40. Use existing 3rd party IDs (e.g. email, phone numbers, Facebook) to authenticate, identify and discover users
  41. Trusted federation of identity servers, tracking public keys and 3rd party ID mappings
  42. TLS by default
  43.  
  44. Open Source Implementations
  45.  
  46. There are many different clients, servers and application services – for a full list please see the Try Matrix Now page.
  47.  
  48. If you like command line clients, you can try out the Weechat Matrix plugin
  49. If you like glossy web clients, try Riot (also available for iOS and Android)
  50. Synapse – reference Matrix homeserver in Python/Twisted
  51. Alternatively, write your own client using one of our SDKs:
  52. matrix-react-sdk – example Matrix client and SDK in React JS
  53. matrix-ios-sdk – example Matrix client and SDK for iOS
  54. matrix-android-sdk – example Matrix client and SDK for Android
  55. matrix-js-sdk – basic client SDK in core JavaScript
  56.  
  57.  
  58. What is Matrix.org?
  59.  
  60. Matrix.org is a non-profit initiative, currently being incorporated as a dedicated non-profit Matrix.org Foundation in the UK. It acts as a neutral guardian of the Matrix spec, nurturing and growing Matrix for the benefit of the whole ecosystem. The board of Matrix.org Foundation will be made up of key participants in the Matrix community as well as independent advisors from the wider internet and telco industries.
  61.  
  62.  
  63. ######################################################################################################################
  64.  
  65.  
  66.  
  67. #https://opensource.com/alternatives/slack
  68.  
  69. Riot.im.is a collection of web and mobile tools which can be used to connect to Matrix, an "open network for secure, decentralized communication."
  70.  
  71. Riot is also perhaps the easiest of these tools to try, since its web client is hosted. You can also check out the full source for all of the projects on GitHub, under an Apache 2.0 license.
  72.  
  73. Thanks to bridge integrations, you can also use Riot to interconnect with services utilizing IRC, Slack or Gitter, potentially allowing you to replace multiple other clients with a single open source option.
  74.  
  75.  
  76. #https://riot.im/app/#/room/#bridges:matrix.org
  77.  
  78.  
  79. '####################################################
  80.  
  81.  
  82. #Twitter Bridge for Matrix
  83. Interact with Twitter through your Matrix Client
  84.  
  85. # This project allows you to bridge Twitter accounts, timelines and hashtags to a Matrix homeserver (see more about that below).
  86.  
  87. You can use a Matrix as a Twitter client and send tweets through, or you can monitor a hashtag through any software that supports the matrix protocol.
  88. Features
  89.  
  90. Read and follow a users timeline
  91. Send tweets from yourself and to other users.
  92. Follow hashtags.
  93. Direct messaging
  94. Read your own timeline
  95.  
  96. Join the discussion on Matrix!
  97. Installation
  98.  
  99. We expect you to be running a standard synapse setup for these instructions
  100.  
  101. The master release for this project is currently unsupported. While work is ongoing to release a version, #develop should be used.
  102.  
  103. Clone this repo and install the npm dependencies as usual.
  104.  
  105. git clone https://github.com/Half-Shot/matrix-appservice-twitter
  106. git checkout develop
  107. npm install
  108.  
  109.  
  110. You will need a twitter application authentication token and secret to continue.
  111.  
  112. Go to https://apps.twitter.com/ and create a new app. If you follow the setup all the way through you should be given all you need to fill in a config.yaml file. Copy config.sample.yaml and fill in the blanks before saving as config.yaml.
  113.  
  114. Next, we need to generate the appropriate registration config so that synapse can interface with the bridge.
  115.  
  116. node twitter-as.js -r -u "URL"
  117.  
  118.  
  119. The URL should be replaced by the domain/ip and port of the bridge. In this case you can usually leave it as http://localhost:9000 if you plan to run it on the same server as synapse and will be keeping the default port.
  120.  
  121. Copy/symlink the generated registration file to your synapse directory and finally edit your homeserver.yaml file for synapse so that the bridge is registered. This means changing app_service_config_files and inserting the name of your config file into the list. It should look similar to this:
  122.  
  123. app_service_config_files: ["twitter-registration.yaml"]
  124.  
  125.  
  126. You can restart synapse after this.
  127.  
  128. Finally, run the bridge!
  129.  
  130. node twitter-as.js -p 9000 -c config.yaml
  131.  
  132.  
  133. config.yaml
  134.  
  135. bridge
  136. domain http://localhost
  137.  
  138. The homeserver's domain.
  139. homeserverUrl http://localhost:8448
  140.  
  141. The homeservers URL.
  142. database_file twitter.db
  143.  
  144. The file to store SQLITE data in.
  145. app_auth
  146. consumer_key
  147.  
  148. The key obtained by registering a new Twitter API application.
  149. consumer_secret
  150.  
  151. The secret obtained by registering a new Twitter API application.
  152. hashtags
  153. enable true/false
  154.  
  155. Should the bridge allow creation of new hashtag rooms.
  156. timelines
  157. enable true/false
  158.  
  159. Should the bridge allow creation of new timeline rooms.
  160. media
  161. enable_download true/false
  162.  
  163. Should media inside tweets be uploaded to the homeserver, or just linked?
  164. enable_profile_images true/false
  165.  
  166. Should profile images be set for twitter accounts.
  167. logging
  168. file logs/twitter-db.log
  169.  
  170. The file to log to. Please make sure to create any directories.
  171. size 50m
  172.  
  173. How big should files be before they are rotated. Use the suffix m for MB.
  174. count 3
  175.  
  176. How many files should be kept before old ones are deleted
  177. compress true/false
  178.  
  179. Compress files using gzip?
  180. level warn
  181.  
  182. One of silent, error, warn, info, verbose, silly
  183.  
  184. Using the bridge
  185. Linking your Twitter account to your Matrix user
  186.  
  187. Linking is not required for reading timelines/hashtags, but interactions must be completed under your own account.
  188.  
  189. Create a room and invite @_twitter_bot:yourdomain.
  190. Send the message account.link (read|write|dm) where the argument sets the requested permission level*.
  191. Follow the URL and instructions. Copy the PIN code
  192. Enter the pin code directly into the room and your account should be linked up.
  193.  
  194. *type help for explanations on commands
  195. User Timelines
  196.  
  197. Simply join #_twitter_@screennamegoeshere:yourdomain to read a users timeline. Protected timelines are not available.
  198.  
  199. Accounts which are bridged (Twitter<->Matrix) will be able to send tweets to these timelines (you do not need to put the @screen_name, it is done automatically)
  200. Hashtags
  201.  
  202. Join #_twitter_#hashtaggoeshere to follow a particular hashtag.
  203.  
  204. Accounts which are bridged (Twitter<->Matrix) will be able to send tweets which will automatically apply this hashtag.
  205. Direct Messages
  206.  
  207. Due to limitations in the Twitter API, group DMs are not possible.
  208.  
  209. On recieving a DM, you will be invited to a room where you can message each other as if it was another Matrix user.
  210.  
  211. Rejoining previous conversations is not possible, but either user sending a message will create a private room
  212.  
  213. https://www.lifewire.com/what-is-a-twitter-widget-1949537
  214.  
  215. https://www.lifewire.com/widgetbox-widgets-made-simple-3486688
  216.  
  217.  
  218.  
  219.  
  220. ####################################################
  221.  
  222.  
  223. https://riot.im/app/#/room/#irc:matrix.org
  224.  
  225. Matrix<->IRC Gateway HOW-TO
  226.  
  227. This guide is designed to familiarise you with the configuration and running of this IRC Application Service (AS) and provide a more thorough look at some of the features of this AS.
  228. Installing
  229.  
  230. If you haven't already, check out the README for instructions on how to install the AS. This project requires nodejs in order to run, and has been tested on v4.4.0.
  231.  
  232. $ git clone https://github.com/matrix-org/matrix-appservice-irc.git
  233. $ cd matrix-appservice-irc
  234. $ npm install
  235. $ npm test # make sure these pass!
  236.  
  237. Once that is done, you're ready to configure the AS.
  238. Configuring
  239.  
  240. A sample configuration file config.sample.yaml is provided with relatively "sensible" defaults, but you will need to modify it before things will work. It is worth examining certain options more closely before running the AS.
  241.  
  242. Either copy config.sample.yaml to config.yaml or create a new file. By default, the AS will look for config.yaml in the current working directory. You can override this by passing --config some_file.yaml or -c some_file.yaml when you call node app.js.
  243. Pointing the AS at the Homeserver
  244.  
  245. +==========================================================================+
  246. | You MUST have access to the homeserver configuration file in order to |
  247. | register this application service with that homeserver. This typically |
  248. | means you must be running your own homeserver to register an AS. |
  249. +==========================================================================+
  250.  
  251. The following options are REQUIRED in order to point the AS to the homeserver (HS) and vice versa:
  252.  
  253. # This section contains information about the HS
  254. homeserver:
  255. # This url will be used by the AS to perform Client-Server API calls.
  256. url: "http://localhost:8008"
  257. # This value will be used when forming user IDs under certain
  258. # circumstances. This is typically the domain part of the 'url' field
  259. # above.
  260. domain: "localhost"
  261.  
  262. Pointing the AS at your chosen IRC network
  263.  
  264. You probably already have an IRC network in mind that you want to bridge. The bare bones REQUIRED configuration options are:
  265.  
  266. ircService:
  267. servers:
  268. # This is the IRC server url to connect to.
  269. irc.example.com:
  270. mappings:
  271. "#some-channel": ["!someroomid:here"]
  272.  
  273. This would set up a simple mapping from #some-channel on irc.example.com to !someroomid:here, and that's it. Dynamic mappings are not enabled by default.
  274.  
  275. To allow dynamic mappings:
  276.  
  277. ircService:
  278. servers:
  279. irc.example.com:
  280. dynamicChannels:
  281. enabled: true
  282.  
  283. This will register a block of aliases which represent all the possible IRC channels on irc.example.com. To join #some-channel as a Matrix client, try to join the room alias #irc_irc.example.com_#some-channel:localhost. You can now join any channel you like by modifying the alias you join.
  284.  
  285.  
  286. Modifying templates
  287.  
  288. You may think that aliases like #irc_irc.example.com_#some-channel:localhost are unwieldy and horrible to type. You may only have one IRC network you plan to bridge, so having to type out the server address every time is tiring. Templates exist to fix this. They look like the localparts of various IDs (user IDs, room aliases) but with the sigil (@ or #) still attached. You can specify an Alias Template which will be used by the AS to form new room aliases. For example, to get rid of the server in the alias:
  289.  
  290. ircService:
  291. servers:
  292. irc.example.com:
  293. dynamicChannels:
  294. enabled: true
  295. aliasTemplate: "#irc_$CHANNEL"
  296.  
  297. This will shorten the alias to be #irc_#some-channel:localhost.
  298.  
  299. The concept of templates extends to Nicks and User IDs as well. IRC users are created with user IDs like @irc.example.com_Alice:localhost which are long and hard to type if you want to send a PM to them. You can shorten this to @irc_Alice:localhost like so:
  300.  
  301. ircService:
  302. servers:
  303. irc.example.com:
  304. matrixClients:
  305. userTemplate:
  306. "@irc_$NICK"
  307.  
  308. The following variables are available for templates:
  309. Nick Template
  310.  
  311. NB: These variables are sanitized by removing non-ASCII and invalid nick characters.
  312. Variable Description
  313. $USERID A real Matrix user's user ID.
  314. $DISPLAY A real Matrix user's display name OR user localpart if they have no display name.
  315. $LOCALPART A real Matrix user's user ID localpart (e.g. alice in @alice:home)
  316. Alias Template
  317. Variable Description
  318. $SERVER An IRC server URL.
  319. $CHANNEL An IRC channel name. Required.
  320. User ID Template
  321. Variable Description
  322. $SERVER An IRC server URL.
  323. $NICK A real IRC user's nick.
  324. Registering
  325.  
  326. Before the HS will send the AS any events, you need to register it. You can generate a registration file for the AS by typing:
  327.  
  328. $ node app.js -r -f appservice-registration-irc.yaml -u "http://where.the.appservice.listens" -c config.yaml -l irc_bot
  329.  
  330. This will create a registration file called appservice-registration-irc.yaml. In this file, it will include the URL where the IRC bridge can be reached from the HS (in this case http://where.the.appservice.listens) and the user ID localpart of the AS (in this case irc_bot to form the AS user ID @irc_bot:localhost). The config file is passed in during the registration phase so the bridge can calculate the regex strings it needs to work.
  331.  
  332. The HS is still unaware of this file currently. In order to tell the HS about the registration, you need to modify the homeserver configuration file (homeserver.yaml). The homeserver configuration file needs to have:
  333.  
  334. app_service_config_files:
  335. # This should be pointed to wherever the generated registration file is.
  336. - "/home/someone/matrix-appservice-irc/appservice-registration-irc.yaml"
  337.  
  338. You will need to restart the homeserver in order for this to take effect.
  339. Architecture
  340.  
  341. +--------+ (3) +-------------+
  342. | IRC AS |<----AS HTTP API-----------| Home Server |
  343. | |--Client-Server HTTP API-->| |
  344. +--------+ (extended) +-------------+
  345. | |
  346. --generate-registration read homserver.yaml
  347. (1)| |(2)
  348. | +-------------------+ |
  349. +-->| Registration File |<----------+
  350. | - as_token |
  351. | - hs_token |
  352. | - app regex |
  353. +-------------------+
  354.  
  355. 1) The IRC AS generates a registration file containing the tokens to use.
  356. 2) The homeserver reads the registration and configures itself.
  357. 3) Both AS and HS communicate over HTTP using the assigned tokens.
  358.  
  359. Registration
  360.  
  361. It is possible for the registration files being used between AS and HS to get out of sync. If this happens, the AS will not recognize the homeserver token and will produce errors Invalid homeserver token. Likewise, the AS may receive errors from the HS Invalid application service token.. Make sure your registration files are in sync!
  362. Features
  363.  
  364. Some of the features listed below require Matrix users the ability to talk to the AS directly. This is done by creating a Matrix room and inviting the AS bot to it. The AS bot's user_id defaults to @matrix-appservice-irc:<domain> but can be changed by the -l CLI flag when generating the registration file.
  365. Changing Nicks
  366.  
  367. By default, Matrix users are assigned a nick from the nick template and that's it. They cannot change their nick. You can grant Matrix users the ability to change their own nick like so:
  368.  
  369. ircService:
  370. servers:
  371. irc.example.com:
  372. ircClients:
  373. allowNickChanges: true
  374.  
  375. Matrix users will now be able to change their nick to anything; the nick is not restricted in any way. Matrix users can set their nick by inviting the AS bot into a one-to-one Matrix room and sending a message with !nick <server> <new_nick> e.g. !nick irc.example.com bob. In order for nick changing to work, you must already have a nick, so you must already be connected to the IRC network (e.g. by having sent a message).
  376. Private bridging
  377.  
  378. By default, dynamic mappings to an IRC network are present in the published room list, and anyone can join these dynamic channels via the room alias. This may be undesirable, and you may want to make these hidden/accessible to select users. To make dynamic mappings private to a select group of users:
  379.  
  380. ircService:
  381. servers:
  382. irc.example.com:
  383. dynamicChannels:
  384. enabled: true
  385. published: false
  386. createAlias: false
  387. joinRule: invite
  388. whitelist:
  389. - "@someone:localhost"
  390. - "@another:localhost"
  391.  
  392. Only @someone:localhost or @another:localhost can join these rooms now. Private rooms cannot be joined via room aliases. You need to get the AS bot to invite you to the room. To do this, create a room and invite the AS bot, then type !join <server name> <channel> e.g. !join irc.example.com #foo. You must be on the whitelist for this to work.
  393.  
  394. For a less restrictive option, you may want similar functionality to +s on IRC (does not appear in the channel list). To do this:
  395.  
  396. ircService:
  397. servers:
  398. irc.example.com:
  399. dynamicChannels:
  400. enabled: true
  401. createAlias: true
  402. joinRule: public
  403. published: false
  404.  
  405. This will still create the room alias for the room, but only people who know the alias will be able to join the room.
  406. Ident
  407. You may want to assign ident-verified usernames to the generated IRC clients e.g. to scope bans to Matrix users rather than the entire application service. This application service can run an ident server to make this possible. Ident is disabled by default. To enable it:
  408.  
  409. ircService:
  410. ident:
  411. enabled: true
  412. port: 1113 # optional (default: 113) but this allows you to run the AS without root.
  413.  
  414. Statsd
  415.  
  416. This application service supports sending metrics to a statsd server. Metrics monitored include:
  417.  
  418. Memory usage (RSS, heap, etc)
  419. Request outcomes (success/fail) and durations (ms).
  420. Number of active IRC client connections Sending metrics is disabled by default. To enable this:
  421.  
  422. ircService:
  423. statsd:
  424. hostname: "127.0.0.1"
  425. port: 8125
  426.  
  427. Logging
  428.  
  429. Logging is configurable in the yaml, but there is also an extra verbose setting you can enable. This is done by passing --verbose or -v to node app.js.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement