diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 99a2f7f..0000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ -GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) 2018 {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - php-tor-detector Copyright (C) 2018 Enrico Sola - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. \ No newline at end of file diff --git a/README.md b/README.md index 0e860df..8508d33 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,18 @@ If you want to get the IP address of the client you can use this method: `$address = PHPTorDetector\PHPTorDetector::getClientIPAddress();` +By default, check result is cached within session (if session is enabled and if the script is not executed in CLI), you can disable this feature by using this method: + +`PHPTorDetector\PHPTorDetector::setSessionCache(false);` + +If you want to change the index where the results will be cached you can use this method: + +`PHPTorDetector\PHPTorDetector::setSessionCacheName('tor_cache');` + +Note that if you want to set multiple indexes within the session array you can separate indexes with a "@" like this: + +`PHPTorDetector\PHPTorDetector::setSessionCacheName('tor@cache');` + +In this way, cache will be stored in `$_SESSION['tor']['cache']`. + Are you looking for the Node.js version? Give a look [here](https://github.com/RyanJ93/tor-detector). \ No newline at end of file diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..4b6f56c --- /dev/null +++ b/changelog.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## Version 1.1.1 + +* Added support for caching within session. +* Some minor changes to documentation. +* Removed "license.txt" in favour of "license.md". +* Updated "README.md" including new features. \ No newline at end of file diff --git a/composer.json b/composer.json index 584621a..467e2b2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "ryanj93/php-tor-detector", - "version": "1.1.0", + "version": "1.1.1", "description": "A very simple library to detect Tor connections using PHP 7 without any dependency.", "type": "library", "license": "GPL-3.0-or-later", diff --git a/nodes.txt b/nodes.txt index d7726da..5948c4d 100644 --- a/nodes.txt +++ b/nodes.txt @@ -4,86 +4,85 @@ 66.175.211.27 176.10.104.240 93.174.93.133 +193.90.12.116 193.171.202.150 185.100.86.217 223.26.48.248 -185.234.218.45 5.248.10.53 185.100.85.61 -185.234.218.237 -146.0.43.126 +195.154.105.205 104.223.123.98 -84.141.67.217 +84.141.67.136 88.161.203.46 46.182.106.190 178.211.45.18 96.66.15.147 72.210.252.137 +187.20.55.95 78.142.175.70 216.218.134.12 220.227.48.213 +185.167.160.7 176.10.99.200 +195.254.134.194 193.201.225.45 93.174.93.71 40.69.62.87 +160.119.249.24 91.237.244.62 85.93.218.204 +49.50.67.11 45.76.115.159 66.70.217.179 -185.234.218.240 -5.248.10.219 +149.202.170.60 92.222.74.226 89.187.150.13 178.17.170.194 54.37.16.241 185.145.131.174 216.218.222.12 -114.24.103.151 -95.165.133.22 +198.245.60.8 +114.24.101.19 195.22.125.137 -185.234.218.228 162.247.72.216 173.249.18.113 +212.51.156.234 87.118.116.90 +94.16.123.176 163.172.97.165 +62.198.32.223 65.19.167.131 +210.50.9.88 176.121.10.52 46.182.19.219 88.99.33.103 64.137.243.67 51.15.86.162 -192.81.223.177 5.187.21.43 -46.98.202.155 -94.141.227.12 198.50.200.134 51.15.92.24 155.4.250.85 185.220.101.5 -77.87.79.63 173.255.253.173 +37.128.222.30 163.172.185.20 65.19.167.132 92.222.180.10 185.220.101.9 217.182.78.177 -85.204.74.139 185.100.84.108 77.81.247.72 199.249.223.67 5.196.29.217 93.115.95.206 -37.220.35.115 62.210.28.211 -91.146.121.3 -185.234.218.37 190.10.8.73 -185.234.218.246 185.16.173.84 188.65.144.2 89.35.178.104 171.25.193.25 204.11.50.131 +198.98.61.36 85.195.107.250 87.118.122.51 51.15.63.229 @@ -94,22 +93,26 @@ 85.90.244.23 82.94.251.227 46.17.97.112 -185.234.218.38 -46.182.18.29 192.36.27.4 45.62.236.62 37.218.240.21 199.249.223.63 104.218.63.75 67.205.146.164 +95.208.43.106 +51.15.47.233 91.219.237.229 160.202.162.186 122.116.50.42 198.73.50.71 +62.210.71.205 77.247.181.162 85.25.44.141 194.88.143.66 +43.252.230.129 109.120.140.127 +178.65.114.191 +188.166.127.251 164.132.106.162 89.31.96.168 178.17.170.164 @@ -118,37 +121,21 @@ 37.228.129.2 70.168.93.214 185.220.101.8 -195.91.66.84 192.99.247.1 185.220.101.46 94.177.123.116 66.155.4.213 -185.234.218.233 139.59.92.42 -185.234.218.244 +103.1.206.100 +192.210.160.8 82.221.139.190 -185.189.14.61 50.116.37.141 -109.195.234.141 -62.212.95.147 +46.147.213.10 128.199.213.157 34.206.4.227 -85.248.227.163 -77.247.181.165 -78.109.23.1 -65.19.167.132 -171.25.193.25 -93.174.93.71 -46.183.218.199 -216.218.222.14 -109.69.67.17 -85.248.227.164 -216.218.222.12 -193.15.16.4 -163.172.174.24 -65.19.167.130 -149.202.238.204 -62.219.3.47 +154.16.149.74 +5.61.34.63 +23.129.64.103 103.3.61.114 198.58.107.53 51.15.64.212 @@ -157,35 +144,33 @@ 163.172.41.228 94.130.170.249 185.165.168.229 +37.128.222.30 189.84.21.44 204.27.60.147 184.105.220.24 +160.119.249.240 185.165.168.77 -31.131.2.19 178.17.170.81 176.10.99.200 23.129.64.101 178.18.83.215 97.74.237.196 -93.234.91.179 92.222.207.228 93.188.162.188 178.209.42.84 144.217.164.185 -185.189.14.230 -91.65.78.43 +91.64.245.225 209.141.43.42 144.217.60.211 54.37.68.143 -178.10.89.70 +88.67.165.62 5.188.10.8 107.181.187.55 162.247.73.74 216.218.222.14 139.162.28.23 185.220.101.21 -83.152.152.150 -77.87.79.51 +185.234.218.190 46.233.0.70 94.31.53.203 178.17.174.196 @@ -198,9 +183,11 @@ 176.126.252.12 185.87.185.45 204.17.56.42 -65.129.128.51 +67.1.253.12 37.220.35.202 46.226.108.26 +193.90.12.117 +142.44.154.169 178.165.72.177 176.31.200.122 163.172.132.199 @@ -209,10 +196,8 @@ 51.15.64.212 35.248.27.205 37.220.35.58 -185.234.218.223 92.222.22.113 84.200.50.18 -185.234.218.236 176.10.99.200 82.211.0.201 72.204.193.71 @@ -222,87 +207,96 @@ 185.191.204.194 192.36.27.7 5.23.53.242 +62.212.95.147 +172.105.231.26 37.218.240.68 212.83.40.239 185.220.101.10 185.100.85.101 -178.175.129.91 -185.234.218.234 -5.2.70.160 139.162.62.105 199.249.223.61 -95.130.12.252 -46.98.203.107 +149.202.170.60 +46.98.202.60 178.17.170.156 209.126.101.29 188.165.59.43 176.10.99.200 165.227.45.125 +84.19.180.139 46.182.18.29 206.248.184.127 199.249.223.76 5.196.0.149 -51.15.80.148 164.132.41.140 185.112.146.138 185.104.120.7 +172.222.31.198 95.130.11.170 78.31.164.41 -93.220.79.60 +93.220.104.82 +59.179.17.196 51.15.205.192 +37.187.180.18 5.39.217.14 -51.15.82.77 45.33.48.204 185.165.169.71 +89.144.12.17 176.10.99.200 +71.19.144.106 +94.248.18.125 185.220.101.34 162.247.72.202 198.58.100.240 +89.34.237.214 162.213.0.243 -46.98.209.69 +46.98.206.254 193.15.16.4 50.7.176.2 51.15.34.228 -88.130.0.144 +88.130.4.235 163.172.185.20 142.4.211.161 +95.130.10.69 91.92.109.116 -185.234.218.232 51.15.143.28 87.118.116.12 -185.234.218.229 -95.85.4.94 87.118.122.50 212.21.66.6 65.19.167.130 45.62.245.119 +188.225.57.29 51.15.34.214 199.127.226.150 +145.239.0.71 139.162.28.31 212.19.17.213 185.62.57.91 80.79.23.7 +89.34.237.223 162.247.73.204 -163.47.119.167 51.15.81.183 -46.166.176.166 +103.234.220.195 178.17.170.135 45.33.23.23 212.81.199.159 185.38.14.215 185.112.146.83 +174.138.4.197 109.236.90.209 192.42.116.13 109.228.51.164 54.36.222.37 62.210.110.181 181.215.104.24 -185.234.218.46 +165.227.56.71 +54.38.133.183 +185.100.85.191 104.236.141.156 130.204.161.3 192.160.102.166 91.237.247.62 82.221.139.25 +173.212.244.116 192.160.102.170 23.238.162.11 91.92.109.43 @@ -311,27 +305,22 @@ 46.249.37.143 64.31.37.154 89.234.157.254 +188.68.45.180 196.41.123.180 84.217.13.138 173.212.233.139 199.195.250.77 -45.62.236.66 185.227.82.9 146.0.40.231 145.239.82.204 -77.87.79.58 77.247.181.163 193.15.16.4 104.218.63.76 -5.39.84.19 46.182.19.15 31.135.255.209 37.200.98.117 5.254.112.154 -185.234.218.243 -50.31.252.11 -62.176.4.10 -185.234.218.222 +193.90.12.119 193.107.85.62 18.248.2.85 66.220.3.179 @@ -347,51 +336,53 @@ 172.98.193.43 128.199.76.145 198.101.8.214 +89.34.237.139 46.182.19.219 93.115.95.204 199.249.223.74 170.250.140.52 -185.234.218.247 107.170.232.75 185.47.62.171 +193.90.12.118 74.50.54.69 -185.234.218.250 +190.216.2.136 185.220.101.28 -89.144.12.14 199.249.223.75 94.130.182.104 37.187.7.74 5.135.158.101 95.128.43.164 +65.19.167.134 185.220.101.20 195.22.125.146 -185.234.218.39 176.10.99.200 -185.234.218.230 +217.182.74.145 103.250.73.13 62.212.73.141 45.63.74.191 185.220.101.17 84.48.199.78 -5.206.225.229 104.131.206.23 212.16.104.33 176.10.99.200 -41.100.120.158 +41.100.41.16 87.120.254.186 51.15.39.2 165.227.58.177 -64.27.17.140 199.249.223.46 163.172.171.163 -185.234.218.47 +185.220.101.15 83.149.99.151 103.8.79.229 213.108.105.92 -5.3.173.40 +5.3.131.187 +5.188.86.30 192.155.95.222 213.108.105.71 5.189.146.133 +54.36.24.242 +77.191.17.12 +176.126.70.240 104.192.0.58 51.15.86.162 216.17.101.79 @@ -399,10 +390,10 @@ 178.17.170.13 128.199.47.160 94.156.77.134 -62.210.105.116 -193.171.202.150 -77.247.181.162 -109.126.9.228 +89.234.157.254 +185.38.14.215 +193.90.12.119 +54.36.222.37 162.247.72.27 79.134.255.200 195.22.125.148 @@ -416,15 +407,15 @@ 64.137.242.29 89.34.237.162 162.247.73.206 -46.98.202.133 +46.4.55.177 +46.98.199.180 62.210.37.82 -104.223.123.98 +142.44.163.100 14.58.118.69 -92.195.92.52 +92.195.117.42 82.148.223.103 37.139.8.104 77.69.98.51 -95.208.43.106 185.220.101.13 185.220.101.30 46.138.193.154 @@ -434,28 +425,22 @@ 46.4.77.210 199.87.154.255 51.254.208.245 -185.234.218.242 46.29.248.238 62.210.105.116 144.217.60.211 -79.114.158.138 213.95.149.22 -139.162.124.207 163.172.151.250 89.34.237.31 195.123.233.59 77.247.181.162 +88.99.23.92 162.247.72.217 144.217.60.239 -185.106.122.188 45.62.253.113 80.68.92.225 46.166.162.53 79.134.234.247 54.93.60.149 -77.87.79.59 -163.172.67.180 -213.136.71.21 204.194.29.4 164.132.51.91 139.162.10.72 @@ -463,32 +448,25 @@ 199.249.223.48 51.15.209.128 176.58.89.182 -46.194.26.56 77.247.181.162 204.85.191.30 185.100.84.82 -185.234.218.31 -185.162.249.232 185.220.101.29 89.31.57.5 -45.62.251.245 176.10.99.200 5.2.76.139 185.220.101.41 -128.199.254.179 -80.82.67.166 -185.234.218.48 199.249.223.69 37.59.116.170 -73.206.117.93 51.15.40.233 82.118.17.235 195.254.135.76 104.223.123.98 192.42.116.16 185.22.152.134 +89.34.237.70 192.160.102.164 -185.234.218.32 +193.138.52.161 133.218.131.90 165.227.39.194 192.87.28.82 @@ -497,28 +475,26 @@ 51.15.63.43 37.97.228.159 104.244.74.78 +195.254.134.242 72.52.75.27 46.182.19.15 80.241.60.207 139.99.130.178 -139.162.228.61 -185.234.218.239 +107.181.174.159 46.235.227.70 -5.248.126.242 125.63.48.226 51.15.53.118 5.9.195.140 80.110.8.49 176.10.104.243 -104.132.1.97 137.74.169.241 172.104.29.241 -46.98.203.204 +46.98.206.28 78.130.128.106 +89.34.237.42 +188.68.242.24 89.187.150.15 89.187.150.12 -204.17.56.42 -185.234.218.41 199.249.223.44 193.107.85.56 208.113.129.191 @@ -527,9 +503,7 @@ 176.10.99.200 195.201.4.207 82.94.132.34 -185.234.218.227 37.187.117.138 -91.221.57.129 94.130.183.184 51.15.40.233 176.223.113.26 @@ -548,6 +522,7 @@ 50.7.151.127 93.115.86.8 185.220.101.33 +185.24.216.42 178.238.237.44 89.234.157.254 46.101.150.49 @@ -563,25 +538,24 @@ 51.15.63.43 45.79.73.22 37.218.245.25 +185.100.87.206 37.218.240.80 163.172.151.250 204.8.156.142 -185.234.218.50 -77.87.79.65 93.115.241.194 23.92.27.23 +5.2.70.160 87.118.92.43 176.10.104.243 178.17.170.149 45.62.234.52 145.239.91.37 -45.62.244.156 37.218.245.25 185.100.86.154 109.201.133.100 94.242.57.161 190.10.8.50 -185.234.218.40 +198.50.200.131 173.255.229.8 192.155.81.225 212.47.246.21 @@ -589,23 +563,24 @@ 46.167.245.51 163.172.223.200 37.233.99.157 +89.34.237.215 162.213.3.221 185.220.101.40 195.22.125.141 +136.144.175.62 178.209.42.84 18.248.1.85 185.100.86.128 176.121.10.44 95.42.98.196 185.220.101.42 -130.193.15.49 95.142.161.63 37.48.120.196 193.110.157.151 128.199.136.79 139.162.16.13 199.249.223.65 -77.87.79.55 +185.234.218.194 93.115.95.201 98.174.90.43 93.115.86.9 @@ -614,49 +589,46 @@ 31.185.104.19 146.185.177.103 199.249.223.64 +109.190.248.212 80.211.164.14 77.81.104.124 +193.90.12.115 185.100.85.190 91.121.192.154 62.133.130.105 51.15.76.142 +82.196.1.82 46.165.230.5 171.25.193.77 89.34.237.72 5.39.86.206 192.36.27.6 -95.143.22.6 +95.143.22.189 192.36.27.6 163.172.45.46 -185.100.86.167 173.255.226.142 -185.234.218.36 -185.129.62.63 171.25.193.78 -198.74.49.228 128.31.0.13 79.172.193.32 +5.2.67.179 +185.165.169.31 144.217.80.80 46.183.218.199 -198.245.60.8 -77.87.79.68 +185.38.14.171 176.67.168.210 -185.234.218.221 162.247.72.200 -185.234.218.33 51.15.81.222 -178.141.158.2 +84.53.192.243 163.172.154.52 -87.118.82.3 -80.82.64.139 +87.118.83.3 151.80.56.62 85.159.237.210 +46.101.161.246 94.142.242.84 51.15.82.2 125.212.241.182 185.117.118.234 37.187.94.86 -92.222.6.12 163.172.171.163 195.22.125.136 87.98.178.61 @@ -672,10 +644,8 @@ 93.89.101.27 46.4.95.244 149.202.238.204 -185.125.32.27 -46.98.231.34 +47.88.194.83 91.203.5.165 -195.22.125.144 87.118.115.176 144.217.164.104 181.40.18.202 @@ -684,28 +654,26 @@ 217.115.10.131 176.126.252.11 199.249.223.72 -78.46.201.148 178.17.174.14 199.249.223.40 176.10.99.200 +50.116.30.165 83.92.47.99 195.22.126.147 192.42.115.101 185.117.215.9 62.210.105.86 +195.123.212.34 93.115.95.207 45.79.137.11 186.120.225.119 93.186.13.12 162.247.72.199 -51.15.208.134 -77.191.18.177 +77.191.17.12 64.137.244.144 62.210.13.58 209.123.234.23 103.236.201.110 -82.146.43.49 -77.87.79.49 178.175.131.194 154.127.60.92 45.79.144.222 @@ -715,32 +683,31 @@ 199.249.223.71 149.56.223.241 179.43.146.230 -88.77.144.145 +178.6.87.174 199.249.223.60 178.63.97.34 108.85.99.10 185.220.101.2 185.220.101.32 23.129.64.104 +93.171.248.14 5.79.68.161 -84.53.225.118 93.115.86.6 85.248.227.164 +185.61.148.30 103.234.220.197 198.211.122.191 158.255.7.61 -185.234.218.224 185.100.85.132 51.15.137.178 -185.61.138.207 84.19.181.25 178.17.171.114 185.127.25.68 80.85.84.23 75.54.229.204 +94.177.12.102 71.46.220.68 37.187.96.78 -185.234.218.231 197.231.221.211 5.2.72.66 185.220.101.12 @@ -749,53 +716,53 @@ 37.220.36.240 199.119.112.66 80.169.241.76 -104.132.0.111 94.198.100.17 192.160.102.169 82.223.27.82 185.220.101.6 5.196.1.129 89.187.143.81 +46.246.81.10 64.137.205.124 162.243.166.137 188.219.232.165 217.170.197.83 178.17.170.194 31.185.104.21 -54.36.24.242 77.254.3.32 154.16.149.74 -85.166.189.186 -144.217.102.236 +185.175.208.180 +195.123.212.34 84.195.252.128 95.141.35.15 +80.82.67.222 51.15.153.164 -77.87.79.53 185.143.230.231 24.3.111.83 43.252.228.31 +185.86.151.69 204.85.191.31 199.249.223.66 178.20.55.18 216.239.90.19 194.67.214.123 193.19.118.171 -191.250.247.66 +179.183.164.164 84.3.10.87 173.254.216.66 78.41.115.145 95.211.118.194 85.248.227.163 91.92.109.119 -126.94.80.238 +31.28.25.145 +185.100.87.207 80.101.143.242 192.160.102.165 +178.132.4.9 78.107.237.16 -77.87.79.66 185.220.101.22 37.228.129.20 23.129.64.102 -77.87.79.70 66.180.193.219 212.47.229.60 163.172.160.182 @@ -814,19 +781,18 @@ 192.34.80.176 51.15.217.217 92.222.127.232 -177.45.164.113 +191.193.171.96 93.115.86.4 51.15.43.205 91.219.239.229 51.15.13.245 5.135.65.145 -85.90.245.11 -185.104.120.60 +91.147.12.134 185.11.167.4 207.192.69.165 5.9.158.75 51.15.72.211 -185.234.218.226 +84.118.178.148 77.68.42.132 104.218.63.74 199.249.223.41 @@ -841,15 +807,13 @@ 37.218.240.110 173.254.216.66 188.214.104.146 -185.234.218.225 +104.218.63.72 90.230.203.134 -5.188.86.30 163.172.151.47 192.42.113.102 198.50.200.135 +160.119.249.239 198.71.81.66 -185.234.218.235 -185.234.218.43 2.7.154.187 185.34.33.2 46.101.169.151 @@ -860,8 +824,7 @@ 91.203.5.146 66.110.216.10 37.187.239.8 -176.8.154.41 -185.234.218.238 +176.8.24.174 51.15.53.83 142.44.156.128 144.217.174.248 @@ -872,112 +835,108 @@ 198.46.138.18 178.17.174.227 87.118.122.30 -77.87.79.69 +185.234.218.208 109.169.33.163 78.109.23.1 171.25.193.20 51.15.78.21 -77.180.127.85 -217.182.74.145 +92.230.143.135 167.114.34.150 +37.205.10.140 92.222.38.67 94.242.57.2 199.249.223.68 139.162.226.245 178.17.166.146 -5.2.67.179 91.219.239.114 -89.34.237.70 62.141.39.47 51.255.202.66 -188.192.85.5 +188.192.103.211 +104.218.63.77 173.212.228.203 192.81.135.229 62.205.133.251 -51.254.195.157 +46.98.205.177 +88.99.35.242 166.70.207.2 51.15.53.83 185.86.151.21 166.70.207.2 192.36.27.7 -51.15.136.98 +82.221.101.67 199.249.223.43 162.247.72.7 185.100.86.182 -84.200.82.163 128.199.216.170 +201.242.177.155 172.104.252.154 -185.19.92.68 185.220.101.44 93.115.95.205 192.99.151.112 82.211.5.20 176.31.180.157 -77.87.79.67 +185.234.218.206 176.58.100.98 -59.127.163.155 195.22.24.162 5.199.130.127 195.22.125.135 -193.33.240.180 173.254.216.66 88.156.182.196 46.17.40.220 -46.227.69.250 176.31.45.3 +176.121.81.51 5.79.113.137 82.247.198.227 185.112.157.135 199.249.223.78 185.220.101.16 -46.246.49.148 +46.246.49.179 171.25.193.235 178.17.170.196 -185.234.218.49 27.124.124.126 192.87.28.28 -93.177.26.186 82.221.128.217 173.249.21.80 -95.215.44.194 -46.194.26.56 +46.194.35.187 185.10.68.114 198.167.223.38 109.69.67.17 178.20.55.16 149.202.238.204 -103.56.207.84 104.218.63.73 -103.194.180.73 +176.38.163.77 +5.2.64.111 185.165.169.55 -134.90.149.180 -82.221.112.122 +185.169.42.206 +91.250.241.241 192.195.80.10 77.247.181.165 -77.87.79.57 -185.234.218.245 178.175.148.138 -46.98.209.237 +46.98.204.224 82.228.252.20 139.162.144.133 192.160.102.168 37.218.240.110 -89.156.43.19 +89.156.192.194 199.249.223.81 -185.234.218.44 185.125.231.254 -46.98.198.59 +177.158.146.99 +46.98.207.184 51.15.3.40 +94.16.123.194 46.165.254.166 -185.234.218.35 45.62.236.67 +137.74.73.179 185.104.120.4 62.210.207.52 51.15.80.14 185.58.226.243 +89.34.237.213 +31.220.42.86 190.10.8.150 185.220.101.45 108.69.109.88 +94.176.239.241 89.236.34.117 103.27.124.82 185.10.68.119 @@ -985,7 +944,7 @@ 192.36.27.4 144.217.161.119 185.15.194.233 -185.234.218.249 +137.74.73.179 77.250.227.12 -88.8.47.214 -66.42.224.235 \ No newline at end of file +66.42.224.235 +94.140.125.117 \ No newline at end of file diff --git a/php-tor-detector.php b/php-tor-detector.php index 81ef684..c44c38f 100755 --- a/php-tor-detector.php +++ b/php-tor-detector.php @@ -9,6 +9,11 @@ namespace PHPTorDetector{ class PHPTorDetector{ + /** + * @const string DEFAULT_SESSION_NAME A string containing the name of the default session's index in where results will be cached for next uses. + */ + const DEFAULT_SESSION_NAME = 'PHPTorDetector'; + /** * @var string $listPath A string containing the path to the file that contains a list of Tor exit points separated by a breakline (\n). */ @@ -24,6 +29,55 @@ class PHPTorDetector{ */ protected static $cache = false; + /** + * @var bool $sessionCache If set to "true" results will be cached within the session for next uses, otherwise the list will be queried everytime giving fresh results. + */ + protected static $sessionCache = true; + + /** + * @var string $sessionName A string containing the index name where results will be cached, separate multiple names with "@" to specify multiple levels in the array ("foo@bar" = ['foo']['bar']). + */ + protected static $sessionName = 'PHPTorDetector'; + + /** + * Enables session and returns the operation result. + * + * @return bool If the session has correctly been started or has already been started will be returned "true", otherwise "false". + */ + protected static function setupSessionCache(): bool{ + $status = session_status(); + if ( $status === \PHP_SESSION_DISABLED ){ + self::$sessionCache = false; + return false; + } + if ( $status !== \PHP_SESSION_ACTIVE ){ + $status = @session_start(); + if ( $status === false ){ + self::$sessionCache = false; + return false; + } + return true; + } + return true; + } + + /** + * Returns a reference to the index where the cache shall be saved within the $_SESSION array. + * + * @return array A reference to the index. + */ + protected static function & getSession(): array{ + $index = mb_split('@', self::$sessionName); + $ref = &$_SESSION; + foreach ( $index as $key => $value ){ + if ( isset($ref[$value]) === false || is_array($ref[$value]) === false ){ + $ref[$value] = array(); + } + $ref = &$ref[$value]; + } + return $ref; + } + /** * Sets the path to the list file. * @@ -58,7 +112,7 @@ public static function setListCache(bool $value = false){ if ( $value !== true ){ self::$cache = false; self::$list = NULL; - return this; + return; } self::$cache = true; } @@ -98,6 +152,65 @@ public static function loadDictionaryCache(): bool{ return true; } + /** + * Sets if the results shall be cached for next uses or not. + * + * @param bool $value If set to "true", results will be cached for next uses, otherwise not. + */ + public static function setSessionCache(bool $value = true){ + if ( $value !== true ){ + if ( self::setupSessionCache() === true ){ + $session =& self::getSession(); + $session = array(); + self::$sessionCache = false; + return; + } + } + self::$sessionCache = true; + } + + /** + * Returns if the results shall be cached for next uses or not. + * + * @return bool If results will be cached will be returned "true", otherwise "false". + */ + public static function getSessionCache(): bool{ + return self::$sessionCache === false ? false : true; + } + + /** + * Sets the name of the session's index in where results will be cached for next uses. + * + * @param string $name A string containing the index name, separate multiple names with "@" to specify multiple levels in the array ("foo@bar" = ['foo']['bar']). + * + * @throws InvalidArgumentException If an invalid name is provided. + */ + public static function setSessionCacheName(string $name){ + if ( $name === NULL || $name === '' ){ + throw new \InvalidArgumentException('Invalid name.'); + } + self::$sessionName = $name; + } + + /** + * Returns the name of the session's index in where results will be cached for next uses. + * + * @return string A string containing the index name. + */ + public static function getSessionCacheName(): string{ + return self::$sessionName; + } + + /** + * Cleares the content of the cache stored within PHP session. + */ + public static function invalidateSessionCache(){ + if ( self::setupSessionCache() === true ){ + $session =& self::getSession(); + $session = array(); + } + } + /** * Updates the content of the list by downloading a new list of Tor exit points, this method is asynchronous and will return a promise used to handle method success or failure. * @@ -199,14 +312,27 @@ public static function isTor(string $address): bool{ if ( $address === NULL || $address === '' || filter_var($address, \FILTER_VALIDATE_IP) === false ){ throw new \InvalidArgumentException('Invalid IP address.'); } + $sessionCache = self::$sessionCache; + $address = strtolower($address); + if ( $sessionCache !== false ){ + if ( self::setupSessionCache() === true ){ + $session =& self::getSession(); + if ( isset($session[$address]) === true ){ + return $session[$address] === true ? true : false; + } + } + } $listPath = self::$listPath; $cache = self::$cache; if ( $listPath === NULL || $listPath === '' ){ throw new \BadMethodCallException('No path has been set.'); } - $address = strtolower($address); if ( $cache === true && self::$list !== NULL ){ - return strpos(self::$list, $address . "\n") !== false || strpos(self::$list, "\n" . $address) !== false || self::$list === $address ? true : false; + $result = strpos(self::$list, $address . "\n") !== false || strpos(self::$list, "\n" . $address) !== false || self::$list === $address ? true : false; + if ( $sessionCache !== false && isset($session) === true ){ + $session[$address] = $result; + } + return $result; } $data = @file_get_contents(dirname(__FILE__) . '/' . $listPath); if ( $data === false ){ @@ -218,7 +344,11 @@ public static function isTor(string $address): bool{ if ( $cache === true ){ self::$list = $data; } - return strpos($data, $address . "\n") !== false || strpos($data, "\n" . $address) !== false || $data === $address ? true : false; + $result = strpos($data, $address . "\n") !== false || strpos($data, "\n" . $address) !== false || $data === $address ? true : false; + if ( $sessionCache !== false && isset($session) === true ){ + $session[$address] = $result; + } + return $result; } } } \ No newline at end of file