Repository: SomajitDey/ipfs-chat Branch: main Commit: 29237313b287 Files: 5 Total size: 112.4 KB Directory structure: gitextract_r71csxvd/ ├── .gitattributes ├── LICENSE ├── README.md ├── ipfs-chat └── mime.types ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ /ipfs-chat linguist-language=bash ================================================ FILE: LICENSE ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: README.md ================================================ # IPFS-Chat [![Featured](https://img.shields.io/badge/Featured%20in-Awesome%20IPFS-green.svg)](https://awesome.ipfs.io/apps/) 1. Real-time, secure, peer-to-peer messaging using [IPFS pubsub](https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipfs-pubsub). Allows in-chat file/directory sharing and private messaging. Works over both internet and LAN. Built-in NAT-traversal using [IPFS autorelay](https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#autorelay). 2. Very basic terminal-based UI without any eye candy. 3. The usual *Create Alias/Nick* + *Create/Join room* workflow (akin to [IRC](https://en.wikipedia.org/wiki/Internet_Relay_Chat)). 4. Fully distributed - serverless/brokerless. Peers are discovered using [DHT](https://docs.ipfs.io/concepts/dht/), [pubsub](https://docs.libp2p.io/concepts/publish-subscribe/) and [mDNS](https://en.wikipedia.org/wiki/Multicast_DNS) (See [Peer discovery](#peer-discovery)). No need for any rendezvous server. Without any central server(s), `ipfs-chat` cannot be censored/blocked easily. 5. Chat-messages are authenticated and end-to-end encrypted (See [Security](#security)). Shared files/directories are encrypted too. 6. Developed with bandwidth, CPU and disk usage efficiency in mind. Option to control shared file size (See [Usage](#usage)). 7. Written entirely in [Bash](https://www.gnu.org/software/bash/manual/bash.html); just a single shell-script. Apart from [go-ipfs](https://docs.ipfs.io/install/command-line/#official-distributions) and possibly `argon2`, depends only on standard GNU/Linux tools and tools that can be easily downloaded from the native package repository. 8. For WSL, supports sharing Windows files or folders (through direct drag-n-drop). Also allows downloading shared files in a Windows folder (See [Usage](#usage)). 9. Downloaded shared files are scanned for malicious intent (See [Security](#security) and [Usage](#usage)). 10. Auto-update enabled. ***Keywords*:** p2p; distributed; server-less; broker-less; TUI; secure; texting; file-sharing; ipfs; pubsub; privacy ## Table of Contents [![tocgen](https://img.shields.io/badge/Generated%20using-tocgen-blue)](https://github.com/SomajitDey/tocgen) - [IPFS-Chat](#ipfs-chat) - [Installation](#installation) - [Download:](#download) - [Install:](#install) - [Usage](#usage) - [Defaults:](#defaults) - [Multiple-instances:](#multiple-instances) - [Snapshot](#snapshot) - [Testing](#testing) - [Changing terminal window size](#changing-terminal-window-size) - [Peer discovery](#peer-discovery) - [Security](#security) - [Messaging](#messaging) - [File or directory sharing](#file-or-directory-sharing) - [Efficiency](#efficiency) - [Fully decentralized vs (Semi-)centralized](#fully-decentralized-vs-semi-centralized) - [Future directions](#future-directions) - [Contribute](#contribute) ##### ## Installation #### Download: ```shell git clone --depth 1 --no-tags https://github.com/SomajitDey/ipfs-chat; cd ipfs-chat ``` or, ```shell wget https://raw.githubusercontent.com/SomajitDey/ipfs-chat/main/ipfs-chat \ && chmod +x ./ipfs-chat ``` #### Install: ```bash sudo mv ./ipfs-chat /usr/local/bin ``` Or, if you don't have sudo priviledge: ```bash mkdir -p ~/.bin; mv ./ipfs-chat ~/.bin; export PATH="${PATH}:${HOME}/.bin" # Also put the last export command inside ${HOME}/.bashrc ``` Do you want an auto-install feature, such as `./ipfs-chat -i`? If so, please [post](#contribute) a feature-request. ## Usage ```shell ipfs-chat -r -n -d
-D -c -o -w|-l -e ipfs-chat -g # Generating a random room name, for when your brain can't do it ipfs-chat -v # Version ipfs-chat -u | # Update ipfs-chat -h # Help ``` All command-line options/flags are optional. Unobvious options are explained below. `-c` passes the directory where `ipfs-chat` would host the IPFS node (repository); similar to the `-c` option in the `ipfs` cli. Unlike `ipfs` cli however, the environment variable `IPFS_PATH` has no effect. `-d` passes the directory where the files received from peers would be downloaded. This can be a Windows folder (just drag-n-drop the folder in the command-line, within quotes) for WSL. `-D` specifies the maximum size in MB for each shared file. Larger files are not downloaded/uploaded. If the specified size is negative, it implies there is no maximum size. `-o` passes the file where the chat from the present session would be logged. `-w` or `-W` denotes WAN-only mode. Local discovery is disabled. Everything happens over internet only. Uses WAN-DHT. `-l` or `-L` denotes LAN-only mode. Peers are discovered only locally, no connection to the IPFS public network is formed over the internet (no bootstrap node, uses LAN-DHT). Saves resources when all chatroom peers are known to be present across LAN. Launches `ipfs-chat` faster when not connected to the internet. `-e` enables basic MIME-type check for the shared files. Suppose a malicious peer sends you an executable file but scrupulously gives it a .txt extension. `ipfs-chat` would add a .com or .exe extension to the file then. This feature is only available as long as there is a map of MIME-types to extensions at `/etc/mime.types` (e.g. in Debian & Ubuntu). If your distribution doesn't have this map, install it at that path manually after downloading from [here](https://raw.githubusercontent.com/SomajitDey/ipfs-chat/main/mime.types). `-u` does a manual update of `ipfs-chat`. This option is not very necessary as `ipfs-chat` auto-updates whenever there is internet connection and it is not running in LAN-only mode. `ipfs-chat -u` may be passed the version-tag (e.g. `v0.2.4`) or git-branch (e.g. `dev` or `issue-15`) to update or roll-back to. With no arguments, the update is to branch `main`, i.e. the latest release. #### Defaults: room: `Lobby` nick: `${USER}` download directory: `${HOME}/ipfs-chat-downloads` max shared file size: -1 (i.e. unlimited) repo: `${HOME}/.ipfs-chat` chat log: N/A WAN + LAN #### Multiple-instances: Multiple instances of `ipfs-chat` may be run for accessing different chatrooms concurrently. This may be done in 2 ways: 1. Provide a separate IPFS repository with the `-c` flag for every instance. Each instance then runs its own IPFS node independent of the others. Example: ```shell ipfs-chat -c '/tmp/repo1' -r chatroom1 -n nick1 # In one terminal ipfs-chat -c '/tmp/repo2' -r chatroom2 -n nick2 # In another terminal ``` 2. If you are okay with using the same *nick* for every chatroom, then it is much more efficient to run the multiple instances on the same IPFS node, i.e. with the same IPFS repository. Example: ```shell ipfs-chat [-c common-repo] -r chatroom1 -n myNick # In one terminal ipfs-chat [-c common-repo] -r chatroom2 -n myNick # In another terminal ``` ## Snapshot ![ipfs-chat_snapshot](./screenshot.png) ## Testing You can test `ipfs-chat` by running multiple instances on your computer. Simply use different nicknames and join the same chatroom. Example: Connect to the internet and do the following. ```shell ipfs-chat -W -b -c '/tmp/ipfs-chat' -n 'partner' # In one terminal ipfs-chat -b # In another terminal ``` `-b` above enables bandwidth stats. Drop it if you are not interested in those stats. Depending on your internet speed, state of the public IPFS network (WAN-DHT) and durations for which other chatroom peers have been online, peer discovery may take a while (upto ~ 30 seconds according to my tests). Test further. Disconnect from the internet and run the above two instances on your local machine (or two LAN-connected hosts) with the `-l` or `-L` flag. ## Changing terminal window size Should you ever need to change the size of the terminal `ipfs-chat` is running on, you would find that it messes up the screen. Don't panic. Simply press ENTER or any of the buttons on the `ipfs-chat` screen and everything will be fixed. ## Peer discovery Name of the room is the shared secret. Every participant provides a (rendezvous) file at regular intervals whose content is a time-based nonce derived from the shared secret, viz. the room name. Along with this, participants publish their public (WAN) multiaddresses at a pubsub topic that is also derived from the room name. To join the chat network, viz. the room, one needs to connect to as many online participants as possible. This is done by first querying the DHT for the providers of the rendezvous file and then swarm connecting to those peer IDs. Participants also listen to the pubsub topic where the multiaddresses are published in order to discover peers they are not directly connected to. To accommodate for peers leaving and joining the room, the query and swarm connect steps are iterated at regular intervals. Peers behind NAT use [autorelay or p2p-circuit](https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#autorelay) to be accessible by others. Local (LAN based) discovery is also enabled ([Discovery.MDNS.Enabled=true](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md)). Also, if a peer sees a message (over pubsub) from a peer that it is not directly connected to, it tries to connect to it immediately. [IPNS over pubsub](https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipns-pubsub) is also used to speed up peer discovery. Every chatroom peer resolves the same IPNS key(s) in order to subscribe to the same name-specific topics. Because of this, some peers are already connected when the peer discovery using DHT and pubsub are launched. During startup, the node tries to connect to the peers from the last session. For `go-ipfs v0.10.0` onwards, a peer, once discovered, is put into the [peering subsystem](https://docs.ipfs.io/reference/cli/#ipfs-swarm-peering). **Note**: The rendezvous nonce changes every 2 mins. Due to this, a peer might be shown to be online upto 2 mins after it goes offline. ## Security Authenticity of the messages is established through IPNS over pubsub (See [Messaging](#messaging)). All general messages are encrypted with a symmetric key (AES128) derived from the room name using a key-derivation-function (kdf) based on [Argon2](https://github.com/P-H-C/phc-winner-argon2). All private messages are encrypted with a public key (ECDH/cv25519) belonging to the recipient. All shared files and directories are encrypted (See [File sharing](#file-sharing)). The pubsub topics are separate keys derived from the room name. Therefore, the public network, that mediates the pubsub and passes the messages along, never knows the actual room name and hence, the encryption key. If the `-e` flag is provided, MIME-types of the shared files are checked against their extensions. This is to thwart an attacker sharing a malicious binary vested as a seemingly harmless filetype such as .doc. This check however requires a MIME types map to be present at `/etc/mime.types`. If your distribution doesn't have this map, it may be downloaded from [here](https://raw.githubusercontent.com/SomajitDey/ipfs-chat/main/mime.types). ## Messaging Every peer publishes its nick and a self-signed PGP public key (primary-key EDDSA/ed25519 for signing + subkey ECDH/cv25519 for encryption) under its peer ID over IPNS at the start of every session. This authenticates its claim over the nick and the public key. After discovering a peer, other peers resolve its IPNS entry and caches its nick and pubkey for use throughout the session. For general messaging, a peer signs its message with its private key and encrypts with the aforementioned symmetric key derived from the room name. For private messaging, the message is encrypted with the recipient's public key instead. The whole encrypted object is encoded in base64 and published over pubsub along with the sender's peer ID. Other peers receive this over pubsub, decrypt the message and verify the signature. If everything is ok, they then display the message in their UI against the sender's nick, peer ID and timestamp. [IPNS-pubsub](https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipns-pubsub) is enabled to aid in resolving IPNS names as quickly as possible, and reducing the dependence on DHT. ## File or directory sharing Directories, when shared, are first archived through `tar` and then those archives are shared like regular files. Shared files are encrypted using their SHA1 hash and then added to IPFS. The CID of the added file and the aforementioned encrypting hash are then sent to the chatroom peer(s) in a general or private message. The receiving peer(s) decrypt the CID and encryption hash, retrieve the encrypted file over IPFS and decrypt the same. (TBD: After decryption, receivers may check the file against the SHA1 hash received). The purpose of encrypting a file with its own hash is to generate the same output every time the same file is encrypted. This causes deduplication. For example, if A and B encrypt and share the same file with C, C only has to download the file once. Because of the content-addressability of IPFS, deduplicated objects would also have more providers, thus increasing availability and hence improving download time. To minimize disk usage by the downloaded and decrypted files, `git`-like content addressing is used. All downloaded and decrypted files remain saved in a global filestore, until garbage-cleaned. The download directory merely contains hard links to these files. The global filestore is GCd only when it exceeds a certain size (TBD:). Encrypting large files is time-consuming. Files once encrypted are therefore cached in the global filestore. Also, adding large encrypted files to IPFS is time-consuming. To avoid encrypting and adding the same file again and again, as long as the IPFS node is online, for every shared file, it maintains a map of the file-hash to its encrypted file CID. **Note**: SHA1 is preferred to other hashes merely for speed. (TBD: For added security, the SHA1 hash of the file may be salted, derived as: `cat ${file} <(echo ${salt}) | sha1sum -b | cut -d' ' -f1`. Cost: The `cat` would add significant overhead for large files). ## Efficiency [IPFS usually consumes a lot of bandwidth](https://github.com/ipfs/go-ipfs/issues/3429). To make it more efficient, all unnecessary connections are closed at regular intervals: The node maintains a list of all chatroom peers seen or discovered in a session. All other connections, except connections to the relays that the node itself or its chatroom peers are connected to, are culled on a frequent basis. New connections are always being formed to nodes within the general IPFS network. The interval between consecutive cullings is large enough to gather sufficient number of nodes for performing DHT operations such as providing the rendezvous file, finding other providers and finding the multiaddresses of those providers. Once these operations are finished, the culling is performed. Connections to the chatroom peers are never closed. To achieve this, `ipfs-chat` uses its own connection manager and does not use the [basic connection manager](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#basic-connection-manager) that ships with `go-ipfs`. The IPFS repo is also garbage-cleaned frequently to clear any irrelevant (unpinned) blocks. Less blocks in cache means smaller *IHAVE* lists and thereby less providing to directly connected peers. Simple `ipfs repo gc` was not trustworthy as it could delete newly downloaded, unpinned blocks during shared file downloads. Instead, `ipfs-chat` runs its own garbage cleaner. Note that the connection manager and frequent repo cleanup reduce bandwidth only at the cost of CPU. The go-ipfs config file has been tuned to reduce resource (CPU/bandwidth/memory) consumption. WAN-only and LAN-only modes are available (see [Usage](#usage)) to further optimize resource consumption under different situations. To minimize disk usage wherever possible, [IPFS-filestore](https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipfs-filestore) is used. For efficiency regarding file-sharing, see [File or directory sharing](#file-or-directory-sharing). **Tip**: To show bandwidth usage by the node at the end of a session, launch `ipfs-chat` with the `-b` flag. Note that this shows the cumulative bandwidth consumption by all `ipfs-chat` instances using the same node at the same time. ## Fully decentralized vs (Semi-)centralized Apart from its dependence on a set of of bootstrap and relay nodes, `ipfs-chat` is fully server/broker-less. As long as these bootstrap and relay nodes are public, there can be much redundancy and resilience. However, should you so need, you can always replace the public bootstrap and relay nodes with your own one(s). ## Future directions 1. Detect and block malicious peers. All direct connections to blocked peers are culled. Users can also block (and unblock later) specific nicks (regex pattern), peer IDs. While blocking, users can opt for - 1. Block permanently; 2. For present session only. **TBD**: News of this blocking (who blocked whom and when) may or may not be published over pubsub for other peers to see and decide for themselves. 2. Offline mode such that even if a peer goes offline, it can obtain the missed messages when it comes back online [This may well be beyond my capabilities]. Once [`orbit-db-cli`](https://github.com/orbitdb/orbit-db-cli) matures, it might help achieve this. Random idea: Online peers publish CIDs of time-based logs at regular intervals over pubsub. Logs are directories containing chats - one message in one file. Even if logs of two peers don't match exactly, they will have many files in common, thus achieving major deduplication and also helping availability across the ipfs-chat network. ## Contribute Post at [issues](https://github.com/SomajitDey/ipfs-chat/issues) and [discussion](https://github.com/SomajitDey/ipfs-chat/discussions), or [write to me](mailto://hereistitan@gmail.com). > If creating bug-reports, please provide the following: > > 1. Version: `ipfs-chat -v` > 2. go-IPFS version: `ipfs --version` > 3. Your Linux distribution > 4. Screenshots [![Sponsor](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://buymeacoffee.com/SomajitDey) ------ ###### GNU GPL v3-or-later © 2021 Somajit Dey ================================================ FILE: ipfs-chat ================================================ #!/usr/bin/env bash export LANGUAGE=C LANG=C LC_ALL=C # Details: See info and usage functions below export version="0.3.0 (beta)" info(){ # Brief: Info about ipfs-chat echo -n " Welcome to ipfs-chat ==================== Repo (For details & Bug-report): https://github.com/SomajitDey/ipfs-chat License: GNU GPL v3-or-later (C) 2021 Somajit Dey Version: " >&2 echo "${version}" }; export -f info usage(){ # Brief: Show help and exit echo -e "\nUsage: ipfs-chat [-n ] [-r ] [-d ] [-D ] [-c ] [-o ] [-w | -l] [-b]" echo -e "\nNote: -w or -W implies WAN-only connection; -l|-L is LAN-only; To have both WAN & LAN, don't use any of these flags" echo -e "\nVersion: ipfs-chat -v" echo -e "\nUpdate: ipfs-chat -u [ | ]" echo -e "\nGenerate random room name: ipfs-chat -g" echo -e "\nEnable shared file extension check against MIME-type: ipfs-chat -e" echo ; exit 1 } >&2; export -f usage kill_proc_tree(){ # Brief: Kill (with SIGKILL) all descendants of the process id given local pid for pid in $(pgrep -P "${1}"); do kill_proc_tree "${pid}" & done kill -KILL "${1}" } &>/dev/null; export -f kill_proc_tree sha1(){ # Usage: sha1 ##or## sha1 < path_to_data_file local string="${@}" if [[ -n "${string}" ]]; then sha1sum <(echo -n "${string}") else sha1sum fi | cut -d ' ' -f 1 } 2>/dev/null; export -f sha1 b64(){ # Brief: Inline base64 encode with / replaced by _, and the trailing = dropped # Deleting last = because base64 encoding 160-bit kdf or hmac always gives single =, hence redundant # Substituting / with _ because / messes up using kdf/hmac outputs as directory or filenames # Usage: b64 xxd -r -p | base64 -w0 | tr -d '=' | tr '/' '_' } 2>/dev/null; export -f b64 hmac(){ # Usage: hmac # Output: base64, with / replaced by _, and trailing = dropped local key="$(sha1 "${1}")" data="$(sha1 "${2}")" echo -n "${data}" | xxd -r -p | openssl dgst -sha1 -mac hmac -macopt hexkey:"${key}" | cut -d ' ' -f 2 | b64 } 2>/dev/null; export -f hmac kdf(){ # Usage: kdf # Output: 160-bit base64 key, with / replaced by _, and the trailing = dropped local key="$(sha1 "${1}")" data="${2}" # No-need to lose `data` bits by prehashing. Hashing `key` ensures argon2 salt is atleast 8 characters long. echo -n "${data}" | argon2 "${key}" -t 3 -m 12 -p 1 -l 20 -r | b64 } 2>/dev/null; export -f kdf dep_check(){ # Brief: Check major dependencies local ipfs_version quit if ipfs_version=$(ipfs version --number 2>/dev/null); then local req_ipfs_ver=0.11.0 # Minimum ipfs-cli version required [[ "$(echo -e "${ipfs_version}\n${req_ipfs_ver}" | sort -t. -k1,1n -k2,2n -k3,3n | head -n1)" == "${req_ipfs_ver}" ]] || \ { echo -e "Required: go-ipfs-cli version >= ${req_ipfs_ver}\nSuggestion: ipfs update install latest\n"; quit="yes";} else echo -e "Required: go-ipfs-cli\nSource: https://docs.ipfs.io/install/command-line/#linux\n" quit="yes" fi if ! command -v dialog &>/dev/null; then echo -e "Required: dialog\nSource: Native package repository" echo -e "Ref: https://command-not-found.com/dialog\n" quit="yes" fi if ! command -v curl &>/dev/null; then echo -e "Required: curl\nSource: Native package repository" echo -e "Ref: https://command-not-found.com/curl\n" quit="yes" fi if ! command -v flock &>/dev/null; then echo -e "Required: flock\nSource: Native package repository" echo -e "Ref: https://command-not-found.com/flock\n" quit="yes" fi if ! command -v openssl &>/dev/null; then echo -e "Required: openssl\nSource: Native package repository" echo -e "Ref: https://command-not-found.com/openssl\n" quit="yes" fi if ! command -v tput &>/dev/null; then echo -e "Required: tput\nSource: Native package repository" echo -e "Ref: https://command-not-found.com/tput\n" quit="yes" fi if ! command -v jq &>/dev/null; then echo -e "Required: jq\nSource: Native package repository" echo -e "Ref: https://stedolan.github.io/jq/download/\n" quit="yes" fi if ! command -v argon2 &>/dev/null; then echo -e "Required: argon2-cli\nSource: Native package repository / web (pre-compiled binary or build from source)" echo -e "Ref: https://command-not-found.com/argon2" echo -e "Ref: https://github.com/SomajitDey/phc-winner-argon2/releases/download/static-build_linux_x86_64/argon2" echo -e "Ref: https://github.com/P-H-C/phc-winner-argon2\n" quit="yes" fi [[ -v quit ]] && exit 1 } >&2; export -f dep_check dep_check win2lin_path(){ # Brief: Convert Windows to Linux path. If Linux path is given, does tilde expansion & quote removal. # Usage: win2lin_path ##or## win2lin_path < file_containing_path # The input can be formatted freely. Path may contain spaces not esacaped by \. Quotes may or may not be used for Win paths local input="${@}"; [[ -n "${input}" ]] || read -r input # Backslash not special due to -r input="${input%/}" # Trailing slash removal, if any if ! [[ "${input}" == ~* ]]; then local quote_less="$(echo "${input//\\/\\\\}" | xargs)" # xargs does quote removal. To save backslash, escaped 'em wslpath "${quote_less}" && return fi eval echo "${input}" # eval does tilde-expansion } 2>/dev/null; export -f win2lin_path update(){ # Usage: update [-s ] [-d ] [git-branch] # Note: If -d, it only downloads the latest version to the given location, doesn't update # Note: If -s, it only updates from the given source local OPTIND=1 opt cli_opt source dest while getopts s:d: opt; do case "${opt}" in s) cli_opt="${opt}"; source="${OPTARG}";; d) cli_opt="${opt}"; dest="${OPTARG}";; esac done local branch="${!OPTIND}" local url="https://raw.githubusercontent.com/SomajitDey/ipfs-chat/${branch:=main}/ipfs-chat" local tmp="$(mktemp)" # Using /tmp instead of tmpdir below as tmpdir won't exist for `ipfs-chat -u` trap "rm -f ${tmp}" return local tags api_url="https://api.github.com/repos/SomajitDey/ipfs-chat/tags" case "${cli_opt}" in s) [[ -x "${source}" ]] || return 1 mv -f "${source}" "${BASH_SOURCE}" 2>/dev/null || sudo mv -f "${source}" "${BASH_SOURCE}" && \ echo "Update: Updated to v$(${BASH_SOURCE} -v)" ;; d) if timeout 4 curl -sfNL -o "${tmp}" "${url}"; then chmod +x "${tmp}" && mv "${tmp}" "${dest}" # Atomic update elif tags="$(timeout 2 curl -sfNL "${api_url}" 2>/dev/null)"; then echo "Error: Couldn't find the requested tag/branch" jq -r '.[].name' <<< "${tags}" | xargs echo "Releases: " return 1 else echo "Error: Failed to update. Check internet connection." return 1 fi ;; *) update -d "${tmp}" "${branch}" && update -s "${tmp}" ;; esac } >&2; export -f update parse_cmdline(){ local opt OPTIND=1 while getopts n:r:d:D:c:gwWlLo:vbeuh opt;do case "${opt}" in n) nick="${OPTARG}";; r) room="${OPTARG}";; d) dldir="$(win2lin_path "${OPTARG}")";; D) max_dl_MB="${OPTARG}";; c) local repo="${OPTARG}";; g) echo -n "Random room: " >&2; dd if=/dev/urandom count=1 bs=6 2>/dev/null | base64 | tr '/' '%'; exit;; w|W) export connect_mode="WAN";; l|L) export connect_mode="LAN";; o) export chat="${OPTARG}";; v) echo "${version}"; exit;; b) export disable_bandwidth_metrics="false";; e) export mime_type_check="enabled";; u) update "${!OPTIND}"; exit "${?}";; h|*) usage;; esac done export room="${room:="Lobby"}" nick="${nick:="${USER}"}" export dldir="${dldir:="${HOME}/ipfs-chat-downloads"}" max_dl_MB="${max_dl_MB:=-1}" mkdir -p "${dldir}" 2>/dev/null || { echo "Error: Directory at '${dldir}' could not be created. Exiting." >&2; exit 1;} [[ "${max_dl_MB}" =~ ^[-]?[[:digit:]]+$ ]] || { echo "Error: -D value should be an integer" >&2; exit 1;} export IPFS_PATH="${repo:-"${HOME}/.ipfs-chat"}" }; export -f parse_cmdline parse_cmdline "$@" info echo "DL dir: $(tput smso)${dldir}$(tput rmso)" >&2 echo "Max filesize: $(tput setaf 1)$(((max_dl_MB>=0)) && echo "${max_dl_MB} MB" || echo 'N/A; Use -D flag')$(tput sgr0)" >&2 cache_peer(){ # Brief: Cache multiaddress given as argument. The cache will be used by con_cull ipfs swarm peering add "${1}" # Add to peering subsystem (go-ipfs >= v0.10.0) # TODO: Ain't relay protected from ConnMgr? echo "${1}" | grep -o '/p2p/[[:alnum:]]*' | grep -vf "${sess_peers}" | \ flock "${sess_peers}" xargs -r -n1 >> "${sess_peers}" } &>/dev/null; export -f cache_peer ipfs_config(){ # Brief: Configure IPFS node # Note: Use random ports for everything so that multiple IPFS nodes can coexist on the same machine # Note: Most configs below are for reducing bandwidth/CPU/disk usage echo "Status: Configuring IPFS node..." if [[ "$(ipfs config 'ipfs-chat-version' 2>/dev/null)" != "${version}" ]] || \ [[ "$(ipfs config 'App' 2>/dev/null)" != "ipfs-chat" ]]; then (ipfs init --profile lowpower || ipfs config profile apply lowpower \ && ipfs config profile apply randomports) &>/dev/null || \ { echo "Error: Failed to create IPFS repo at ${IPFS_PATH}"; exit 1;} ipfs config --json Pubsub.Enabled true ipfs config --json Ipns.UsePubsub true ipfs config Pubsub.Router gossipsub ipfs config Ipns.RepublishPeriod 2m0s ipfs config Ipns.RecordLifetime 24h ipfs config Reprovider.Interval 2m0s ipfs config Reprovider.Strategy roots ipfs config Routing.Type dhtclient ipfs config Swarm.ConnMgr.Type none ipfs config --json Experimental.FilestoreEnabled true ipfs config 'ipfs-chat-version' "${version}" ipfs config 'App' "ipfs-chat" fi export sess_peers="${IPFS_PATH}/session_peers" # This file caches all ipfs-chat peers (multiaddresses) seen when node is online local prev_sess_peers="$(cat "${sess_peers}" 2>/dev/null)" # Holds peers from last session, if any export sess_uplds="${IPFS_PATH}/session_uploads" # Maps SHA1 hash of file to CID of its hash-encrypted object # Repo cleanup when no other instance is running; i.e. node is offline if ! ipfs swarm peers; then rm -rf "${IPFS_PATH}/room#"* rm -f "${sess_peers}" "${sess_uplds}" ipfs pin ls --type=recursive --quiet | xargs -r -n1 -P0 ipfs pin rm # Remove stale pins to destress reprovider fi &>/dev/null # Can't be non-blocking. Otherwise launching IPFS daemon shows, "ERROR: lock ... :someone else has lock" export global_fs="${HOME}/.filestore-ipfs-chat"; mkdir -p "${global_fs}" # For multinode deduplication. UL files named after SHA1, DL files after CID # Cleanup global cache in background when disk usage exceeds 1 GB # ICGFS: IPFS_CHAT_GLOBAL_FILESTORE_SIZE in MB (type: integer) if (("$(du -BM "${global_fs}" | awk '{print $1}' | tr -d M)" > "${ICGFS:=1024}")); then flock -n "${global_fs}" rm -rf "${global_fs}"/* fi & echo "$(tput cuu1; tput ed)Status: Preparing the IPFS config file..." ipfs config --bool Swarm.DisableBandwidthMetrics "${disable_bandwidth_metrics:-true}" case "${connect_mode}" in LAN) ipfs config profile apply local-discovery &>/dev/null # Revert changes done by Server profile #ipfs config --bool Discovery.MDNS.Enabled true ipfs config --json Addresses.NoAnnounce '[]' ipfs bootstrap rm all &>/dev/null # For faster startup # Disable NAT traversal ipfs config --bool Swarm.DisableNatPortMap true ipfs config --bool Swarm.Transports.Network.Relay false ipfs config --bool Swarm.RelayClient.Enabled false ipfs config --bool Swarm.EnableHolePunching false ;; WAN | *) if [[ "${connect_mode}" == WAN ]]; then ipfs config profile apply server &>/dev/null # Server profile disables swarm connecting to private IPs. Doesn't announce own private IPs. Disables MDNS discovery #ipfs config --bool Discovery.MDNS.Enabled false ipfs config show | \ jq '.Addresses.NoAnnounce += ["/ip4/127.0.0.1/ipcidr/1", "/ip6/::1/ipcidr/1"]' > "${IPFS_PATH}"/.config && \ ipfs config replace "${IPFS_PATH}"/.config else ipfs config profile apply local-discovery &>/dev/null # Revert changes done by Server profile #ipfs config --bool Discovery.MDNS.Enabled true ipfs config --json Addresses.NoAnnounce '[]' fi ipfs bootstrap add default &>/dev/null # For WAN-DHT # For NAT traversal ipfs config --bool Swarm.DisableNatPortMap false ipfs config --bool Swarm.Transports.Network.Relay true ipfs config --bool Swarm.RelayClient.Enabled true ipfs config --bool Swarm.EnableHolePunching true ;; esac # Disable RelayService. This config is given last as server profile in WAN mode turns it on ipfs config --bool Swarm.RelayService.Enabled false rm -f "${IPFS_PATH}/config-pre-"* # Remove config backup files generated with `ipfs config profile apply` echo "$(tput cuu1; tput ed)Status: Configuring ports..." pscan(){ # Brief: Give an unused, random, local TCP port except the one passed as argument local port except="${1}" while port="$(( 0x"$(dd if=/dev/urandom bs=2 count=1 2> /dev/null | xxd -p)" - 1 ))";do ((port!=except)) || continue nc -z localhost "${port}" || break done echo "${port}" } 2>/dev/null; export -f pscan local API_port="$(pscan)"; ipfs config Addresses.API "/ip4/127.0.0.1/tcp/${API_port:=5001}" local gateway_port="$(pscan "${API_port}")"; ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/${gateway_port:=8080}" echo "$(tput cuu1; tput ed)Status: Getting node online (launching IPFS daemon)..." launch_ipfs(){ # Brief: Launch IPFS daemon in the background, if not already running. Reflect online status through exit code ipfs swarm peers || \ [[ "$(flock -s "${global_fs}" ipfs daemon ${@} | grep -iom1 'Daemon is ready' &)" ]] } &>/dev/null; export -f launch_ipfs if launch_ipfs ; then echo "$(tput cuu1; tput ed)Status: IPFS node is configured" else echo "Error: Failed to launch IPFS daemon"; exit 1 fi 2>/dev/null declare -rigx daemon_launch_time="${EPOCHSECONDS}" export selfID="$(ipfs config Identity.PeerID)"; cache_peer "/p2p/${selfID}" (# Prime the network with the peers from last session, if any grep -v "/p2p/${selfID}" <<< "${prev_sess_peers}" | xargs -r -n1 ipfs swarm connect # Subscribe to common topics over IPNS pubsub so that peer discovery becomes faster ipfs name resolve --dhtt=1s "$(echo -n IPFS-Chat | ipfs add -n --pin=false -Q)" # App-specific key ipfs bootstrap | grep -o '[[:alnum:]]*$' | xargs -r -n1 ipfs name resolve --dhtt=1s # General key ) &>/dev/null & export topic="$(kdf "ipfs-chat" "${room}")" broadcast="$(kdf "peer-addresses" "${room}")" } >&2; export -f ipfs_config ipfs_config config(){ # Brief: General config. Compute and export variables. Setup tmp dir and runtime filesystem. if ls -d "${IPFS_PATH}/room#"* &>/dev/null; then export nick="$(tail -n1 $(ls -d1 "${IPFS_PATH}/room#"* | head -n1)/pubkey.asc)" echo "Note: Using ${nick} as nick" # Using separate nicks with same peer ID will cause conflicts with IPNS fi export enc_key="$(kdf "symmetric-encryption-key" "${room}")" tmpdir="${IPFS_PATH}/room#${topic}" mkdir "${tmpdir}" 2>/dev/null || { echo "Error: Another instance running"; exit 1;} tmpgen(){ mktemp "${tmpdir}/.XXXXX";}; export -f tmpgen export chat="${chat:-"${tmpdir}/chat"}"; :>"${chat}" # Redirected no-op to clear file export peers="${tmpdir}/peers"; :>"${peers}" # File must exist for `dialog` to show through its tailbox export peers_buffer="${tmpdir}/peers.buffer" peers_ready="${tmpdir}/peers.ready" export input="${tmpdir}/input" dl_lock="${tmpdir}/dl.lock" export bg_pids="${tmpdir}/background.proc.id.list" export code="${tmpdir}/latest_version" [[ "${connect_mode}" != LAN ]] && update -d "${code}" &>/dev/null & export cb_wd="${tmpdir}/chatbox.width" # Chatbox width lwrap(){ # Brief: Line wrapping to fit our chatbox width # Usage: lwrap [file] # Note: If file is provided, file is folded in-place under lock. Otherwise, stdin to stdout local file="${1}" width="$(($(flock -s "${cb_wd}" cat "${cb_wd}")-5))" # Read lock; note option -s in flock if [[ -n "${file}" ]]; then local buff="$(tmpgen)" fold -s -w "${width}" "${file}" > "${buff}" && flock "${file}" mv "${buff}" "${file}" # In-place, atomic edit else fold -s -w "${width}" fi }; export -f lwrap } >&2; export -f config config safe_gc(){ # Brief: Remove blocks that are not pinned. Difference with `ipfs repo gc` is that this removes only those blocks # that are there when function is called, even if the actual cleanup takes time. Also, can check lock for added safety. # Usage: safe_gc [] # Note: Requires IPFS to be online flock -n 3 || return 1 local lock="${1}" if [[ -n "${lock}" ]]; then flock -n "${lock}" ipfs refs local # This doesn't take much time else ipfs refs local fi | xargs -r -n1 ipfs block rm # This is the time consuming part } &>/dev/null 3<"${IPFS_PATH}/config"; export -f safe_gc safe_gc & echo "${!}" >> "${bg_pids}" identity(){ # Brief: Generate key-pair. Claim nick & pubkey using IPNS. export GNUPGHOME="${IPFS_PATH}/gpg" pubkey="${tmpdir}/pubkey.asc" peer_kbx="${tmpdir}/peer.kbx" gnupg(){ flock "${GNUPGHOME}" gpg --batch -q --always-trust "${@}";}; export -f gnupg # Thread-safe gpg in batch mode if mkdir "${GNUPGHOME}"; then gnupg --gen-key << EOF %no-protection Key-Type: EDDSA Key-Curve: ed25519 Subkey-Type: ECDH Subkey-Curve: cv25519 Name-Real: ${selfID} Expire-Date: 0 EOF (($? == 0)) || return 1 gnupg -a -o "${GNUPGHOME}/pubkey.asc" --export "${selfID}" fi cat "${GNUPGHOME}/pubkey.asc" <(echo "${nick}") > "${pubkey}" ipfs name publish --allow-offline --ipns-base=b58mh "/ipfs/$(ipfs add -Q "${pubkey}")" & # Claim nick & pubkey using IPNS } &>/dev/null; export -f identity identity || { echo "Error: Failed to generate key-pair" >&2; exit 1;} on_exit(){ # Brief: Perform these tasks on exit; called by trap local pid for pid in $(cat ${bg_pids}); do kill_proc_tree "${pid}" & done rm -rf "${tmpdir}" if ! ls -d ${IPFS_PATH}/room#*; then gpgconf --kill gpg-agent ipfs shutdown fi } &>/dev/null; export -f on_exit trap "on_exit" exit connect_peer(){ # Brief: Connect to peer ID or multiaddress provided as argument # TODO: Simplify and economize local input="${1}" peerID="${1##*/}" multiaddress if [[ "${peerID}" == "${selfID}" ]]; then return 0 elif [[ "${peerID}" != "${input}" ]]; then multiaddress="${input}" else multiaddress="/p2p/${peerID}" fi if ipfs swarm connect "${multiaddress}"; then # Swarm connect autochecks whether peerID is already connected. If not, only then tries multiaddress for multiaddress in $(ipfs swarm peers | grep "${peerID}"); do cache_peer "${multiaddress}" # Add multiaddress of both peer and any relay it is accessed through done else cache_peer "/p2p/${peerID}" return 1 fi } &>/dev/null; export -f connect_peer peer_pubkey_nick(){ # Brief: Import pubkey of peer ID or multiaddress passed as argument and output its nick. Flag -n to force IPNS update (nocache). # TODO: TBD: peer_pubkey=CID_peerID # TODO: Optimize performance / eliminate repetitions with lock. Solve sometimes peer_nick not showing local OPTIND=1 opt nocache getopts n opt; [[ "${opt}" == "n" ]] && nocache="--nocache" local multiaddress="${!OPTIND}" local peerID="${multiaddress##*/}" peer_nick connect_peer "${multiaddress}" & local ipfs_path="$(i=0; until ipfs name resolve ${nocache} "/ipns/${peerID}" || ((i>5));do ((i++)); done)" [[ -n "${ipfs_path}" ]] || return 1 local peer_pubkey="${tmpdir}/${ipfs_path##*/}" if ! [[ -e "${peer_pubkey}" ]]; then # Check size of file before download to avoid spam. Pubkey is 669 bytes to be exact. Add some grace for nick etc. (("$(ipfs files stat --size "${ipfs_path}" || 1001)" < 1000)) || return 1 gnupg --yes --no-default-keyring --keyring "${peer_kbx}" --delete-keys "${peerID}" flock "${peer_pubkey}" ipfs get -o "${peer_pubkey}" "${ipfs_path}" && ipfs pin add "${ipfs_path}" && \ gnupg --no-default-keyring --keyring "${peer_kbx}" --import "${peer_pubkey}" || rm -f "${peer_pubkey}" fi &>/dev/null if peer_nick="$(tail -n1 "${peer_pubkey}")"; then [[ -n "${peer_nick}" ]] || return 1 # TODO: Understand how peer_nick can ever be empty local peer_buff="${peer_nick} @${peerID:${#peerID}-6:6}" grep -q -m1 "${peer_buff}" "${peers}" || flock "${peers}" echo "${peer_buff}" >> "${peers}" # Live update of online-peers window flock "${peers_buffer}" echo "${peer_buff}" >> "${peers_buffer}" echo "${peer_buff}" else return 1 fi } 2>/dev/null ; export -f peer_pubkey_nick check_mime_type(){ # Brief: Checks if mime-type of given file matches with the file extension. If extension is unknown, let it be. # If extension refers to different mime-type, Fail. # Usage: check_mime_type [[ -v mime_type_check ]] || return 0 local mime_type_table="/etc/mime.types" path="${1}" ext="${2##*.}" [[ -f "${mime_type_table}" ]] || return 0 # Perhaps this table exists only in Debian and Ubuntu local mime_frm_ext="$(grep -m1 -w "${ext}" "${mime_type_table}" | awk '{print $1}')" if [[ -n "${mime_frm_ext}" ]]; then local actual_mime="$(file -ib "${path}" | cut -d ';' -f 1)" # -i or --mime is more supported than --mime-type [[ "${actual_mime}" != "${mime_frm_ext}" ]] && [[ "${actual_mime}" =~ ^application/.*$ ]] && \ echo ".$(grep -w "${actual_mime}" "${mime_type_table}" | awk '{print $2}')" fi } 2>/dev/null; export check_mime_type file_unpack(){ # Brief: Download and decrypt shared file # Usage: file_unpack # TODO: Ask user for permission to download instead of rejecting for size>max_dl_MB flock -s 3 local dec_hash="${1}" cid="${2}" dlpath="${dldir}/${3}" local cache="${global_fs}/${cid}" if ! [[ -f "${cache}" ]]; then ((max_dl_MB < 0)) || (($(ipfs files stat --size /ipfs/"${cid}") < max_dl_MB*1024*1024)) || return 1 local buffer="$(tmpgen)" ipfs cat "${cid}" | openssl enc -aes128 -pass pass:"${dec_hash}" -nosalt -a -A -d -out "${buffer}" && \ mv "${buffer}" "${cache}" && ipfs pin add "${cid}" fi local mime_ext="$(check_mime_type "${cache}" "${dlpath}")" ln --backup=numbered "${cache}" "${dlpath}${mime_ext}" || \ cp --backup=numbered "${cache}" "${dlpath}${mime_ext}" } &>/dev/null 3>"${dl_lock}"; export -f file_unpack subscriber_daemon(){ # Brief: Listen to messages at pubsub, decrypt & verify signature, display if ok # TODO: Malicious peer detection and blocking. local timestamp CID peerID readbuff recipID sender buffer="$(tmpgen)" gpg_stderr="$(tmpgen)" prefix while read -r peerID readbuff recipID;do (sender="$(peer_pubkey_nick "${peerID}")" || exit 1 # Note absence of -n flag in peer_pubkey_nick case "${recipID}" in all) prefix="$(printf '=%.0s' {1..40})"$'\n' gnupg --keyring "${peer_kbx}" --passphrase "${enc_key}" --pinentry-mode loopback -d ;; "${selfID}") prefix='**************Private message***********'$'\n' gnupg --keyring "${peer_kbx}" -d ;; *) exit 1;; esac < <(echo -n "${readbuff}" | base64 -d) > "${buffer}" 2> "${gpg_stderr}" || exit 1 grep -iq "Good signature from \"${peerID}\"" "${gpg_stderr}" || exit 1 # Verify authenticity/signature grep -xq '[[:print:]]*' "${buffer}" || exit 1 # Check msg is text only to avoid spam read timestamp dec_hash CID < <(head -n1 "${buffer}" | grep -xE '[[:digit:]]*[[:blank:]]([[:alnum:]+_]*[[:blank:]][[:alnum:]]*)?') timestamp="$(date -d @${timestamp} +"%a %H:%M:%S")" || exit 1 prefix="${prefix}${sender} ${timestamp} -- " flock "${chat}" cat <(echo -n "${prefix}") <(tail -n+2 "${buffer}") <(echo -e \\n) | lwrap >> "${chat}" if [[ -n "${dec_hash}" ]]; then [[ "${peerID}" != "${selfID}" ]] || [[ "${recipID}" == "${selfID}" ]] || exit 1 eval filename="$(awk NR==2 "${buffer}" | cut -d ' ' -f 3-)" # eval is for quote removal file_unpack "${dec_hash}" "${CID}" "${filename}" || \ flock "${chat}" echo -e "Download failed -- ${filename}\n" | lwrap >> "${chat}" fi )& done < <(ipfs pubsub sub "${topic}" | grep --line-buffered -x '[[:alnum:]]*[[:blank:]][[:alnum:]+/=]*[[:blank:]][[:alnum:]]*') } &>"${tmpdir}/subscriber_daemon.log"; export -f subscriber_daemon subscriber_daemon & echo "${!}" >> "${bg_pids}" pubsub_conn(){ # Brief: Connect to multiaddresses that are broadcast over pubsub # TODO: Economize same peerID multiple multiaddress local multiaddress peerID while read -r multiaddress;do peerID="${multiaddress##*/}" [[ "${peerID}" == "${selfID}" ]] || peer_pubkey_nick "${multiaddress}" # TODO: TBD: & (bg) or not? done < <(ipfs pubsub sub "${broadcast}" | grep --line-buffered -x '[[:alnum:]/.:-]*') } &>"${tmpdir}/pubsub_conn.log"; export -f pubsub_conn echo "Status: Launching peer-discovery over pubsub..." >&2; pubsub_conn & echo "${!}" >> "${bg_pids}" con_cull(){ # Brief: Cull all connections except those in the cache, and the connection to relay (if any) # Purpose: Reducing bandwidth usage by killing all irrelevant connections local own_relay="$(ipfs id "${selfID}" -f="\n" | grep -o '/p2p/[[:alnum:]]*' | sort -u)" ipfs swarm peers | grep -o '/p2p/[[:alnum:]]*' | grep -vf "${sess_peers}" | grep -vf <(echo "${own_relay}") | \ xargs -r -n1 ipfs swarm disconnect } &>/dev/null; export -f con_cull declare -irx ICPDI="${ICPDI:=30}" # IPFS_CHAT_PEER_DISCOVERY_INTERVAL in seconds (type: integer) peering_daemon(){ # Brief: Discover & connect to chat-peers & announce self for others to discover - at regular intervals local peerID local -a dht_ops_pid local -A peerID_list # Associative array local -r start_peer_discov="${EPOCHSECONDS}" while :;do dht_ops_pid=() # Stores pid's of background DHT operations executing in the current pass local timestamp="${EPOCHSECONDS}" # Current Unix time local nonce="$(hmac "${broadcast}" "$((timestamp/120))" | ipfs add -Q --stdin-name='Rendezvous')" # Announce time based nonce #ipfs dht provide "${nonce}" & dht_ops_pid+=($!) # TODO: TBD: Isnt `ipfs add` enough? `ipfs dht provide` takes loooong time peerID_list=() # Would store peerIDs seen in this pass while read -r -t 5 peerID; do # Connecting to peers and importing their latest pubkeys. Exp: No timeout messes things up ((peerID_list["${peerID}"] != 1)) || continue # peerID handled already, so move on peerID_list["${peerID}"]=1 # Add to list so that other iterations won't handle this peerID again peer_pubkey_nick -n "${peerID}" &>/dev/null & dht_ops_pid+=($!) # Notice the nocache flag -n forcing IPNS update done < <(cat <(ipfs pubsub peers "${topic}") <(ipfs pubsub peers "${broadcast}") <(timeout 5.5 ipfs dht findprovs "${nonce}")) # Makes things concurrent. Note: Without the `ipfs dht` timeout, `ps` would be replete with older `cat` and `ipfs dht` [[ -n "${dht_ops_pid}" ]] && wait "${dht_ops_pid[@]}" # Wait till all DHT operations are complete ipfs id "${selfID}" -f="\n" | grep -vf <(ipfs diag sys | jq -r .net.interface_addresses[]) | \ ipfs pubsub pub "${broadcast}" # Announce own public multiaddresses over pubsub ipfs pin rm "${nonce}" &>/dev/null & # Otherwise reprovider will continue announcing stale nonce. Pin still necessary to save from auto-GC flock "${peers_buffer}" sort -uo "${peers_buffer}" "${peers_buffer}" && mv "${peers_buffer}" "${peers_ready}" # In-place sort followed by atomic move. -u defends against peers_buffer containing repetitions if ((EPOCHSECONDS-start_peer_discov > 30)); then con_cull & # Need for DHT is over for now. So, let's cull unnecessary connections to reduce bandwidth usage. safe_gc "${dl_lock}" & # Remove irrelevant blocks in bg # Lockfile makes sure this is not run during file download, as otherwise downloaded but yet unpinned blocks might be GCd sleep "$((ICPDI-EPOCHSECONDS+timestamp))" 2>/dev/null # Redirection for when the sleep time is negative else continue # For the initial 30s after launch be relentless in peer discovery. No culling, no GC. fi done } &>"${tmpdir}/peering_daemon.log"; export -f peering_daemon echo "Status: Launching peer-discovery over DHT..." >&2; peering_daemon & echo "${!}" >> "${bg_pids}" file_pack(){ # Brief: Encrypt file with its salted hash, add to IPFS & output CID and encrypt key # Usage: file_pack # This is just for simplicity of `send` code below # This function also replaces the path present in the given file with just the filename local msg="${1}" path filename path="$(win2lin_path < "${msg}")" if [[ -f "${path}" ]]; then filename="${path##*/}" elif [[ -d "${path}" ]]; then local dir="${path}"; path="$(tmpgen)" local dirname="${dir##*/}" (cd "${dir}"/.. ; tar -czf "${path}" "${dirname}") # This trick makes sure tar -xzf gives only the desired directory, not its parents filename="${dirname}.tar.gz" else return 0 fi local enc_hash="$(sha1sum -b "${path}" | cut -d' ' -f1 | b64)" if ! grep -m1 "${enc_hash}" "${sess_uplds}"; then local cache="${global_fs}/${enc_hash}" [[ -f "${cache}" ]] || openssl enc -aes128 -pass pass:"${enc_hash}" -nosalt -a -A -in "${path}" -out "${cache}" local hlink="$(tmpgen)"; ln -f "${cache}" "${hlink}" # This is necessary for ipfs add --nocopy below; otherwise ipfs add fails if cache is outside "${IPFS_PATH}/.." ((max_dl_MB < 0)) || (("$(wc -c "${hlink}" | cut -d ' ' -f1)" < max_dl_MB*1024*1024)) || return 1 echo "${enc_hash} $(ipfs add --nocopy --fscache -Q "${hlink}")" | flock "${sess_uplds}" tee -a "${sess_uplds}" fi # Openssl with -nosalt instead of GPG, because GPG or Openssl -salt encryption is time dependent echo -n "Sent file: \"${filename}\"" > "${msg}" } 2>/dev/null; export -f file_pack send(){ # Brief: Encrypt and sign user's msg & publish to pubsub [[ -s "${input}" ]] || return # Skip empty input local msg="$(tmpgen)" recipID="all" local first_word="$(cut -z -d ' ' -f 1 "${input}")" if [[ "${first_word}" =~ ^@[[:alnum:]]{6}$ ]]; then recipID="$(grep -Eom1 "[[:alnum:]]*${first_word/@/}$" "${sess_peers}")" cut -d ' ' -f 2- "${input}" | tr -d $'\n' > "${msg}" grep -xq "${first_word}" "${msg}" && return # Skip empty input local prefix="PM to $(grep -m1 "${first_word}" "${peers}") $(date +"%a %H:%M:%S") -- " else mv "${input}" "${msg}" fi ( if enc_hash_cid="$(file_pack "${msg}")"; then buffer="$(cat <(echo "${EPOCHSECONDS} ${enc_hash_cid}") "${msg}" | \ case "${recipID}" in all) gnupg --passphrase "${enc_key}" --pinentry-mode loopback -s -c --cipher-algo AES128;; *) peer_pubkey_nick "${recipID}" >/dev/null ; gnupg --keyring "${peer_kbx}" -s -r "${recipID}" -e;; esac | base64 -w0)" ipfs pubsub pub "${topic}" <<< "${selfID} ${buffer} ${recipID}" else prefix="Failed to send -- " fi [[ -v prefix ]] && flock "${chat}" cat <(echo -n "${prefix}") "${msg}" <(echo -e \\n) | lwrap >> "${chat}" ) & } &>/dev/null; export -f send ui(){ # Brief: UI event-loop. Window numbering: 1(Top Left) 2(Top Right) 3(Spanning Bottom) local PM_buffer="$(tmpgen)" txt_buffer="$(tmpgen)" local input_help="\Zb\Z4Nick: \Zu\Z0${nick}\Zn \Zb\Z4peerID: \Zu\Z0@${selfID:${#selfID}-6:6}\Zn \Zb\Z4General-Message:\Z1 Type, then \Z4Send\Z1 (or press \Z4Enter\Z1)\Zn \Zb\Z4Fle-sharing:\Z2 Drag-n-drop file/directory, or use \Z4Explorer\Zn \Zb\Z4Private-Message:\Z5 Select peer using \Z4PM\Z5, then type and \Z4Send\Zn" local chat_title="Room: ${room}" local peers_title="Online-peers" local peering_mode="\Zb\Z4${connect_mode:-"WAN+LAN"}\Zn" while :;do # Dimensions are computed just before calling `dialog` to accomodate for the latest terminal window size changes local tty_height="$(tput lines)" tty_width="$(tput cols)" local win3_height=10 win3_width="${tty_width}" local win12_height="$((tty_height-win3_height-1))" # The -1 gap looks awesome as it demarcates better local win2_width="$((tty_width/4))" local win1_width="$((tty_width-win2_width))" if ((win1_width != last_win1_width)); then flock -x "${cb_wd}" echo "${win1_width}" > "${cb_wd}" # Write lock; note option -x in flock lwrap "${chat}" local last_win1_width="${win1_width}" fi # Conditionality decreases lag between pressing Send and subsequent chatbox update DIALOG_CANCEL=4 dialog --keep-tite \ --title "${chat_title}" --begin 0 0 --tailboxbg "${chat}" "${win12_height}" "${win1_width}" \ --and-widget --colors --hline "${peering_mode}" \ --title "${peers_title}" --begin 0 "${win1_width}" --tailboxbg "${peers}" "${win12_height}" "${win2_width}" \ --and-widget --colors \ --no-shadow --title "Press Esc to exit" --begin "$((tty_height-win3_height))" 0 \ --ok-label "Send" --cancel-label "Explorer" \ --extra-button --extra-label "Chat" \ --help-button --help-label "PM" \ --inputbox "${input_help}" "${win3_height}" "${win3_width}" "$(cat "${PM_buffer}" "${txt_buffer}")" \ 2> "${input}" local exit_code=$? mv -f "${peers_ready}" "${peers}" &>/dev/null # Refresh online-peers case "${exit_code}" in 0) # Button: Send send : > "${PM_buffer}"; : > "${txt_buffer}" ;; 2) # Button: PM sed -E s/^@[[:alnum:]]{6}[[:blank:]]?// "${input}" > "${txt_buffer}" # Put anything except recipID in buffer dialog --keep-tite --no-shadow --colors --hline "${peering_mode}" --exit-label "Back" --ok-label "Select" \ --title "${peers_title}" --begin 0 0 --menu "Choose peer" "${tty_height}" "${tty_width}" "${tty_height}" \ $(awk '{print $2,$1}' "${peers}") 2> "${PM_buffer}" && echo -n ' ' >> "${PM_buffer}" ;; 3) # Button: Chat dialog --keep-tite --no-shadow --scrollbar --exit-label "Back" \ --title "${chat_title}" --begin 0 0 --textbox "${chat}" "${tty_height}" "${tty_width}" : > "${PM_buffer}"; : > "${txt_buffer}" ;; 4) # Button: Explorer dialog --keep-tite --colors --begin 0 0 \ --title "Help: \Z1Tab\Zn for choosing window; \Z1Spacebar\Zn for autocomplete or select/copy" \ --fselect "${PWD}/" "${win12_height}" "${tty_width}" 2> "${txt_buffer}" ;; 1 | *) # Ctrl-C or Esc local confirm_quit="Shared file download is in progress. Still wanna quit?" if ! flock -n "${dl_lock}" -c : ; then # Check if dl_lock is held by file_unpack or safe_gc. In the latter case, return without prompt. if flock -s "${dl_lock}" -c : ; then # Read lock could be acquired, hence it must be file_unpack that's holding dl_lock dialog --keep-tite --yesno "${confirm_quit}" "$(tput lines)" "$(tput cols)" && return "${exit_code}" else return "${exit_code}" # Lock held by safe_gc fi else return "${exit_code}" fi ;; esac done }; export -f ui echo "Status: Launching UI...(If it takes a long time to open, try pressing Enter)" >&2; ui [[ -v disable_bandwidth_metrics ]] && \ echo -e "Stats: $(ipfs stats bw | head -n3)\nTime: $((EPOCHSECONDS-daemon_launch_time))s" >&2 if [[ -x "${code}" ]] && updateto="$(${code} -v 2>/dev/null)" && [[ "${updateto}" != "${version}" ]]; then confirm_update="Update ipfs-chat from v${version} to v${updateto}?" dialog --keep-tite --yesno "${confirm_update}" "$(tput lines)" "$(tput cols)" && update -s "${code}" fi echo "Status: Exiting..." >&2 exit ================================================ FILE: mime.types ================================================ ############################################################################### # # MIME media types and the extensions that represent them. # # The format of this file is a media type on the left and zero or more # filename extensions on the right. Programs using this file will map # files ending with those extensions to the associated type. # # This file is part of the "mime-support" package. Please report a bug using # the "reportbug" command of the "reportbug" package if you would like new # types or extensions to be added. # # The reason that all types are managed by the mime-support package instead # allowing individual packages to install types in much the same way as they # add entries in to the mailcap file is so these types can be referenced by # other programs (such as a web server) even if the specific support package # for that type is not installed. # # Users can add their own types if they wish by creating a ".mime.types" # file in their home directory. Definitions included there will take # precedence over those listed here. # ############################################################################### application/activemessage application/andrew-inset ez application/annodex anx application/applefile application/atom+xml atom application/atomcat+xml atomcat application/atomicmail application/atomserv+xml atomsrv application/batch-SMTP application/bbolin lin application/beep+xml application/cals-1840 application/commonground application/cu-seeme cu application/cybercash application/davmount+xml davmount application/dca-rft application/dec-dx application/dicom dcm application/docbook+xml application/dsptype tsp application/dvcs application/ecmascript es application/edi-consent application/edi-x12 application/edifact application/epub+zip epub application/eshop application/font-sfnt otf ttf application/font-tdpfr pfr application/font-woff woff application/futuresplash spl application/ghostview application/gzip gz application/hta hta application/http application/hyperstudio application/iges application/index application/index.cmd application/index.obj application/index.response application/index.vnd application/iotp application/ipp application/isup application/java-archive jar application/java-serialized-object ser application/java-vm class application/javascript js mjs application/json json application/ld+json jsonld application/m3g m3g application/mac-binhex40 hqx application/mac-compactpro cpt application/macwriteii application/marc application/mathematica nb nbp application/mbox mbox application/ms-tnef application/msaccess mdb application/msword doc dot application/mxf mxf application/news-message-id application/news-transmission application/ocsp-request application/ocsp-response application/octet-stream bin deploy msu msp application/oda oda application/oebps-package+xml opf application/ogg ogx application/onenote one onetoc2 onetmp onepkg application/parityfec application/pdf pdf application/pgp-encrypted pgp application/pgp-keys key application/pgp-signature sig application/pics-rules prf application/pkcs10 application/pkcs7-mime application/pkcs7-signature application/pkix-cert application/pkix-crl application/pkixcmp application/postscript ps ai eps epsi epsf eps2 eps3 application/prs.alvestrand.titrax-sheet application/prs.cww application/prs.nprend application/qsig application/rar rar application/rdf+xml rdf application/remote-printing application/riscos application/rtf rtf application/sdp application/set-payment application/set-payment-initiation application/set-registration application/set-registration-initiation application/sgml application/sgml-open-catalog application/sieve application/sla stl application/slate application/smil+xml smi smil application/timestamp-query application/timestamp-reply application/vemmi application/wasm wasm application/whoispp-query application/whoispp-response application/wita application/x400-bp application/xhtml+xml xhtml xht application/xml xml xsd application/xml-dtd application/xml-external-parsed-entity application/xslt+xml xsl xslt application/xspf+xml xspf application/zip zip application/vnd.3M.Post-it-Notes application/vnd.accpac.simply.aso application/vnd.accpac.simply.imp application/vnd.acucobol application/vnd.aether.imp application/vnd.android.package-archive apk application/vnd.anser-web-certificate-issue-initiation application/vnd.anser-web-funds-transfer-initiation application/vnd.audiograph application/vnd.bmi application/vnd.businessobjects application/vnd.canon-cpdl application/vnd.canon-lips application/vnd.cinderella cdy application/vnd.claymore application/vnd.commerce-battelle application/vnd.commonspace application/vnd.comsocaller application/vnd.contact.cmsg application/vnd.cosmocaller application/vnd.ctc-posml application/vnd.cups-postscript application/vnd.cups-raster application/vnd.cups-raw application/vnd.cybank application/vnd.debian.binary-package deb ddeb udeb application/vnd.dna application/vnd.dpgraph application/vnd.dxr application/vnd.ecdis-update application/vnd.ecowin.chart application/vnd.ecowin.filerequest application/vnd.ecowin.fileupdate application/vnd.ecowin.series application/vnd.ecowin.seriesrequest application/vnd.ecowin.seriesupdate application/vnd.enliven application/vnd.epson.esf application/vnd.epson.msf application/vnd.epson.quickanime application/vnd.epson.salt application/vnd.epson.ssf application/vnd.ericsson.quickcall application/vnd.eudora.data application/vnd.fdf application/vnd.ffsns application/vnd.flographit application/vnd.font-fontforge-sfd sfd application/vnd.framemaker application/vnd.fsc.weblaunch application/vnd.fujitsu.oasys application/vnd.fujitsu.oasys2 application/vnd.fujitsu.oasys3 application/vnd.fujitsu.oasysgp application/vnd.fujitsu.oasysprs application/vnd.fujixerox.ddd application/vnd.fujixerox.docuworks application/vnd.fujixerox.docuworks.binder application/vnd.fut-misnet application/vnd.google-earth.kml+xml kml application/vnd.google-earth.kmz kmz application/vnd.grafeq application/vnd.groove-account application/vnd.groove-identity-message application/vnd.groove-injector application/vnd.groove-tool-message application/vnd.groove-tool-template application/vnd.groove-vcard application/vnd.hhe.lesson-player application/vnd.hp-HPGL application/vnd.hp-PCL application/vnd.hp-PCLXL application/vnd.hp-hpid application/vnd.hp-hps application/vnd.httphone application/vnd.hzn-3d-crossword application/vnd.ibm.MiniPay application/vnd.ibm.afplinedata application/vnd.ibm.modcap application/vnd.informix-visionary application/vnd.intercon.formnet application/vnd.intertrust.digibox application/vnd.intertrust.nncp application/vnd.intu.qbo application/vnd.intu.qfx application/vnd.irepository.package+xml application/vnd.is-xpr application/vnd.japannet-directory-service application/vnd.japannet-jpnstore-wakeup application/vnd.japannet-payment-wakeup application/vnd.japannet-registration application/vnd.japannet-registration-wakeup application/vnd.japannet-setstore-wakeup application/vnd.japannet-verification application/vnd.japannet-verification-wakeup application/vnd.koan application/vnd.lotus-1-2-3 application/vnd.lotus-approach application/vnd.lotus-freelance application/vnd.lotus-notes application/vnd.lotus-organizer application/vnd.lotus-screencam application/vnd.lotus-wordpro application/vnd.mcd application/vnd.mediastation.cdkey application/vnd.meridian-slingshot application/vnd.mif application/vnd.minisoft-hp3000-save application/vnd.mitsubishi.misty-guard.trustweb application/vnd.mobius.daf application/vnd.mobius.dis application/vnd.mobius.msl application/vnd.mobius.plc application/vnd.mobius.txf application/vnd.motorola.flexsuite application/vnd.motorola.flexsuite.adsi application/vnd.motorola.flexsuite.fis application/vnd.motorola.flexsuite.gotap application/vnd.motorola.flexsuite.kmr application/vnd.motorola.flexsuite.ttc application/vnd.motorola.flexsuite.wem application/vnd.mozilla.xul+xml xul application/vnd.ms-artgalry application/vnd.ms-asf application/vnd.ms-excel xls xlb xlt application/vnd.ms-excel.addin.macroEnabled.12 xlam application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb application/vnd.ms-excel.sheet.macroEnabled.12 xlsm application/vnd.ms-excel.template.macroEnabled.12 xltm application/vnd.ms-fontobject eot application/vnd.ms-lrm application/vnd.ms-officetheme thmx application/vnd.ms-pki.seccat cat #application/vnd.ms-pki.stl stl application/vnd.ms-powerpoint ppt pps application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm application/vnd.ms-powerpoint.slide.macroEnabled.12 sldm application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm application/vnd.ms-powerpoint.template.macroEnabled.12 potm application/vnd.ms-project application/vnd.ms-tnef application/vnd.ms-word.document.macroEnabled.12 docm application/vnd.ms-word.template.macroEnabled.12 dotm application/vnd.ms-works application/vnd.mseq application/vnd.msign application/vnd.music-niff application/vnd.musician application/vnd.netfpx application/vnd.noblenet-directory application/vnd.noblenet-sealer application/vnd.noblenet-web application/vnd.novadigm.EDM application/vnd.novadigm.EDX application/vnd.novadigm.EXT application/vnd.oasis.opendocument.chart odc application/vnd.oasis.opendocument.database odb application/vnd.oasis.opendocument.formula odf application/vnd.oasis.opendocument.graphics odg application/vnd.oasis.opendocument.graphics-template otg application/vnd.oasis.opendocument.image odi application/vnd.oasis.opendocument.presentation odp application/vnd.oasis.opendocument.presentation-template otp application/vnd.oasis.opendocument.spreadsheet ods application/vnd.oasis.opendocument.spreadsheet-template ots application/vnd.oasis.opendocument.text odt application/vnd.oasis.opendocument.text-master odm application/vnd.oasis.opendocument.text-template ott application/vnd.oasis.opendocument.text-web oth application/vnd.openxmlformats-officedocument.presentationml.presentation pptx application/vnd.openxmlformats-officedocument.presentationml.slide sldx application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx application/vnd.openxmlformats-officedocument.presentationml.template potx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx application/vnd.openxmlformats-officedocument.wordprocessingml.document docx application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx application/vnd.osa.netdeploy application/vnd.palm application/vnd.pg.format application/vnd.pg.osasli application/vnd.powerbuilder6 application/vnd.powerbuilder6-s application/vnd.powerbuilder7 application/vnd.powerbuilder7-s application/vnd.powerbuilder75 application/vnd.powerbuilder75-s application/vnd.previewsystems.box application/vnd.publishare-delta-tree application/vnd.pvi.ptid1 application/vnd.pwg-xhtml-print+xml application/vnd.rapid application/vnd.rim.cod cod application/vnd.s3sms application/vnd.seemail application/vnd.shana.informed.formdata application/vnd.shana.informed.formtemplate application/vnd.shana.informed.interchange application/vnd.shana.informed.package application/vnd.smaf mmf application/vnd.sss-cod application/vnd.sss-dtf application/vnd.sss-ntf application/vnd.stardivision.calc sdc application/vnd.stardivision.chart sds application/vnd.stardivision.draw sda application/vnd.stardivision.impress sdd application/vnd.stardivision.math sdf application/vnd.stardivision.writer sdw application/vnd.stardivision.writer-global sgl application/vnd.street-stream application/vnd.sun.xml.calc sxc application/vnd.sun.xml.calc.template stc application/vnd.sun.xml.draw sxd application/vnd.sun.xml.draw.template std application/vnd.sun.xml.impress sxi application/vnd.sun.xml.impress.template sti application/vnd.sun.xml.math sxm application/vnd.sun.xml.writer sxw application/vnd.sun.xml.writer.global sxg application/vnd.sun.xml.writer.template stw application/vnd.svd application/vnd.swiftview-ics application/vnd.symbian.install sis application/vnd.tcpdump.pcap cap pcap application/vnd.triscape.mxs application/vnd.trueapp application/vnd.truedoc application/vnd.tve-trigger application/vnd.ufdl application/vnd.uplanet.alert application/vnd.uplanet.alert-wbxml application/vnd.uplanet.bearer-choice application/vnd.uplanet.bearer-choice-wbxml application/vnd.uplanet.cacheop application/vnd.uplanet.cacheop-wbxml application/vnd.uplanet.channel application/vnd.uplanet.channel-wbxml application/vnd.uplanet.list application/vnd.uplanet.list-wbxml application/vnd.uplanet.listcmd application/vnd.uplanet.listcmd-wbxml application/vnd.uplanet.signal application/vnd.vcx application/vnd.vectorworks application/vnd.vidsoft.vidconference application/vnd.visio vsd vst vsw vss application/vnd.vividence.scriptfile application/vnd.wap.sic application/vnd.wap.slc application/vnd.wap.wbxml wbxml application/vnd.wap.wmlc wmlc application/vnd.wap.wmlscriptc wmlsc application/vnd.webturbo application/vnd.wordperfect wpd application/vnd.wordperfect5.1 wp5 application/vnd.wrq-hp3000-labelled application/vnd.wt.stf application/vnd.xara application/vnd.xfdl application/vnd.yellowriver-custom-menu application/zlib application/x-123 wk application/x-7z-compressed 7z application/x-abiword abw application/x-apple-diskimage dmg application/x-bcpio bcpio application/x-bittorrent torrent application/x-cab cab application/x-cbr cbr application/x-cbz cbz application/x-cdf cdf cda application/x-cdlink vcd application/x-chess-pgn pgn application/x-comsol mph application/x-core application/x-cpio cpio application/x-csh csh application/x-debian-package deb udeb application/x-director dcr dir dxr application/x-dms dms application/x-doom wad application/x-dvi dvi application/x-executable application/x-font pfa pfb gsf application/x-font-pcf pcf pcf.Z application/x-freemind mm application/x-futuresplash spl application/x-ganttproject gan application/x-gnumeric gnumeric application/x-go-sgf sgf application/x-graphing-calculator gcf application/x-gtar gtar application/x-gtar-compressed tgz taz application/x-hdf hdf #application/x-httpd-eruby rhtml #application/x-httpd-php phtml pht php #application/x-httpd-php-source phps #application/x-httpd-php3 php3 #application/x-httpd-php3-preprocessed php3p #application/x-httpd-php4 php4 #application/x-httpd-php5 php5 application/x-hwp hwp application/x-ica ica application/x-info info application/x-internet-signup ins isp application/x-iphone iii application/x-iso9660-image iso application/x-jam jam application/x-java-applet application/x-java-bean application/x-java-jnlp-file jnlp application/x-jmol jmz application/x-kchart chrt application/x-kdelnk application/x-killustrator kil application/x-koan skp skd skt skm application/x-kpresenter kpr kpt application/x-kspread ksp application/x-kword kwd kwt application/x-latex latex application/x-lha lha application/x-lyx lyx application/x-lzh lzh application/x-lzx lzx application/x-maker frm maker frame fm fb book fbdoc application/x-mif mif application/x-mpegURL m3u8 application/x-ms-application application application/x-ms-manifest manifest application/x-ms-wmd wmd application/x-ms-wmz wmz application/x-msdos-program com exe bat dll application/x-msi msi application/x-netcdf nc application/x-ns-proxy-autoconfig pac application/x-nwc nwc application/x-object o application/x-oz-application oza application/x-pkcs7-certreqresp p7r application/x-pkcs7-crl crl application/x-python-code pyc pyo application/x-qgis qgs shp shx application/x-quicktimeplayer qtl application/x-rdp rdp application/x-redhat-package-manager rpm application/x-rss+xml rss application/x-ruby rb application/x-rx application/x-scilab sci sce application/x-scilab-xcos xcos application/x-sh sh application/x-shar shar application/x-shellscript application/x-shockwave-flash swf swfl application/x-silverlight scr application/x-sql sql application/x-stuffit sit sitx application/x-sv4cpio sv4cpio application/x-sv4crc sv4crc application/x-tar tar application/x-tcl tcl application/x-tex-gf gf application/x-tex-pk pk application/x-texinfo texinfo texi application/x-trash ~ % bak old sik application/x-troff t tr roff application/x-troff-man man application/x-troff-me me application/x-troff-ms ms application/x-ustar ustar application/x-videolan application/x-wais-source src application/x-wingz wz application/x-x509-ca-cert crt application/x-xcf xcf application/x-xfig fig application/x-xpinstall xpi application/x-xz xz audio/32kadpcm audio/3gpp audio/amr amr audio/amr-wb awb audio/annodex axa audio/basic au snd audio/csound csd orc sco audio/flac flac audio/g.722.1 audio/l16 audio/midi mid midi kar audio/mp4a-latm audio/mpa-robust audio/mpeg mpga mpega mp2 mp3 m4a audio/mpegurl m3u audio/ogg oga ogg opus spx audio/parityfec audio/prs.sid sid audio/telephone-event audio/tone audio/vnd.cisco.nse audio/vnd.cns.anp1 audio/vnd.cns.inf1 audio/vnd.digital-winds audio/vnd.everad.plj audio/vnd.lucent.voice audio/vnd.nortel.vbk audio/vnd.nuera.ecelp4800 audio/vnd.nuera.ecelp7470 audio/vnd.nuera.ecelp9600 audio/vnd.octel.sbc audio/vnd.qcelp audio/vnd.rhetorex.32kadpcm audio/vnd.vmx.cvsd audio/x-aiff aif aiff aifc audio/x-gsm gsm audio/x-mpegurl m3u audio/x-ms-wma wma audio/x-ms-wax wax audio/x-pn-realaudio-plugin audio/x-pn-realaudio ra rm ram audio/x-realaudio ra audio/x-scpls pls audio/x-sd2 sd2 audio/x-wav wav chemical/x-alchemy alc chemical/x-cache cac cache chemical/x-cache-csf csf chemical/x-cactvs-binary cbin cascii ctab chemical/x-cdx cdx chemical/x-cerius cer chemical/x-chem3d c3d chemical/x-chemdraw chm chemical/x-cif cif chemical/x-cmdf cmdf chemical/x-cml cml chemical/x-compass cpa chemical/x-crossfire bsd chemical/x-csml csml csm chemical/x-ctx ctx chemical/x-cxf cxf cef #chemical/x-daylight-smiles smi chemical/x-embl-dl-nucleotide emb embl chemical/x-galactic-spc spc chemical/x-gamess-input inp gam gamin chemical/x-gaussian-checkpoint fch fchk chemical/x-gaussian-cube cub chemical/x-gaussian-input gau gjc gjf chemical/x-gaussian-log gal chemical/x-gcg8-sequence gcg chemical/x-genbank gen chemical/x-hin hin chemical/x-isostar istr ist chemical/x-jcamp-dx jdx dx chemical/x-kinemage kin chemical/x-macmolecule mcm chemical/x-macromodel-input mmd mmod chemical/x-mdl-molfile mol chemical/x-mdl-rdfile rd chemical/x-mdl-rxnfile rxn chemical/x-mdl-sdfile sd sdf chemical/x-mdl-tgf tgf #chemical/x-mif mif chemical/x-mmcif mcif chemical/x-mol2 mol2 chemical/x-molconn-Z b chemical/x-mopac-graph gpt chemical/x-mopac-input mop mopcrt mpc zmt chemical/x-mopac-out moo chemical/x-mopac-vib mvb chemical/x-ncbi-asn1 asn chemical/x-ncbi-asn1-ascii prt ent chemical/x-ncbi-asn1-binary val aso chemical/x-ncbi-asn1-spec asn chemical/x-pdb pdb ent chemical/x-rosdal ros chemical/x-swissprot sw chemical/x-vamas-iso14976 vms chemical/x-vmd vmd chemical/x-xtel xtel chemical/x-xyz xyz font/collection ttc font/otf ttf otf font/sfnt ttf otf font/ttf ttf otf font/woff woff font/woff2 woff2 image/cgm image/g3fax image/gif gif image/ief ief image/jp2 jp2 jpg2 image/jpeg jpeg jpg jpe image/jpm jpm image/jpx jpx jpf image/naplps image/pcx pcx image/png png image/prs.btif image/prs.pti image/svg+xml svg svgz image/tiff tiff tif image/vnd.cns.inf2 image/vnd.djvu djvu djv image/vnd.dwg image/vnd.dxf image/vnd.fastbidsheet image/vnd.fpx image/vnd.fst image/vnd.fujixerox.edmics-mmr image/vnd.fujixerox.edmics-rlc image/vnd.microsoft.icon ico image/vnd.mix image/vnd.net-fpx image/vnd.svf image/vnd.wap.wbmp wbmp image/vnd.xiff image/x-canon-cr2 cr2 image/x-canon-crw crw image/x-cmu-raster ras image/x-coreldraw cdr image/x-coreldrawpattern pat image/x-coreldrawtemplate cdt image/x-corelphotopaint cpt image/x-epson-erf erf image/x-icon image/x-jg art image/x-jng jng image/x-ms-bmp bmp image/x-nikon-nef nef image/x-olympus-orf orf image/x-photoshop psd image/x-portable-anymap pnm image/x-portable-bitmap pbm image/x-portable-graymap pgm image/x-portable-pixmap ppm image/x-rgb rgb image/x-xbitmap xbm image/x-xpixmap xpm image/x-xwindowdump xwd inode/chardevice inode/blockdevice inode/directory-locked inode/directory inode/fifo inode/socket message/delivery-status message/disposition-notification message/external-body message/http message/s-http message/news message/partial message/rfc822 eml model/iges igs iges model/mesh msh mesh silo model/vnd.dwf model/vnd.flatland.3dml model/vnd.gdl model/vnd.gs-gdl model/vnd.gtw model/vnd.mts model/vnd.vtu model/vrml wrl vrml model/x3d+vrml x3dv model/x3d+xml x3d model/x3d+binary x3db multipart/alternative multipart/appledouble multipart/byteranges multipart/digest multipart/encrypted multipart/form-data multipart/header-set multipart/mixed multipart/parallel multipart/related multipart/report multipart/signed multipart/voice-message text/cache-manifest appcache text/calendar ics icz text/css css text/csv csv text/directory text/english text/enriched text/h323 323 text/html html htm shtml text/iuls uls text/mathml mml text/markdown md markdown text/parityfec text/plain asc txt text pot brf srt text/prs.lines.tag text/rfc822-headers text/richtext rtx text/rtf text/scriptlet sct wsc text/t140 text/texmacs tm text/tab-separated-values tsv text/turtle ttl text/uri-list text/vcard vcf vcard text/vnd.abc text/vnd.curl text/vnd.debian.copyright text/vnd.DMClientScript text/vnd.flatland.3dml text/vnd.fly text/vnd.fmi.flexstor text/vnd.in3d.3dml text/vnd.in3d.spot text/vnd.IPTC.NewsML text/vnd.IPTC.NITF text/vnd.latex-z text/vnd.motorola.reflex text/vnd.ms-mediapackage text/vnd.sun.j2me.app-descriptor jad text/vnd.wap.si text/vnd.wap.sl text/vnd.wap.wml wml text/vnd.wap.wmlscript wmls text/x-bibtex bib text/x-boo boo text/x-c++hdr h++ hpp hxx hh text/x-c++src c++ cpp cxx cc text/x-chdr h text/x-component htc text/x-crontab text/x-csh csh text/x-csrc c text/x-dsrc d text/x-diff diff patch text/x-haskell hs text/x-java java text/x-lilypond ly text/x-literate-haskell lhs text/x-makefile text/x-moc moc text/x-pascal p pas text/x-pcs-gcd gcd text/x-perl pl pm text/x-python py text/x-scala scala text/x-server-parsed-html text/x-setext etx text/x-sfv sfv text/x-sh sh text/x-tcl tcl tk text/x-tex tex ltx sty cls text/x-vcalendar vcs video/3gpp 3gp video/annodex axv video/dl dl video/dv dif dv video/fli fli video/gl gl video/mpeg mpeg mpg mpe video/MP2T ts video/mp4 mp4 video/quicktime qt mov video/mp4v-es video/ogg ogv video/parityfec video/pointer video/webm webm video/vnd.fvt video/vnd.motorola.video video/vnd.motorola.videop video/vnd.mpegurl mxu video/vnd.mts video/vnd.nokia.interleaved-multimedia video/vnd.vivo video/x-flv flv video/x-la-asf lsf lsx video/x-mng mng video/x-ms-asf asf asx video/x-ms-wm wm video/x-ms-wmv wmv video/x-ms-wmx wmx video/x-ms-wvx wvx video/x-msvideo avi video/x-sgi-movie movie video/x-matroska mpv mkv x-conference/x-cooltalk ice x-epoc/x-sisx-app sisx x-world/x-vrml vrm vrml wrl