diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8f37ca4 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# v2ray +最好用的 V2Ray 一键安装脚本 & 管理脚本 diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..c7e0ef6 --- /dev/null +++ b/install.sh @@ -0,0 +1,1084 @@ +#!/bin/bash + +red='\e[91m' +green='\e[92m' +yellow='\e[93m' +magenta='\e[95m' +cyan='\e[96m' +none='\e[0m' + +# Root +[[ $(id -u) != 0 ]] && echo -e "\n 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}\n" && exit 1 + +cmd="apt-get" + +sys_bit=$(uname -m) + +if [[ $sys_bit == "i386" || $sys_bit == "i686" ]]; then + v2ray_bit="32" +elif [[ $sys_bit == "x86_64" ]]; then + v2ray_bit="64" +else + echo -e " + 哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none} + + 备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统 + " && exit 1 +fi + +# 笨笨的检测方法 +if [[ -f /usr/bin/apt-get || -f /usr/bin/yum ]] && [[ -f /bin/systemctl ]]; then + + if [[ -f /usr/bin/yum ]]; then + + cmd="yum" + + fi + +else + + echo -e " + 哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none} + + 备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统 + " && exit 1 + +fi + +uuid=$(cat /proc/sys/kernel/random/uuid) +old_id="e55c8d17-2cf3-b21a-bcf1-eeacb011ed79" +v2ray_server_config="/etc/v2ray/config.json" +v2ray_client_config="/etc/v2ray/233blog_v2ray_config.json" +backup="/etc/v2ray/233blog_v2ray_backup.conf" +_v2ray_sh="/usr/local/sbin/v2ray" +systemd=true +# _test=true + +transport=( + TCP + TCP_HTTP + WebSocket + "WebSocket + TLS" + HTTP/2 + mKCP + mKCP_utp + mKCP_srtp + mKCP_wechat-video + mKCP_dtls + mKCP_wireguard + QUIC + QUIC_utp + QUIC_srtp + QUIC_wechat-video + QUIC_dtls + QUIC_wireguard + TCP_dynamicPort + TCP_HTTP_dynamicPort + WebSocket_dynamicPort + mKCP_dynamicPort + mKCP_utp_dynamicPort + mKCP_srtp_dynamicPort + mKCP_wechat-video_dynamicPort + mKCP_dtls_dynamicPort + mKCP_wireguard_dynamicPort + QUIC_dynamicPort + QUIC_utp_dynamicPort + QUIC_srtp_dynamicPort + QUIC_wechat-video_dynamicPort + QUIC_dtls_dynamicPort + QUIC_wireguard_dynamicPort +) + +ciphers=( + aes-128-cfb + aes-256-cfb + chacha20 + chacha20-ietf + aes-128-gcm + aes-256-gcm + chacha20-ietf-poly1305 +) + +_load() { + local _dir="/etc/v2ray/233boy/v2ray/src/" + . "${_dir}$@" +} + +v2ray_config() { + # clear + echo + while :; do + echo -e "请选择 "$yellow"V2Ray"$none" 传输协议 [${magenta}1-${#transport[*]}$none]" + echo + for ((i = 1; i <= ${#transport[*]}; i++)); do + Stream="${transport[$i - 1]}" + if [[ "$i" -le 9 ]]; then + # echo + echo -e "$yellow $i. $none${Stream}" + else + # echo + echo -e "$yellow $i. $none${Stream}" + fi + done + echo + echo "备注1: 含有 [dynamicPort] 的即启用动态端口.." + echo "备注2: [utp | srtp | wechat-video | dtls | wireguard] 分别伪装成 [BT下载 | 视频通话 | 微信视频通话 | DTLS 1.2 数据包 | WireGuard 数据包]" + echo + read -p "$(echo -e "(默认协议: ${cyan}TCP$none)"):" v2ray_transport + [ -z "$v2ray_transport" ] && v2ray_transport=1 + case $v2ray_transport in + [1-9] | [1-2][0-9] | 3[0-2]) + echo + echo + echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport - 1]}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + done + v2ray_port_config +} +v2ray_port_config() { + case $v2ray_transport in + 4 | 5) + tls_config + ;; + *) + local random=$(shuf -i20001-65535 -n1) + while :; do + echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port + [ -z "$v2ray_port" ] && v2ray_port=$random + case $v2ray_port in + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + echo + echo + echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + done + if [[ $v2ray_transport -ge 18 ]]; then + v2ray_dynamic_port_start + fi + ;; + esac +} + +v2ray_dynamic_port_start() { + + while :; do + echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(默认开始端口: ${cyan}10000$none):")" v2ray_dynamic_port_start_input + [ -z $v2ray_dynamic_port_start_input ] && v2ray_dynamic_port_start_input=10000 + case $v2ray_dynamic_port_start_input in + $v2ray_port) + echo + echo " 不能和 V2Ray 端口一毛一样...." + echo + echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}" + error + ;; + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + echo + echo + echo -e "$yellow V2Ray 动态端口开始 = $cyan$v2ray_dynamic_port_start_input$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + + done + + if [[ $v2ray_dynamic_port_start_input -lt $v2ray_port ]]; then + lt_v2ray_port=true + fi + + v2ray_dynamic_port_end +} +v2ray_dynamic_port_end() { + + while :; do + echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input + [ -z $v2ray_dynamic_port_end_input ] && v2ray_dynamic_port_end_input=20000 + case $v2ray_dynamic_port_end_input in + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + + if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then + echo + echo " 不能小于或等于 V2Ray 动态端口开始范围" + echo + echo -e " 当前 V2Ray 动态端口开始:${cyan}$v2ray_dynamic_port_start_input${none}" + error + elif [ $lt_v2ray_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $v2ray_port ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 V2Ray 端口..." + echo + echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}" + error + else + echo + echo + echo -e "$yellow V2Ray 动态端口结束 = $cyan$v2ray_dynamic_port_end_input$none" + echo "----------------------------------------------------------------" + echo + break + fi + ;; + *) + error + ;; + esac + + done + +} + +tls_config() { + + echo + local random=$(shuf -i20001-65535 -n1) + while :; do + echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"],不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口" + read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port + [ -z "$v2ray_port" ] && v2ray_port=$random + case $v2ray_port in + 80) + echo + echo " ...都说了不能选择 80 端口了咯....." + error + ;; + 443) + echo + echo " ..都说了不能选择 443 端口了咯....." + error + ;; + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + echo + echo + echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + done + + while :; do + echo + echo -e "请输入一个 $magenta正确的域名$none,一定一定一定要正确,不!能!出!错!" + read -p "(例如:233blog.com): " domain + [ -z "$domain" ] && error && continue + echo + echo + echo -e "$yellow 你的域名 = $cyan$domain$none" + echo "----------------------------------------------------------------" + break + done + get_ip + echo + echo + echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none" + echo + echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none" + echo + echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none" + echo "----------------------------------------------------------------" + echo + + while :; do + + read -p "$(echo -e "(是否已经正确解析: [${magenta}Y$none]):") " record + if [[ -z "$record" ]]; then + error + else + if [[ "$record" == [Yy] ]]; then + domain_check + echo + echo + echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none" + echo "----------------------------------------------------------------" + echo + break + else + error + fi + fi + + done + + if [[ $v2ray_transport -ne 5 ]]; then + auto_tls_config + else + caddy=true + install_caddy_info="打开" + fi + + if [[ $caddy ]]; then + path_config_ask + fi +} +auto_tls_config() { + echo -e " + + 安装 Caddy 来实现 自动配置 TLS + + 如果你已经安装 Nginx 或 Caddy + + $yellow并且..自己能搞定配置 TLS$none + + 那么就不需要 打开自动配置 TLS + " + echo "----------------------------------------------------------------" + echo + + while :; do + + read -p "$(echo -e "(是否自动配置 TLS: [${magenta}Y/N$none]):") " auto_install_caddy + if [[ -z "$auto_install_caddy" ]]; then + error + else + if [[ "$auto_install_caddy" == [Yy] ]]; then + caddy=true + install_caddy_info="打开" + echo + echo + echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none" + echo "----------------------------------------------------------------" + echo + break + elif [[ "$auto_install_caddy" == [Nn] ]]; then + install_caddy_info="关闭" + echo + echo + echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none" + echo "----------------------------------------------------------------" + echo + break + else + error + fi + fi + + done +} +path_config_ask() { + echo + while :; do + echo -e "是否开启 网站伪装 和 路径分流 [${magenta}Y/N$none]" + read -p "$(echo -e "(默认: [${cyan}N$none]):")" path_ask + [[ -z $path_ask ]] && path_ask="n" + + case $path_ask in + Y | y) + path_config + break + ;; + N | n) + echo + echo + echo -e "$yellow 网站伪装 和 路径分流 = $cyan不想配置$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + done +} +path_config() { + echo + while :; do + echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可" + read -p "$(echo -e "(默认: [${cyan}233blog$none]):")" path + [[ -z $path ]] && path="233blog" + + case $path in + *[/$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以分流的路径不能包含$red / $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 分流的路径 = ${cyan}/${path}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done + is_path=true + proxy_site_config +} +proxy_site_config() { + echo + while :; do + echo -e "请输入 ${magenta}一个正确的$none ${cyan}网址$none 用来作为 ${cyan}网站的伪装$none , 例如 https://liyafly.com" + echo -e "举例...你当前的域名是 $green$domain$none , 伪装的网址的是 https://liyafly.com" + echo -e "然后打开你的域名时候...显示出来的内容就是来自 https://liyafly.com 的内容" + echo -e "其实就是一个反代...明白就好..." + echo -e "如果不能伪装成功...可以使用 v2ray config 修改伪装的网址" + read -p "$(echo -e "(默认: [${cyan}https://liyafly.com$none]):")" proxy_site + [[ -z $proxy_site ]] && proxy_site="https://liyafly.com" + + case $proxy_site in + *[#$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以伪装的网址不能包含$red # $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 伪装的网址 = ${cyan}${proxy_site}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done +} + +blocked_hosts() { + echo + while :; do + echo -e "是否开启广告拦截(会影响性能) [${magenta}Y/N$none]" + read -p "$(echo -e "(默认 [${cyan}N$none]):")" blocked_ad + [[ -z $blocked_ad ]] && blocked_ad="n" + + case $blocked_ad in + Y | y) + blocked_ad_info="开启" + ban_ad=true + echo + echo + echo -e "$yellow 广告拦截 = $cyan开启$none" + echo "----------------------------------------------------------------" + echo + break + ;; + N | n) + blocked_ad_info="关闭" + echo + echo + echo -e "$yellow 广告拦截 = $cyan关闭$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + done +} +shadowsocks_config() { + + echo + + while :; do + echo -e "是否配置 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]" + read -p "$(echo -e "(默认 [${cyan}N$none]):") " install_shadowsocks + [[ -z "$install_shadowsocks" ]] && install_shadowsocks="n" + if [[ "$install_shadowsocks" == [Yy] ]]; then + echo + shadowsocks=true + shadowsocks_port_config + break + elif [[ "$install_shadowsocks" == [Nn] ]]; then + break + else + error + fi + + done + +} + +shadowsocks_port_config() { + local random=$(shuf -i20001-65535 -n1) + while :; do + echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2Ray"$none" 端口相同" + read -p "$(echo -e "(默认端口: ${cyan}${random}$none):") " ssport + [ -z "$ssport" ] && ssport=$random + case $ssport in + $v2ray_port) + echo + echo " 不能和 V2Ray 端口一毛一样...." + error + ;; + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + if [[ $v2ray_transport == [45] ]]; then + local tls=ture + fi + if [[ $tls && $ssport == "80" ]] || [[ $tls && $ssport == "443" ]]; then + echo + echo -e "由于你已选择了 "$green"WebSocket + TLS $none或$green HTTP/2"$none" 传输协议." + echo + echo -e "所以不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口" + error + elif [[ $v2ray_dynamic_port_start_input == $ssport || $v2ray_dynamic_port_end_input == $ssport ]]; then + local multi_port="${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}" + echo + echo " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:$multi_port" + error + elif [[ $v2ray_dynamic_port_start_input -lt $ssport && $ssport -le $v2ray_dynamic_port_end_input ]]; then + local multi_port="${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}" + echo + echo " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:$multi_port" + error + else + echo + echo + echo -e "$yellow Shadowsocks 端口 = $cyan$ssport$none" + echo "----------------------------------------------------------------" + echo + break + fi + ;; + *) + error + ;; + esac + + done + + shadowsocks_password_config +} +shadowsocks_password_config() { + + while :; do + echo -e "请输入 "$yellow"Shadowsocks"$none" 密码" + read -p "$(echo -e "(默认密码: ${cyan}233blog.com$none)"): " sspass + [ -z "$sspass" ] && sspass="233blog.com" + case $sspass in + *[/$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以密码不能包含$red / $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow Shadowsocks 密码 = $cyan$sspass$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + + done + + shadowsocks_ciphers_config +} +shadowsocks_ciphers_config() { + + while :; do + echo -e "请选择 "$yellow"Shadowsocks"$none" 加密协议 [${magenta}1-${#ciphers[*]}$none]" + for ((i = 1; i <= ${#ciphers[*]}; i++)); do + ciphers_show="${ciphers[$i - 1]}" + echo + echo -e "$yellow $i. $none${ciphers_show}" + done + echo + read -p "$(echo -e "(默认加密协议: ${cyan}${ciphers[6]}$none)"):" ssciphers_opt + [ -z "$ssciphers_opt" ] && ssciphers_opt=7 + case $ssciphers_opt in + [1-7]) + ssciphers=${ciphers[$ssciphers_opt - 1]} + echo + echo + echo -e "$yellow Shadowsocks 加密协议 = $cyan${ssciphers}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + + done + pause +} + +install_info() { + clear + echo + echo " ....准备安装了咯..看看有毛有配置正确了..." + echo + echo "---------- 安装信息 -------------" + echo + echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport - 1]}$none" + + if [[ $v2ray_transport == [45] ]]; then + echo + echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none" + echo + echo -e "$yellow 你的域名 = $cyan$domain$none" + echo + echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none" + echo + echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none" + + if [[ $ban_ad ]]; then + echo + echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none" + fi + if [[ $is_path ]]; then + echo + echo -e "$yellow 路径分流 = ${cyan}/${path}$none" + fi + elif [[ $v2ray_transport -ge 18 ]]; then + echo + echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none" + echo + echo -e "$yellow V2Ray 动态端口范围 = $cyan${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}$none" + + if [[ $ban_ad ]]; then + echo + echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none" + fi + else + echo + echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none" + + if [[ $ban_ad ]]; then + echo + echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none" + fi + fi + if [ $shadowsocks ]; then + echo + echo -e "$yellow Shadowsocks 端口 = $cyan$ssport$none" + echo + echo -e "$yellow Shadowsocks 密码 = $cyan$sspass$none" + echo + echo -e "$yellow Shadowsocks 加密协议 = $cyan${ssciphers}$none" + else + echo + echo -e "$yellow 是否配置 Shadowsocks = ${cyan}未配置${none}" + fi + echo + echo "---------- END -------------" + echo + pause + echo +} + +domain_check() { + # if [[ $cmd == "yum" ]]; then + # yum install bind-utils -y + # else + # $cmd install dnsutils -y + # fi + # test_domain=$(dig $domain +short) + test_domain=$(ping $domain -c 1 | grep -oE -m1 "([0-9]{1,3}\.){3}[0-9]{1,3}") + if [[ $test_domain != $ip ]]; then + echo + echo -e "$red 检测域名解析错误....$none" + echo + echo -e " 你的域名: $yellow$domain$none 未解析到: $cyan$ip$none" + echo + echo -e " 你的域名当前解析到: $cyan$test_domain$none" + echo + echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 Status 那里点一下那图标..让它变灰" + echo + exit 1 + fi +} + +install_caddy() { + # download caddy file then install + _load download-caddy.sh + _download_caddy_file + _install_caddy_service + caddy_config + +} +caddy_config() { + # local email=$(shuf -i1-10000000000 -n1) + _load caddy-config.sh + + # systemctl restart caddy + do_service restart caddy +} + +install_v2ray() { + $cmd update -y + if [[ $cmd == "apt-get" ]]; then + $cmd install -y lrzsz git zip unzip curl wget qrencode libcap2-bin + else + # $cmd install -y lrzsz git zip unzip curl wget qrencode libcap iptables-services + $cmd install -y lrzsz git zip unzip curl wget qrencode libcap + fi + ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime + [ -d /etc/v2ray ] && rm -rf /etc/v2ray + date -s "$(curl -sI g.cn | grep Date | cut -d' ' -f3-6)Z" + + if [[ $local_install ]]; then + if [[ ! -d $(pwd)/config ]]; then + echo + echo -e "$red 哎呀呀...安装失败了咯...$none" + echo + echo -e " 请确保你有完整的上传 v2ray6.com 的 V2Ray 一键安装脚本 & 管理脚本到当前 ${green}$(pwd) $none目录下" + echo + exit 1 + fi + mkdir -p /etc/v2ray/233boy/v2ray + cp -rf $(pwd)/* /etc/v2ray/233boy/v2ray + else + pushd /tmp + if [[ $_test ]]; then + git clone https://github.com/233boy/v2ray -b test /etc/v2ray/233boy/v2ray + else + git clone https://github.com/233boy/v2ray /etc/v2ray/233boy/v2ray + fi + popd + + fi + + if [[ ! -d /etc/v2ray/233boy/v2ray ]]; then + echo + echo -e "$red 哎呀呀...克隆脚本仓库出错了...$none" + echo + echo -e " 温馨提示..... 请尝试自行安装 Git: ${green}$cmd install -y git $none 之后再安装此脚本" + echo + exit 1 + fi + + # download v2ray file then install + _load download-v2ray.sh + _download_v2ray_file + _install_v2ray_service + _mkdir_dir +} + +open_port() { + if [[ $cmd == "apt-get" ]]; then + if [[ $1 != "multiport" ]]; then + + iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT + iptables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT + ip6tables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT + ip6tables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT + + # firewall-cmd --permanent --zone=public --add-port=$1/tcp + # firewall-cmd --permanent --zone=public --add-port=$1/udp + # firewall-cmd --reload + + else + + local multiport="${v2ray_dynamic_port_start_input}:${v2ray_dynamic_port_end_input}" + iptables -I INPUT -p tcp --match multiport --dports $multiport -j ACCEPT + iptables -I INPUT -p udp --match multiport --dports $multiport -j ACCEPT + ip6tables -I INPUT -p tcp --match multiport --dports $multiport -j ACCEPT + ip6tables -I INPUT -p udp --match multiport --dports $multiport -j ACCEPT + + # local multi_port="${v2ray_dynamic_port_start_input}-${v2ray_dynamic_port_end_input}" + # firewall-cmd --permanent --zone=public --add-port=$multi_port/tcp + # firewall-cmd --permanent --zone=public --add-port=$multi_port/udp + # firewall-cmd --reload + + fi + iptables-save >/etc/iptables.rules.v4 + ip6tables-save >/etc/iptables.rules.v6 + # else + # service iptables save >/dev/null 2>&1 + # service ip6tables save >/dev/null 2>&1 + fi +} +del_port() { + if [[ $cmd == "apt-get" ]]; then + if [[ $1 != "multiport" ]]; then + # if [[ $cmd == "apt-get" ]]; then + iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT + iptables -D INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT + ip6tables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT + ip6tables -D INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT + # else + # firewall-cmd --permanent --zone=public --remove-port=$1/tcp + # firewall-cmd --permanent --zone=public --remove-port=$1/udp + # fi + else + # if [[ $cmd == "apt-get" ]]; then + local ports="${v2ray_dynamicPort_start}:${v2ray_dynamicPort_end}" + iptables -D INPUT -p tcp --match multiport --dports $ports -j ACCEPT + iptables -D INPUT -p udp --match multiport --dports $ports -j ACCEPT + ip6tables -D INPUT -p tcp --match multiport --dports $ports -j ACCEPT + ip6tables -D INPUT -p udp --match multiport --dports $ports -j ACCEPT + # else + # local ports="${v2ray_dynamicPort_start}-${v2ray_dynamicPort_end}" + # firewall-cmd --permanent --zone=public --remove-port=$ports/tcp + # firewall-cmd --permanent --zone=public --remove-port=$ports/udp + # fi + fi + iptables-save >/etc/iptables.rules.v4 + ip6tables-save >/etc/iptables.rules.v6 + # else + # service iptables save >/dev/null 2>&1 + # service ip6tables save >/dev/null 2>&1 + fi + +} + +config() { + cp -f /etc/v2ray/233boy/v2ray/config/backup.conf $backup + cp -f /etc/v2ray/233boy/v2ray/v2ray.sh $_v2ray_sh + chmod +x $_v2ray_sh + + v2ray_id=$uuid + alterId=233 + ban_bt=true + if [[ $v2ray_transport -ge 18 ]]; then + v2ray_dynamicPort_start=${v2ray_dynamic_port_start_input} + v2ray_dynamicPort_end=${v2ray_dynamic_port_end_input} + fi + _load config.sh + + if [[ $cmd == "apt-get" ]]; then + cat >/etc/network/if-pre-up.d/iptables <<-EOF +#!/bin/sh +/sbin/iptables-restore < /etc/iptables.rules.v4 +/sbin/ip6tables-restore < /etc/iptables.rules.v6 + EOF + chmod +x /etc/network/if-pre-up.d/iptables + # else + # [ $(pgrep "firewall") ] && systemctl stop firewalld + # systemctl mask firewalld + # systemctl disable firewalld + # systemctl enable iptables + # systemctl enable ip6tables + # systemctl start iptables + # systemctl start ip6tables + fi + + [[ $shadowsocks ]] && open_port $ssport + if [[ $v2ray_transport == [45] ]]; then + open_port "80" + open_port "443" + open_port $v2ray_port + elif [[ $v2ray_transport -ge 18 ]]; then + open_port $v2ray_port + open_port "multiport" + else + open_port $v2ray_port + fi + # systemctl restart v2ray + do_service restart v2ray + backup_config + +} + +backup_config() { + sed -i "18s/=1/=$v2ray_transport/; 21s/=2333/=$v2ray_port/; 24s/=$old_id/=$uuid/" $backup + if [[ $v2ray_transport -ge 18 ]]; then + sed -i "30s/=10000/=$v2ray_dynamic_port_start_input/; 33s/=20000/=$v2ray_dynamic_port_end_input/" $backup + fi + if [[ $shadowsocks ]]; then + sed -i "42s/=/=true/; 45s/=6666/=$ssport/; 48s/=233blog.com/=$sspass/; 51s/=chacha20-ietf/=$ssciphers/" $backup + fi + [[ $v2ray_transport == [45] ]] && sed -i "36s/=233blog.com/=$domain/" $backup + [[ $caddy ]] && sed -i "39s/=/=true/" $backup + [[ $ban_ad ]] && sed -i "54s/=/=true/" $backup + if [[ $is_path ]]; then + sed -i "57s/=/=true/; 60s/=233blog/=$path/" $backup + sed -i "63s#=https://liyafly.com#=$proxy_site#" $backup + fi +} + +try_enable_bbr() { + if [[ $(uname -r | cut -b 1) -eq 4 ]]; then + case $(uname -r | cut -b 3-4) in + 9. | [1-9][0-9]) + sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf + sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf + echo "net.ipv4.tcp_congestion_control = bbr" >>/etc/sysctl.conf + echo "net.core.default_qdisc = fq" >>/etc/sysctl.conf + sysctl -p >/dev/null 2>&1 + ;; + esac + fi +} + +get_ip() { + ip=$(curl -s https://ipinfo.io/ip) + [[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip) + [[ -z $ip ]] && ip=$(curl -s https://api.ipify.org) + [[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org) + [[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/ip) + [[ -z $ip ]] && ip=$(curl -s https://api.myip.com | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") + [[ -z $ip ]] && ip=$(curl -s icanhazip.com) + [[ -z $ip ]] && ip=$(curl -s myip.ipip.net | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") + [[ -z $ip ]] && echo -e "\n$red 这垃圾小鸡扔了吧!$none\n" && exit +} + +error() { + + echo -e "\n$red 输入错误!$none\n" + +} + +pause() { + + read -rsp "$(echo -e "按$green Enter 回车键 $none继续....或按$red Ctrl + C $none取消.")" -d $'\n' + echo +} +do_service() { + if [[ $systemd ]]; then + systemctl $1 $2 + else + service $2 $1 + fi +} +show_config_info() { + clear + _load v2ray-info.sh + _v2_args + _v2_info + _load ss-info.sh + +} + +install() { + if [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f $backup && -d /etc/v2ray/233boy/v2ray ]]; then + echo + echo " 大佬...你已经安装 V2Ray 啦...无需重新安装" + echo + echo -e " $yellow输入 ${cyan}v2ray${none} $yellow即可管理 V2Ray${none}" + echo + exit 1 + elif [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f /etc/v2ray/233blog_v2ray_backup.txt && -d /etc/v2ray/233boy/v2ray ]]; then + echo + echo " 如果你需要继续安装.. 请先卸载旧版本" + echo + echo -e " $yellow输入 ${cyan}v2ray uninstall${none} $yellow即可卸载${none}" + echo + exit 1 + fi + v2ray_config + blocked_hosts + shadowsocks_config + install_info + try_enable_bbr + # [[ $caddy ]] && domain_check + install_v2ray + if [[ $caddy || $v2ray_port == "80" ]]; then + if [[ $cmd == "yum" ]]; then + [[ $(pgrep "httpd") ]] && systemctl stop httpd + [[ $(command -v httpd) ]] && yum remove httpd -y + else + [[ $(pgrep "apache2") ]] && service apache2 stop + [[ $(command -v apache2) ]] && apt-get remove apache2* -y + fi + fi + [[ $caddy ]] && install_caddy + get_ip + config + show_config_info +} +uninstall() { + + if [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f $backup && -d /etc/v2ray/233boy/v2ray ]]; then + . $backup + if [[ $mark ]]; then + _load uninstall.sh + else + echo + echo -e " $yellow输入 ${cyan}v2ray uninstall${none} $yellow即可卸载${none}" + echo + fi + + elif [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f /etc/v2ray/233blog_v2ray_backup.txt && -d /etc/v2ray/233boy/v2ray ]]; then + echo + echo -e " $yellow输入 ${cyan}v2ray uninstall${none} $yellow即可卸载${none}" + echo + else + echo -e " + $red 大胸弟...你貌似毛有安装 V2Ray ....卸载个鸡鸡哦...$none + + 备注...仅支持卸载使用我 (v2ray6.com) 提供的 V2Ray 一键安装脚本 + " && exit 1 + fi + +} + +args=$1 +[ -z $1 ] && args="online" +case $args in +online) + #hello world + ;; +local) + local_install=true + ;; +*) + echo + echo -e " 你输入的这个参数 <$red $args $none> ...这个是什么鬼啊...脚本不认识它哇" + echo + echo -e " 这个辣鸡脚本仅支持输入$green local / online $none参数" + echo + echo -e " 输入$yellow local $none即是使用本地安装" + echo + echo -e " 输入$yellow online $none即是使用在线安装 (默认)" + echo + exit 1 + ;; +esac + +clear +while :; do + echo + echo "........... V2Ray 一键安装脚本 & 管理脚本 by v2ray6.com .........." + echo + echo "帮助说明: https://v2ray6.com/post/1/" + echo + echo "搭建教程: https://v2ray6.com/post/2/" + echo + echo " 1. 安装" + echo + echo " 2. 卸载" + echo + if [[ $local_install ]]; then + echo -e "$yellow 温馨提示.. 本地安装已启用 ..$none" + echo + fi + read -p "$(echo -e "请选择 [${magenta}1-2$none]:")" choose + case $choose in + 1) + install + break + ;; + 2) + uninstall + break + ;; + *) + error + ;; + esac +done diff --git a/v2ray.sh b/v2ray.sh new file mode 100644 index 0000000..535512b --- /dev/null +++ b/v2ray.sh @@ -0,0 +1,2972 @@ +#!/bin/bash + +red='\e[91m' +green='\e[92m' +yellow='\e[93m' +magenta='\e[95m' +cyan='\e[96m' +none='\e[0m' + +# Root +[[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1 + +_version="v3.05" + +cmd="apt-get" + +sys_bit=$(uname -m) + +if [[ $sys_bit == "i386" || $sys_bit == "i686" ]]; then + v2ray_bit="32" +elif [[ $sys_bit == "x86_64" ]]; then + v2ray_bit="64" +else + echo -e " 哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}" && exit 1 +fi + +if [[ -f /usr/bin/yum ]]; then + + cmd="yum" + +fi + +backup="/etc/v2ray/233blog_v2ray_backup.conf" + +if [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f $backup && -d /etc/v2ray/233boy/v2ray ]]; then + + . $backup + +elif [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f /etc/v2ray/233blog_v2ray_backup.txt && -d /etc/v2ray/233boy/v2ray ]]; then + + . /etc/v2ray/233boy/v2ray/tools/v1xx_to_v3xx.sh + +else + echo -e " 哎呀哎呀…… ${red}出错咯...请重新安装V2Ray${none} ${yellow}~(^_^) ${none}" && exit 1 +fi + +if [[ $mark != "v3" ]]; then + . /etc/v2ray/233boy/v2ray/tools/v3.sh +fi +if [[ $v2ray_transport -ge 18 ]]; then + dynamicPort=true + port_range="${v2ray_dynamicPort_start}-${v2ray_dynamicPort_end}" +fi +if [[ $path_status ]]; then + is_path=true +fi + +uuid=$(cat /proc/sys/kernel/random/uuid) +old_id="e55c8d17-2cf3-b21a-bcf1-eeacb011ed79" +v2ray_server_config="/etc/v2ray/config.json" +v2ray_client_config="/etc/v2ray/233blog_v2ray_config.json" +v2ray_pid=$(pgrep -f /usr/bin/v2ray/v2ray) +caddy_pid=$(pgrep -f /usr/local/bin/caddy) +_v2ray_sh="/usr/local/sbin/v2ray" +v2ray_ver="$(/usr/bin/v2ray/v2ray -version | head -n 1 | cut -d " " -f2)" +. /etc/v2ray/233boy/v2ray/src/init.sh +systemd=true +# _test=true + +if [[ $v2ray_ver != v* ]]; then + v2ray_ver="v$v2ray_ver" +fi +if [[ ! -f $_v2ray_sh ]]; then + mv -f /usr/local/bin/v2ray $_v2ray_sh + chmod +x $_v2ray_sh + echo -e "\n $yellow 警告: 请重新登录 SSH 以避免出现 v2ray 命令未找到的情况。$none \n" && exit 1 +fi + +if [ $v2ray_pid ]; then + v2ray_status="$green正在运行$none" +else + v2ray_status="$red未在运行$none" +fi +if [[ $v2ray_transport == [45] && $caddy ]] && [[ $caddy_pid ]]; then + caddy_run_status="$green正在运行$none" +else + caddy_run_status="$red未在运行$none" +fi + +_load transport.sh +ciphers=( + aes-128-cfb + aes-256-cfb + chacha20 + chacha20-ietf + aes-128-gcm + aes-256-gcm + chacha20-ietf-poly1305 +) + +get_transport_args() { + _load v2ray-info.sh + _v2_args +} +create_vmess_URL_config() { + + [[ -z $net ]] && get_transport_args + + if [[ $v2ray_transport == [45] ]]; then + cat >/etc/v2ray/vmess_qr.json <<-EOF + { + "v": "2", + "ps": "v2ray6.com_${domain}", + "add": "${domain}", + "port": "443", + "id": "${v2ray_id}", + "aid": "${alterId}", + "net": "${net}", + "type": "none", + "host": "${domain}", + "path": "$_path", + "tls": "tls" + } + EOF + else + [[ -z $ip ]] && get_ip + cat >/etc/v2ray/vmess_qr.json <<-EOF + { + "v": "2", + "ps": "v2ray6.com_${ip}", + "add": "${ip}", + "port": "${v2ray_port}", + "id": "${v2ray_id}", + "aid": "${alterId}", + "net": "${net}", + "type": "${header}", + "host": "${host}", + "path": "", + "tls": "" + } + EOF + fi +} +view_v2ray_config_info() { + + _load v2ray-info.sh + _v2_args + _v2_info +} +get_shadowsocks_config() { + if [[ $shadowsocks ]]; then + + while :; do + echo + echo -e "$yellow 1. $none查看 Shadowsocks 配置信息" + echo + echo -e "$yellow 2. $none生成二维码链接" + echo + read -p "$(echo -e "请选择 [${magenta}1-2$none]:")" _opt + if [[ -z $_opt ]]; then + error + else + case $_opt in + 1) + view_shadowsocks_config_info + break + ;; + 2) + get_shadowsocks_config_qr_link + break + ;; + *) + error + ;; + esac + fi + + done + else + shadowsocks_config + fi +} +view_shadowsocks_config_info() { + if [[ $shadowsocks ]]; then + _load ss-info.sh + else + shadowsocks_config + fi +} +get_shadowsocks_config_qr_link() { + if [[ $shadowsocks ]]; then + echo + echo -e "$green 正在生成链接.... 稍等片刻即可....$none" + echo + get_ip + local ss="ss://$(echo -n "${ssciphers}:${sspass}@${ip}:${ssport}" | base64 -w 0)#v2ray6.com_ss_${ip}" + echo "${ss}" >/tmp/233blog_shadowsocks.txt + cat /tmp/233blog_shadowsocks.txt | qrencode -s 50 -o /tmp/233blog_shadowsocks.png + + local random=$(echo $RANDOM-$RANDOM-$RANDOM | base64 -w 0) + local link=$(curl -s --upload-file /tmp/233blog_shadowsocks.png "https://transfer.sh/${random}_v2ray6_shadowsocks.png") + if [[ $link ]]; then + echo + echo "---------- Shadowsocks 二维码链接 -------------" + echo + echo -e "$yellow 链接 = $cyan$link$none" + echo + echo -e " 温馨提示...$red Shadowsocks Win 4.0.6 $none客户端可能无法识别该二维码" + echo + echo "备注...链接将在 14 天后失效" + echo + echo "提醒...请不要把链接分享出去...除非你有特别的理由...." + echo + else + echo + echo -e "$red 哎呀呀呀...出错咯...请重试$none" + echo + fi + rm -rf /tmp/233blog_shadowsocks.png + rm -rf /tmp/233blog_shadowsocks.txt + else + shadowsocks_config + fi + +} + +get_shadowsocks_config_qr_ask() { + echo + while :; do + echo -e "是否需要生成$yellow Shadowsocks 配置信息 $none二维码链接 [${magenta}Y/N$none]" + read -p "$(echo -e "默认 [${magenta}N$none]:")" y_n + [ -z $y_n ] && y_n="n" + if [[ $y_n == [Yy] ]]; then + get_shadowsocks_config_qr_link + break + elif [[ $y_n == [Nn] ]]; then + break + else + error + fi + done + +} +change_shadowsocks_config() { + if [[ $shadowsocks ]]; then + + while :; do + echo + echo -e "$yellow 1. $none修改 Shadowsocks 端口" + echo + echo -e "$yellow 2. $none修改 Shadowsocks 密码" + echo + echo -e "$yellow 3. $none修改 Shadowsocks 加密协议" + echo + echo -e "$yellow 4. $none关闭 Shadowsocks" + echo + read -p "$(echo -e "请选择 [${magenta}1-4$none]:")" _opt + if [[ -z $_opt ]]; then + error + else + case $_opt in + 1) + change_shadowsocks_port + break + ;; + 2) + change_shadowsocks_password + break + ;; + 3) + change_shadowsocks_ciphers + break + ;; + 4) + disable_shadowsocks + break + ;; + *) + error + ;; + esac + fi + + done + else + + shadowsocks_config + fi +} +shadowsocks_config() { + echo + echo + echo -e " $red大佬...你没有配置 Shadowsocks $none...不过现在想要配置的话也是可以的 ^_^" + echo + echo + + while :; do + echo -e "是否配置 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]" + read -p "$(echo -e "(默认 [${cyan}N$none]):") " install_shadowsocks + [[ -z "$install_shadowsocks" ]] && install_shadowsocks="n" + if [[ "$install_shadowsocks" == [Yy] ]]; then + echo + shadowsocks=true + shadowsocks_port_config + shadowsocks_password_config + shadowsocks_ciphers_config + pause + open_port $new_ssport + backup_config +ss + ssport=$new_ssport + sspass=$new_sspass + ssciphers=$new_ssciphers + config + clear + view_shadowsocks_config_info + # get_shadowsocks_config_qr_ask + break + elif [[ "$install_shadowsocks" == [Nn] ]]; then + echo + echo -e " $green已取消配置 Shadowsocks ....$none" + echo + break + else + error + fi + + done +} +shadowsocks_port_config() { + local random=$(shuf -i20001-65535 -n1) + while :; do + echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2ray"$none" 端口相同" + read -p "$(echo -e "(默认端口: ${cyan}${random}$none):") " new_ssport + [ -z "$new_ssport" ] && new_ssport=$random + case $new_ssport in + $v2ray_port) + echo + echo -e " 不能和$cyan V2Ray 端口 $none一毛一样...." + echo + echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}" + error + ;; + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + if [[ $v2ray_transport == [45] ]]; then + local tls=ture + fi + if [[ $tls && $new_ssport == "80" ]] || [[ $tls && $new_ssport == "443" ]]; then + echo + echo -e "由于你当前已使用了 "$green"WebSocket + TLS $none或$green HTTP/2"$none" 传输协议." + echo + echo -e "所以不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口" + error + elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start == $new_ssport || $v2ray_dynamicPort_end == $new_ssport ]]; then + echo + echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}" + error + elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start -lt $new_ssport && $new_ssport -le $v2ray_dynamicPort_end ]]; then + echo + echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}" + error + elif [[ $socks && $new_ssport == $socks_port ]]; then + echo + echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none" + error + elif [[ $mtproto && $new_ssport == $mtproto_port ]]; then + echo + echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none" + error + else + echo + echo + echo -e "$yellow Shadowsocks 端口 = $cyan$new_ssport$none" + echo "----------------------------------------------------------------" + echo + break + fi + ;; + *) + error + ;; + esac + + done + +} + +shadowsocks_password_config() { + + while :; do + echo -e "请输入 "$yellow"Shadowsocks"$none" 密码" + read -p "$(echo -e "(默认密码: ${cyan}233blog.com$none)"): " new_sspass + [ -z "$new_sspass" ] && new_sspass="233blog.com" + case $new_sspass in + *[/$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以密码不能包含$red / $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow Shadowsocks 密码 = $cyan$new_sspass$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + + done + +} + +shadowsocks_ciphers_config() { + + while :; do + echo -e "请选择 "$yellow"Shadowsocks"$none" 加密协议 [${magenta}1-7$none]" + for ((i = 1; i <= ${#ciphers[*]}; i++)); do + ciphers_show="${ciphers[$i - 1]}" + echo + echo -e "$yellow $i. $none${ciphers_show}" + done + echo + read -p "$(echo -e "(默认加密协议: ${cyan}${ciphers[6]}$none)"):" ssciphers_opt + [ -z "$ssciphers_opt" ] && ssciphers_opt=7 + case $ssciphers_opt in + [1-7]) + new_ssciphers=${ciphers[$ssciphers_opt - 1]} + echo + echo + echo -e "$yellow Shadowsocks 加密协议 = $cyan${new_ssciphers}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + + done +} + +change_shadowsocks_port() { + echo + while :; do + echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(当前端口: ${cyan}$ssport$none):") " new_ssport + [ -z "$new_ssport" ] && error && continue + case $new_ssport in + $ssport) + echo + echo " 跟当前端口一毛一样....修改个鸡鸡哦" + error + ;; + $v2ray_port) + echo + echo -e " 不能和$cyan V2Ray 端口 $none一毛一样...." + error + ;; + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + if [[ $v2ray_transport == [45] ]]; then + local tls=ture + fi + if [[ $tls && $new_ssport == "80" ]] || [[ $tls && $new_ssport == "443" ]]; then + echo + echo -e "由于你已选择了 "$green"WebSocket + TLS $none或$green HTTP/2"$none" 传输协议." + echo + echo -e "所以不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口" + error + elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start == $new_ssport || $v2ray_dynamicPort_end == $new_ssport ]]; then + echo + echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}" + error + elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start -lt $new_ssport && $new_ssport -le $v2ray_dynamicPort_end ]]; then + echo + echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}" + error + elif [[ $socks && $new_ssport == $socks_port ]]; then + echo + echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none" + error + elif [[ $mtproto && $new_ssport == $mtproto_port ]]; then + echo + echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none" + error + else + echo + echo + echo -e "$yellow Shadowsocks 端口 = $cyan$new_ssport$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config ssport + del_port $ssport + open_port $new_ssport + ssport=$new_ssport + config + clear + view_shadowsocks_config_info + # get_shadowsocks_config_qr_ask + break + fi + ;; + *) + error + ;; + esac + + done +} +change_shadowsocks_password() { + echo + while :; do + echo -e "请输入 "$yellow"Shadowsocks"$none" 密码" + read -p "$(echo -e "(当前密码:${cyan}$sspass$none)"): " new_sspass + [ -z "$new_sspass" ] && error && continue + case $new_sspass in + $sspass) + echo + echo " 跟当前密码一毛一样....修改个鸡鸡哦" + error + ;; + *[/$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以密码不能包含$red / $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow Shadowsocks 密码 = $cyan$new_sspass$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config sspass + sspass=$new_sspass + config + clear + view_shadowsocks_config_info + # get_shadowsocks_config_qr_ask + break + ;; + esac + + done + +} + +change_shadowsocks_ciphers() { + echo + while :; do + echo -e "请选择 "$yellow"Shadowsocks"$none" 加密协议 [${magenta}1-${#ciphers[*]}$none]" + for ((i = 1; i <= ${#ciphers[*]}; i++)); do + ciphers_show="${ciphers[$i - 1]}" + echo + echo -e "$yellow $i. $none${ciphers_show}" + done + echo + read -p "$(echo -e "(当前加密协议: ${cyan}${ssciphers}$none)"):" ssciphers_opt + [ -z "$ssciphers_opt" ] && error && continue + case $ssciphers_opt in + [1-7]) + new_ssciphers=${ciphers[$ssciphers_opt - 1]} + if [[ $new_ssciphers == $ssciphers ]]; then + echo + echo " 跟当前加密协议一毛一样....修改个鸡鸡哦" + error && continue + fi + echo + echo + echo -e "$yellow Shadowsocks 加密协议 = $cyan${new_ssciphers}$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config ssciphers + ssciphers=$new_ssciphers + config + clear + view_shadowsocks_config_info + # get_shadowsocks_config_qr_ask + break + ;; + *) + error + ;; + esac + + done + +} +disable_shadowsocks() { + echo + + while :; do + echo -e "是否关闭 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]" + read -p "$(echo -e "(默认 [${cyan}N$none]):") " y_n + [[ -z "$y_n" ]] && y_n="n" + if [[ "$y_n" == [Yy] ]]; then + echo + echo + echo -e "$yellow 关闭 Shadowsocks = $cyan是$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config -ss + del_port $ssport + shadowsocks='' + config + # clear + echo + echo + echo + echo -e "$green Shadowsocks 已关闭...不过你也可以随时重新启用 Shadowsocks ...只要你喜欢$none" + echo + break + elif [[ "$y_n" == [Nn] ]]; then + echo + echo -e " $green已取消关闭 Shadowsocks ....$none" + echo + break + else + error + fi + + done +} +change_v2ray_config() { + local _menu=( + "修改 V2Ray 端口" + "修改 V2Ray 传输协议" + "修改 V2Ray 动态端口 (如果可以)" + "修改 用户ID ( UUID )" + "修改 TLS 域名 (如果可以)" + "修改 分流的路径 (如果可以)" + "修改 伪装的网址 (如果可以)" + "关闭 网站伪装 和 路径分流 (如果可以)" + "开启 / 关闭 广告拦截" + ) + while :; do + for ((i = 1; i <= ${#_menu[*]}; i++)); do + if [[ "$i" -le 9 ]]; then + echo + echo -e "$yellow $i. $none${_menu[$i - 1]}" + else + echo + echo -e "$yellow $i. $none${_menu[$i - 1]}" + fi + done + echo + read -p "$(echo -e "请选择 [${magenta}1-${#_menu[*]}$none]:")" _opt + if [[ -z $_opt ]]; then + error + else + case $_opt in + 1) + change_v2ray_port + break + ;; + 2) + change_v2ray_transport + break + ;; + 3) + change_v2ray_dynamicport + break + ;; + 4) + change_v2ray_id + break + ;; + 5) + change_domain + break + ;; + 6) + change_path_config + break + ;; + 7) + change_proxy_site_config + break + ;; + 8) + disable_path + break + ;; + 9) + blocked_hosts + break + ;; + [aA][Ii][aA][Ii] | [Dd][Dd]) + custom_uuid + break + ;; + [Dd] | [Aa][Ii] | 233 | 233[Bb][Ll][Oo][Gg] | 233[Bb][Ll][Oo][Gg].[Cc][Oo][Mm] | 233[Bb][Oo][Yy] | [Aa][Ll][Tt][Ee][Rr][Ii][Dd]) + change_v2ray_alterId + break + ;; + *) + error + ;; + esac + fi + done +} +change_v2ray_port() { + if [[ $v2ray_transport == 4 ]]; then + echo + echo -e " 由于你目前使用的是$yellow WebSocket + TLS $none传输协议...所以修不修改 V2Ray 端口没有什么不一样的" + echo + echo " 如果你想要使用其他端口...可以先修改 V2Ray 的传输协议..之后再修改 V2Ray 端口" + echo + change_v2ray_transport_ask + elif [[ $v2ray_transport == 5 ]]; then + echo + echo -e " 由于你目前使用的是$yellow HTTP/2 $none传输协议...所以修不修改 V2Ray 端口没有什么不一样的" + echo + echo " 如果你想要使用其他端口...可以先修改 V2Ray 的传输协议..之后再修改 V2Ray 端口" + echo + change_v2ray_transport_ask + else + echo + while :; do + echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(当前端口: ${cyan}${v2ray_port}$none):")" v2ray_port_opt + [[ -z $v2ray_port_opt ]] && error && continue + case $v2ray_port_opt in + $v2ray_port) + echo + echo " 哎呀...跟当前端口一毛一样呀...修改个鸡鸡哦" + error + ;; + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + if [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start == $v2ray_port_opt || $v2ray_dynamicPort_end == $v2ray_port_opt ]]; then + echo + echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}" + error + elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start -lt $v2ray_port_opt && $v2ray_port_opt -le $v2ray_dynamicPort_end ]]; then + echo + echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}" + error + elif [[ $shadowsocks && $v2ray_port_opt == $ssport ]]; then + echo + echo -e "抱歉, 此端口跟 Shadowsocks 端口冲突...当前 Shadowsocks 端口: ${cyan}$ssport$none" + error + elif [[ $socks && $v2ray_port_opt == $socks_port ]]; then + echo + echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none" + error + elif [[ $mtproto && $v2ray_port_opt == $mtproto_port ]]; then + echo + echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none" + error + else + echo + echo + echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port_opt$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config v2ray_port + del_port $v2ray_port + open_port $v2ray_port_opt + v2ray_port=$v2ray_port_opt + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + break + fi + ;; + *) + error + ;; + esac + + done + fi + +} +download_v2ray_config_ask() { + echo + while :; do + echo -e "是否需要 下载 V2Ray 配置 / 生成配置信息链接 / 生成二维码链接 [${magenta}Y/N$none]" + read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n + [ -z $y_n ] && y_n="n" + if [[ $y_n == [Yy] ]]; then + download_v2ray_config + break + elif [[ $y_n == [Nn] ]]; then + break + else + error + fi + done + +} +change_v2ray_transport_ask() { + echo + while :; do + echo -e "是否需要修改$yellow V2Ray $none传输协议 [${magenta}Y/N$none]" + read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n + [ -z $y_n ] && break + if [[ $y_n == [Yy] ]]; then + change_v2ray_transport + break + elif [[ $y_n == [Nn] ]]; then + break + else + error + fi + done +} +change_v2ray_transport() { + echo + while :; do + echo -e "请选择 "$yellow"V2Ray"$none" 传输协议 [${magenta}1-${#transport[*]}$none]" + echo + for ((i = 1; i <= ${#transport[*]}; i++)); do + Stream="${transport[$i - 1]}" + if [[ "$i" -le 9 ]]; then + # echo + echo -e "$yellow $i. $none${Stream}" + else + # echo + echo -e "$yellow $i. $none${Stream}" + fi + done + echo + echo "备注1: 含有 [dynamicPort] 的即启用动态端口.." + echo "备注2: [utp | srtp | wechat-video | dtls | wireguard] 分别伪装成 [BT下载 | 视频通话 | 微信视频通话 | DTLS 1.2 数据包 | WireGuard 数据包]" + echo + read -p "$(echo -e "(当前传输协议: ${cyan}${transport[$v2ray_transport - 1]}$none)"):" v2ray_transport_opt + if [ -z "$v2ray_transport_opt" ]; then + error + else + case $v2ray_transport_opt in + $v2ray_transport) + echo + echo " 哎呀...跟当前传输协议一毛一样呀...修改个鸡鸡哦" + error + ;; + 4 | 5) + if [[ $v2ray_port == "80" || $v2ray_port == "443" ]]; then + echo + echo -e " 抱歉...如果你想要使用${cyan} ${transport[$v2ray_transport_opt - 1]} $none传输协议.. ${red}V2Ray 端口不能为 80 或者 443 ...$none" + echo + echo -e " 当前 V2Ray 端口: ${cyan}$v2ray_port$none" + error + elif [[ $shadowsocks ]] && [[ $ssport == "80" || $ssport == "443" ]]; then + echo + echo -e " 抱歉...如果你想要使用${cyan} ${transport[$v2ray_transport_opt - 1]} $none传输协议.. ${red}Shadowsocks 端口不能为 80 或者 443 ...$none" + echo + echo -e " 当前 Shadowsocks 端口: ${cyan}$ssport$none" + error + elif [[ $socks ]] && [[ $socks_port == "80" || $socks_port == "443" ]]; then + echo + echo -e " 抱歉...如果你想要使用${cyan} ${transport[$v2ray_transport_opt - 1]} $none传输协议.. ${red}Socks 端口不能为 80 或者 443 ...$none" + echo + echo -e " 当前 Socks 端口: ${cyan}$socks_port$none" + error + elif [[ $mtproto ]] && [[ $mtproto_port == "80" || $mtproto_port == "443" ]]; then + echo + echo -e " 抱歉...如果你想要使用${cyan} ${transport[$v2ray_transport_opt - 1]} $none传输协议.. ${red}MTProto 端口不能为 80 或者 443 ...$none" + echo + echo -e " 当前 MTProto 端口: ${cyan}$mtproto_port$none" + error + else + echo + echo + echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport_opt - 1]}$none" + echo "----------------------------------------------------------------" + echo + break + fi + ;; + [1-9] | [1-2][0-9] | 3[0-2]) + echo + echo + echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport_opt - 1]}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + fi + + done + pause + + if [[ $v2ray_transport_opt == [45] ]]; then + tls_config + elif [[ $v2ray_transport_opt -ge 18 ]]; then + v2ray_dynamic_port_start + v2ray_dynamic_port_end + pause + old_transport + open_port "multiport" + backup_config v2ray_transport v2ray_dynamicPort_start v2ray_dynamicPort_end + port_range="${v2ray_dynamic_port_start_input}-${v2ray_dynamic_port_end_input}" + v2ray_transport=$v2ray_transport_opt + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + else + old_transport + backup_config v2ray_transport + v2ray_transport=$v2ray_transport_opt + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + fi + +} +old_transport() { + if [[ $v2ray_transport == [45] ]]; then + del_port "80" + del_port "443" + if [[ $caddy && $caddy_pid ]]; then + do_service stop caddy + if [[ $systemd ]]; then + systemctl disable caddy >/dev/null 2>&1 + else + update-rc.d -f caddy remove >/dev/null 2>&1 + fi + elif [[ $caddy ]]; then + if [[ $systemd ]]; then + systemctl disable caddy >/dev/null 2>&1 + else + update-rc.d -f caddy remove >/dev/null 2>&1 + fi + fi + if [[ $is_path ]]; then + backup_config -path + fi + elif [[ $v2ray_transport -ge 18 ]]; then + del_port "multiport" + fi +} + +tls_config() { + while :; do + echo + echo + echo + echo -e "请输入一个 $magenta正确的域名$none,一定一定一定要正确,不!能!出!错!" + read -p "(例如:233blog.com): " new_domain + [ -z "$new_domain" ] && error && continue + echo + echo + echo -e "$yellow 你的域名 = $cyan$new_domain$none" + echo "----------------------------------------------------------------" + break + done + get_ip + echo + echo + echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none" + echo + echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none" + echo + echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none" + echo "----------------------------------------------------------------" + echo + + while :; do + + read -p "$(echo -e "(是否已经正确解析: [${magenta}Y$none]):") " record + if [[ -z "$record" ]]; then + error + else + if [[ "$record" == [Yy] ]]; then + domain_check + echo + echo + echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none" + echo "----------------------------------------------------------------" + echo + break + else + error + fi + fi + + done + + if [[ $caddy ]]; then + path_config_ask + pause + # domain_check + backup_config v2ray_transport domain + if [[ $new_path ]]; then + backup_config +path + path=$new_path + proxy_site=$new_proxy_site + is_path=true + fi + + if [[ $v2ray_transport -ge 18 ]]; then + del_port "multiport" + fi + domain=$new_domain + + open_port "80" + open_port "443" + if [[ $systemd ]]; then + systemctl enable caddy >/dev/null 2>&1 + else + update-rc.d -f caddy defaults >/dev/null 2>&1 + fi + v2ray_transport=$v2ray_transport_opt + caddy_config + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + else + if [[ $v2ray_transport_opt == 5 ]]; then + path_config_ask + pause + domain_check + backup_config v2ray_transport domain caddy + if [[ $new_path ]]; then + backup_config +path + path=$new_path + proxy_site=$new_proxy_site + is_path=true + fi + if [[ $v2ray_transport -ge 18 ]]; then + del_port "multiport" + fi + domain=$new_domain + install_caddy + open_port "80" + open_port "443" + v2ray_transport=$v2ray_transport_opt + caddy_config + config + caddy=true + clear + view_v2ray_config_info + # download_v2ray_config_ask + else + auto_tls_config + fi + fi + +} +auto_tls_config() { + echo -e " + + 安装 Caddy 来实现 自动配置 TLS + + 如果你已经安装 Nginx 或 Caddy + + $yellow并且..自己能搞定配置 TLS$none + + 那么就不需要 打开自动配置 TLS + " + echo "----------------------------------------------------------------" + echo + + while :; do + + read -p "$(echo -e "(是否自动配置 TLS: [${magenta}Y/N$none]):") " auto_install_caddy + if [[ -z "$auto_install_caddy" ]]; then + error + else + if [[ "$auto_install_caddy" == [Yy] ]]; then + echo + echo + echo -e "$yellow 自动配置 TLS = $cyan打开$none" + echo "----------------------------------------------------------------" + echo + path_config_ask + pause + domain_check + backup_config v2ray_transport domain caddy + if [[ $new_path ]]; then + backup_config +path + path=$new_path + proxy_site=$new_proxy_site + is_path=true + fi + if [[ $v2ray_transport -ge 18 ]]; then + del_port "multiport" + fi + domain=$new_domain + install_caddy + open_port "80" + open_port "443" + v2ray_transport=$v2ray_transport_opt + caddy_config + config + caddy=true + clear + view_v2ray_config_info + # download_v2ray_config_ask + break + elif [[ "$auto_install_caddy" == [Nn] ]]; then + echo + echo + echo -e "$yellow 自动配置 TLS = $cyan关闭$none" + echo "----------------------------------------------------------------" + echo + pause + domain_check + backup_config v2ray_transport domain + if [[ $v2ray_transport -ge 18 ]]; then + del_port "multiport" + fi + domain=$new_domain + open_port "80" + open_port "443" + v2ray_transport=$v2ray_transport_opt + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + break + else + error + fi + fi + + done +} + +path_config_ask() { + echo + while :; do + echo -e "是否开启 网站伪装 和 路径分流 [${magenta}Y/N$none]" + read -p "$(echo -e "(默认: [${cyan}N$none]):")" path_ask + [[ -z $path_ask ]] && path_ask="n" + + case $path_ask in + Y | y) + path_config + break + ;; + N | n) + echo + echo + echo -e "$yellow 网站伪装 和 路径分流 = $cyan不想配置$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + done +} +path_config() { + echo + while :; do + echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可" + read -p "$(echo -e "(默认: [${cyan}233blog$none]):")" new_path + [[ -z $new_path ]] && new_path="233blog" + + case $new_path in + *[/$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以分流的路径不能包含$red / $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 分流的路径 = ${cyan}/${new_path}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done + proxy_site_config +} +proxy_site_config() { + echo + while :; do + echo -e "请输入 ${magenta}一个正确的$none ${cyan}网址$none 用来作为 ${cyan}网站的伪装$none , 例如 https://liyafly.com" + echo -e "举例...假设你当前的域名是$green $domain $none, 伪装的网址的是 https://liyafly.com" + echo -e "然后打开你的域名时候...显示出来的内容就是来自 https://liyafly.com 的内容" + echo -e "其实就是一个反代...明白就好..." + echo -e "如果不能伪装成功...可以使用 v2ray config 修改伪装的网址" + read -p "$(echo -e "(默认: [${cyan}https://liyafly.com$none]):")" new_proxy_site + [[ -z $new_proxy_site ]] && new_proxy_site="https://liyafly.com" + + case $new_proxy_site in + *[#$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以伪装的网址不能包含$red # $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 伪装的网址 = ${cyan}${new_proxy_site}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done +} + +install_caddy() { + _load download-caddy.sh + _download_caddy_file + _install_caddy_service + +} +caddy_config() { + # local email=$(shuf -i1-10000000000 -n1) + _load caddy-config.sh + # systemctl restart caddy + do_service restart caddy +} +v2ray_dynamic_port_start() { + echo + echo + while :; do + echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(默认开始端口: ${cyan}10000$none):")" v2ray_dynamic_port_start_input + [ -z $v2ray_dynamic_port_start_input ] && v2ray_dynamic_port_start_input=10000 + case $v2ray_dynamic_port_start_input in + $v2ray_port) + echo + echo " 不能和 V2Ray 端口一毛一样...." + echo + echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}" + error + ;; + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + if [[ $shadowsocks && $v2ray_dynamic_port_start_input == $ssport ]]; then + echo + echo -e "抱歉, 此端口跟 Shadowsocks 端口冲突...当前 Shadowsocks 端口: ${cyan}$ssport$none" + error + elif [[ $socks && $v2ray_dynamic_port_start_input == $socks_port ]]; then + echo + echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none" + error + elif [[ $mtproto && $v2ray_dynamic_port_start_input == $mtproto_port ]]; then + echo + echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none" + error + else + echo + echo + echo -e "$yellow V2Ray 动态端口开始 = $cyan$v2ray_dynamic_port_start_input$none" + echo "----------------------------------------------------------------" + echo + break + fi + + ;; + *) + error + ;; + esac + + done + + if [[ $v2ray_dynamic_port_start_input -lt $v2ray_port ]]; then + lt_v2ray_port=true + fi + if [[ $shadowsocks ]] && [[ $v2ray_dynamic_port_start_input -lt $ssport ]]; then + lt_ssport=true + fi + if [[ $socks ]] && [[ $v2ray_dynamic_port_start_input -lt $socks_port ]]; then + lt_socks_port=true + fi + if [[ $mtproto ]] && [[ $v2ray_dynamic_port_start_input -lt $mtproto_port ]]; then + lt_mtproto_port=true + fi + +} + +v2ray_dynamic_port_end() { + echo + while :; do + echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input + [ -z $v2ray_dynamic_port_end_input ] && v2ray_dynamic_port_end_input=20000 + case $v2ray_dynamic_port_end_input in + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + + if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then + echo + echo " 不能小于或等于 V2Ray 动态端口开始范围" + echo + echo -e " 当前 V2Ray 动态端口开始:${cyan}$v2ray_dynamic_port_start_input${none}" + error + elif [ $lt_v2ray_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $v2ray_port ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 V2Ray 端口..." + echo + echo -e " 当前 V2Ray 端口: ${cyan}$v2ray_port$none" + error + elif [ $lt_ssport ] && [[ ${v2ray_dynamic_port_end_input} -ge $ssport ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 Shadowsocks 端口..." + echo + echo -e " 当前 Shadowsocks 端口: ${cyan}$ssport$none" + error + elif [ $lt_socks_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $socks_port ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 Socks 端口..." + echo + echo -e " 当前 Socks 端口: ${cyan}$socks_port$none" + error + elif [ $lt_mtproto_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $mtproto_port ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 MTProto 端口..." + echo + echo -e " 当前 MTProto 端口: ${cyan}$mtproto_port$none" + error + else + echo + echo + echo -e "$yellow V2Ray 动态端口结束 = $cyan$v2ray_dynamic_port_end_input$none" + echo "----------------------------------------------------------------" + echo + break + fi + ;; + *) + error + ;; + esac + + done + +} +change_v2ray_dynamicport() { + if [[ $v2ray_transport -ge 18 ]]; then + change_v2ray_dynamic_port_start + change_v2ray_dynamic_port_end + pause + del_port "multiport" + open_port "multiport" + backup_config v2ray_dynamicPort_start v2ray_dynamicPort_end + port_range="${v2ray_dynamic_port_start_input}-${v2ray_dynamic_port_end_input}" + config + # clear + echo + echo -e "$green 动态端口修改成功啦...你不需要修改 V2Ray 客户端配置...保持原有的配置即可...$none" + echo + else + echo + echo -e "$red ...当前传输协议木有启用动态端口...$none" + echo + while :; do + echo -e "是否需要修改传输协议 [${magenta}Y/N$none]" + read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n + if [[ -z $y_n ]]; then + echo + echo -e "$green 已取消修改传输协议...$none" + echo + break + else + if [[ $y_n == [Yy] ]]; then + change_v2ray_transport + break + elif [[ $y_n == [Nn] ]]; then + echo + echo -e "$green 已取消修改传输协议...$none" + echo + break + else + error + fi + fi + done + + fi +} +change_v2ray_dynamic_port_start() { + echo + echo + while :; do + echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(当前动态开始端口: ${cyan}$v2ray_dynamicPort_start$none):")" v2ray_dynamic_port_start_input + [ -z $v2ray_dynamic_port_start_input ] && error && continue + case $v2ray_dynamic_port_start_input in + $v2ray_port) + echo + echo " 不能和 V2Ray 端口一毛一样...." + echo + echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}" + error + ;; + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + if [[ $shadowsocks && $v2ray_dynamic_port_start_input == $ssport ]]; then + echo + echo -e "抱歉, 此端口跟 Shadowsocks 端口冲突...当前 Shadowsocks 端口: ${cyan}$ssport$none" + error + elif [[ $socks && $v2ray_dynamic_port_start_input == $socks_port ]]; then + echo + echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none" + error + elif [[ $mtproto && $v2ray_dynamic_port_start_input == $mtproto_port ]]; then + echo + echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none" + error + else + echo + echo + echo -e "$yellow V2Ray 动态端口开始 = $cyan$v2ray_dynamic_port_start_input$none" + echo "----------------------------------------------------------------" + echo + break + fi + + ;; + *) + error + ;; + esac + + done + + if [[ $v2ray_dynamic_port_start_input -lt $v2ray_port ]]; then + lt_v2ray_port=true + fi + if [[ $shadowsocks ]] && [[ $v2ray_dynamic_port_start_input -lt $ssport ]]; then + lt_ssport=true + fi + if [[ $socks ]] && [[ $v2ray_dynamic_port_start_input -lt $socks_port ]]; then + lt_socks_port=true + fi + if [[ $mtproto ]] && [[ $v2ray_dynamic_port_start_input -lt $mtproto_port ]]; then + lt_mtproto_port=true + fi +} + +change_v2ray_dynamic_port_end() { + echo + while :; do + echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]" + read -p "$(echo -e "(当前动态结束端口: ${cyan}$v2ray_dynamicPort_end$none):")" v2ray_dynamic_port_end_input + [ -z $v2ray_dynamic_port_end_input ] && error && continue + case $v2ray_dynamic_port_end_input in + [1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + + if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then + echo + echo " 不能小于或等于 V2Ray 动态端口开始范围" + echo + echo -e " 当前 V2Ray 动态端口开始:${cyan}$v2ray_dynamic_port_start_input${none}" + error + elif [ $lt_v2ray_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $v2ray_port ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 V2Ray 端口..." + echo + echo -e " 当前 V2Ray 端口: ${cyan}$v2ray_port$none" + error + elif [ $lt_ssport ] && [[ ${v2ray_dynamic_port_end_input} -ge $ssport ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 Shadowsocks 端口..." + echo + echo -e " 当前 Shadowsocks 端口: ${cyan}$ssport$none" + error + elif [ $lt_socks_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $socks_port ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 Socks 端口..." + echo + echo -e " 当前 Socks 端口: ${cyan}$socks_port$none" + error + elif [ $lt_mtproto_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $mtproto_port ]]; then + echo + echo " V2Ray 动态端口结束范围 不能包括 MTProto 端口..." + echo + echo -e " 当前 MTProto 端口: ${cyan}$mtproto_port$none" + error + else + echo + echo + echo -e "$yellow V2Ray 动态端口结束 = $cyan$v2ray_dynamic_port_end_input$none" + echo "----------------------------------------------------------------" + echo + break + fi + ;; + *) + error + ;; + esac + + done + +} +change_v2ray_id() { + echo + while :; do + echo -e "是否确定要修改用户ID [${magenta}Y/N$none]" + read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n + if [[ -z $y_n ]]; then + echo + echo -e "$green 已取消修改用户ID...$none" + echo + break + else + if [[ $y_n == [Yy] ]]; then + echo + echo + echo -e "$yellow 修改用户ID = $cyan确定$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config uuid + v2ray_id=$uuid + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + break + elif [[ $y_n == [Nn] ]]; then + echo + echo -e "$green 已取消修改用户ID...$none" + echo + break + else + error + fi + fi + done +} +change_domain() { + if [[ $v2ray_transport == [45] ]] && [[ $caddy ]]; then + while :; do + echo + echo -e "请输入一个 $magenta正确的域名$none,一定一定一定要正确,不!能!出!错!" + read -p "$(echo -e "(当前域名: ${cyan}$domain$none):") " new_domain + [ -z "$new_domain" ] && error && continue + if [[ $new_domain == $domain ]]; then + echo + echo -e " 跟当前域名一毛一样啊...修改个鸡鸡哦" + echo + error && continue + fi + echo + echo + echo -e "$yellow 你的域名 = $cyan$new_domain$none" + echo "----------------------------------------------------------------" + break + done + get_ip + echo + echo + echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none" + echo + echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none" + echo + echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none" + echo "----------------------------------------------------------------" + echo + + while :; do + + read -p "$(echo -e "(是否已经正确解析: [${magenta}Y$none]):") " record + if [[ -z "$record" ]]; then + error + else + if [[ "$record" == [Yy] ]]; then + domain_check + echo + echo + echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none" + echo "----------------------------------------------------------------" + echo + pause + # domain_check + backup_config domain + domain=$new_domain + caddy_config + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + break + else + error + fi + fi + + done + else + echo + echo -e "$red 抱歉...不支持修改...$none" + echo + echo -e " 备注..修改 TLS 域名仅支持传输协议为 ${yellow}WebSocket + TLS$none 或 ${yellow}HTTP/2$none 并且$yellow 自动配置 TLS = 打开$none" + echo + echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}" + echo + if [[ $caddy ]]; then + echo -e " 自动配置 TLS = ${cyan}打开$none" + else + echo -e " 自动配置 TLS = $red关闭$none" + fi + echo + fi +} +change_path_config() { + if [[ $v2ray_transport == [45] ]] && [[ $caddy && $is_path ]]; then + echo + while :; do + echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可" + read -p "$(echo -e "(当前分流的路径: [${cyan}/${path}$none]):")" new_path + [[ -z $new_path ]] && error && continue + + case $new_path in + $path) + echo + echo -e " 大佬...跟 当前分流的路径 一毛一样啊...修改个鸡鸡哦 " + echo + error + ;; + *[/$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以分流的路径不能包含$red / $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 分流的路径 = ${cyan}/${new_path}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done + pause + backup_config path + path=$new_path + caddy_config + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + elif [[ $v2ray_transport == [45] ]] && [[ $caddy ]]; then + path_config_ask + if [[ $new_path ]]; then + backup_config +path + path=$new_path + proxy_site=$new_proxy_site + is_path=true + caddy_config + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + else + echo + echo + echo " 给大佬点赞....好果断的放弃配置 网站伪装 和 路径分流" + echo + echo + fi + else + echo + echo -e "$red 抱歉...不支持修改...$none" + echo + echo -e " 备注..修改 分流的路径 仅支持传输协议为 ${yellow}WebSocket + TLS$none 或 ${yellow}HTTP/2$none 并且$yellow 自动配置 TLS = 打开$none" + echo + echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}" + echo + if [[ $caddy ]]; then + echo -e " 自动配置 TLS = ${cyan}打开$none" + else + echo -e " 自动配置 TLS = $red关闭$none" + fi + echo + change_v2ray_transport_ask + fi + +} +change_proxy_site_config() { + if [[ $v2ray_transport == [45] ]] && [[ $caddy && $is_path ]]; then + echo + while :; do + echo -e "请输入 ${magenta}一个正确的$none ${cyan}网址$none 用来作为 ${cyan}网站的伪装$none , 例如 https://liyafly.com" + echo -e "举例...你当前的域名是$green $domain $none, 伪装的网址的是 https://liyafly.com" + echo -e "然后打开你的域名时候...显示出来的内容就是来自 https://liyafly.com 的内容" + echo -e "其实就是一个反代...明白就好..." + echo -e "如果不能伪装成功...可以使用 v2ray config 修改伪装的网址" + read -p "$(echo -e "(当前伪装的网址: [${cyan}${proxy_site}$none]):")" new_proxy_site + [[ -z $new_proxy_site ]] && error && continue + + case $new_proxy_site in + *[#$]*) + echo + echo -e " 由于这个脚本太辣鸡了..所以伪装的网址不能包含$red # $none或$red $ $none这两个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 伪装的网址 = ${cyan}${new_proxy_site}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done + pause + backup_config proxy_site + proxy_site=$new_proxy_site + caddy_config + echo + echo + echo " 哎哟...好像是修改成功了..." + echo + echo -e " 赶紧打开你的域名 ${cyan}https://${domain}$none 检查一下看看" + echo + echo + elif [[ $v2ray_transport == [45] ]] && [[ $caddy ]]; then + path_config_ask + if [[ $new_path ]]; then + backup_config +path + path=$new_path + proxy_site=$new_proxy_site + is_path=true + caddy_config + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + else + echo + echo + echo " 给大佬点赞....好果断的放弃配置 网站伪装 和 路径分流" + echo + echo + fi + else + echo + echo -e "$red 抱歉...不支持修改...$none" + echo + echo -e " 备注..修改 伪装的网址 仅支持传输协议为 ${yellow}WebSocket + TLS$none 或 ${yellow}HTTP/2$none 并且$yellow 自动配置 TLS = 打开$none" + echo + echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}" + echo + if [[ $caddy ]]; then + echo -e " 自动配置 TLS = ${cyan}打开$none" + else + echo -e " 自动配置 TLS = $red关闭$none" + fi + echo + change_v2ray_transport_ask + fi + +} +domain_check() { + # test_domain=$(dig $new_domain +short) + test_domain=$(ping $new_domain -c 1 | grep -oE -m1 "([0-9]{1,3}\.){3}[0-9]{1,3}") + if [[ $test_domain != $ip ]]; then + echo + echo -e "$red 检测域名解析错误....$none" + echo + echo -e " 你的域名: $yellow$new_domain$none 未解析到: $cyan$ip$none" + echo + echo -e " 你的域名当前解析到: $cyan$test_domain$none" + echo + echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 Status 那里点一下那图标..让它变灰" + echo + exit 1 + fi +} +disable_path() { + if [[ $v2ray_transport == [45] ]] && [[ $caddy && $is_path ]]; then + echo + + while :; do + echo -e "是否关闭 ${yellow}网站伪装 和 路径分流${none} [${magenta}Y/N$none]" + read -p "$(echo -e "(默认 [${cyan}N$none]):") " y_n + [[ -z "$y_n" ]] && y_n="n" + if [[ "$y_n" == [Yy] ]]; then + echo + echo + echo -e "$yellow 关闭 网站伪装 和 路径分流 = $cyan是$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config -path + is_path='' + caddy_config + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + break + elif [[ "$y_n" == [Nn] ]]; then + echo + echo -e " $green已取消关闭 网站伪装 和 路径分流 ....$none" + echo + break + else + error + fi + + done + else + echo + echo -e "$red 抱歉...不支持修改...$none" + echo + echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}" + echo + if [[ $caddy ]]; then + echo -e " 自动配置 TLS = ${cyan}打开$none" + else + echo -e " 自动配置 TLS = $red关闭$none" + fi + echo + if [[ $is_path ]]; then + echo -e " 路径分流 = ${cyan}打开$none" + else + echo -e " 路径分流 = $red关闭$none" + fi + echo + echo -e " 必须为 WebSocket + TLS 或 HTTP/2 传输协议, 自动配置 TLS = ${cyan}打开$none, 路径分流 = ${cyan}打开$none, 才能修改" + echo + + fi +} +blocked_hosts() { + if [[ $ban_ad ]]; then + local _info="$green已开启$none" + else + local _info="$red已关闭$none" + fi + _opt='' + while :; do + echo + echo -e "$yellow 1. $none开启 广告拦截" + echo + echo -e "$yellow 2. $none关闭 广告拦截" + echo + echo "备注: 广告拦截是基于 域名 拦截的..所以也许会造成浏览网页的时候出现部分元素留白..或者其他问题" + echo + echo "反馈问题或请求拦截更多域名: https://github.com/233boy/v2ray/issues" + echo + echo -e "当前广告拦截状态: $_info" + echo + read -p "$(echo -e "请选择 [${magenta}1-2$none]:")" _opt + if [[ -z $_opt ]]; then + error + else + case $_opt in + 1) + if [[ $ban_ad ]]; then + echo + echo -e " 大胸弟...难不成你没有看到 (当前广告拦截状态: $_info) 这个帅帅的提示么.....还开启个鸡鸡哦" + echo + else + echo + echo + echo -e "$yellow 广告拦截 = $cyan开启$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config +ad + ban_ad=true + config + echo + echo + echo -e "$green 广告拦截已开启...如果出现异常..那就关闭它咯$none" + echo + fi + break + ;; + 2) + if [[ $ban_ad ]]; then + echo + echo + echo -e "$yellow 广告拦截 = $cyan关闭$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config -ad + ban_ad='' + config + echo + echo + echo -e "$red 广告拦截已关闭...不过你也可以随时重新开启 ...只要你喜欢$none" + echo + else + echo + echo -e " 大胸弟...难不成你没有看到 (当前广告拦截状态: $_info) 这个帅帅的提示么.....还关闭个鸡鸡哦" + echo + fi + break + ;; + *) + error + ;; + esac + fi + done + +} +change_v2ray_alterId() { + echo + while :; do + echo -e "请输入 ${yellow}alterId${none} 的数值 [${magenta}0-65535$none]" + read -p "$(echo -e "(当前数值是: ${cyan}$alterId$none):") " new_alterId + [[ -z $new_alterId ]] && error && continue + case $new_alterId in + $alterId) + echo + echo -e " 大佬...跟 当前 alterId 一毛一样啊...修改个鸡鸡哦 " + echo + error + ;; + [0-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5]) + echo + echo + echo -e "$yellow alterId = $cyan$new_alterId$none" + echo "----------------------------------------------------------------" + echo + pause + backup_config alterId + alterId=$new_alterId + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + break + ;; + *) + error + ;; + esac + done +} + +custom_uuid() { + echo + while :; do + echo -e "请输入$yello自定义的 UUID$none...(${cyan}UUID 格式一定要对!!!$none)" + read -p "$(echo -e "(当前 UUID: ${cyan}${v2ray_id}$none)"): " myuuid + [ -z "$myuuid" ] && error && continue + case $myuuid in + $v2ray_id) + echo + echo -e " 大佬...跟 当前 UUID 一毛一样啊...修改个鸡鸡哦 " + echo + error + ;; + *[/$]* | *\&*) + echo + echo -e " 由于这个脚本太辣鸡了..所以 UUID 不能包含$red / $none或$red $ $none或$red & $none这三个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow UUID = $cyan$myuuid$none" + echo + echo -e " 如果 UUID 格式不正确.. V2Ray 会跪...使用$cyan v2ray reuuid$none 复活" + echo "----------------------------------------------------------------" + echo + pause + uuid=$myuuid + backup_config uuid + v2ray_id=$uuid + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + break + ;; + esac + done +} +v2ray_service() { + while :; do + echo + echo -e "$yellow 1. $none启动 V2Ray" + echo + echo -e "$yellow 2. $none停止 V2Ray" + echo + echo -e "$yellow 3. $none重启 V2Ray" + echo + echo -e "$yellow 4. $none查看访问日志" + echo + echo -e "$yellow 5. $none查看错误日志" + echo + read -p "$(echo -e "请选择 [${magenta}1-5$none]:")" _opt + if [[ -z $_opt ]]; then + error + else + case $_opt in + 1) + start_v2ray + break + ;; + 2) + stop_v2ray + break + ;; + 3) + restart_v2ray + break + ;; + 4) + view_v2ray_log + break + ;; + 5) + view_v2ray_error_log + break + ;; + *) + error + ;; + esac + fi + done +} +start_v2ray() { + if [[ $v2ray_pid ]]; then + echo + echo -e "${green} V2Ray 正在运行...无需再启动$none" + echo + else + + # systemctl start v2ray + service v2ray start >/dev/null 2>&1 + if [[ $? -ne 0 ]]; then + echo + echo -e "${red} V2Ray 启动失败!$none" + echo + else + echo + echo -e "${green} V2Ray 已启动$none" + echo + fi + + fi +} +stop_v2ray() { + if [[ $v2ray_pid ]]; then + # systemctl stop v2ray + service v2ray stop >/dev/null 2>&1 + echo + echo -e "${green} V2Ray 已停止$none" + echo + else + echo + echo -e "${red} V2Ray 没有在运行$none" + echo + fi +} +restart_v2ray() { + # systemctl restart v2ray + service v2ray restart >/dev/null 2>&1 + if [[ $? -ne 0 ]]; then + echo + echo -e "${red} V2Ray 重启失败!$none" + echo + else + echo + echo -e "${green} V2Ray 重启完成 $none" + echo + fi +} +view_v2ray_log() { + echo + echo -e "$green 按 Ctrl + C 即可退出...$none" + echo + tail -f /var/log/v2ray/access.log +} +view_v2ray_error_log() { + echo + echo -e "$green 按 Ctrl + C 即可退出...$none" + echo + tail -f /var/log/v2ray/error.log +} +download_v2ray_config() { + while :; do + echo + echo -e "$yellow 1. $none直接下载 V2Ray 客户端配置文件(仅支持 Xshell)" + echo + echo -e "$yellow 2. $none生成 V2Ray 客户端配置文件下载链接" + echo + echo -e "$yellow 3. $none生成 V2Ray 配置信息链接" + echo + echo -e "$yellow 4. $none生成 V2Ray 配置二维码链接" + echo + read -p "$(echo -e "请选择 [${magenta}1-4$none]:")" other_opt + if [[ -z $other_opt ]]; then + error + else + case $other_opt in + 1) + get_v2ray_config + break + ;; + 2) + get_v2ray_config_link + break + ;; + 3) + get_v2ray_config_info_link + break + ;; + 4) + get_v2ray_config_qr_link + break + ;; + *) + error + ;; + esac + fi + done +} +get_v2ray_config() { + config + echo + echo " 如果你当前使用的 SSH 客户端不是 Xshell 的话...下载 V2Ray 客户端配置文件将会出现卡死情况" + echo + while :; do + read -p "$(echo -e "不要BB...哥就是在使用 Xshell [${magenta}Y$none]:")" is_xshell + if [[ -z $is_xshell ]]; then + error + else + if [[ $is_xshell == [yY] ]]; then + echo + echo "开始下载....请选择 V2Ray 客户端配置文件保存位置" + echo + # sz /etc/v2ray/233blog_v2ray.zip + local tmpfile="/tmp/233blog_v2ray_config_$RANDOM.json" + cp -f $v2ray_client_config $tmpfile + sz $tmpfile + echo + echo + echo -e "$green 下载完成咯...$none" + echo + # echo -e "$yellow 解压密码 = ${cyan}233blog.com$none" + # echo + echo -e "$yellow SOCKS 监听端口 = ${cyan}2333${none}" + echo + echo -e "${yellow} HTTP 监听端口 = ${cyan}6666$none" + echo + echo "V2Ray 客户端使用教程: https://v2ray6.com/post/4/" + echo + break + else + error + fi + fi + done + [[ -f $tmpfile ]] && rm -rf $tmpfile + +} +get_v2ray_config_link() { + echo + echo -e "$green 正在生成链接.... 稍等片刻即可....$none" + echo + local random=$(echo $RANDOM-$RANDOM-$RANDOM | base64 -w 0) + local link=$(curl -s --upload-file $v2ray_client_config "https://transfer.sh/${random}_v2ray6_v2ray.json") + if [[ $link ]]; then + echo + echo "---------- V2Ray 客户端配置文件链接 -------------" + echo + echo -e "$yellow 链接 = $cyan$link$none" + echo + echo -e "$yellow SOCKS 监听端口 = ${cyan}2333${none}" + echo + echo -e "${yellow} HTTP 监听端口 = ${cyan}6666$none" + echo + echo " V2Ray 客户端使用教程: https://v2ray6.com/post/4/" + echo + echo "备注...链接将在 14 天后失效" + echo + echo "提醒...请不要把链接分享出去...除非你有特别的理由...." + echo + else + echo + echo -e "$red 哎呀呀呀...出错咯...请重试$none" + echo + fi +} +create_v2ray_config_text() { + + get_transport_args + + echo + echo + echo "---------- V2Ray 配置信息 -------------" + if [[ $v2ray_transport == [45] ]]; then + if [[ ! $caddy ]]; then + echo + echo " 警告!请自行配置 TLS...教程: https://v2ray6.com/post/3/" + fi + echo + echo "地址 (Address) = ${domain}" + echo + echo "端口 (Port) = 443" + echo + echo "用户ID (User ID / UUID) = ${v2ray_id}" + echo + echo "额外ID (Alter Id) = ${alterId}" + echo + echo "传输协议 (Network) = ${net}" + echo + echo "伪装类型 (header type) = ${header}" + echo + echo "伪装域名 (host) = ${domain}" + echo + echo "路径 (path) = ${_path}" + echo + echo "TLS (Enable TLS) = 打开" + echo + if [[ $ban_ad ]]; then + echo " 备注: 广告拦截已开启.." + echo + fi + else + [[ -z $ip ]] && get_ip + echo + echo "地址 (Address) = ${ip}" + echo + echo "端口 (Port) = $v2ray_port" + echo + echo "用户ID (User ID / UUID) = ${v2ray_id}" + echo + echo "额外ID (Alter Id) = ${alterId}" + echo + echo "传输协议 (Network) = ${net}" + echo + echo "伪装类型 (header type) = ${header}" + echo + fi + if [[ $v2ray_transport -ge 18 ]] && [[ $ban_ad ]]; then + echo "备注: 动态端口已启用...广告拦截已开启..." + echo + elif [[ $v2ray_transport -ge 18 ]]; then + echo "备注: 动态端口已启用..." + echo + elif [[ $ban_ad ]]; then + echo "备注: 广告拦截已开启.." + echo + fi + echo "---------- END -------------" + echo + echo "V2Ray 客户端使用教程: https://v2ray6.com/post/4/" + echo +} +get_v2ray_config_info_link() { + echo + echo -e "$green 正在生成链接.... 稍等片刻即可....$none" + echo + create_v2ray_config_text >/tmp/233blog_v2ray.txt + local random=$(echo $RANDOM-$RANDOM-$RANDOM | base64 -w 0) + local link=$(curl -s --upload-file /tmp/233blog_v2ray.txt "https://transfer.sh/${random}_v2ray6_v2ray.txt") + if [[ $link ]]; then + echo + echo "---------- V2Ray 配置信息链接-------------" + echo + echo -e "$yellow 链接 = $cyan$link$none" + echo + echo -e " V2Ray 客户端使用教程: https://v2ray6.com/post/4/" + echo + echo "备注...链接将在 14 天后失效..." + echo + echo "提醒...请不要把链接分享出去...除非你有特别的理由...." + echo + else + echo + echo -e "$red 哎呀呀呀...出错咯...请重试$none" + echo + fi + rm -rf /tmp/233blog_v2ray.txt +} +get_v2ray_config_qr_link() { + + create_vmess_URL_config + + echo + echo -e "$green 正在生成链接.... 稍等片刻即可....$none" + echo + local vmess="vmess://$(cat /etc/v2ray/vmess_qr.json | tr -d '\n' | base64 -w 0)" + echo $vmess | tr -d '\n' >/etc/v2ray/vmess.txt + cat /etc/v2ray/vmess.txt | qrencode -s 50 -o /tmp/233blog_v2ray.png + local random=$(echo $RANDOM-$RANDOM-$RANDOM | base64 -w 0) + local link=$(curl -s --upload-file /tmp/233blog_v2ray.png "https://transfer.sh/${random}_v2ray6_v2ray.png") + if [[ $link ]]; then + echo + echo "---------- V2Ray 二维码链接 -------------" + echo + echo -e "$yellow 适用于 V2RayNG v0.4.1+ / Kitsunebi = $cyan$link$none" + echo + echo + echo -e "$red 友情提醒: 请务必核对扫码结果 (V2RayNG 除外) $none" + echo + echo + echo " V2Ray 客户端使用教程: https://v2ray6.com/post/4/" + echo + echo "备注...链接将在 14 天后失效" + echo + echo "提醒...请不要把链接分享出去...除非你有特别的理由...." + echo + else + echo + echo -e "$red 哎呀呀呀...出错咯...$none" + echo + echo -e "请尝试使用${cyan} v2ray qr ${none}重新生成" + echo + fi + rm -rf /tmp/233blog_v2ray.png + rm -rf /etc/v2ray/vmess_qr.json + rm -rf /etc/v2ray/vmess.txt +} +get_v2ray_vmess_URL_link() { + create_vmess_URL_config + local vmess="vmess://$(cat /etc/v2ray/vmess_qr.json | base64 -w 0)" + echo + echo "---------- V2Ray vmess URL / V2RayNG v0.4.1+ / V2RayN v2.1+ / 仅适合部分客户端 -------------" + echo + echo -e ${cyan}$vmess${none} + echo + rm -rf /etc/v2ray/vmess_qr.json +} +other() { + while :; do + echo + echo -e "$yellow 1. $none安装 BBR" + echo + echo -e "$yellow 2. $none安装 LotServer(锐速)" + echo + echo -e "$yellow 3. $none卸载 LotServer(锐速)" + echo + read -p "$(echo -e "请选择 [${magenta}1-3$none]:")" _opt + if [[ -z $_opt ]]; then + error + else + case $_opt in + 1) + install_bbr + break + ;; + 2) + install_lotserver + break + ;; + 3) + uninstall_lotserver + break + ;; + *) + error + ;; + esac + fi + done +} +install_bbr() { + local test1=$(sed -n '/net.ipv4.tcp_congestion_control/p' /etc/sysctl.conf) + local test2=$(sed -n '/net.core.default_qdisc/p' /etc/sysctl.conf) + if [[ $(uname -r | cut -b 1) -eq 4 ]]; then + case $(uname -r | cut -b 3-4) in + 9. | [1-9][0-9]) + if [[ $test1 == "net.ipv4.tcp_congestion_control = bbr" && $test2 == "net.core.default_qdisc = fq" ]]; then + local is_bbr=true + else + local try_enable_bbr=true + fi + ;; + esac + fi + if [[ $is_bbr ]]; then + echo + echo -e "$green BBR 已经启用啦...无需再安装$none" + echo + elif [[ $try_enable_bbr ]]; then + sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf + sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf + echo "net.ipv4.tcp_congestion_control = bbr" >>/etc/sysctl.conf + echo "net.core.default_qdisc = fq" >>/etc/sysctl.conf + sysctl -p >/dev/null 2>&1 + echo + echo -e "$green ..由于你的 VPS 内核支持开启 BBR ...已经为你启用 BBR 优化....$none" + echo + else + # https://teddysun.com/489.html + bash <(curl -s -L https://github.com/teddysun/across/raw/master/bbr.sh) + fi +} +install_lotserver() { + # https://moeclub.org/2017/03/08/14/ + wget --no-check-certificate -qO /tmp/appex.sh "https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh" + bash /tmp/appex.sh 'install' + rm -rf /tmp/appex.sh +} +uninstall_lotserver() { + # https://moeclub.org/2017/03/08/14/ + wget --no-check-certificate -qO /tmp/appex.sh "https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh" + bash /tmp/appex.sh 'uninstall' + rm -rf /tmp/appex.sh +} + +open_port() { + if [[ $cmd == "apt-get" ]]; then + if [[ $1 != "multiport" ]]; then + # if [[ $cmd == "apt-get" ]]; then + iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT + iptables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT + ip6tables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT + ip6tables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT + + # iptables-save >/etc/iptables.rules.v4 + # ip6tables-save >/etc/iptables.rules.v6 + # else + # firewall-cmd --permanent --zone=public --add-port=$1/tcp + # firewall-cmd --permanent --zone=public --add-port=$1/udp + # firewall-cmd --reload + # fi + else + # if [[ $cmd == "apt-get" ]]; then + local multiport="${v2ray_dynamic_port_start_input}:${v2ray_dynamic_port_end_input}" + iptables -I INPUT -p tcp --match multiport --dports $multiport -j ACCEPT + iptables -I INPUT -p udp --match multiport --dports $multiport -j ACCEPT + ip6tables -I INPUT -p tcp --match multiport --dports $multiport -j ACCEPT + ip6tables -I INPUT -p udp --match multiport --dports $multiport -j ACCEPT + + # iptables-save >/etc/iptables.rules.v4 + # ip6tables-save >/etc/iptables.rules.v6 + # else + # local multi_port="${v2ray_dynamic_port_start_input}-${v2ray_dynamic_port_end_input}" + # firewall-cmd --permanent --zone=public --add-port=$multi_port/tcp + # firewall-cmd --permanent --zone=public --add-port=$multi_port/udp + # firewall-cmd --reload + # fi + fi + iptables-save >/etc/iptables.rules.v4 + ip6tables-save >/etc/iptables.rules.v6 + # else + # service iptables save >/dev/null 2>&1 + # service ip6tables save >/dev/null 2>&1 + fi + +} +del_port() { + if [[ $cmd == "apt-get" ]]; then + if [[ $1 != "multiport" ]]; then + # if [[ $cmd == "apt-get" ]]; then + iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT + iptables -D INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT + ip6tables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT + ip6tables -D INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT + # else + # firewall-cmd --permanent --zone=public --remove-port=$1/tcp + # firewall-cmd --permanent --zone=public --remove-port=$1/udp + # fi + else + # if [[ $cmd == "apt-get" ]]; then + local ports="${v2ray_dynamicPort_start}:${v2ray_dynamicPort_end}" + iptables -D INPUT -p tcp --match multiport --dports $ports -j ACCEPT + iptables -D INPUT -p udp --match multiport --dports $ports -j ACCEPT + ip6tables -D INPUT -p tcp --match multiport --dports $ports -j ACCEPT + ip6tables -D INPUT -p udp --match multiport --dports $ports -j ACCEPT + # else + # local ports="${v2ray_dynamicPort_start}-${v2ray_dynamicPort_end}" + # firewall-cmd --permanent --zone=public --remove-port=$ports/tcp + # firewall-cmd --permanent --zone=public --remove-port=$ports/udp + # fi + fi + iptables-save >/etc/iptables.rules.v4 + ip6tables-save >/etc/iptables.rules.v6 + # else + # service iptables save >/dev/null 2>&1 + # service ip6tables save >/dev/null 2>&1 + fi +} +update() { + while :; do + echo + echo -e "$yellow 1. $none更新 V2Ray 主程序" + echo + echo -e "$yellow 2. $none更新 V2Ray 管理脚本" + echo + read -p "$(echo -e "请选择 [${magenta}1-2$none]:")" _opt + if [[ -z $_opt ]]; then + error + else + case $_opt in + 1) + update_v2ray + break + ;; + 2) + update_v2ray.sh + exit + break + ;; + *) + error + ;; + esac + fi + done +} +update_v2ray() { + _load download-v2ray.sh + _update_v2ray_version +} +update_v2ray.sh() { + if [[ $_test ]]; then + local latest_version=$(curl -H 'Cache-Control: no-cache' -s -L "https://raw.githubusercontent.com/233boy/v2ray/test/v2ray.sh" | grep '_version' -m1 | cut -d\" -f2) + else + local latest_version=$(curl -H 'Cache-Control: no-cache' -s -L "https://raw.githubusercontent.com/233boy/v2ray/master/v2ray.sh" | grep '_version' -m1 | cut -d\" -f2) + fi + + if [[ ! $latest_version ]]; then + echo + echo -e " $red获取 V2Ray 最新版本失败!!!$none" + echo + echo -e " 请尝试执行如下命令: $green echo 'nameserver 8.8.8.8' >/etc/resolv.conf $none" + echo + echo " 然后再继续...." + echo + exit 1 + fi + + if [[ $latest_version == $_version ]]; then + echo + echo -e "$green 木有发现新版本 $none" + echo + else + echo + echo -e " $green 咦...发现新版本耶....正在拼命更新.......$none" + echo + cd /etc/v2ray/233boy/v2ray + git pull + cp -f /etc/v2ray/233boy/v2ray/v2ray.sh $_v2ray_sh + chmod +x $_v2ray_sh + echo + echo -e "$green 更新成功啦...当前 V2Ray 管理脚本 版本: ${cyan}$latest_version$none" + echo + fi + +} +uninstall_v2ray() { + _load uninstall.sh +} +config() { + _load config.sh + + if [[ $v2ray_port == "80" ]]; then + if [[ $cmd == "yum" ]]; then + [[ $(pgrep "httpd") ]] && systemctl stop httpd >/dev/null 2>&1 + [[ $(command -v httpd) ]] && yum remove httpd -y >/dev/null 2>&1 + else + [[ $(pgrep "apache2") ]] && service apache2 stop >/dev/null 2>&1 + [[ $(command -v apache2) ]] && apt-get remove apache2* -y >/dev/null 2>&1 + fi + fi + do_service restart v2ray +} +backup_config() { + for keys in $*; do + case $keys in + v2ray_transport) + sed -i "18s/=$v2ray_transport/=$v2ray_transport_opt/" $backup + ;; + v2ray_port) + sed -i "21s/=$v2ray_port/=$v2ray_port_opt/" $backup + ;; + uuid) + sed -i "24s/=$v2ray_id/=$uuid/" $backup + ;; + alterId) + sed -i "27s/=$alterId/=$new_alterId/" $backup + ;; + v2ray_dynamicPort_start) + sed -i "30s/=$v2ray_dynamicPort_start/=$v2ray_dynamic_port_start_input/" $backup + ;; + v2ray_dynamicPort_end) + sed -i "33s/=$v2ray_dynamicPort_end/=$v2ray_dynamic_port_end_input/" $backup + ;; + domain) + sed -i "36s/=$domain/=$new_domain/" $backup + ;; + caddy) + sed -i "39s/=/=true/" $backup + ;; + +ss) + sed -i "42s/=/=true/; 45s/=$ssport/=$new_ssport/; 48s/=$sspass/=$new_sspass/; 51s/=$ssciphers/=$new_ssciphers/" $backup + ;; + -ss) + sed -i "42s/=true/=/" $backup + ;; + ssport) + sed -i "45s/=$ssport/=$new_ssport/" $backup + ;; + sspass) + sed -i "48s/=$sspass/=$new_sspass/" $backup + ;; + ssciphers) + sed -i "51s/=$ssciphers/=$new_ssciphers/" $backup + ;; + +ad) + sed -i "54s/=/=true/" $backup + ;; + -ad) + sed -i "54s/=true/=/" $backup + ;; + +path) + sed -i "57s/=/=true/; 60s/=$path/=$new_path/; 63s#=$proxy_site#=$new_proxy_site#" $backup + ;; + -path) + sed -i "57s/=true/=/" $backup + ;; + path) + sed -i "60s/=$path/=$new_path/" $backup + ;; + proxy_site) + sed -i "63s#=$proxy_site#=$new_proxy_site#" $backup + ;; + +socks) + sed -i "66s/=/=true/; 69s/=$socks_port/=$new_socks_port/; 72s/=$socks_username/=$new_socks_username/; 75s/=$socks_userpass/=$new_socks_userpass/;" $backup + ;; + -socks) + sed -i "66s/=true/=/" $backup + ;; + socks_port) + sed -i "69s/=$socks_port/=$new_socks_port/" $backup + ;; + socks_username) + sed -i "72s/=$socks_username/=$new_socks_username/" $backup + ;; + socks_userpass) + sed -i "75s/=$socks_userpass/=$new_socks_userpass/" $backup + ;; + +mtproto) + sed -i "78s/=/=true/; 81s/=$mtproto_port/=$new_mtproto_port/; 84s/=$mtproto_secret/=$new_mtproto_secret/" $backup + ;; + -mtproto) + sed -i "78s/=true/=/" $backup + ;; + mtproto_port) + sed -i "81s/=$mtproto_port/=$new_mtproto_port/" $backup + ;; + mtproto_secret) + sed -i "84s/=$mtproto_secret/=$new_mtproto_secret/" $backup + ;; + +bt) + sed -i "87s/=/=true/" $backup + ;; + -bt) + sed -i "87s/=true/=/" $backup + ;; + esac + done + +} + +get_ip() { + ip=$(curl -s https://ipinfo.io/ip) + [[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip) + [[ -z $ip ]] && ip=$(curl -s https://api.ipify.org) + [[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org) + [[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/ip) + [[ -z $ip ]] && ip=$(curl -s https://api.myip.com | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") + [[ -z $ip ]] && ip=$(curl -s icanhazip.com) + [[ -z $ip ]] && ip=$(curl -s myip.ipip.net | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") + [[ -z $ip ]] && echo -e "\n$red 这垃圾小鸡扔了吧!$none\n" && exit +} + +error() { + + echo -e "\n$red 输入错误!$none\n" + +} + +pause() { + + read -rsp "$(echo -e "按$green Enter 回车键 $none继续....或按$red Ctrl + C $none取消.")" -d $'\n' + echo +} +do_service() { + if [[ $systemd ]]; then + systemctl $1 $2 + else + service $2 $1 + fi +} +_help() { + echo + echo "........... V2Ray 管理脚本帮助信息 by v2ray6.com .........." + echo -e " + ${green}v2ray menu $none管理 V2Ray (同等于直接输入 v2ray) + + ${green}v2ray info $none查看 V2Ray 配置信息 + + ${green}v2ray config $none修改 V2Ray 配置 + + ${green}v2ray link $none生成 V2Ray 客户端配置文件链接 + + ${green}v2ray textlink $none生成 V2Ray 配置信息链接 + + ${green}v2ray qr $none生成 V2Ray 配置二维码链接 + + ${green}v2ray ss $none修改 Shadowsocks 配置 + + ${green}v2ray ssinfo $none查看 Shadowsocks 配置信息 + + ${green}v2ray ssqr $none生成 Shadowsocks 配置二维码链接 + + ${green}v2ray status $none查看 V2Ray 运行状态 + + ${green}v2ray start $none启动 V2Ray + + ${green}v2ray stop $none停止 V2Ray + + ${green}v2ray restart $none重启 V2Ray + + ${green}v2ray log $none查看 V2Ray 运行日志 + + ${green}v2ray update $none更新 V2Ray + + ${green}v2ray update.sh $none更新 V2Ray 管理脚本 + + ${green}v2ray uninstall $none卸载 V2Ray +" +} +menu() { + clear + while :; do + echo + echo "........... V2Ray 管理脚本 $_version by v2ray6.com .........." + echo + echo -e "## V2Ray 版本: $cyan$v2ray_ver$none / V2Ray 状态: $v2ray_status ##" + echo + echo "帮助说明: https://v2ray6.com/post/1/" + echo + echo "反馈问题: https://github.com/233boy/v2ray/issues" + echo + echo "TG 群组: https://t.me/blog233" + echo + echo "捐赠脚本作者: https://v2ray6.com/donate/" + echo + echo "捐助 V2Ray: https://www.v2ray.com/chapter_00/02_donate.html" + echo + echo -e "$yellow 1. $none查看 V2Ray 配置" + echo + echo -e "$yellow 2. $none修改 V2Ray 配置" + echo + echo -e "$yellow 3. $none下载 V2Ray 配置 / 生成配置信息链接 / 生成二维码链接" + echo + echo -e "$yellow 4. $none查看 Shadowsocks 配置 / 生成二维码链接" + echo + echo -e "$yellow 5. $none修改 Shadowsocks 配置" + echo + echo -e "$yellow 6. $none查看 MTProto 配置 / 修改 MTProto 配置" + echo + echo -e "$yellow 7. $none查看 Socks5 配置 / 修改 Socks5 配置" + echo + echo -e "$yellow 8. $none启动 / 停止 / 重启 / 查看日志" + echo + echo -e "$yellow 9. $none更新 V2Ray / 更新 V2Ray 管理脚本" + echo + echo -e "$yellow 10. $none卸载 V2Ray" + echo + echo -e "$yellow 11. $none其他" + echo + echo -e "温馨提示...如果你不想执行选项...按$yellow Ctrl + C $none即可退出" + echo + read -p "$(echo -e "请选择菜单 [${magenta}1-9$none]:")" choose + if [[ -z $choose ]]; then + exit 1 + else + case $choose in + 1) + view_v2ray_config_info + break + ;; + 2) + change_v2ray_config + break + ;; + 3) + download_v2ray_config + break + ;; + 4) + get_shadowsocks_config + break + ;; + 5) + change_shadowsocks_config + break + ;; + 6) + _load mtproto.sh + _mtproto_main + break + ;; + 7) + _load socks.sh + _socks_main + break + ;; + 8) + v2ray_service + break + ;; + 9) + update + break + ;; + 10) + uninstall_v2ray + break + ;; + 11) + other + break + ;; + *) + error + ;; + esac + fi + done +} +args=$1 +[ -z $1 ] && args="menu" +case $args in +menu) + menu + ;; +i | info) + view_v2ray_config_info + ;; +c | config) + change_v2ray_config + ;; +l | link) + get_v2ray_config_link + ;; +L | infolink) + get_v2ray_config_info_link + ;; +q | qr) + get_v2ray_config_qr_link + ;; +s | ss) + change_shadowsocks_config + ;; +S | ssinfo) + view_shadowsocks_config_info + ;; +Q | ssqr) + get_shadowsocks_config_qr_link + ;; +socks) + _load socks.sh + _socks_main + ;; +socksinfo) + _load socks.sh + _view_socks_info + ;; +tg) + _load mtproto.sh + _mtproto_main + ;; +tginfo) + _load mtproto.sh + _view_mtproto_info + ;; +bt) + _load bt.sh + _ban_bt_main + ;; +status) + echo + if [[ $v2ray_transport == [45] && $caddy ]]; then + echo -e " V2Ray 状态: $v2ray_status / Caddy 状态: $caddy_run_status" + else + echo -e " V2Ray 状态: $v2ray_status" + fi + echo + ;; +start) + start_v2ray + ;; +stop) + stop_v2ray + ;; +restart) + [[ $v2ray_transport == [45] && $caddy ]] && do_service restart caddy + restart_v2ray + ;; +reload) + config + [[ $v2ray_transport == [45] && $caddy ]] && caddy_config + clear + view_v2ray_config_info + ;; +time) + date -s "$(curl -sI g.cn | grep Date | cut -d' ' -f3-6)Z" + ;; +log) + view_v2ray_log + ;; +url | URL) + get_v2ray_vmess_URL_link + ;; +u | update) + update_v2ray + ;; +U | update.sh) + update_v2ray.sh + exit + ;; +un | uninstall) + uninstall_v2ray + ;; +reinstall) + uninstall_v2ray + if [[ $is_uninstall_v2ray ]]; then + cd + cd - >/dev/null 2>&1 + bash <(curl -s -L https://git.io/v2ray.sh) + fi + ;; +[aA][Ii] | [Dd]) + change_v2ray_alterId + ;; +[aA][Ii][aA][Ii] | [Dd][Dd]) + custom_uuid + ;; +reuuid) + backup_config uuid + v2ray_id=$uuid + config + clear + view_v2ray_config_info + # download_v2ray_config_ask + ;; +v | version) + echo + echo -e " 当前 V2Ray 版本: ${green}$v2ray_ver$none / 当前 V2Ray 管理脚本版本: ${cyan}$_version$none" + echo + ;; +bbr) + other + ;; +help | *) + _help + ;; +esac