[
  {
    "path": ".gitattributes",
    "content": "/ipfs-chat linguist-language=bash\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# IPFS-Chat\r\n\r\n[![Featured](https://img.shields.io/badge/Featured%20in-Awesome%20IPFS-green.svg)](https://awesome.ipfs.io/apps/)\r\n\r\n1. 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).\r\n2. Very basic terminal-based UI without any eye candy.\r\n3. The usual *Create Alias/Nick* + *Create/Join room* workflow (akin to [IRC](https://en.wikipedia.org/wiki/Internet_Relay_Chat)).\r\n4. 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.\r\n5. Chat-messages are authenticated and end-to-end encrypted (See [Security](#security)). Shared files/directories are encrypted too.\r\n6. Developed with bandwidth, CPU and disk usage efficiency in mind. Option to control shared file size (See [Usage](#usage)).\r\n7. 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.\r\n8. 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)).\r\n9. Downloaded shared files are scanned for malicious intent (See [Security](#security) and  [Usage](#usage)).\r\n10. Auto-update enabled.\r\n\r\n***Keywords*:** p2p; distributed; server-less; broker-less; TUI; secure; texting; file-sharing; ipfs; pubsub; privacy\r\n\r\n## Table of Contents  \n[![tocgen](https://img.shields.io/badge/Generated%20using-tocgen-blue)](https://github.com/SomajitDey/tocgen)  \n  - [IPFS-Chat](#ipfs-chat)  \n    - [Installation](#installation)  \n        - [Download:](#download)  \n        - [Install:](#install)  \n    - [Usage](#usage)  \n        - [Defaults:](#defaults)  \n        - [Multiple-instances:](#multiple-instances)  \n    - [Snapshot](#snapshot)  \n    - [Testing](#testing)  \n    - [Changing terminal window size](#changing-terminal-window-size)  \n    - [Peer discovery](#peer-discovery)  \n    - [Security](#security)  \n    - [Messaging](#messaging)  \n    - [File or directory sharing](#file-or-directory-sharing)  \n    - [Efficiency](#efficiency)  \n    - [Fully decentralized vs (Semi-)centralized](#fully-decentralized-vs-semi-centralized)  \n    - [Future directions](#future-directions)  \n    - [Contribute](#contribute)  \n#####   \n\r\n## Installation\r\n\r\n#### Download:\r\n\r\n```shell\r\ngit clone --depth 1 --no-tags https://github.com/SomajitDey/ipfs-chat; cd ipfs-chat\r\n```\r\n\r\nor, \r\n\r\n```shell\r\nwget https://raw.githubusercontent.com/SomajitDey/ipfs-chat/main/ipfs-chat \\\r\n&& chmod +x ./ipfs-chat\r\n```\r\n\r\n#### Install:\r\n\r\n```bash\r\nsudo mv ./ipfs-chat /usr/local/bin\r\n```\r\n\r\nOr, if you don't have sudo priviledge:\r\n\r\n```bash\r\nmkdir -p ~/.bin; mv ./ipfs-chat ~/.bin; export PATH=\"${PATH}:${HOME}/.bin\"\r\n# Also put the last export command inside ${HOME}/.bashrc\r\n```\r\n\r\nDo you want an auto-install feature, such as `./ipfs-chat -i`? If so, please [post](#contribute) a feature-request.\r\n\r\n## Usage\r\n\r\n```shell\r\nipfs-chat -r <room> -n <nick> -d <dl dir> -D <max file MB> -c <repo> -o <log> -w|-l -e\r\nipfs-chat -g # Generating a random room name, for when your brain can't do it\r\nipfs-chat -v # Version\r\nipfs-chat -u <version>|<branch> # Update\r\nipfs-chat -h # Help\r\n```\r\n\r\nAll command-line options/flags are optional. Unobvious options are explained below.\r\n\r\n`-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.\r\n\r\n`-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.\r\n\r\n`-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.\r\n\r\n`-o` passes the file where the chat from the present session would be logged.\r\n\r\n`-w` or `-W` denotes WAN-only mode. Local discovery is disabled. Everything happens over internet only. Uses WAN-DHT.\r\n\r\n`-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.\r\n\r\n`-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).\r\n\r\n`-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.\r\n\r\n#### Defaults:\r\n\r\nroom: `Lobby`\r\n\r\nnick: `${USER}`\r\n\r\ndownload directory: `${HOME}/ipfs-chat-downloads`\r\n\r\nmax shared file size:  -1 (i.e. unlimited)\r\n\r\nrepo: `${HOME}/.ipfs-chat`\r\n\r\nchat log: N/A\r\n\r\nWAN + LAN\r\n\r\n#### Multiple-instances:\r\n\r\nMultiple instances of `ipfs-chat` may be run for accessing different chatrooms concurrently. This may be done in 2 ways:\r\n\r\n1. 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: \r\n\r\n   ```shell\r\n   ipfs-chat -c '/tmp/repo1' -r chatroom1 -n nick1 # In one terminal\r\n   ipfs-chat -c '/tmp/repo2' -r chatroom2 -n nick2 # In another terminal\r\n   ```\r\n\r\n2. 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: \r\n\r\n   ```shell\r\n   ipfs-chat [-c common-repo] -r chatroom1 -n myNick # In one terminal\r\n   ipfs-chat [-c common-repo] -r chatroom2 -n myNick # In another terminal\r\n   ```\r\n\r\n## Snapshot\r\n\r\n![ipfs-chat_snapshot](./screenshot.png)\r\n\r\n## Testing\r\n\r\nYou 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.\r\n\r\n```shell\r\nipfs-chat -W -b -c '/tmp/ipfs-chat' -n 'partner' # In one terminal\r\nipfs-chat -b # In another terminal\r\n```\r\n\r\n`-b` above enables bandwidth stats. Drop it if you are not interested in those stats.\r\n\r\nDepending 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).\r\n\r\nTest 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.\r\n\r\n## Changing terminal window size\r\n\r\nShould 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.\r\n\r\n## Peer discovery\r\n\r\nName of the room is the shared secret. \r\n\r\nEvery 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.\r\n\r\nTo 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.\r\n\r\nPeers 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.\r\n\r\nLocal (LAN based) discovery is also enabled ([Discovery.MDNS.Enabled=true](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md)).\r\n\r\nAlso, 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.\r\n\r\n[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.\r\n\r\nDuring startup, the node tries to connect to the peers from the last session.\r\n\r\nFor `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).\r\n\r\n**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.\r\n\r\n## Security\r\n\r\nAuthenticity of the messages is established through IPNS over pubsub (See [Messaging](#messaging)).\r\n\r\nAll 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).\r\n\r\nAll private messages are encrypted with a public key (ECDH/cv25519) belonging to the recipient.\r\n\r\nAll shared files and directories are encrypted (See [File sharing](#file-sharing)).\r\n\r\nThe 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.\r\n\r\nIf 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).\r\n\r\n## Messaging\r\n\r\nEvery 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.\r\n\r\nAfter discovering a peer, other peers resolve its IPNS entry and caches its nick and pubkey for use throughout the session.\r\n\r\nFor 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.\r\n\r\nOther 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.\r\n\r\n[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.\r\n\r\n## File or directory sharing\r\n\r\nDirectories, when shared, are first archived through `tar` and then those archives are shared like regular files.\r\n\r\nShared 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.\r\n\r\nThe 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).\r\n\r\nThe 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.\r\n\r\nTo 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:).\r\n\r\nEncrypting 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.\r\n\r\n**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).\r\n\r\n## Efficiency\r\n\r\n[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.\r\n\r\nNew 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.\r\n\r\nConnections to the chatroom peers are never closed.\r\n\r\nTo 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`.\r\n\r\nThe 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.\r\n\r\nNote that the connection manager and frequent repo cleanup reduce bandwidth only at the cost of CPU.\r\n\r\nThe go-ipfs config file has been tuned to reduce resource (CPU/bandwidth/memory) consumption.\r\n\r\nWAN-only and LAN-only modes are available (see [Usage](#usage)) to further optimize resource consumption under different situations.\r\n\r\nTo minimize disk usage wherever possible, [IPFS-filestore](https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipfs-filestore) is used.\r\n\r\nFor efficiency regarding file-sharing, see [File or directory sharing](#file-or-directory-sharing).\r\n\r\n**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.\r\n\r\n## Fully decentralized vs (Semi-)centralized\r\n\r\nApart 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).\r\n\r\n## Future directions\r\n\r\n1. 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.\r\n2. 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.\r\n\r\n## Contribute\r\n\r\nPost 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). \r\n\r\n> If creating bug-reports, please provide the following:\r\n>\r\n> 1. Version: `ipfs-chat -v`\r\n> 2. go-IPFS version: `ipfs --version`\r\n> 3. Your Linux distribution\r\n> 4. Screenshots\r\n\r\n[![Sponsor](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://buymeacoffee.com/SomajitDey)\r\n\r\n------\r\n\r\n###### GNU GPL v3-or-later &copy; 2021 Somajit Dey"
  },
  {
    "path": "ipfs-chat",
    "content": "#!/usr/bin/env bash\nexport LANGUAGE=C LANG=C LC_ALL=C\n# Details: See info and usage functions below\n\nexport version=\"0.3.0 (beta)\"\n\ninfo(){\n  # Brief: Info about ipfs-chat\n  echo -n \"\n                        Welcome to ipfs-chat\n                        ====================\nRepo (For details & Bug-report): https://github.com/SomajitDey/ipfs-chat\nLicense: GNU GPL v3-or-later (C) 2021 Somajit Dey\nVersion: \" >&2\n  echo \"${version}\"\n}; export -f info\n\nusage(){\n  # Brief: Show help and exit\n  echo -e \"\\nUsage: ipfs-chat [-n <nick>] [-r <room>] [-d <file-download-dir>] [-D <max-download-MB>] [-c <ipfs-repo-path>] [-o <chat-log-path>] [-w | -l] [-b]\"\n  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\"\n  echo -e \"\\nVersion: ipfs-chat -v\"\n  echo -e \"\\nUpdate: ipfs-chat -u [<version e.g. v0.2.6> | <branch-name>]\"\n  echo -e \"\\nGenerate random room name: ipfs-chat -g\"\n  echo -e \"\\nEnable shared file extension check against MIME-type: ipfs-chat -e\"\n  echo ; exit 1\n} >&2; export -f usage\n\nkill_proc_tree(){\n  # Brief: Kill (with SIGKILL) all descendants of the process id given\n  local pid\n  for pid in $(pgrep -P \"${1}\"); do\n    kill_proc_tree \"${pid}\" &\n  done\n  kill -KILL \"${1}\" \n} &>/dev/null; export -f kill_proc_tree\n\nsha1(){\n  # Usage: sha1 <string> ##or## sha1 < path_to_data_file\n  local string=\"${@}\"\n  if [[ -n \"${string}\" ]]; then\n    sha1sum <(echo -n \"${string}\")\n  else\n    sha1sum \n  fi | cut -d ' ' -f 1\n} 2>/dev/null; export -f sha1\n\nb64(){\n  # Brief: Inline base64 encode with / replaced by _, and the trailing = dropped\n  # Deleting last = because base64 encoding 160-bit kdf or hmac always gives single =, hence redundant\n  # Substituting / with _ because / messes up using kdf/hmac outputs as directory or filenames\n  # Usage: b64 <hexdump>\n  xxd -r -p | base64 -w0 | tr -d '=' | tr '/' '_'\n} 2>/dev/null; export -f b64\n\nhmac(){\n  # Usage: hmac <salt> <string>\n  # Output: base64, with / replaced by _, and trailing = dropped\n  local key=\"$(sha1 \"${1}\")\" data=\"$(sha1 \"${2}\")\"\n  echo -n \"${data}\" | xxd -r -p | openssl dgst -sha1 -mac hmac -macopt hexkey:\"${key}\" | cut -d ' ' -f 2 | b64\n} 2>/dev/null; export -f hmac\n\nkdf(){\n  # Usage: kdf <salt> <string>\n  # Output: 160-bit base64 key, with / replaced by _, and the trailing = dropped\n  local key=\"$(sha1 \"${1}\")\" data=\"${2}\"\n  # No-need to lose `data` bits by prehashing. Hashing `key` ensures argon2 salt is atleast 8 characters long.\n  echo -n \"${data}\" | argon2 \"${key}\" -t 3 -m 12 -p 1 -l 20 -r | b64\n} 2>/dev/null; export -f kdf\n\ndep_check(){\n  # Brief: Check major dependencies\n  local ipfs_version quit\n  if ipfs_version=$(ipfs version --number 2>/dev/null); then\n    local req_ipfs_ver=0.11.0 # Minimum ipfs-cli version required\n    [[ \"$(echo -e \"${ipfs_version}\\n${req_ipfs_ver}\" | sort -t. -k1,1n -k2,2n -k3,3n | head -n1)\" == \"${req_ipfs_ver}\" ]] || \\\n      { echo -e \"Required: go-ipfs-cli version >= ${req_ipfs_ver}\\nSuggestion: ipfs update install latest\\n\"; quit=\"yes\";}\n  else\n    echo -e \"Required: go-ipfs-cli\\nSource: https://docs.ipfs.io/install/command-line/#linux\\n\"\n    quit=\"yes\"\n  fi\n  if ! command -v dialog &>/dev/null; then\n    echo -e \"Required: dialog\\nSource: Native package repository\"\n    echo -e \"Ref: https://command-not-found.com/dialog\\n\"\n    quit=\"yes\"\n  fi\n  if ! command -v curl &>/dev/null; then\n    echo -e \"Required: curl\\nSource: Native package repository\"\n    echo -e \"Ref: https://command-not-found.com/curl\\n\"\n    quit=\"yes\"\n  fi\n  if ! command -v flock &>/dev/null; then\n    echo -e \"Required: flock\\nSource: Native package repository\"\n    echo -e \"Ref: https://command-not-found.com/flock\\n\"\n    quit=\"yes\"\n  fi\n  if ! command -v openssl &>/dev/null; then\n    echo -e \"Required: openssl\\nSource: Native package repository\"\n    echo -e \"Ref: https://command-not-found.com/openssl\\n\"\n    quit=\"yes\"\n  fi\n  if ! command -v tput &>/dev/null; then\n    echo -e \"Required: tput\\nSource: Native package repository\"\n    echo -e \"Ref: https://command-not-found.com/tput\\n\"\n    quit=\"yes\"\n  fi\n  if ! command -v jq &>/dev/null; then\n    echo -e \"Required: jq\\nSource: Native package repository\"\n    echo -e \"Ref: https://stedolan.github.io/jq/download/\\n\"\n    quit=\"yes\"\n  fi\n  if ! command -v argon2 &>/dev/null; then\n    echo -e \"Required: argon2-cli\\nSource: Native package repository / web (pre-compiled binary or build from source)\"\n    echo -e \"Ref: https://command-not-found.com/argon2\"\n    echo -e \"Ref: https://github.com/SomajitDey/phc-winner-argon2/releases/download/static-build_linux_x86_64/argon2\"\n    echo -e \"Ref: https://github.com/P-H-C/phc-winner-argon2\\n\"\n    quit=\"yes\"\n  fi\n  [[ -v quit ]] && exit 1\n} >&2; export -f dep_check\n\ndep_check\n\nwin2lin_path(){\n  # Brief: Convert Windows to Linux path. If Linux path is given, does tilde expansion & quote removal.\n  # Usage: win2lin_path <path> ##or## win2lin_path < file_containing_path\n  # The input can be formatted freely. Path may contain spaces not esacaped by \\. Quotes may or may not be used for Win paths\n  local input=\"${@}\"; [[ -n \"${input}\" ]] || read -r input # Backslash not special due to -r\n  input=\"${input%/}\" # Trailing slash removal, if any\n  if ! [[ \"${input}\" == ~* ]]; then\n    local quote_less=\"$(echo \"${input//\\\\/\\\\\\\\}\" | xargs)\" # xargs does quote removal. To save backslash, escaped 'em\n    wslpath \"${quote_less}\" && return\n  fi\n  eval echo \"${input}\" # eval does tilde-expansion\n} 2>/dev/null; export -f win2lin_path\n\nupdate(){\n  # Usage: update [-s <update-from-file-path>] [-d <download-to-file-path>] [git-branch]\n  # Note: If -d, it only downloads the latest version to the given location, doesn't update\n  # Note: If -s, it only updates from the given source\n  local OPTIND=1 opt cli_opt source dest\n  while getopts s:d: opt; do\n    case \"${opt}\" in\n      s) cli_opt=\"${opt}\"; source=\"${OPTARG}\";;\n      d) cli_opt=\"${opt}\"; dest=\"${OPTARG}\";;\n    esac\n  done\n  local branch=\"${!OPTIND}\"\n  local url=\"https://raw.githubusercontent.com/SomajitDey/ipfs-chat/${branch:=main}/ipfs-chat\"\n  local tmp=\"$(mktemp)\" # Using /tmp instead of tmpdir below as tmpdir won't exist for `ipfs-chat -u`\n  trap \"rm -f ${tmp}\" return\n  local tags api_url=\"https://api.github.com/repos/SomajitDey/ipfs-chat/tags\"\n  case \"${cli_opt}\" in\n    s)\n      [[ -x \"${source}\" ]] || return 1\n      mv -f \"${source}\" \"${BASH_SOURCE}\" 2>/dev/null || sudo mv -f \"${source}\" \"${BASH_SOURCE}\" && \\\n        echo \"Update: Updated to v$(${BASH_SOURCE} -v)\"\n      ;;\n    d) \n      if timeout 4 curl -sfNL -o \"${tmp}\" \"${url}\"; then \n        chmod +x \"${tmp}\" && mv \"${tmp}\" \"${dest}\" # Atomic update\n      elif tags=\"$(timeout 2 curl -sfNL \"${api_url}\" 2>/dev/null)\"; then\n        echo \"Error: Couldn't find the requested tag/branch\"\n        jq -r '.[].name' <<< \"${tags}\" | xargs echo \"Releases: \"\n        return 1\n      else\n        echo \"Error: Failed to update. Check internet connection.\"\n        return 1\n      fi\n      ;;\n    *) \n      update -d \"${tmp}\" \"${branch}\" && update -s \"${tmp}\"\n      ;;\n  esac\n} >&2; export -f update\n\nparse_cmdline(){\n  local opt OPTIND=1\n  while getopts n:r:d:D:c:gwWlLo:vbeuh opt;do\n    case \"${opt}\" in\n      n) nick=\"${OPTARG}\";;\n      r) room=\"${OPTARG}\";;\n      d) dldir=\"$(win2lin_path \"${OPTARG}\")\";;\n      D) max_dl_MB=\"${OPTARG}\";;\n      c) local repo=\"${OPTARG}\";;\n      g) echo -n \"Random room: \" >&2; dd if=/dev/urandom count=1 bs=6 2>/dev/null | base64 | tr '/' '%'; exit;;\n      w|W) export connect_mode=\"WAN\";;\n      l|L) export connect_mode=\"LAN\";;\n      o) export chat=\"${OPTARG}\";;\n      v) echo \"${version}\"; exit;;\n      b) export disable_bandwidth_metrics=\"false\";;\n      e) export mime_type_check=\"enabled\";;\n      u) update \"${!OPTIND}\"; exit \"${?}\";;\n      h|*) usage;;\n    esac\n  done\n  export room=\"${room:=\"Lobby\"}\" nick=\"${nick:=\"${USER}\"}\"\n\n  export dldir=\"${dldir:=\"${HOME}/ipfs-chat-downloads\"}\" max_dl_MB=\"${max_dl_MB:=-1}\"\n  mkdir -p \"${dldir}\" 2>/dev/null || { echo \"Error: Directory at '${dldir}' could not be created. Exiting.\" >&2; exit 1;}\n  [[ \"${max_dl_MB}\" =~ ^[-]?[[:digit:]]+$ ]] || { echo \"Error: -D value should be an integer\" >&2; exit 1;}\n\n  export IPFS_PATH=\"${repo:-\"${HOME}/.ipfs-chat\"}\"\n}; export -f parse_cmdline\n\nparse_cmdline \"$@\"\n\ninfo\necho \"DL dir: $(tput smso)${dldir}$(tput rmso)\" >&2\necho \"Max filesize: $(tput setaf 1)$(((max_dl_MB>=0)) && echo \"${max_dl_MB} MB\" || echo 'N/A; Use -D flag')$(tput sgr0)\" >&2\n\ncache_peer(){\n  # Brief: Cache multiaddress given as argument. The cache will be used by con_cull\n  ipfs swarm peering add \"${1}\" # Add to peering subsystem (go-ipfs >= v0.10.0) # TODO: Ain't relay protected from ConnMgr?\n  echo \"${1}\" | grep -o '/p2p/[[:alnum:]]*' | grep -vf \"${sess_peers}\" | \\\n    flock \"${sess_peers}\" xargs -r -n1 >> \"${sess_peers}\"\n} &>/dev/null; export -f cache_peer\n\nipfs_config(){\n  # Brief: Configure IPFS node\n  # Note: Use random ports for everything so that multiple IPFS nodes can coexist on the same machine\n  # Note: Most configs below are for reducing bandwidth/CPU/disk usage\n  echo \"Status: Configuring IPFS node...\"\n  if [[ \"$(ipfs config 'ipfs-chat-version' 2>/dev/null)\" != \"${version}\" ]] || \\\n    [[ \"$(ipfs config 'App' 2>/dev/null)\" != \"ipfs-chat\" ]]; then\n    (ipfs init --profile lowpower || ipfs config profile apply lowpower \\\n      && ipfs config profile apply randomports) &>/dev/null || \\\n      { echo \"Error: Failed to create IPFS repo at ${IPFS_PATH}\"; exit 1;}\n    ipfs config --json Pubsub.Enabled true\n    ipfs config --json Ipns.UsePubsub true\n    ipfs config Pubsub.Router gossipsub\n    ipfs config Ipns.RepublishPeriod 2m0s\n    ipfs config Ipns.RecordLifetime 24h\n    ipfs config Reprovider.Interval 2m0s\n    ipfs config Reprovider.Strategy roots\n    ipfs config Routing.Type dhtclient\n    ipfs config Swarm.ConnMgr.Type none\n    ipfs config --json Experimental.FilestoreEnabled true\n    ipfs config 'ipfs-chat-version' \"${version}\"\n    ipfs config 'App' \"ipfs-chat\"\n  fi\n\n  export sess_peers=\"${IPFS_PATH}/session_peers\" # This file caches all ipfs-chat peers (multiaddresses) seen when node is online\n  local prev_sess_peers=\"$(cat \"${sess_peers}\" 2>/dev/null)\" # Holds peers from last session, if any\n  export sess_uplds=\"${IPFS_PATH}/session_uploads\" # Maps SHA1 hash of file to CID of its hash-encrypted object\n\n  # Repo cleanup when no other instance is running; i.e. node is offline\n  if ! ipfs swarm peers; then\n    rm -rf \"${IPFS_PATH}/room#\"*\n    rm -f \"${sess_peers}\" \"${sess_uplds}\"\n    ipfs pin ls --type=recursive --quiet | xargs -r -n1 -P0 ipfs pin rm # Remove stale pins to destress reprovider\n  fi &>/dev/null # Can't be non-blocking. Otherwise launching IPFS daemon shows, \"ERROR: lock ... :someone else has lock\"\n\n  export global_fs=\"${HOME}/.filestore-ipfs-chat\"; mkdir -p \"${global_fs}\"\n  # For multinode deduplication. UL files named after SHA1, DL files after CID  \n  # Cleanup global cache in background when disk usage exceeds 1 GB\n  # ICGFS: IPFS_CHAT_GLOBAL_FILESTORE_SIZE in MB (type: integer)\n  if ((\"$(du -BM \"${global_fs}\" | awk '{print $1}' | tr -d M)\" > \"${ICGFS:=1024}\")); then\n    flock -n \"${global_fs}\" rm -rf \"${global_fs}\"/*\n  fi &\n  \n  echo \"$(tput cuu1; tput ed)Status: Preparing the IPFS config file...\"  \n  ipfs config --bool Swarm.DisableBandwidthMetrics \"${disable_bandwidth_metrics:-true}\"\n  case \"${connect_mode}\" in\n    LAN)\n      ipfs config profile apply local-discovery &>/dev/null # Revert changes done by Server profile\n      #ipfs config --bool Discovery.MDNS.Enabled true\n      ipfs config --json Addresses.NoAnnounce '[]'\n      ipfs bootstrap rm all &>/dev/null # For faster startup\n      # Disable NAT traversal\n      ipfs config --bool Swarm.DisableNatPortMap true\n      ipfs config --bool Swarm.Transports.Network.Relay false\n      ipfs config --bool Swarm.RelayClient.Enabled false\n      ipfs config --bool Swarm.EnableHolePunching false\n      ;;\n    WAN | *)\n      if [[ \"${connect_mode}\" == WAN ]]; then\n        ipfs config profile apply server &>/dev/null\n        # Server profile disables swarm connecting to private IPs. Doesn't announce own private IPs. Disables MDNS discovery\n        #ipfs config --bool Discovery.MDNS.Enabled false\n        ipfs config show | \\\n        jq '.Addresses.NoAnnounce += [\"/ip4/127.0.0.1/ipcidr/1\", \"/ip6/::1/ipcidr/1\"]' > \"${IPFS_PATH}\"/.config && \\\n        ipfs config replace \"${IPFS_PATH}\"/.config\n      else\n        ipfs config profile apply local-discovery &>/dev/null # Revert changes done by Server profile\n        #ipfs config --bool Discovery.MDNS.Enabled true\n        ipfs config --json Addresses.NoAnnounce '[]'\n      fi\n      ipfs bootstrap add default &>/dev/null # For WAN-DHT\n      # For NAT traversal\n      ipfs config --bool Swarm.DisableNatPortMap false\n      ipfs config --bool Swarm.Transports.Network.Relay true\n      ipfs config --bool Swarm.RelayClient.Enabled true\n      ipfs config --bool Swarm.EnableHolePunching true\n      ;;\n  esac\n  # Disable RelayService. This config is given last as server profile in WAN mode turns it on\n  ipfs config --bool Swarm.RelayService.Enabled false\n  rm -f \"${IPFS_PATH}/config-pre-\"* # Remove config backup files generated with `ipfs config profile apply`\n\n  echo \"$(tput cuu1; tput ed)Status: Configuring ports...\"\n  pscan(){\n    # Brief: Give an unused, random, local TCP port except the one passed as argument\n    local port except=\"${1}\"\n    while port=\"$(( 0x\"$(dd if=/dev/urandom bs=2 count=1 2> /dev/null | xxd -p)\" - 1 ))\";do\n      ((port!=except)) || continue\n      nc -z localhost \"${port}\" || break\n    done\n    echo \"${port}\"\n  } 2>/dev/null; export -f pscan\n  local API_port=\"$(pscan)\"; ipfs config Addresses.API \"/ip4/127.0.0.1/tcp/${API_port:=5001}\"\n  local gateway_port=\"$(pscan \"${API_port}\")\"; ipfs config Addresses.Gateway \"/ip4/127.0.0.1/tcp/${gateway_port:=8080}\"\n\n  echo \"$(tput cuu1; tput ed)Status: Getting node online (launching IPFS daemon)...\"\n  launch_ipfs(){\n    # Brief: Launch IPFS daemon in the background, if not already running. Reflect online status through exit code\n    ipfs swarm peers || \\\n      [[ \"$(flock -s \"${global_fs}\" ipfs daemon ${@} | grep -iom1 'Daemon is ready' &)\" ]]\n  } &>/dev/null; export -f launch_ipfs\n\n  if launch_ipfs ; then\n    echo \"$(tput cuu1; tput ed)Status: IPFS node is configured\"\n  else\n    echo \"Error: Failed to launch IPFS daemon\"; exit 1\n  fi 2>/dev/null\n  declare -rigx daemon_launch_time=\"${EPOCHSECONDS}\"\n  \n  export selfID=\"$(ipfs config Identity.PeerID)\"; cache_peer \"/p2p/${selfID}\"\n  (# Prime the network with the peers from last session, if any\n    grep -v \"/p2p/${selfID}\" <<< \"${prev_sess_peers}\" | xargs -r -n1 ipfs swarm connect\n  # Subscribe to common topics over IPNS pubsub so that peer discovery becomes faster\n    ipfs name resolve --dhtt=1s \"$(echo -n IPFS-Chat | ipfs add -n --pin=false -Q)\" # App-specific key\n    ipfs bootstrap | grep -o '[[:alnum:]]*$' | xargs -r -n1 ipfs name resolve --dhtt=1s # General key\n  ) &>/dev/null &\n  export topic=\"$(kdf \"ipfs-chat\" \"${room}\")\" broadcast=\"$(kdf \"peer-addresses\" \"${room}\")\"\n} >&2; export -f ipfs_config\n\nipfs_config\n\nconfig(){\n  # Brief: General config. Compute and export variables. Setup tmp dir and runtime filesystem.\n  if ls -d \"${IPFS_PATH}/room#\"* &>/dev/null; then\n    export nick=\"$(tail -n1 $(ls -d1 \"${IPFS_PATH}/room#\"* | head -n1)/pubkey.asc)\"\n    echo \"Note: Using ${nick} as nick\" # Using separate nicks with same peer ID will cause conflicts with IPNS\n  fi\n\n  export enc_key=\"$(kdf \"symmetric-encryption-key\" \"${room}\")\" tmpdir=\"${IPFS_PATH}/room#${topic}\"\n  mkdir \"${tmpdir}\" 2>/dev/null || { echo \"Error: Another instance running\"; exit 1;}\n  tmpgen(){ mktemp \"${tmpdir}/.XXXXX\";}; export -f tmpgen\n\n  export chat=\"${chat:-\"${tmpdir}/chat\"}\"; :>\"${chat}\" # Redirected no-op to clear file\n  export peers=\"${tmpdir}/peers\"; :>\"${peers}\" # File must exist for `dialog` to show through its tailbox\n  export peers_buffer=\"${tmpdir}/peers.buffer\" peers_ready=\"${tmpdir}/peers.ready\"\n  export input=\"${tmpdir}/input\" dl_lock=\"${tmpdir}/dl.lock\"\n  export bg_pids=\"${tmpdir}/background.proc.id.list\"\n\n  export code=\"${tmpdir}/latest_version\"\n  [[ \"${connect_mode}\" != LAN ]] && update -d \"${code}\" &>/dev/null &\n\n  export cb_wd=\"${tmpdir}/chatbox.width\" # Chatbox width\n  lwrap(){\n    # Brief: Line wrapping to fit our chatbox width\n    # Usage: lwrap [file]\n    # Note: If file is provided, file is folded in-place under lock. Otherwise, stdin to stdout\n    local file=\"${1}\" width=\"$(($(flock -s \"${cb_wd}\" cat \"${cb_wd}\")-5))\" # Read lock; note option -s in flock\n    if [[ -n \"${file}\" ]]; then\n      local buff=\"$(tmpgen)\"\n      fold -s -w \"${width}\" \"${file}\" > \"${buff}\" && flock \"${file}\" mv \"${buff}\" \"${file}\" # In-place, atomic edit\n    else\n      fold -s -w \"${width}\"\n    fi\n  }; export -f lwrap\n  \n} >&2; export -f config\n\nconfig\n\nsafe_gc(){\n  # Brief: Remove blocks that are not pinned. Difference with `ipfs repo gc` is that this removes only those blocks\n  # that are there when function is called, even if the actual cleanup takes time. Also, can check lock for added safety.\n  # Usage: safe_gc [<lock-file>]\n  # Note: Requires IPFS to be online\n  flock -n 3 || return 1\n  local lock=\"${1}\"\n  if [[ -n \"${lock}\" ]]; then\n    flock -n \"${lock}\" ipfs refs local # This doesn't take much time\n  else\n    ipfs refs local\n  fi | xargs -r -n1 ipfs block rm # This is the time consuming part\n} &>/dev/null 3<\"${IPFS_PATH}/config\"; export -f safe_gc\n\nsafe_gc & echo \"${!}\" >> \"${bg_pids}\"\n\nidentity(){\n  # Brief: Generate key-pair. Claim nick & pubkey using IPNS.\n  export GNUPGHOME=\"${IPFS_PATH}/gpg\" pubkey=\"${tmpdir}/pubkey.asc\" peer_kbx=\"${tmpdir}/peer.kbx\"\n  gnupg(){ flock \"${GNUPGHOME}\" gpg --batch -q --always-trust \"${@}\";}; export -f gnupg # Thread-safe gpg in batch mode\n  if mkdir \"${GNUPGHOME}\"; then\n    gnupg --gen-key << EOF\n  %no-protection\n  Key-Type: EDDSA\n    Key-Curve: ed25519\n  Subkey-Type: ECDH\n    Subkey-Curve: cv25519\n  Name-Real: ${selfID}\n  Expire-Date: 0\nEOF\n    (($? == 0)) || return 1\n    gnupg -a -o \"${GNUPGHOME}/pubkey.asc\" --export \"${selfID}\"\n  fi\n  cat \"${GNUPGHOME}/pubkey.asc\" <(echo \"${nick}\") > \"${pubkey}\"\n  ipfs name publish --allow-offline --ipns-base=b58mh \"/ipfs/$(ipfs add -Q \"${pubkey}\")\" & # Claim nick & pubkey using IPNS\n} &>/dev/null; export -f identity\n\nidentity || { echo \"Error: Failed to generate key-pair\" >&2; exit 1;}\n\non_exit(){\n  # Brief: Perform these tasks on exit; called by trap\n  local pid\n  for pid in $(cat ${bg_pids}); do\n    kill_proc_tree \"${pid}\" &\n  done\n  rm -rf \"${tmpdir}\"\n  if ! ls -d ${IPFS_PATH}/room#*; then \n    gpgconf --kill gpg-agent\n    ipfs shutdown\n  fi\n} &>/dev/null; export -f on_exit\n  \ntrap \"on_exit\" exit\n\nconnect_peer(){\n  # Brief: Connect to peer ID or multiaddress provided as argument\n  # TODO: Simplify and economize\n  local input=\"${1}\" peerID=\"${1##*/}\" multiaddress\n  if [[ \"${peerID}\" == \"${selfID}\" ]]; then\n    return 0\n  elif [[ \"${peerID}\" != \"${input}\" ]]; then\n    multiaddress=\"${input}\"\n  else\n    multiaddress=\"/p2p/${peerID}\"\n  fi\n  if ipfs swarm connect \"${multiaddress}\"; then\n    # Swarm connect autochecks whether peerID is already connected. If not, only then tries multiaddress\n    for multiaddress in $(ipfs swarm peers | grep \"${peerID}\"); do\n      cache_peer \"${multiaddress}\" # Add multiaddress of both peer and any relay it is accessed through\n    done\n  else\n    cache_peer \"/p2p/${peerID}\"\n    return 1\n  fi\n} &>/dev/null; export -f connect_peer\n\npeer_pubkey_nick(){\n  # Brief: Import pubkey of peer ID or multiaddress passed as argument and output its nick. Flag -n to force IPNS update (nocache).\n  # TODO: TBD: peer_pubkey=CID_peerID\n  # TODO: Optimize performance / eliminate repetitions with lock. Solve sometimes peer_nick not showing\n  local OPTIND=1 opt nocache\n  getopts n opt; [[ \"${opt}\" == \"n\" ]] && nocache=\"--nocache\"\n  local multiaddress=\"${!OPTIND}\"\n  local peerID=\"${multiaddress##*/}\" peer_nick\n  connect_peer \"${multiaddress}\" &\n  local ipfs_path=\"$(i=0; until ipfs name resolve ${nocache} \"/ipns/${peerID}\" || ((i>5));do ((i++)); done)\"\n  [[ -n \"${ipfs_path}\" ]] || return 1\n  local peer_pubkey=\"${tmpdir}/${ipfs_path##*/}\"\n  if ! [[ -e \"${peer_pubkey}\" ]]; then\n    # Check size of file before download to avoid spam. Pubkey is 669 bytes to be exact. Add some grace for nick etc.\n    ((\"$(ipfs files stat --size \"${ipfs_path}\" || 1001)\" < 1000)) || return 1\n    gnupg --yes --no-default-keyring --keyring \"${peer_kbx}\" --delete-keys \"${peerID}\"\n    flock \"${peer_pubkey}\" ipfs get -o \"${peer_pubkey}\" \"${ipfs_path}\" && ipfs pin add \"${ipfs_path}\" && \\\n    gnupg --no-default-keyring --keyring \"${peer_kbx}\" --import \"${peer_pubkey}\" || rm -f \"${peer_pubkey}\"\n  fi &>/dev/null\n  if peer_nick=\"$(tail -n1 \"${peer_pubkey}\")\"; then\n    [[ -n \"${peer_nick}\" ]] || return 1 # TODO: Understand how peer_nick can ever be empty\n    local peer_buff=\"${peer_nick} @${peerID:${#peerID}-6:6}\"\n    grep -q -m1 \"${peer_buff}\" \"${peers}\" || flock \"${peers}\" echo \"${peer_buff}\" >> \"${peers}\" # Live update of online-peers window\n    flock \"${peers_buffer}\" echo \"${peer_buff}\" >> \"${peers_buffer}\"\n    echo \"${peer_buff}\"\n  else\n    return 1\n  fi\n} 2>/dev/null ; export -f peer_pubkey_nick\n\ncheck_mime_type(){\n  # Brief: Checks if mime-type of given file matches with the file extension. If extension is unknown, let it be.\n  # If extension refers to different mime-type, Fail.\n  # Usage: check_mime_type <path> <extension>\n  [[ -v mime_type_check ]] || return 0\n  local mime_type_table=\"/etc/mime.types\" path=\"${1}\" ext=\"${2##*.}\"\n  [[ -f \"${mime_type_table}\" ]] || return 0 # Perhaps this table exists only in Debian and Ubuntu\n  local mime_frm_ext=\"$(grep -m1 -w \"${ext}\" \"${mime_type_table}\" | awk '{print $1}')\"\n  if [[ -n \"${mime_frm_ext}\" ]]; then\n    local actual_mime=\"$(file -ib \"${path}\" | cut -d ';' -f 1)\" # -i or --mime is more supported than --mime-type\n    [[ \"${actual_mime}\" != \"${mime_frm_ext}\" ]] && [[ \"${actual_mime}\" =~ ^application/.*$ ]] && \\\n      echo \".$(grep -w \"${actual_mime}\" \"${mime_type_table}\" | awk '{print $2}')\"\n  fi\n} 2>/dev/null; export check_mime_type\n\nfile_unpack(){\n  # Brief: Download and decrypt shared file\n  # Usage: file_unpack <file-hash> <IPFS-CID> <filename>\n  # TODO: Ask user for permission to download instead of rejecting for size>max_dl_MB\n  flock -s 3\n  local dec_hash=\"${1}\" cid=\"${2}\" dlpath=\"${dldir}/${3}\"\n  local cache=\"${global_fs}/${cid}\"\n  if ! [[ -f \"${cache}\" ]]; then\n    ((max_dl_MB < 0)) || (($(ipfs files stat --size /ipfs/\"${cid}\") < max_dl_MB*1024*1024)) || return 1\n    local buffer=\"$(tmpgen)\"\n    ipfs cat \"${cid}\" | openssl enc -aes128 -pass pass:\"${dec_hash}\" -nosalt -a -A -d -out \"${buffer}\" && \\\n      mv \"${buffer}\" \"${cache}\" && ipfs pin add \"${cid}\"\n  fi\n  local mime_ext=\"$(check_mime_type \"${cache}\" \"${dlpath}\")\"\n  ln --backup=numbered \"${cache}\" \"${dlpath}${mime_ext}\" || \\\n    cp --backup=numbered \"${cache}\" \"${dlpath}${mime_ext}\"\n} &>/dev/null 3>\"${dl_lock}\"; export -f file_unpack\n\nsubscriber_daemon(){\n  # Brief: Listen to messages at pubsub, decrypt & verify signature, display if ok\n  # TODO: Malicious peer detection and blocking.\n  local timestamp CID peerID readbuff recipID sender buffer=\"$(tmpgen)\" gpg_stderr=\"$(tmpgen)\" prefix\n  while read -r peerID readbuff recipID;do\n    (sender=\"$(peer_pubkey_nick \"${peerID}\")\" || exit 1 # Note absence of -n flag in peer_pubkey_nick\n    case \"${recipID}\" in\n      all) \n        prefix=\"$(printf '=%.0s' {1..40})\"$'\\n'\n        gnupg --keyring \"${peer_kbx}\" --passphrase \"${enc_key}\" --pinentry-mode loopback -d\n        ;;\n      \"${selfID}\")\n        prefix='**************Private message***********'$'\\n'\n        gnupg --keyring \"${peer_kbx}\" -d\n        ;;\n      *) exit 1;;\n    esac < <(echo -n \"${readbuff}\" | base64 -d) > \"${buffer}\" 2> \"${gpg_stderr}\" || exit 1\n    grep -iq \"Good signature from \\\"${peerID}\\\"\" \"${gpg_stderr}\" || exit 1 # Verify authenticity/signature\n    grep -xq '[[:print:]]*' \"${buffer}\" || exit 1 # Check msg is text only to avoid spam\n    read timestamp dec_hash CID < <(head -n1 \"${buffer}\" | grep -xE '[[:digit:]]*[[:blank:]]([[:alnum:]+_]*[[:blank:]][[:alnum:]]*)?')\n    timestamp=\"$(date -d @${timestamp} +\"%a %H:%M:%S\")\" || exit 1\n    prefix=\"${prefix}${sender} ${timestamp} -- \"\n    flock \"${chat}\" cat <(echo -n \"${prefix}\") <(tail -n+2 \"${buffer}\") <(echo -e \\\\n) | lwrap >> \"${chat}\"\n    if [[ -n \"${dec_hash}\" ]]; then\n      [[ \"${peerID}\" != \"${selfID}\" ]] || [[ \"${recipID}\" == \"${selfID}\" ]] || exit 1\n      eval filename=\"$(awk NR==2 \"${buffer}\" | cut -d ' ' -f 3-)\" # eval is for quote removal\n      file_unpack \"${dec_hash}\" \"${CID}\" \"${filename}\" || \\\n        flock \"${chat}\" echo -e \"Download failed -- ${filename}\\n\" | lwrap >> \"${chat}\"\n    fi\n    )&\n  done < <(ipfs pubsub sub \"${topic}\" | grep --line-buffered -x '[[:alnum:]]*[[:blank:]][[:alnum:]+/=]*[[:blank:]][[:alnum:]]*')\n} &>\"${tmpdir}/subscriber_daemon.log\"; export -f subscriber_daemon\n\nsubscriber_daemon & echo \"${!}\" >> \"${bg_pids}\"\n\npubsub_conn(){\n  # Brief: Connect to multiaddresses that are broadcast over pubsub\n  # TODO: Economize same peerID multiple multiaddress\n  local multiaddress peerID\n  while read -r multiaddress;do\n    peerID=\"${multiaddress##*/}\"\n    [[ \"${peerID}\" == \"${selfID}\" ]] || peer_pubkey_nick \"${multiaddress}\" # TODO: TBD: & (bg) or not?\n  done < <(ipfs pubsub sub \"${broadcast}\" | grep --line-buffered -x '[[:alnum:]/.:-]*')\n} &>\"${tmpdir}/pubsub_conn.log\"; export -f pubsub_conn\n\necho \"Status: Launching peer-discovery over pubsub...\" >&2; pubsub_conn & echo \"${!}\" >> \"${bg_pids}\"\n\ncon_cull(){\n  # Brief: Cull all connections except those in the cache, and the connection to relay (if any)\n  # Purpose: Reducing bandwidth usage by killing all irrelevant connections\n  local own_relay=\"$(ipfs id \"${selfID}\" -f=\"<addrs>\\n\" | grep -o '/p2p/[[:alnum:]]*' | sort -u)\"\n  ipfs swarm peers | grep -o '/p2p/[[:alnum:]]*' | grep -vf \"${sess_peers}\" | grep -vf <(echo \"${own_relay}\") | \\\n    xargs -r -n1 ipfs swarm disconnect\n} &>/dev/null; export -f con_cull\n\ndeclare -irx ICPDI=\"${ICPDI:=30}\" # IPFS_CHAT_PEER_DISCOVERY_INTERVAL in seconds (type: integer)\n\npeering_daemon(){\n  # Brief: Discover & connect to chat-peers & announce self for others to discover - at regular intervals\n  local peerID\n  local -a dht_ops_pid\n  local -A peerID_list # Associative array\n\n  local -r start_peer_discov=\"${EPOCHSECONDS}\"\n  while :;do\n    dht_ops_pid=() # Stores pid's of background DHT operations executing in the current pass\n    local timestamp=\"${EPOCHSECONDS}\" # Current Unix time\n    local nonce=\"$(hmac \"${broadcast}\" \"$((timestamp/120))\" | ipfs add -Q --stdin-name='Rendezvous')\" # Announce time based nonce\n    #ipfs dht provide \"${nonce}\" & dht_ops_pid+=($!) # TODO: TBD: Isnt `ipfs add` enough? `ipfs dht provide` takes loooong time\n\n    peerID_list=() # Would store peerIDs seen in this pass\n    while read -r -t 5 peerID; do # Connecting to peers and importing their latest pubkeys. Exp: No timeout messes things up\n      ((peerID_list[\"${peerID}\"] != 1)) || continue # peerID handled already, so move on\n      peerID_list[\"${peerID}\"]=1 # Add to list so that other iterations won't handle this peerID again\n      peer_pubkey_nick -n \"${peerID}\" &>/dev/null & dht_ops_pid+=($!) # Notice the nocache flag -n forcing IPNS update      \n    done < <(cat <(ipfs pubsub peers \"${topic}\") <(ipfs pubsub peers \"${broadcast}\") <(timeout 5.5 ipfs dht findprovs \"${nonce}\"))\n    # Makes things concurrent. Note: Without the `ipfs dht` timeout, `ps` would be replete with older `cat` and `ipfs dht`\n\n    [[ -n \"${dht_ops_pid}\" ]] && wait \"${dht_ops_pid[@]}\" # Wait till all DHT operations are complete\n    ipfs id \"${selfID}\" -f=\"<addrs>\\n\" | grep -vf <(ipfs diag sys | jq -r .net.interface_addresses[]) | \\\n      ipfs pubsub pub \"${broadcast}\" # Announce own public multiaddresses over pubsub\n    ipfs pin rm \"${nonce}\" &>/dev/null & # Otherwise reprovider will continue announcing stale nonce. Pin still necessary to save from auto-GC\n    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\n    if ((EPOCHSECONDS-start_peer_discov > 30)); then\n      con_cull & # Need for DHT is over for now. So, let's cull unnecessary connections to reduce bandwidth usage.\n      safe_gc \"${dl_lock}\" & # Remove irrelevant blocks in bg\n      # Lockfile makes sure this is not run during file download, as otherwise downloaded but yet unpinned blocks might be GCd\n      sleep \"$((ICPDI-EPOCHSECONDS+timestamp))\" 2>/dev/null # Redirection for when the sleep time is negative\n    else\n      continue # For the initial 30s after launch be relentless in peer discovery. No culling, no GC.\n    fi\n  done  \n} &>\"${tmpdir}/peering_daemon.log\"; export -f peering_daemon\n\necho \"Status: Launching peer-discovery over DHT...\" >&2; peering_daemon & echo \"${!}\" >> \"${bg_pids}\"\n\nfile_pack(){\n  # Brief: Encrypt file with its salted hash, add to IPFS & output CID and encrypt key\n  # Usage: file_pack <file containing the path of the file to be shared> # This is just for simplicity of `send` code below\n  # This function also replaces the path present in the given file with just the filename\n  local msg=\"${1}\" path filename\n  path=\"$(win2lin_path < \"${msg}\")\"\n  if [[ -f \"${path}\" ]]; then\n    filename=\"${path##*/}\"\n  elif [[ -d \"${path}\" ]]; then\n    local dir=\"${path}\"; path=\"$(tmpgen)\"\n    local dirname=\"${dir##*/}\"\n    (cd \"${dir}\"/.. ; tar -czf \"${path}\" \"${dirname}\") # This trick makes sure tar -xzf gives only the desired directory, not its parents\n    filename=\"${dirname}.tar.gz\"\n  else\n    return 0    \n  fi\n  local enc_hash=\"$(sha1sum -b \"${path}\" | cut -d' ' -f1 | b64)\"\n  if ! grep -m1 \"${enc_hash}\" \"${sess_uplds}\"; then\n    local cache=\"${global_fs}/${enc_hash}\"\n    [[ -f \"${cache}\" ]] || openssl enc -aes128 -pass pass:\"${enc_hash}\" -nosalt -a -A -in \"${path}\" -out \"${cache}\"\n    local hlink=\"$(tmpgen)\"; ln -f \"${cache}\" \"${hlink}\"\n    # This is necessary for ipfs add --nocopy below; otherwise ipfs add fails if cache is outside \"${IPFS_PATH}/..\"\n    ((max_dl_MB < 0)) || ((\"$(wc -c \"${hlink}\" | cut -d ' ' -f1)\" < max_dl_MB*1024*1024)) || return 1\n    echo \"${enc_hash} $(ipfs add --nocopy --fscache -Q \"${hlink}\")\" | flock \"${sess_uplds}\" tee -a \"${sess_uplds}\"\n  fi\n  # Openssl with -nosalt instead of GPG, because GPG or Openssl -salt encryption is time dependent\n  echo -n \"Sent file: \\\"${filename}\\\"\" > \"${msg}\"\n} 2>/dev/null; export -f file_pack\n\nsend(){\n  # Brief: Encrypt and sign user's msg & publish to pubsub\n  [[ -s \"${input}\" ]] || return # Skip empty input\n  local msg=\"$(tmpgen)\" recipID=\"all\"\n  local first_word=\"$(cut -z -d ' ' -f 1 \"${input}\")\"\n  if [[ \"${first_word}\" =~ ^@[[:alnum:]]{6}$ ]]; then\n    recipID=\"$(grep -Eom1 \"[[:alnum:]]*${first_word/@/}$\" \"${sess_peers}\")\"\n    cut -d ' ' -f 2- \"${input}\" | tr -d $'\\n' > \"${msg}\"\n    grep -xq \"${first_word}\" \"${msg}\" && return # Skip empty input\n    local prefix=\"PM to $(grep -m1 \"${first_word}\" \"${peers}\") $(date +\"%a %H:%M:%S\") -- \"\n  else  \n    mv \"${input}\" \"${msg}\"\n  fi\n  (\n  if enc_hash_cid=\"$(file_pack \"${msg}\")\"; then\n    buffer=\"$(cat <(echo \"${EPOCHSECONDS} ${enc_hash_cid}\") \"${msg}\" | \\\n      case \"${recipID}\" in\n        all) gnupg --passphrase \"${enc_key}\" --pinentry-mode loopback -s -c --cipher-algo AES128;;\n        *) peer_pubkey_nick \"${recipID}\" >/dev/null ; gnupg --keyring \"${peer_kbx}\" -s -r \"${recipID}\" -e;;\n      esac | base64 -w0)\"\n    ipfs pubsub pub \"${topic}\" <<< \"${selfID} ${buffer} ${recipID}\"\n  else\n    prefix=\"Failed to send -- \"\n  fi\n  [[ -v prefix ]] && flock \"${chat}\" cat <(echo -n \"${prefix}\") \"${msg}\" <(echo -e \\\\n) | lwrap >> \"${chat}\"\n  ) &\n} &>/dev/null; export -f send\n\nui(){\n  # Brief: UI event-loop. Window numbering: 1(Top Left) 2(Top Right) 3(Spanning Bottom)\n    local PM_buffer=\"$(tmpgen)\" txt_buffer=\"$(tmpgen)\"\n    local input_help=\"\\Zb\\Z4Nick: \\Zu\\Z0${nick}\\Zn \\Zb\\Z4peerID: \\Zu\\Z0@${selfID:${#selfID}-6:6}\\Zn\n\\Zb\\Z4General-Message:\\Z1 Type, then \\Z4Send\\Z1 (or press \\Z4Enter\\Z1)\\Zn\n\\Zb\\Z4Fle-sharing:\\Z2 Drag-n-drop file/directory, or use \\Z4Explorer\\Zn\n\\Zb\\Z4Private-Message:\\Z5 Select peer using \\Z4PM\\Z5, then type and \\Z4Send\\Zn\"\n    local chat_title=\"Room: ${room}\"\n    local peers_title=\"Online-peers\"\n    local peering_mode=\"\\Zb\\Z4${connect_mode:-\"WAN+LAN\"}\\Zn\"\n\n  while :;do\n    # Dimensions are computed just before calling `dialog` to accomodate for the latest terminal window size changes\n    local tty_height=\"$(tput lines)\" tty_width=\"$(tput cols)\"\n    local win3_height=10 win3_width=\"${tty_width}\"\n    local win12_height=\"$((tty_height-win3_height-1))\" # The -1 gap looks awesome as it demarcates better\n    local win2_width=\"$((tty_width/4))\"\n    local win1_width=\"$((tty_width-win2_width))\"\n    if ((win1_width != last_win1_width)); then\n      flock -x \"${cb_wd}\" echo \"${win1_width}\" > \"${cb_wd}\" # Write lock; note option -x in flock\n      lwrap \"${chat}\"\n      local last_win1_width=\"${win1_width}\"\n    fi # Conditionality decreases lag between pressing Send and subsequent chatbox update\n\n    DIALOG_CANCEL=4 dialog --keep-tite \\\n      --title \"${chat_title}\" --begin 0 0 --tailboxbg \"${chat}\" \"${win12_height}\" \"${win1_width}\" \\\n      --and-widget --colors --hline \"${peering_mode}\" \\\n      --title \"${peers_title}\" --begin 0 \"${win1_width}\" --tailboxbg \"${peers}\" \"${win12_height}\" \"${win2_width}\" \\\n      --and-widget --colors \\\n      --no-shadow --title \"Press Esc to exit\" --begin \"$((tty_height-win3_height))\" 0 \\\n      --ok-label \"Send\" --cancel-label \"Explorer\" \\\n      --extra-button --extra-label \"Chat\" \\\n      --help-button --help-label \"PM\" \\\n      --inputbox \"${input_help}\" \"${win3_height}\" \"${win3_width}\" \"$(cat \"${PM_buffer}\" \"${txt_buffer}\")\" \\\n      2> \"${input}\"\n      local exit_code=$?\n\n      mv -f \"${peers_ready}\" \"${peers}\" &>/dev/null # Refresh online-peers\n\n      case \"${exit_code}\" in\n        0) # Button: Send\n           send \n           : > \"${PM_buffer}\"; : > \"${txt_buffer}\"\n           ;;\n        2) # Button: PM\n           sed -E s/^@[[:alnum:]]{6}[[:blank:]]?// \"${input}\" > \"${txt_buffer}\" # Put anything except recipID in buffer\n           dialog --keep-tite --no-shadow --colors --hline \"${peering_mode}\" --exit-label \"Back\" --ok-label \"Select\" \\\n           --title \"${peers_title}\" --begin 0 0 --menu \"Choose peer\" \"${tty_height}\" \"${tty_width}\" \"${tty_height}\" \\\n           $(awk '{print $2,$1}' \"${peers}\") 2> \"${PM_buffer}\" &&  echo -n ' ' >> \"${PM_buffer}\"\n           ;;\n        3) # Button: Chat\n           dialog --keep-tite --no-shadow --scrollbar --exit-label \"Back\" \\\n           --title \"${chat_title}\" --begin 0 0 --textbox \"${chat}\" \"${tty_height}\" \"${tty_width}\"\n           : > \"${PM_buffer}\"; : > \"${txt_buffer}\"\n           ;;\n        4) # Button: Explorer\n           dialog --keep-tite --colors --begin 0 0 \\\n           --title \"Help: \\Z1Tab\\Zn for choosing window; \\Z1Spacebar\\Zn for autocomplete or select/copy\" \\\n           --fselect \"${PWD}/\" \"${win12_height}\" \"${tty_width}\" 2> \"${txt_buffer}\"\n           ;;\n        1 | *) # Ctrl-C or Esc\n           local confirm_quit=\"Shared file download is in progress. Still wanna quit?\"\n           if ! flock -n \"${dl_lock}\" -c : ; then\n            # Check if dl_lock is held by file_unpack or safe_gc. In the latter case, return without prompt.\n            if flock -s \"${dl_lock}\" -c : ; then\n              # Read lock could be acquired, hence it must be file_unpack that's holding dl_lock\n              dialog --keep-tite --yesno \"${confirm_quit}\" \"$(tput lines)\" \"$(tput cols)\" && return \"${exit_code}\"\n            else\n              return \"${exit_code}\" # Lock held by safe_gc\n            fi\n           else\n            return \"${exit_code}\"\n           fi\n           ;;\n      esac\n  done\n}; export -f ui\n\necho \"Status: Launching UI...(If it takes a long time to open, try pressing Enter)\" >&2; ui\n\n[[ -v disable_bandwidth_metrics ]] && \\\n  echo -e \"Stats: $(ipfs stats bw | head -n3)\\nTime: $((EPOCHSECONDS-daemon_launch_time))s\" >&2\n\nif [[ -x \"${code}\" ]] && updateto=\"$(${code} -v 2>/dev/null)\" && [[ \"${updateto}\" != \"${version}\" ]]; then\n  confirm_update=\"Update ipfs-chat from v${version} to v${updateto}?\"\n  dialog --keep-tite --yesno \"${confirm_update}\" \"$(tput lines)\" \"$(tput cols)\" && update -s \"${code}\"\nfi\n\necho \"Status: Exiting...\" >&2\n\nexit\n"
  },
  {
    "path": "mime.types",
    "content": "###############################################################################\n#\n#  MIME media types and the extensions that represent them.\n#\n#  The format of this file is a media type on the left and zero or more\n#  filename extensions on the right.  Programs using this file will map\n#  files ending with those extensions to the associated type.\n#\n#  This file is part of the \"mime-support\" package.  Please report a bug using\n#  the \"reportbug\" command of the \"reportbug\" package if you would like new\n#  types or extensions to be added.\n#\n#  The reason that all types are managed by the mime-support package instead\n#  allowing individual packages to install types in much the same way as they\n#  add entries in to the mailcap file is so these types can be referenced by\n#  other programs (such as a web server) even if the specific support package\n#  for that type is not installed.\n#\n#  Users can add their own types if they wish by creating a \".mime.types\"\n#  file in their home directory.  Definitions included there will take\n#  precedence over those listed here.\n#\n###############################################################################\n\n\napplication/activemessage\napplication/andrew-inset\t\t\tez\napplication/annodex\t\t\t\tanx\napplication/applefile\napplication/atom+xml\t\t\t\tatom\napplication/atomcat+xml\t\t\t\tatomcat\napplication/atomicmail\napplication/atomserv+xml\t\t\tatomsrv\napplication/batch-SMTP\napplication/bbolin\t\t\t\tlin\napplication/beep+xml\napplication/cals-1840\napplication/commonground\napplication/cu-seeme\t\t\t\tcu\napplication/cybercash\napplication/davmount+xml\t\t\tdavmount\napplication/dca-rft\napplication/dec-dx\napplication/dicom\t\t\t\tdcm\napplication/docbook+xml\napplication/dsptype\t\t\t\ttsp\napplication/dvcs\napplication/ecmascript\t\t\t\tes\napplication/edi-consent\napplication/edi-x12\napplication/edifact\napplication/epub+zip\t\t\t\tepub\napplication/eshop\napplication/font-sfnt\t\t\t\totf ttf\napplication/font-tdpfr\t\t\t\tpfr\napplication/font-woff\t\t\t\twoff\napplication/futuresplash\t\t\tspl\napplication/ghostview\napplication/gzip\t\t\t\tgz\napplication/hta\t\t\t\t\thta\napplication/http\napplication/hyperstudio\napplication/iges\napplication/index\napplication/index.cmd\napplication/index.obj\napplication/index.response\napplication/index.vnd\napplication/iotp\napplication/ipp\napplication/isup\napplication/java-archive\t\t\tjar\napplication/java-serialized-object\t\tser\napplication/java-vm\t\t\t\tclass\napplication/javascript\t\t\t\tjs mjs\napplication/json\t\t\t\tjson\napplication/ld+json\t\t\t\tjsonld\napplication/m3g\t\t\t\t\tm3g\napplication/mac-binhex40\t\t\thqx\napplication/mac-compactpro\t\t\tcpt\napplication/macwriteii\napplication/marc\napplication/mathematica\t\t\t\tnb nbp\napplication/mbox\t\t\t\tmbox\napplication/ms-tnef\napplication/msaccess\t\t\t\tmdb\napplication/msword\t\t\t\tdoc dot\napplication/mxf\t\t\t\t\tmxf\napplication/news-message-id\napplication/news-transmission\napplication/ocsp-request\napplication/ocsp-response\napplication/octet-stream\t\t\tbin deploy msu msp\napplication/oda\t\t\t\t\toda\napplication/oebps-package+xml\t\t\topf\napplication/ogg\t\t\t\t\togx\napplication/onenote\t\t\t\tone onetoc2 onetmp onepkg\napplication/parityfec\napplication/pdf\t\t\t\t\tpdf\napplication/pgp-encrypted\t\t\tpgp\napplication/pgp-keys\t\t\t\tkey\napplication/pgp-signature\t\t\tsig\napplication/pics-rules\t\t\t\tprf\napplication/pkcs10\napplication/pkcs7-mime\napplication/pkcs7-signature\napplication/pkix-cert\napplication/pkix-crl\napplication/pkixcmp\napplication/postscript\t\t\t\tps ai eps epsi epsf eps2 eps3\napplication/prs.alvestrand.titrax-sheet\napplication/prs.cww\napplication/prs.nprend\napplication/qsig\napplication/rar\t\t\t\t\trar\napplication/rdf+xml\t\t\t\trdf\napplication/remote-printing\napplication/riscos\napplication/rtf\t\t\t\t\trtf\napplication/sdp\napplication/set-payment\napplication/set-payment-initiation\napplication/set-registration\napplication/set-registration-initiation\napplication/sgml\napplication/sgml-open-catalog\napplication/sieve\napplication/sla\t\t\t\t\tstl\napplication/slate\napplication/smil+xml\t\t\t\tsmi smil\napplication/timestamp-query\napplication/timestamp-reply\napplication/vemmi\napplication/wasm                                wasm\napplication/whoispp-query\napplication/whoispp-response\napplication/wita\napplication/x400-bp\napplication/xhtml+xml\t\t\t\txhtml xht\napplication/xml\t\t\t\t\txml xsd\napplication/xml-dtd\napplication/xml-external-parsed-entity\napplication/xslt+xml\t\t\t\txsl xslt\napplication/xspf+xml\t\t\t\txspf\napplication/zip\t\t\t\t\tzip\napplication/vnd.3M.Post-it-Notes\napplication/vnd.accpac.simply.aso\napplication/vnd.accpac.simply.imp\napplication/vnd.acucobol\napplication/vnd.aether.imp\napplication/vnd.android.package-archive\t\t\t\t\t\tapk\napplication/vnd.anser-web-certificate-issue-initiation\napplication/vnd.anser-web-funds-transfer-initiation\napplication/vnd.audiograph\napplication/vnd.bmi\napplication/vnd.businessobjects\napplication/vnd.canon-cpdl\napplication/vnd.canon-lips\napplication/vnd.cinderella\t\t\t\t\t\t\tcdy\napplication/vnd.claymore\napplication/vnd.commerce-battelle\napplication/vnd.commonspace\napplication/vnd.comsocaller\napplication/vnd.contact.cmsg\napplication/vnd.cosmocaller\napplication/vnd.ctc-posml\napplication/vnd.cups-postscript\napplication/vnd.cups-raster\napplication/vnd.cups-raw\napplication/vnd.cybank\napplication/vnd.debian.binary-package\t\t\t\t\t\tdeb ddeb udeb\napplication/vnd.dna\napplication/vnd.dpgraph\napplication/vnd.dxr\napplication/vnd.ecdis-update\napplication/vnd.ecowin.chart\napplication/vnd.ecowin.filerequest\napplication/vnd.ecowin.fileupdate\napplication/vnd.ecowin.series\napplication/vnd.ecowin.seriesrequest\napplication/vnd.ecowin.seriesupdate\napplication/vnd.enliven\napplication/vnd.epson.esf\napplication/vnd.epson.msf\napplication/vnd.epson.quickanime\napplication/vnd.epson.salt\napplication/vnd.epson.ssf\napplication/vnd.ericsson.quickcall\napplication/vnd.eudora.data\napplication/vnd.fdf\napplication/vnd.ffsns\napplication/vnd.flographit\napplication/vnd.font-fontforge-sfd\t\t\t\t\t\tsfd\napplication/vnd.framemaker\napplication/vnd.fsc.weblaunch\napplication/vnd.fujitsu.oasys\napplication/vnd.fujitsu.oasys2\napplication/vnd.fujitsu.oasys3\napplication/vnd.fujitsu.oasysgp\napplication/vnd.fujitsu.oasysprs\napplication/vnd.fujixerox.ddd\napplication/vnd.fujixerox.docuworks\napplication/vnd.fujixerox.docuworks.binder\napplication/vnd.fut-misnet\napplication/vnd.google-earth.kml+xml\t\t\t\t\t\tkml\napplication/vnd.google-earth.kmz\t\t\t\t\t\tkmz\napplication/vnd.grafeq\napplication/vnd.groove-account\napplication/vnd.groove-identity-message\napplication/vnd.groove-injector\napplication/vnd.groove-tool-message\napplication/vnd.groove-tool-template\napplication/vnd.groove-vcard\napplication/vnd.hhe.lesson-player\napplication/vnd.hp-HPGL\napplication/vnd.hp-PCL\napplication/vnd.hp-PCLXL\napplication/vnd.hp-hpid\napplication/vnd.hp-hps\napplication/vnd.httphone\napplication/vnd.hzn-3d-crossword\napplication/vnd.ibm.MiniPay\napplication/vnd.ibm.afplinedata\napplication/vnd.ibm.modcap\napplication/vnd.informix-visionary\napplication/vnd.intercon.formnet\napplication/vnd.intertrust.digibox\napplication/vnd.intertrust.nncp\napplication/vnd.intu.qbo\napplication/vnd.intu.qfx\napplication/vnd.irepository.package+xml\napplication/vnd.is-xpr\napplication/vnd.japannet-directory-service\napplication/vnd.japannet-jpnstore-wakeup\napplication/vnd.japannet-payment-wakeup\napplication/vnd.japannet-registration\napplication/vnd.japannet-registration-wakeup\napplication/vnd.japannet-setstore-wakeup\napplication/vnd.japannet-verification\napplication/vnd.japannet-verification-wakeup\napplication/vnd.koan\napplication/vnd.lotus-1-2-3\napplication/vnd.lotus-approach\napplication/vnd.lotus-freelance\napplication/vnd.lotus-notes\napplication/vnd.lotus-organizer\napplication/vnd.lotus-screencam\napplication/vnd.lotus-wordpro\napplication/vnd.mcd\napplication/vnd.mediastation.cdkey\napplication/vnd.meridian-slingshot\napplication/vnd.mif\napplication/vnd.minisoft-hp3000-save\napplication/vnd.mitsubishi.misty-guard.trustweb\napplication/vnd.mobius.daf\napplication/vnd.mobius.dis\napplication/vnd.mobius.msl\napplication/vnd.mobius.plc\napplication/vnd.mobius.txf\napplication/vnd.motorola.flexsuite\napplication/vnd.motorola.flexsuite.adsi\napplication/vnd.motorola.flexsuite.fis\napplication/vnd.motorola.flexsuite.gotap\napplication/vnd.motorola.flexsuite.kmr\napplication/vnd.motorola.flexsuite.ttc\napplication/vnd.motorola.flexsuite.wem\napplication/vnd.mozilla.xul+xml\t\t\t\t\t\t\txul\napplication/vnd.ms-artgalry\napplication/vnd.ms-asf\napplication/vnd.ms-excel\t\t\t\t\t\t\txls xlb xlt\napplication/vnd.ms-excel.addin.macroEnabled.12\t\t\t\t\txlam\napplication/vnd.ms-excel.sheet.binary.macroEnabled.12\t\t\t\txlsb\napplication/vnd.ms-excel.sheet.macroEnabled.12\t\t\t\t\txlsm\napplication/vnd.ms-excel.template.macroEnabled.12\t\t\t\txltm\napplication/vnd.ms-fontobject\t\t\t\t\t\t\teot\napplication/vnd.ms-lrm\napplication/vnd.ms-officetheme\t\t\t\t\t\t\tthmx\napplication/vnd.ms-pki.seccat\t\t\t\t\t\t\tcat\n#application/vnd.ms-pki.stl\t\t\t\t\t\t\tstl\napplication/vnd.ms-powerpoint\t\t\t\t\t\t\tppt pps\napplication/vnd.ms-powerpoint.addin.macroEnabled.12\t\t\t\tppam\napplication/vnd.ms-powerpoint.presentation.macroEnabled.12\t\t\tpptm\napplication/vnd.ms-powerpoint.slide.macroEnabled.12\t\t\t\tsldm\napplication/vnd.ms-powerpoint.slideshow.macroEnabled.12\t\t\t\tppsm\napplication/vnd.ms-powerpoint.template.macroEnabled.12\t\t\t\tpotm\napplication/vnd.ms-project\napplication/vnd.ms-tnef\napplication/vnd.ms-word.document.macroEnabled.12\t\t\t\tdocm\napplication/vnd.ms-word.template.macroEnabled.12\t\t\t\tdotm\napplication/vnd.ms-works\napplication/vnd.mseq\napplication/vnd.msign\napplication/vnd.music-niff\napplication/vnd.musician\napplication/vnd.netfpx\napplication/vnd.noblenet-directory\napplication/vnd.noblenet-sealer\napplication/vnd.noblenet-web\napplication/vnd.novadigm.EDM\napplication/vnd.novadigm.EDX\napplication/vnd.novadigm.EXT\napplication/vnd.oasis.opendocument.chart\t\t\t\t\todc\napplication/vnd.oasis.opendocument.database\t\t\t\t\todb\napplication/vnd.oasis.opendocument.formula\t\t\t\t\todf\napplication/vnd.oasis.opendocument.graphics\t\t\t\t\todg\napplication/vnd.oasis.opendocument.graphics-template\t\t\t\totg\napplication/vnd.oasis.opendocument.image\t\t\t\t\todi\napplication/vnd.oasis.opendocument.presentation\t\t\t\t\todp\napplication/vnd.oasis.opendocument.presentation-template\t\t\totp\napplication/vnd.oasis.opendocument.spreadsheet\t\t\t\t\tods\napplication/vnd.oasis.opendocument.spreadsheet-template\t\t\t\tots\napplication/vnd.oasis.opendocument.text\t\t\t\t\t\todt\napplication/vnd.oasis.opendocument.text-master\t\t\t\t\todm\napplication/vnd.oasis.opendocument.text-template\t\t\t\tott\napplication/vnd.oasis.opendocument.text-web\t\t\t\t\toth\napplication/vnd.openxmlformats-officedocument.presentationml.presentation\tpptx\napplication/vnd.openxmlformats-officedocument.presentationml.slide\t\tsldx\napplication/vnd.openxmlformats-officedocument.presentationml.slideshow\t\tppsx\napplication/vnd.openxmlformats-officedocument.presentationml.template\t\tpotx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet\t\txlsx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.template\t\txltx\napplication/vnd.openxmlformats-officedocument.wordprocessingml.document\t\tdocx\napplication/vnd.openxmlformats-officedocument.wordprocessingml.template\t\tdotx\napplication/vnd.osa.netdeploy\napplication/vnd.palm\napplication/vnd.pg.format\napplication/vnd.pg.osasli\napplication/vnd.powerbuilder6\napplication/vnd.powerbuilder6-s\napplication/vnd.powerbuilder7\napplication/vnd.powerbuilder7-s\napplication/vnd.powerbuilder75\napplication/vnd.powerbuilder75-s\napplication/vnd.previewsystems.box\napplication/vnd.publishare-delta-tree\napplication/vnd.pvi.ptid1\napplication/vnd.pwg-xhtml-print+xml\napplication/vnd.rapid\napplication/vnd.rim.cod\t\t\t\t\t\t\t\tcod\napplication/vnd.s3sms\napplication/vnd.seemail\napplication/vnd.shana.informed.formdata\napplication/vnd.shana.informed.formtemplate\napplication/vnd.shana.informed.interchange\napplication/vnd.shana.informed.package\napplication/vnd.smaf\t\t\t\t\t\t\t\tmmf\napplication/vnd.sss-cod\napplication/vnd.sss-dtf\napplication/vnd.sss-ntf\napplication/vnd.stardivision.calc\t\t\t\t\t\tsdc\napplication/vnd.stardivision.chart\t\t\t\t\t\tsds\napplication/vnd.stardivision.draw\t\t\t\t\t\tsda\napplication/vnd.stardivision.impress\t\t\t\t\t\tsdd\napplication/vnd.stardivision.math\t\t\t\t\t\tsdf\napplication/vnd.stardivision.writer\t\t\t\t\t\tsdw\napplication/vnd.stardivision.writer-global\t\t\t\t\tsgl\napplication/vnd.street-stream\napplication/vnd.sun.xml.calc\t\t\t\t\t\t\tsxc\napplication/vnd.sun.xml.calc.template\t\t\t\t\t\tstc\napplication/vnd.sun.xml.draw\t\t\t\t\t\t\tsxd\napplication/vnd.sun.xml.draw.template\t\t\t\t\t\tstd\napplication/vnd.sun.xml.impress\t\t\t\t\t\t\tsxi\napplication/vnd.sun.xml.impress.template\t\t\t\t\tsti\napplication/vnd.sun.xml.math\t\t\t\t\t\t\tsxm\napplication/vnd.sun.xml.writer\t\t\t\t\t\t\tsxw\napplication/vnd.sun.xml.writer.global\t\t\t\t\t\tsxg\napplication/vnd.sun.xml.writer.template\t\t\t\t\t\tstw\napplication/vnd.svd\napplication/vnd.swiftview-ics\napplication/vnd.symbian.install\t\t\t\t\t\t\tsis\napplication/vnd.tcpdump.pcap\t\t\t\t\t\t\tcap pcap\napplication/vnd.triscape.mxs\napplication/vnd.trueapp\napplication/vnd.truedoc\napplication/vnd.tve-trigger\napplication/vnd.ufdl\napplication/vnd.uplanet.alert\napplication/vnd.uplanet.alert-wbxml\napplication/vnd.uplanet.bearer-choice\napplication/vnd.uplanet.bearer-choice-wbxml\napplication/vnd.uplanet.cacheop\napplication/vnd.uplanet.cacheop-wbxml\napplication/vnd.uplanet.channel\napplication/vnd.uplanet.channel-wbxml\napplication/vnd.uplanet.list\napplication/vnd.uplanet.list-wbxml\napplication/vnd.uplanet.listcmd\napplication/vnd.uplanet.listcmd-wbxml\napplication/vnd.uplanet.signal\napplication/vnd.vcx\napplication/vnd.vectorworks\napplication/vnd.vidsoft.vidconference\napplication/vnd.visio\t\t\t\t\t\t\t\tvsd vst vsw vss\napplication/vnd.vividence.scriptfile\napplication/vnd.wap.sic\napplication/vnd.wap.slc\napplication/vnd.wap.wbxml\t\t\t\t\t\t\twbxml\napplication/vnd.wap.wmlc\t\t\t\t\t\t\twmlc\napplication/vnd.wap.wmlscriptc\t\t\t\t\t\t\twmlsc\napplication/vnd.webturbo\napplication/vnd.wordperfect\t\t\t\t\t\t\twpd\napplication/vnd.wordperfect5.1\t\t\t\t\t\t\twp5\napplication/vnd.wrq-hp3000-labelled\napplication/vnd.wt.stf\napplication/vnd.xara\napplication/vnd.xfdl\napplication/vnd.yellowriver-custom-menu\napplication/zlib\napplication/x-123\t\t\t\twk\napplication/x-7z-compressed\t\t\t7z\napplication/x-abiword\t\t\t\tabw\napplication/x-apple-diskimage\t\t\tdmg\napplication/x-bcpio\t\t\t\tbcpio\napplication/x-bittorrent\t\t\ttorrent\napplication/x-cab\t\t\t\tcab\napplication/x-cbr\t\t\t\tcbr\napplication/x-cbz\t\t\t\tcbz\napplication/x-cdf\t\t\t\tcdf cda\napplication/x-cdlink\t\t\t\tvcd\napplication/x-chess-pgn\t\t\t\tpgn\napplication/x-comsol\t\t\t\tmph\napplication/x-core\napplication/x-cpio\t\t\t\tcpio\napplication/x-csh\t\t\t\tcsh\napplication/x-debian-package\t\t\tdeb udeb\napplication/x-director\t\t\t\tdcr dir dxr\napplication/x-dms\t\t\t\tdms\napplication/x-doom\t\t\t\twad\napplication/x-dvi\t\t\t\tdvi\napplication/x-executable\napplication/x-font\t\t\t\tpfa pfb gsf\napplication/x-font-pcf\t\t\t\tpcf pcf.Z\napplication/x-freemind\t\t\t\tmm\napplication/x-futuresplash\t\t\tspl\napplication/x-ganttproject\t\t\tgan\napplication/x-gnumeric\t\t\t\tgnumeric\napplication/x-go-sgf\t\t\t\tsgf\napplication/x-graphing-calculator\t\tgcf\napplication/x-gtar\t\t\t\tgtar\napplication/x-gtar-compressed\t\t\ttgz taz\napplication/x-hdf\t\t\t\thdf\n#application/x-httpd-eruby\t\t\trhtml\n#application/x-httpd-php\t\t\tphtml pht php\n#application/x-httpd-php-source\t\t\tphps\n#application/x-httpd-php3\t\t\tphp3\n#application/x-httpd-php3-preprocessed\t\tphp3p\n#application/x-httpd-php4\t\t\tphp4\n#application/x-httpd-php5\t\t\tphp5\napplication/x-hwp\t\t\t\thwp\napplication/x-ica\t\t\t\tica\napplication/x-info\t\t\t\tinfo\napplication/x-internet-signup\t\t\tins isp\napplication/x-iphone\t\t\t\tiii\napplication/x-iso9660-image\t\t\tiso\napplication/x-jam\t\t\t\tjam\napplication/x-java-applet\napplication/x-java-bean\napplication/x-java-jnlp-file\t\t\tjnlp\napplication/x-jmol\t\t\t\tjmz\napplication/x-kchart\t\t\t\tchrt\napplication/x-kdelnk\napplication/x-killustrator\t\t\tkil\napplication/x-koan\t\t\t\tskp skd skt skm\napplication/x-kpresenter\t\t\tkpr kpt\napplication/x-kspread\t\t\t\tksp\napplication/x-kword\t\t\t\tkwd kwt\napplication/x-latex\t\t\t\tlatex\napplication/x-lha\t\t\t\tlha\napplication/x-lyx\t\t\t\tlyx\napplication/x-lzh\t\t\t\tlzh\napplication/x-lzx\t\t\t\tlzx\napplication/x-maker\t\t\t\tfrm maker frame fm fb book fbdoc\napplication/x-mif\t\t\t\tmif\napplication/x-mpegURL\t\t\t\tm3u8\napplication/x-ms-application\t\t\tapplication\napplication/x-ms-manifest\t\t\tmanifest\napplication/x-ms-wmd\t\t\t\twmd\napplication/x-ms-wmz\t\t\t\twmz\napplication/x-msdos-program\t\t\tcom exe bat dll\napplication/x-msi\t\t\t\tmsi\napplication/x-netcdf\t\t\t\tnc\napplication/x-ns-proxy-autoconfig\t\tpac\napplication/x-nwc\t\t\t\tnwc\napplication/x-object\t\t\t\to\napplication/x-oz-application\t\t\toza\napplication/x-pkcs7-certreqresp\t\t\tp7r\napplication/x-pkcs7-crl\t\t\t\tcrl\napplication/x-python-code\t\t\tpyc pyo\napplication/x-qgis\t\t\t\tqgs shp shx\napplication/x-quicktimeplayer\t\t\tqtl\napplication/x-rdp\t\t\t\trdp\napplication/x-redhat-package-manager\t\trpm\napplication/x-rss+xml\t\t\t\trss\napplication/x-ruby\t\t\t\trb\napplication/x-rx\napplication/x-scilab\t\t\t\tsci sce\napplication/x-scilab-xcos\t\t\txcos\napplication/x-sh\t\t\t\tsh\napplication/x-shar\t\t\t\tshar\napplication/x-shellscript\napplication/x-shockwave-flash\t\t\tswf swfl\napplication/x-silverlight\t\t\tscr\napplication/x-sql\t\t\t\tsql\napplication/x-stuffit\t\t\t\tsit sitx\napplication/x-sv4cpio\t\t\t\tsv4cpio\napplication/x-sv4crc\t\t\t\tsv4crc\napplication/x-tar\t\t\t\ttar\napplication/x-tcl\t\t\t\ttcl\napplication/x-tex-gf\t\t\t\tgf\napplication/x-tex-pk\t\t\t\tpk\napplication/x-texinfo\t\t\t\ttexinfo texi\napplication/x-trash\t\t\t\t~ % bak old sik\napplication/x-troff\t\t\t\tt tr roff\napplication/x-troff-man\t\t\t\tman\napplication/x-troff-me\t\t\t\tme\napplication/x-troff-ms\t\t\t\tms\napplication/x-ustar\t\t\t\tustar\napplication/x-videolan\napplication/x-wais-source\t\t\tsrc\napplication/x-wingz\t\t\t\twz\napplication/x-x509-ca-cert\t\t\tcrt\napplication/x-xcf\t\t\t\txcf\napplication/x-xfig\t\t\t\tfig\napplication/x-xpinstall\t\t\t\txpi\napplication/x-xz\t\t\t\txz\n\naudio/32kadpcm\naudio/3gpp\naudio/amr\t\t\t\t\tamr\naudio/amr-wb\t\t\t\t\tawb\naudio/annodex\t\t\t\t\taxa\naudio/basic\t\t\t\t\tau snd\naudio/csound\t\t\t\t\tcsd orc sco\naudio/flac\t\t\t\t\tflac\naudio/g.722.1\naudio/l16\naudio/midi\t\t\t\t\tmid midi kar\naudio/mp4a-latm\naudio/mpa-robust\naudio/mpeg\t\t\t\t\tmpga mpega mp2 mp3 m4a\naudio/mpegurl\t\t\t\t\tm3u\naudio/ogg\t\t\t\t\toga ogg opus spx\naudio/parityfec\naudio/prs.sid\t\t\t\t\tsid\naudio/telephone-event\naudio/tone\naudio/vnd.cisco.nse\naudio/vnd.cns.anp1\naudio/vnd.cns.inf1\naudio/vnd.digital-winds\naudio/vnd.everad.plj\naudio/vnd.lucent.voice\naudio/vnd.nortel.vbk\naudio/vnd.nuera.ecelp4800\naudio/vnd.nuera.ecelp7470\naudio/vnd.nuera.ecelp9600\naudio/vnd.octel.sbc\naudio/vnd.qcelp\naudio/vnd.rhetorex.32kadpcm\naudio/vnd.vmx.cvsd\naudio/x-aiff\t\t\t\t\taif aiff aifc\naudio/x-gsm\t\t\t\t\tgsm\naudio/x-mpegurl\t\t\t\t\tm3u\naudio/x-ms-wma\t\t\t\t\twma\naudio/x-ms-wax\t\t\t\t\twax\naudio/x-pn-realaudio-plugin\naudio/x-pn-realaudio\t\t\t\tra rm ram\naudio/x-realaudio\t\t\t\tra\naudio/x-scpls\t\t\t\t\tpls\naudio/x-sd2\t\t\t\t\tsd2\naudio/x-wav\t\t\t\t\twav\n\nchemical/x-alchemy\t\t\t\talc\nchemical/x-cache\t\t\t\tcac cache\nchemical/x-cache-csf\t\t\t\tcsf\nchemical/x-cactvs-binary\t\t\tcbin cascii ctab\nchemical/x-cdx\t\t\t\t\tcdx\nchemical/x-cerius\t\t\t\tcer\nchemical/x-chem3d\t\t\t\tc3d\nchemical/x-chemdraw\t\t\t\tchm\nchemical/x-cif\t\t\t\t\tcif\nchemical/x-cmdf\t\t\t\t\tcmdf\nchemical/x-cml\t\t\t\t\tcml\nchemical/x-compass\t\t\t\tcpa\nchemical/x-crossfire\t\t\t\tbsd\nchemical/x-csml\t\t\t\t\tcsml csm\nchemical/x-ctx\t\t\t\t\tctx\nchemical/x-cxf\t\t\t\t\tcxf cef\n#chemical/x-daylight-smiles\t\t\tsmi\nchemical/x-embl-dl-nucleotide\t\t\temb embl\nchemical/x-galactic-spc\t\t\t\tspc\nchemical/x-gamess-input\t\t\t\tinp gam gamin\nchemical/x-gaussian-checkpoint\t\t\tfch fchk\nchemical/x-gaussian-cube\t\t\tcub\nchemical/x-gaussian-input\t\t\tgau gjc gjf\nchemical/x-gaussian-log\t\t\t\tgal\nchemical/x-gcg8-sequence\t\t\tgcg\nchemical/x-genbank\t\t\t\tgen\nchemical/x-hin\t\t\t\t\thin\nchemical/x-isostar\t\t\t\tistr ist\nchemical/x-jcamp-dx\t\t\t\tjdx dx\nchemical/x-kinemage\t\t\t\tkin\nchemical/x-macmolecule\t\t\t\tmcm\nchemical/x-macromodel-input\t\t\tmmd mmod\nchemical/x-mdl-molfile\t\t\t\tmol\nchemical/x-mdl-rdfile\t\t\t\trd\nchemical/x-mdl-rxnfile\t\t\t\trxn\nchemical/x-mdl-sdfile\t\t\t\tsd sdf\nchemical/x-mdl-tgf\t\t\t\ttgf\n#chemical/x-mif\t\t\t\t\tmif\nchemical/x-mmcif\t\t\t\tmcif\nchemical/x-mol2\t\t\t\t\tmol2\nchemical/x-molconn-Z\t\t\t\tb\nchemical/x-mopac-graph\t\t\t\tgpt\nchemical/x-mopac-input\t\t\t\tmop mopcrt mpc zmt\nchemical/x-mopac-out\t\t\t\tmoo\nchemical/x-mopac-vib\t\t\t\tmvb\nchemical/x-ncbi-asn1\t\t\t\tasn\nchemical/x-ncbi-asn1-ascii\t\t\tprt ent\nchemical/x-ncbi-asn1-binary\t\t\tval aso\nchemical/x-ncbi-asn1-spec\t\t\tasn\nchemical/x-pdb\t\t\t\t\tpdb ent\nchemical/x-rosdal\t\t\t\tros\nchemical/x-swissprot\t\t\t\tsw\nchemical/x-vamas-iso14976\t\t\tvms\nchemical/x-vmd\t\t\t\t\tvmd\nchemical/x-xtel\t\t\t\t\txtel\nchemical/x-xyz\t\t\t\t\txyz\n\nfont/collection\t\t\t\t\tttc\nfont/otf\t\t\t\t\tttf otf\nfont/sfnt\t\t\t\t\tttf otf\nfont/ttf\t\t\t\t\tttf otf\nfont/woff\t\t\t\t\twoff\nfont/woff2\t\t\t\t\twoff2\n\nimage/cgm\nimage/g3fax\nimage/gif\t\t\t\t\tgif\nimage/ief\t\t\t\t\tief\nimage/jp2\t\t\t\t\tjp2 jpg2\nimage/jpeg\t\t\t\t\tjpeg jpg jpe\nimage/jpm\t\t\t\t\tjpm\nimage/jpx\t\t\t\t\tjpx jpf\nimage/naplps\nimage/pcx\t\t\t\t\tpcx\nimage/png\t\t\t\t\tpng\nimage/prs.btif\nimage/prs.pti\nimage/svg+xml\t\t\t\t\tsvg svgz\nimage/tiff\t\t\t\t\ttiff tif\nimage/vnd.cns.inf2\nimage/vnd.djvu\t\t\t\t\tdjvu djv\nimage/vnd.dwg\nimage/vnd.dxf\nimage/vnd.fastbidsheet\nimage/vnd.fpx\nimage/vnd.fst\nimage/vnd.fujixerox.edmics-mmr\nimage/vnd.fujixerox.edmics-rlc\nimage/vnd.microsoft.icon\t\t\tico\nimage/vnd.mix\nimage/vnd.net-fpx\nimage/vnd.svf\nimage/vnd.wap.wbmp\t\t\t\twbmp\nimage/vnd.xiff\nimage/x-canon-cr2\t\t\t\tcr2\nimage/x-canon-crw\t\t\t\tcrw\nimage/x-cmu-raster\t\t\t\tras\nimage/x-coreldraw\t\t\t\tcdr\nimage/x-coreldrawpattern\t\t\tpat\nimage/x-coreldrawtemplate\t\t\tcdt\nimage/x-corelphotopaint\t\t\t\tcpt\nimage/x-epson-erf\t\t\t\terf\nimage/x-icon\nimage/x-jg\t\t\t\t\tart\nimage/x-jng\t\t\t\t\tjng\nimage/x-ms-bmp\t\t\t\t\tbmp\nimage/x-nikon-nef\t\t\t\tnef\nimage/x-olympus-orf\t\t\t\torf\nimage/x-photoshop\t\t\t\tpsd\nimage/x-portable-anymap\t\t\t\tpnm\nimage/x-portable-bitmap\t\t\t\tpbm\nimage/x-portable-graymap\t\t\tpgm\nimage/x-portable-pixmap\t\t\t\tppm\nimage/x-rgb\t\t\t\t\trgb\nimage/x-xbitmap\t\t\t\t\txbm\nimage/x-xpixmap\t\t\t\t\txpm\nimage/x-xwindowdump\t\t\t\txwd\n\ninode/chardevice\ninode/blockdevice\ninode/directory-locked\ninode/directory\ninode/fifo\ninode/socket\n\nmessage/delivery-status\nmessage/disposition-notification\nmessage/external-body\nmessage/http\nmessage/s-http\nmessage/news\nmessage/partial\nmessage/rfc822\t\t\t\t\teml\n\nmodel/iges\t\t\t\t\tigs iges\nmodel/mesh\t\t\t\t\tmsh mesh silo\nmodel/vnd.dwf\nmodel/vnd.flatland.3dml\nmodel/vnd.gdl\nmodel/vnd.gs-gdl\nmodel/vnd.gtw\nmodel/vnd.mts\nmodel/vnd.vtu\nmodel/vrml\t\t\t\t\twrl vrml\nmodel/x3d+vrml\t\t\t\t\tx3dv\nmodel/x3d+xml\t\t\t\t\tx3d\nmodel/x3d+binary\t\t\t\tx3db\n\nmultipart/alternative\nmultipart/appledouble\nmultipart/byteranges\nmultipart/digest\nmultipart/encrypted\nmultipart/form-data\nmultipart/header-set\nmultipart/mixed\nmultipart/parallel\nmultipart/related\nmultipart/report\nmultipart/signed\nmultipart/voice-message\n\ntext/cache-manifest\t\t\t\tappcache\ntext/calendar\t\t\t\t\tics icz\ntext/css\t\t\t\t\tcss\ntext/csv\t\t\t\t\tcsv\ntext/directory\ntext/english\ntext/enriched\ntext/h323\t\t\t\t\t323\ntext/html\t\t\t\t\thtml htm shtml\ntext/iuls\t\t\t\t\tuls\ntext/mathml\t\t\t\t\tmml\ntext/markdown                                   md markdown\ntext/parityfec\ntext/plain\t\t\t\t\tasc txt text pot brf srt\ntext/prs.lines.tag\ntext/rfc822-headers\ntext/richtext\t\t\t\t\trtx\ntext/rtf\ntext/scriptlet\t\t\t\t\tsct wsc\ntext/t140\ntext/texmacs\t\t\t\t\ttm\ntext/tab-separated-values\t\t\ttsv\ntext/turtle\t\t\t\t\tttl\ntext/uri-list\ntext/vcard\t\t\t\t\tvcf vcard\ntext/vnd.abc\ntext/vnd.curl\ntext/vnd.debian.copyright\ntext/vnd.DMClientScript\ntext/vnd.flatland.3dml\ntext/vnd.fly\ntext/vnd.fmi.flexstor\ntext/vnd.in3d.3dml\ntext/vnd.in3d.spot\ntext/vnd.IPTC.NewsML\ntext/vnd.IPTC.NITF\ntext/vnd.latex-z\ntext/vnd.motorola.reflex\ntext/vnd.ms-mediapackage\ntext/vnd.sun.j2me.app-descriptor\t\tjad\ntext/vnd.wap.si\ntext/vnd.wap.sl\ntext/vnd.wap.wml\t\t\t\twml\ntext/vnd.wap.wmlscript\t\t\t\twmls\ntext/x-bibtex\t\t\t\t\tbib\ntext/x-boo\t\t\t\t\tboo\ntext/x-c++hdr\t\t\t\t\th++ hpp hxx hh\ntext/x-c++src\t\t\t\t\tc++ cpp cxx cc\ntext/x-chdr\t\t\t\t\th\ntext/x-component\t\t\t\thtc\ntext/x-crontab\ntext/x-csh\t\t\t\t\tcsh\ntext/x-csrc\t\t\t\t\tc\ntext/x-dsrc\t\t\t\t\td\ntext/x-diff\t\t\t\t\tdiff patch\ntext/x-haskell\t\t\t\t\ths\ntext/x-java\t\t\t\t\tjava\ntext/x-lilypond\t\t\t\t\tly\ntext/x-literate-haskell\t\t\t\tlhs\ntext/x-makefile\ntext/x-moc\t\t\t\t\tmoc\ntext/x-pascal\t\t\t\t\tp pas\ntext/x-pcs-gcd\t\t\t\t\tgcd\ntext/x-perl\t\t\t\t\tpl pm\ntext/x-python\t\t\t\t\tpy\ntext/x-scala\t\t\t\t\tscala\ntext/x-server-parsed-html\ntext/x-setext\t\t\t\t\tetx\ntext/x-sfv\t\t\t\t\tsfv\ntext/x-sh\t\t\t\t\tsh\ntext/x-tcl\t\t\t\t\ttcl tk\ntext/x-tex\t\t\t\t\ttex ltx sty cls\ntext/x-vcalendar\t\t\t\tvcs\n\nvideo/3gpp\t\t\t\t\t3gp\nvideo/annodex\t\t\t\t\taxv\nvideo/dl\t\t\t\t\tdl\nvideo/dv\t\t\t\t\tdif dv\nvideo/fli\t\t\t\t\tfli\nvideo/gl\t\t\t\t\tgl\nvideo/mpeg\t\t\t\t\tmpeg mpg mpe\nvideo/MP2T\t\t\t\t\tts\nvideo/mp4\t\t\t\t\tmp4\nvideo/quicktime\t\t\t\t\tqt mov\nvideo/mp4v-es\nvideo/ogg\t\t\t\t\togv\nvideo/parityfec\nvideo/pointer\nvideo/webm\t\t\t\t\twebm\nvideo/vnd.fvt\nvideo/vnd.motorola.video\nvideo/vnd.motorola.videop\nvideo/vnd.mpegurl\t\t\t\tmxu\nvideo/vnd.mts\nvideo/vnd.nokia.interleaved-multimedia\nvideo/vnd.vivo\nvideo/x-flv\t\t\t\t\tflv\nvideo/x-la-asf\t\t\t\t\tlsf lsx\nvideo/x-mng\t\t\t\t\tmng\nvideo/x-ms-asf\t\t\t\t\tasf asx\nvideo/x-ms-wm\t\t\t\t\twm\nvideo/x-ms-wmv\t\t\t\t\twmv\nvideo/x-ms-wmx\t\t\t\t\twmx\nvideo/x-ms-wvx\t\t\t\t\twvx\nvideo/x-msvideo\t\t\t\t\tavi\nvideo/x-sgi-movie\t\t\t\tmovie\nvideo/x-matroska\t\t\t\tmpv mkv\n\nx-conference/x-cooltalk\t\t\t\tice\n\nx-epoc/x-sisx-app\t\t\t\tsisx\nx-world/x-vrml\t\t\t\t\tvrm vrml wrl\n"
  }
]