2023-11-18 08:15:25 Auto Sync

This commit is contained in:
WindyMadman 2023-11-18 08:15:26 +00:00
parent 41ef103432
commit 50b55fed17
410 changed files with 290695 additions and 0 deletions

674
chinadns-ng/LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
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:
<program> Copyright (C) <year> <name of author>
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
<https://www.gnu.org/licenses/>.
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
<https://www.gnu.org/licenses/why-not-lgpl.html>.

75
chinadns-ng/Makefile Normal file
View File

@ -0,0 +1,75 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=chinadns-ng
PKG_VERSION:=2023.10.28
PKG_RELEASE:=42
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/zfl9/chinadns-ng.git
PKG_SOURCE_VERSION:=66426e2da2c9e34d70f25a5adf5cb3f588556f41
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_SOURCE_SUBDIR)
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=pexcn <pexcn97@gmail.com>
include $(INCLUDE_DIR)/package.mk
define Package/chinadns-ng
SECTION:=net
CATEGORY:=Network
TITLE:=ChinaDNS Next Generation, refactoring with epoll and ipset
URL:=https://github.com/zfl9/chinadns-ng
DEPENDS:=+ipset
endef
define Package/chinadns-ng/description
ChinaDNS Next Generation, refactoring with epoll and ipset.
endef
define Package/chinadns-ng/conffiles
/etc/config/chinadns-ng
/etc/chinadns-ng/chnroute.txt
/etc/chinadns-ng/chnroute6.txt
/etc/chinadns-ng/gfwlist.txt
/etc/chinadns-ng/chinalist.txt
endef
MAKE_FLAGS += STATIC=1
define Package/chinadns-ng/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/chinadns-ng $(1)/usr/bin
$(INSTALL_BIN) files/chinadns-ng-daily.sh $(1)/usr/bin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) files/chinadns-ng.init $(1)/etc/init.d/chinadns-ng
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) files/chinadns-ng.config $(1)/etc/config/chinadns-ng
$(INSTALL_DIR) $(1)/etc/chinadns-ng
$(INSTALL_DATA) files/chnroute.txt $(1)/etc/chinadns-ng
$(INSTALL_DATA) files/chnroute6.txt $(1)/etc/chinadns-ng
$(INSTALL_DATA) files/gfwlist.txt $(1)/etc/chinadns-ng
$(INSTALL_DATA) files/chinalist.txt $(1)/etc/chinadns-ng
endef
define Package/chinadns-ng/postinst
#!/bin/sh
if ! crontab -l | grep -q "chinadns-ng"; then
(crontab -l; echo -e "# chinadns-ng\n10 3 * * * /usr/bin/chinadns-ng-daily.sh") | crontab -
fi
exit 0
endef
define Package/chinadns-ng/postrm
#!/bin/sh
rmdir --ignore-fail-on-non-empty /etc/chinadns-ng
(crontab -l | grep -v "chinadns-ng") | crontab -
exit 0
endef
$(eval $(call BuildPackage,chinadns-ng))

53
chinadns-ng/README.md Normal file
View File

@ -0,0 +1,53 @@
# ChinaDNS Next Generation for OpenWrt
## 简介
本项目是 [chinadns-ng](https://github.com/zfl9/chinadns-ng) 在 OpenWrt 上的移植。
## 编译
从 OpenWrt 的 [SDK](https://openwrt.org/docs/guide-developer/obtain.firmware.sdk) 编译
```bash
cd openwrt-sdk
# 获取源码
git clone https://github.com/pexcn/openwrt-chinadns-ng.git package/chinadns-ng
# 选中 Network -> chinadns-ng
make menuconfig
# 编译 chinadns-ng
make package/chinadns-ng/{clean,compile} V=s
```
## 配置
配置文件位于 `/etc/config/chinadns-ng`, 详细的解释见: [命令选项](https://github.com/zfl9/chinadns-ng#%E5%91%BD%E4%BB%A4%E9%80%89%E9%A1%B9)
## 发布
https://github.com/openwrt-dev/feeds
## 鸣谢
- [@zfl9/chinadns-ng](https://github.com/zfl9/chinadns-ng)
- [@aa65535/openwrt-chinadns](https://github.com/aa65535/openwrt-chinadns)
## 许可证
```
Copyright (C) 2019-2023, pexcn <pexcn97@gmail.com>
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 <http://www.gnu.org/licenses/>.
```

View File

@ -0,0 +1,19 @@
#!/bin/sh -e
[ -d /etc/chinadns-ng ] || mkdir /etc/chinadns-ng
wget https://raw.githubusercontent.com/pexcn/daily/gh-pages/chnroute/chnroute.txt -O /etc/chinadns-ng/chnroute.tmp
mv -f /etc/chinadns-ng/chnroute.tmp /etc/chinadns-ng/chnroute.txt
wget https://raw.githubusercontent.com/pexcn/daily/gh-pages/chnroute/chnroute6.txt -O /etc/chinadns-ng/chnroute6.tmp
mv -f /etc/chinadns-ng/chnroute6.tmp /etc/chinadns-ng/chnroute6.txt
wget https://raw.githubusercontent.com/pexcn/daily/gh-pages/gfwlist/gfwlist.txt -O /etc/chinadns-ng/gfwlist.tmp
mv -f /etc/chinadns-ng/gfwlist.tmp /etc/chinadns-ng/gfwlist.txt
#sed -n -i '1,100p' /etc/chinadns-ng/gfwlist.txt
wget https://raw.githubusercontent.com/pexcn/daily/gh-pages/chinalist/chinalist.txt -O /etc/chinadns-ng/chinalist.tmp
mv -f /etc/chinadns-ng/chinalist.tmp /etc/chinadns-ng/chinalist.txt
#sed -n -i '1,100p' /etc/chinadns-ng/chinalist.txt
/etc/init.d/chinadns-ng restart

View File

@ -0,0 +1,22 @@
config chinadns-ng
option enable '0'
option bind_addr '0.0.0.0'
option bind_port '5353'
option china_dns '223.5.5.5,119.29.29.29'
option trust_dns '8.8.8.8,8.8.4.4'
option chnlist_file '/etc/chinadns-ng/chinalist.txt'
option gfwlist_file '/etc/chinadns-ng/gfwlist.txt'
option chnlist_first '0'
option default_tag 'none'
option add_tagchn_ip '0'
option add_taggfw_ip '0'
option ipset_name4 'chnroute'
option ipset_name6 'chnroute6'
option no_ipv6 '0'
option timeout_sec '3'
option repeat_times '2'
option noip_as_chnip '0'
option reuse_port '1'
option verbose '0'

View File

@ -0,0 +1,183 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2019-2023 pexcn <pexcn97@gmail.com>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
# shellcheck disable=SC2155,SC3043,SC2034
START=99
USE_PROCD=1
#PROCD_DEBUG=1
append_param() {
local section="$1"
local option="$2"
local switch="$3"
local default="$4"
local _loctmp
config_get _loctmp "$section" "$option" "$default"
[ -n "$_loctmp" ] || return 0
procd_append_param command "$switch" "$_loctmp"
}
append_bool() {
local section="$1"
local option="$2"
local value="$3"
local default="$4"
local _loctmp
config_get_bool _loctmp "$section" "$option" "$default"
[ "$_loctmp" = 1 ] || return 0
procd_append_param command "$value"
}
append_param_if_neq() {
local section="$1"
local option="$2"
local switch="$3"
local compare="$4"
local _loctmp
config_get _loctmp "$section" "$option"
[ -n "$_loctmp" ] || return 0
[ "$_loctmp" != "$compare" ] || return 0
procd_append_param command "$switch" "$_loctmp"
}
append_param_with_val() {
local section="$1"
local option="$2"
local switch="$3"
local _loctmp
config_get _loctmp "$section" "$option"
[ -n "$_loctmp" ] || return 0
[ "$_loctmp" != 0 ] || return 0
if [ "$_loctmp" = 1 ]; then
procd_append_param command "$switch"
else
procd_append_param command "$switch" "$_loctmp"
fi
}
get_cpu_cores() {
grep -c "^processor" /proc/cpuinfo
}
is_exist_ipset() {
ipset list -n "$1" >/dev/null 2>&1
}
destroy_ipset() {
ipset flush "$1" 2>/dev/null
ipset destroy "$1" 2>/dev/null
}
create_chnroute_ipset() {
local enable
config_get_bool enable "$1" enable
[ "$enable" = 1 ] || return 0
config_foreach create_ipv4_ipset chinadns-ng
config_foreach create_ipv6_ipset chinadns-ng
}
create_ipv4_ipset() {
local ipset_name
config_get ipset_name "$1" "ipset_name4" "chnroute"
if is_exist_ipset "$ipset_name"; then
ipset flush "$ipset_name"
else
ipset create "$ipset_name" hash:net hashsize 64 family inet
fi
ipset restore <<-EOF
$(sed "s/^/add $ipset_name /" </etc/chinadns-ng/chnroute.txt)
EOF
}
create_ipv6_ipset() {
local ipset_name
config_get ipset_name "$1" "ipset_name6" "chnroute6"
if is_exist_ipset "$ipset_name"; then
ipset flush "$ipset_name"
else
ipset create "$ipset_name" hash:net hashsize 64 family inet6
fi
ipset restore <<-EOF
$(sed "s/^/add $ipset_name /" </etc/chinadns-ng/chnroute6.txt)
EOF
}
destroy_chnroute_ipset() {
# force destroy, even though does not exist or config file changed
config_foreach destroy_ipv4_ipset chinadns-ng
config_foreach destroy_ipv6_ipset chinadns-ng
}
destroy_ipv4_ipset() {
local ipset_name
config_get ipset_name "$1" "ipset_name4" "chnroute"
destroy_ipset "$ipset_name"
}
destroy_ipv6_ipset() {
local ipset_name
config_get ipset_name "$1" "ipset_name6" "chnroute6"
destroy_ipset "$ipset_name"
}
start_chinadns_ng() {
local enable
config_get_bool enable "$1" enable
[ "$enable" = 1 ] || return 0
local reuse_port instances="$(get_cpu_cores)"
config_get_bool reuse_port "$1" reuse_port
[ "$reuse_port" = 1 ] || instances=1
for i in $(seq 1 "$instances"); do
procd_open_instance
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param nice -5
procd_set_param limits nofile="1048576 1048576"
procd_set_param command /usr/bin/chinadns-ng
append_param "$1" bind_addr "-b"
append_param "$1" bind_port "-l"
append_param "$1" china_dns "-c"
append_param "$1" trust_dns "-t"
append_param "$1" chnlist_file "-m"
append_param "$1" gfwlist_file "-g"
append_bool "$1" chnlist_first "-M"
append_param_if_neq "$1" default_tag "-d" "none"
append_param_with_val "$1" add_tagchn_ip "-a"
append_param_with_val "$1" add_taggfw_ip "-A"
append_param_if_neq "$1" ipset_name4 "-4" "chnroute"
append_param_if_neq "$1" ipset_name6 "-6" "chnroute6"
append_param_with_val "$1" no_ipv6 "-N"
append_param_if_neq "$1" timeout_sec "-o" "5"
append_param_if_neq "$1" repeat_times "-p" "1"
append_bool "$1" noip_as_chnip "-n"
append_bool "$1" reuse_port "-r"
append_bool "$1" verbose "-v"
procd_close_instance
done
}
start_service() {
config_load chinadns-ng
config_foreach create_chnroute_ipset chinadns-ng
config_foreach start_chinadns_ng chinadns-ng
}
stop_service() {
config_load chinadns-ng
config_foreach destroy_chnroute_ipset chinadns-ng
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

59
hysteria/Makefile Normal file
View File

@ -0,0 +1,59 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=hysteria
PKG_VERSION:=2.2.0
PKG_RELEASE:=53
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/apernet/hysteria/tar.gz/app/v$(PKG_VERSION)?
PKG_HASH:=skip
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-app-v$(PKG_VERSION)
PKG_LICENSE:=MIT
PKG_LICENSE_FILE:=LICENSE
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
PKG_BUILD_FLAGS:=no-mips16
GO_PKG:=github.com/apernet/hysteria
GO_PKG_BUILD_PKG:=$(GO_PKG)/app
GO_PKG_LDFLAGS_X = \
$(GO_PKG)/app/cmd.appVersion=v$(PKG_VERSION) \
$(GO_PKG)/app/cmd.appType=release \
$(GO_PKG)/app/cmd.appPlatform=$(GO_OS) \
$(GO_PKG)/app/cmd.appArch=$(GO_ARCH)
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
define Package/hysteria
SECTION:=net
CATEGORY:=Network
TITLE:=A feature-packed network utility optimized for networks of poor quality
URL:=https://github.com/apernet/hysteria
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
endef
define Package/hysteria/description
Hysteria is a feature-packed network utility optimized for networks
of poor quality (e.g. satellite connections, congested public Wi-Fi,
connecting from China to servers abroad) powered by a custom version
of QUIC protocol.
endef
define Package/hysteria/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/app $(1)/usr/bin/hysteria
endef
$(eval $(call GoBinPackage,hysteria))
$(eval $(call BuildPackage,hysteria))

44
lua-maxminddb/Makefile Normal file
View File

@ -0,0 +1,44 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2020 jerryk <jerrykuku@qq.com>
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=lua-maxminddb
PKG_VERSION:=0.2
PKG_RELEASE:=18
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/fabled/lua-maxminddb.git
PKG_SOURCE_DATE:=2019-03-14
PKG_SOURCE_VERSION:=93da9f4e6c814c3a23044dd2cdd22d4a6b4f665b
PKG_MIRROR_HASH:=skip
PKG_LICENSE:=MIT
PKG_LICENSE_FILE:=LICENSE
PKG_MAINTAINER:=fabled
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/lua-maxminddb
SUBMENU:=Lua
SECTION:=lang
CATEGORY:=Languages
TITLE:=libmaxminddb bindings for lua
URL:=https://github.com/jerrykuku/lua-maxminddb
DEPENDS:=+lua +libmaxminddb
endef
TARGET_CFLAGS += $(FPIC)
MAKE_VARS += LUA_PKG=lua
define Package/lua-maxminddb/install
$(INSTALL_DIR) $(1)/usr/lib/lua
$(INSTALL_BIN) $(PKG_BUILD_DIR)/maxminddb.so $(1)/usr/lib/lua/
endef
$(eval $(call BuildPackage,lua-maxminddb))

44
lua-neturl/Makefile Normal file
View File

@ -0,0 +1,44 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2022-2023 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=neturl
PKG_VERSION:=1.1-1
PKG_RELEASE:=7
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/golgote/neturl/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=skip
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_LICENSE:=MIT
PKG_LICNESE_FILES:=LICENSE.txt
include $(INCLUDE_DIR)/package.mk
define Package/lua-neturl
SUBMENU:=Lua
SECTION:=lang
CATEGORY:=Languages
TITLE:=URL and Query string parser, builder, normalizer for Lua
URL:=https://github.com/golgote/neturl
DEPENDS:=+lua
PKGARCH:=all
endef
define Package/lua-neturl/description
This small Lua library provides a few functions to parse URL with
querystring and build new URL easily.
endef
define Build/Compile
endef
define Package/lua-neturl/install
$(INSTALL_DIR) $(1)/usr/lib/lua
$(CP) $(PKG_BUILD_DIR)/lib/net/url.lua $(1)/usr/lib/lua/
endef
$(eval $(call BuildPackage,lua-neturl))

View File

@ -0,0 +1,20 @@
--- a/lib/net/url.lua
+++ b/lib/net/url.lua
@@ -340,7 +340,7 @@ function M:setAuthority(authority)
self.password = v
return ''
end)
- if string.find(userinfo, "^[%w%+%.]+$") then
+ if string.find(userinfo, "^[%p%w%+%.]+$") then
self.user = userinfo
else
-- incorrect userinfo
@@ -369,7 +369,7 @@ function M.parse(url)
comp.fragment = v
return ''
end)
- url =url:gsub('^([%w][%w%+%-%.]*)%:', function(v)
+ url =url:gsub('^([%w][%w%+%-%_%.]*)%:', function(v)
comp.scheme = v:lower()
return ''
end)

View File

@ -0,0 +1,72 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-chinadns-ng
PKG_VERSION:=1.0
PKG_RELEASE:=5
include $(INCLUDE_DIR)/package.mk
define Create/uci-defaults
( \
echo '#!/bin/sh'; \
echo 'uci -q batch <<-EOF >/dev/null'; \
echo " delete ucitrack.@$(1)[-1]"; \
echo " add ucitrack $(1)"; \
echo " set ucitrack.@$(1)[-1].init=$(1)"; \
echo ' commit ucitrack'; \
echo 'EOF'; \
echo 'rm -f /tmp/luci-indexcache'; \
echo 'exit 0'; \
) > $(PKG_BUILD_DIR)/luci-$(1)
endef
define Package/$(PKG_NAME)
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI support for chinadns-ng
LUCI_DEPENDS:=+chinadns-ng
endef
define Build/Prepare
$(foreach po,$(wildcard ${CURDIR}/luasrc/i18n/*.po), \
po2lmo $(po) ${CURDIR}/luasrc/i18n/$(patsubst %.po,%.lmo,$(notdir $(po)));)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/luci-app-chinadns-ng/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
( . /etc/uci-defaults/luci-chinadns-ng ) && rm -f /etc/uci-defaults/luci-chinadns-ng
chmod 755 /etc/init.d/chinadns-ng >/dev/null 2>&1
/etc/init.d/chinadns-ng enable >/dev/null 2>&1
fi
exit 0
endef
define Package/luci-app-chinadns-ng/postrm
#!/bin/sh
rm -f /tmp/luci-indexcache
exit 0
endef
define Package/$(PKG_NAME)/install
$(call Create/uci-defaults,'chinadns-ng')
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d/
$(INSTALL_DATA) root/usr/share/rpcd/acl.d/luci-app-chinadns-ng.json $(1)/usr/share/rpcd/acl.d/luci-app-chinadns-ng.json
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(INSTALL_DATA) ${CURDIR}/luasrc/i18n/*.lmo $(1)/usr/lib/lua/luci/i18n/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
$(INSTALL_DATA) luasrc/model/cbi/chinadns-ng.lua $(1)/usr/lib/lua/luci/model/cbi/chinadns-ng.lua
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DATA) luasrc/controller/chinadns-ng.lua $(1)/usr/lib/lua/luci/controller/chinadns-ng.lua
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) $(PKG_BUILD_DIR)/luci-chinadns-ng $(1)/etc/uci-defaults/luci-chinadns-ng
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -0,0 +1,43 @@
# LuCI Interface for ChinaDNS Next Generation for OpenWrt
## 简介
此仓库克隆自https://github.com/pexcn/openwrt-chinadns-ng/tree/luci
本项目为 [openwrt-chinadns-ng](https://github.com/pexcn/openwrt-chinadns-ng) 提供 LuCI 接口。
## 编译
从 OpenWrt 的 [SDK](https://openwrt.org/docs/guide-developer/obtain.firmware.sdk) 编译
```bash
cd openwrt-sdk
# 获取源码
git clone https://github.com/izilzty/luci-app-chinadns-ng.git package/luci-app-chinadns-ng
# 选中 LuCI -> Applications -> luci-app-chinadns-ng
make menuconfig
# 编译 luci-app-chinadns-ng
make package/luci-app-chinadns-ng/{clean,compile} V=s
```
## 配置应用后自动重启
如果想要在配置应用后自动重启 ChinaDNS-NG ,则需要添加一个触发器用来重启服务,否在在配置应用后需要手动重启 ChinaDNS-NG 才可以加载新配置。
您可以选择其中一种:
- 编译并安装这个修改好的 ChinaDNS-NG 包: https://github.com/izilzty/openwrt-chinadns-ng.git 。
- 手动编辑已经安装好的 ChinaDNS-NG 文件:
打开 `/etc/init.d/chinadns-ng`,将下面的代码添加到文件最后,完成后保存文件并手动重启一下 ChinaDNS-NG 的服务或者重启系统。
```
service_triggers() {
procd_add_reload_trigger "chinadns-ng"
}
```
## 鸣谢
- [@zfl9/chinadns-ng](https://github.com/zfl9/chinadns-ng)
- [@aa65535/openwrt-chinadns](https://github.com/aa65535/openwrt-chinadns)

View File

@ -0,0 +1,10 @@
module("luci.controller.chinadns-ng", package.seeall)
function index()
if not nixio.fs.access("/etc/config/chinadns-ng") then
return
end
page = entry({"admin", "services", "chinadns-ng"}, cbi("chinadns-ng"), _("ChinaDNS-NG"), 70)
page.dependent = true
page.acl_depends = { "luci-app-chinadns-ng" }
end

Binary file not shown.

View File

@ -0,0 +1,122 @@
msgid "RUNNING"
msgstr "运行中"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "General Setting"
msgstr "基本设置"
msgid "Enable"
msgstr "启用"
msgid "use Fair_Mode"
msgstr "使用公平模式"
msgid "Enable the Fair_Mode"
msgstr "启用公平模式"
msgid "Enable the Fair_Mode or use the Compete_Mode. Only fair mode from version 2023.03.06"
msgstr "启用公平模式,否则系统运行在竞争模式,默认使用竞争模式,仅当可信 DNS 返回速度快于国内 DNS 时采用公平模式。从版本 2023.03.06 开始仅支持公平模式"
msgid "Listen Port"
msgstr "监听端口"
msgid "Listen Address"
msgstr "监听地址"
msgid "CHNRoute File"
msgstr "国内路由表"
msgid "GFWRoute File"
msgstr "国外路由表"
msgid "China DNS Servers"
msgstr "国内 DNS 服务器地址"
msgid "Trusted DNS Servers"
msgstr "可信 DNS 服务器地址"
msgid "Use commas to separate multiple ip address, Max 2 Servers"
msgstr "使用逗号分隔多个 IP 地址,最多使用两个服务器"
msgid "match chnlist first"
msgstr "国内路由表优先"
msgid "match chnlist first, default is gfwfirst"
msgstr "优先匹配国内路由表,默认是优先匹配国外路由表"
msgid "reuse_port"
msgstr "多进程端口复用"
msgid "reuse_port, for Multi-process load balancing"
msgstr "多进程负载均衡,提升性能"
msgid "accept no ip"
msgstr "接受无 IP 地址的应答"
msgid "accept reply without ipaddr (A/AAAA query)"
msgstr "接受 qtype 为 A/AAAA 但却没有 IP 的 reply"
msgid "timeout_sec"
msgstr "查询超时时间 秒"
msgid "repeat_times"
msgstr "同一地址对可信 DNS 发送查询包数量"
msgid "disable ipv6-address query"
msgstr "禁用 IPv6 查询"
msgid "disable ipv6-address query (qtype: AAAA)"
msgstr "禁用 IPv6 查询记录类型AAAA"
msgid "none"
msgstr "无"
msgid "all (a)"
msgstr "所有查询a"
msgid "name with tag chn (m)"
msgstr "标签为 chn 的查询m"
msgid "name with tag gfw (g)"
msgstr "标签为 gfw 的查询g"
msgid "name with tag none (n)"
msgstr "标签为 none 的查询n"
msgid "do not forward to china upstream (c)"
msgstr "禁止向 china 上游转发查询c"
msgid "do not forward to trust upstream (t)"
msgstr "禁止向 trust 上游转发查询t"
msgid "check answer ip of china upstream (C)"
msgstr "当标签为 none 域名的查询只存在 china 上游路径时,过滤 china 上游的非大陆 IP 响应C"
msgid "check answer ip of trust upstream (T)"
msgstr "当标签为 none 域名的查询只存在 trust 上游路径时,过滤 trust 上游的非大陆 IP 响应T"
msgid "Domain default tag"
msgstr "默认域名标签"
msgid "Specify ipset/nftset name for china ipv4"
msgstr "大陆 IPv4 地址的 ipset/nftset 集合"
msgid "Specify ipset/nftset name for china ipv6"
msgstr "大陆 IPv6 地址的 ipset/nftset 集合"
msgid "Add the ip of tag chn to ipset/nftset"
msgstr "添加标签为 chn 域名的解析结果到 ipset/nftset"
msgid "Add the ip of tag gfw to ipset/nftset"
msgstr "添加标签为 gfw 域名的解析结果到 ipset/nftset"
msgid "Use commas to separate ipv4 and ipv6 table name, all table name must be specified"
msgstr "使用逗号分隔多个集合名称,必须同时指定 IPv4 和 IPv6 集合名称,但可以不创建"
msgid "Verbose log"
msgstr "详细日志"
msgid "Print the verbose log"
msgstr "记录详细的运行日志,除非调试,否则不建议启用"

View File

@ -0,0 +1,130 @@
local m, s, o
if luci.sys.call("pidof chinadns-ng >/dev/null") == 0 then
m = Map("chinadns-ng", translate("ChinaDNS-NG"), "%s - %s" %{translate("ChinaDNS-NG"), translate("RUNNING")})
else
m = Map("chinadns-ng", translate("ChinaDNS-NG"), "%s - %s" %{translate("ChinaDNS-NG"), translate("NOT RUNNING")})
end
s = m:section(TypedSection, "chinadns-ng", translate("General Setting"))
s.anonymous = true
o = s:option(Flag, "enable", translate("Enable"))
o.rmempty = false
o = s:option(Flag, "fair_mode",
translate("Enable the Fair_Mode"),
translate("Enable the Fair_Mode or use the Compete_Mode. Only fair mode from version 2023.03.06"))
o.rmempty = false
o = s:option(Value, "bind_port", translate("Listen Port"))
o.placeholder = 5353
o.default = 5353
o.datatype = "port"
o.rmempty = false
o = s:option(Value, "bind_addr", translate("Listen Address"))
o.placeholder = "0.0.0.0"
o.default = "0.0.0.0"
o.datatype = "ipaddr"
o.rmempty = false
o = s:option(Value, "chnlist_file", translate("CHNRoute File"))
o.placeholder = "/etc/chinadns-ng/chinalist.txt"
o.default = "/etc/chinadns-ng/chinalist.txt"
o.rmempty = false
o = s:option(Value, "gfwlist_file", translate("GFWRoute File"))
o.placeholder = "/etc/chinadns-ng/gfwlist.txt"
o.default = "/etc/chinadns-ng/gfwlist.txt"
o.rmempty = false
o = s:option(Value, "timeout_sec", translate("timeout_sec"))
o.placeholder = "3"
o.default = "3"
o.datatype = "uinteger"
o.rmempty = false
o = s:option(Value, "repeat_times", translate("repeat_times"))
o.placeholder = "1"
o.default = "1"
o.datatype = "uinteger"
o.rmempty = false
o = s:option(Value, "china_dns",
translate("China DNS Servers"),
translate("Use commas to separate multiple ip address, Max 2 Servers"))
o.placeholder = "114.114.114.114"
o.default = "114.114.114.114"
o.rmempty = false
o = s:option(Value, "trust_dns",
translate("Trusted DNS Servers"),
translate("Use commas to separate multiple ip address, Max 2 Servers"))
o.placeholder = "127.0.0.1#5300"
o.default = "127.0.0.1#5300"
o.rmempty = false
o = s:option(Flag, "chnlist_first",
translate("match chnlist first"),
translate("match chnlist first, default is gfwfirst"))
o.rmempty = false
o = s:option(Flag, "reuse_port",
translate("reuse_port"),
translate("reuse_port, for Multi-process load balancing"))
o.rmempty = false
o = s:option(Flag, "noip_as_chnip",
translate("accept no ip"),
translate("accept reply without ipaddr (A/AAAA query)"))
o.rmempty = false
o = s:option(Value, "no_ipv6",
translate("disable ipv6-address query"),
translate("disable ipv6-address query (qtype: AAAA)"))
o:value("0", translate("none"))
o:value("a", translate("all (a)"))
o:value("m", translate("name with tag chn (m)"))
o:value("g", translate("name with tag gfw (g)"))
o:value("n", translate("name with tag none (n)"))
o:value("c", translate("do not forward to china upstream (c)"))
o:value("t", translate("do not forward to trust upstream (t)"))
o:value("C", translate("check answer ip of china upstream (C)"))
o:value("T", translate("check answer ip of trust upstream (T)"))
o.default = "0"
o.rmempty = false
o = s:option(Value, "default_tag", translate("Domain default tag"))
o:value("none", "none")
o:value("chn", "chn")
o:value("gfw", "gfw")
o.default = "none"
o.rmempty = false
o = s:option(Value, "ipset_name4", translate("Specify ipset/nftset name for china ipv4"))
o.placeholder = "chnroute"
o.default = "chnroute"
o.rmempty = false
o = s:option(Value, "ipset_name6", translate("Specify ipset/nftset name for china ipv6"))
o.placeholder = "chnroute6"
o.default = "chnroute6"
o.rmempty = false
o = s:option(Value, "add_tagchn_ip", translate("Add the ip of tag chn to ipset/nftset"),
translate("Use commas to separate ipv4 and ipv6 table name, all table name must be specified"))
o.placeholder = ""
o.default = ""
o = s:option(Value, "add_taggfw_ip", translate("Add the ip of tag gfw to ipset/nftset"),
translate("Use commas to separate ipv4 and ipv6 table name, all table name must be specified"))
o.placeholder = ""
o.default = ""
o = s:option(Flag, "verbose",
translate("Verbose log"),
translate("Print the verbose log"))
o.rmempty = false
return m

View File

@ -0,0 +1,11 @@
{
"luci-app-chinadns-ng": {
"description": "Grant UCI access for luci-app-chinadns-ng",
"read": {
"uci": [ "chinadns-ng" ]
},
"write": {
"uci": [ "chinadns-ng" ]
}
}
}

12
luci-app-fullconenat/Makefile Executable file
View File

@ -0,0 +1,12 @@
#-- Copyright (C) 2018 dz <dingzhong110@gmail.com>
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for FullConeNat
LUCI_DEPENDS:=+iptables-mod-fullconenat
LUCI_PKGARCH:=all
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,5 @@
# luci-app-fullconenat
本软件包是 [fullconenat]的 LuCI 控制界面
[fullconenat]: https://github.com/LGA1150/openwrt-fullconenat

View File

@ -0,0 +1,12 @@
module("luci.controller.fullconenat", package.seeall)
function index()
if not nixio.fs.access("/etc/config/fullconenat") then
return
end
local page
page = entry({"admin", "network", "fullconenat"}, cbi("fullconenat"), _("fullconenat"), 101)
page.i18n = "fullconenat"
page.dependent = true
page.acl_depends = { "luci-app-fullconenat" }
end

View File

@ -0,0 +1,65 @@
#-- Copyright (C) 2018 dz <dingzhong110@gmail.com>
local fwm = require "luci.model.firewall".init()
local def = fwm:get_defaults()
local zn = fwm:get_zone("wan")
local m, s, o, fw3_buildin, has_module, status, des
local function testcmd (cmd)
return luci.sys.call(cmd) == 0
end
has_module = testcmd("modprobe -q xt_FULLCONENAT")
fw3_buildin = testcmd("strings `which fw3` | grep -q fullcone")
m = Map("fullconenat", translate("Full cone NAT"),
translate("FullConeNat."))
status="<strong><font color=\"red\">Not supported, Kernel module needed: xt_FULLCONENAT</font></strong>"
if has_module then
if testcmd("iptables -t nat -L -n --line-numbers | grep FULLCONENAT >/dev/null") then
status="<strong><font color=\"green\">Running</font></strong>"
else
status="<strong><font color=\"red\">Not Running</font></strong>"
end
end
m = Map("fullconenat", translate("FullConeNat"), "%s - %s" %{translate("FULLCONENAT"), translate(status)})
des = fw3_buildin and "Build-in mode, set the `fullcone` option to firewall configure either." or "Manual mode, write to the firewall custom rules settings only."
s = m:section(TypedSection, "fullconenat", translate("Settings"), translate(des))
s.anonymous = true
o = s:option(ListValue, "mode", translate("Register modes"), translate("<strong><font color=\"red\">Warning!!! There is security risk if enabled.</font></strong>"))
o.widget = "radio"
o.orientation = "horizontal"
o.default = "disable"
o.rmempty = false
o:value("disable", translate("Disable"))
o:value("ips", translate("IP Address Only"))
o:value("all", translate("ALL Enabled"))
o.cfgvalue = function (self, sec)
local ret = "disable"
if fw3_buildin and def:get("fullcone") == "1" then
ret = "all"
else
ret = self.map:get(sec, self.option)
end
return has_module and ret or "disable"
end
o.write = function (self, sec, val)
val = has_module and val or "disable"
if fw3_buildin then
def:set("fullcone", val == "all" and 1 or 0)
zn:set("fullcone", val == "all" and 1 or 0)
end
fwm.commit()
return self.map:set(sec, self.option, val)
end
o = s:option(Value, "fullconenat_ip", translate("FullConeNat IP"), translate("Enable FullConeNat for specified IP Address.") .. "<br />" .. (fw3_buildin and translate("Manual mode, write to the firewall custom rules settings only.") or ""))
o.placeholder="192.168.1.100,192.168.1.101,192.168.1.102"
o.rempty = true
o.optional = false
o:depends("mode", "ips")
return m

View File

@ -0,0 +1,45 @@
msgid "fullconenat"
msgstr "全端口映射"
msgid "FULLCONENAT"
msgstr "Fullcone NAT"
msgid "<strong><font color=\"green\">Running</font></strong>"
msgstr "<strong><font color=\"green\">正在运行</font></strong>"
msgid "<strong><font color=\"red\">Not Running</font></strong>"
msgstr "<strong><font color=\"red\">未运行</font></strong>"
msgid "<strong><font color=\"red\">Not supported, Kernel module needed: xt_FULLCONENAT</font></strong>"
msgstr "<strong><font color=\"red\">不支持,缺少 xt_FULLCONENAT 内核组件</font></strong>"
msgid "Settings"
msgstr "设置"
msgid "Build-in mode, set the `fullcone` option to firewall configure either."
msgstr "防火墙内置模式,同时配置防火墙(firewall)中对应的选项。"
msgid "Manual mode, write to the firewall custom rules settings only."
msgstr "手动模式,仅将配置写入到防火墙(firewall)自定义规则中。"
msgid "Register modes"
msgstr "运行模式"
msgid "Disable"
msgstr "停用"
msgid "IP Address Only"
msgstr "限指定IP"
msgid "ALL Enabled"
msgstr "全网开启"
msgid "<strong><font color=\"red\">Warning!!! There is security risk if enabled.</font></strong>"
msgstr "<strong><font color=\"red\">警告!!!开启后存在安全风险。</font></strong>"
msgid "FullConeNat IP"
msgstr "映射IP"
msgid "Enable FullConeNat for specified IP Address."
msgstr "多IP映射用英文逗号分隔。"

View File

@ -0,0 +1 @@
zh-cn

View File

@ -0,0 +1,3 @@
config fullconenat 'config'
option mode 'disable'
option fullconenat_ip '192.168.1.100'

View File

@ -0,0 +1,70 @@
#!/bin/sh /etc/rc.common
#-- Copyright (C) 2018 dz <dingzhong110@gmail.com>
START=99
re=0
start(){
local fw3_buildin mode fullconenat_ip fullcone masq
strings `which fw3` | grep -q "fullcone"
fw3_buildin=$?
mode=$(uci get fullconenat.config.mode 2>/dev/null)
if modprobe -q "xt_FULLCONENAT"; then
[ $fw3_buildin -eq 0 ] && echo -n "fw3 build-in, change settings in /etc/config/firewall either. "
echo "$mode."
else
echo "not supported."
return 1
fi
fullcone=0
fullconenat_ip=$(uci get fullconenat.config.fullconenat_ip 2>/dev/null)
if [ "$mode" == "ips" ]; then
sed -i '/FULLCONENAT/d' /etc/firewall.user
echo "iptables -t nat -A zone_wan_prerouting -j FULLCONENAT" >> /etc/firewall.user
echo "iptables -t nat -A zone_wan_postrouting -s $fullconenat_ip -j FULLCONENAT" >> /etc/firewall.user
echo "iptables -t nat -A zone_wan_postrouting -j MASQUERADE" >> /etc/firewall.user
elif [ "$mode" == "all" ]; then
if [ $fw3_buildin -ne 0 ]; then
iptables -t nat -D zone_wan_postrouting -s $fullconenat_ip -j FULLCONENAT
iptables -t nat -D zone_wan_postrouting -j MASQUERADE
sed -i '/zone_wan_postrouting -j MASQUERADE/d' /etc/firewall.user
sed -i '/FULLCONENAT/d' /etc/firewall.user
echo "iptables -t nat -A zone_wan_prerouting -j FULLCONENAT" >> /etc/firewall.user
echo "iptables -t nat -A zone_wan_postrouting -j FULLCONENAT" >> /etc/firewall.user
else
fullcone=1
fi
fi
[ $fw3_buildin -eq 0 ] && {
uci set firewall.@defaults[0].fullcone=$fullcone
uci set firewall.@zone[1].fullcone=$fullcone
}
uci commit firewall
/etc/init.d/firewall restart
}
stop(){
fullconenat_ip=$(uci get fullconenat.config.fullconenat_ip 2>/dev/null)
mode=$(uci get fullconenat.config.mode 2>/dev/null)
echo "$mode, $fullconenat_ip"
iptables -t nat -D zone_wan_prerouting -j FULLCONENAT
iptables -t nat -D zone_wan_postrouting -s $fullconenat_ip -j FULLCONENAT
iptables -t nat -D zone_wan_postrouting -j MASQUERADE
iptables -t nat -D zone_wan_postrouting -j FULLCONENAT
sed -i '/zone_wan_postrouting -j MASQUERADE/d' /etc/firewall.user
sed -i '/FULLCONENAT/d' /etc/firewall.user
[ $re -eq 0 ] && {
uci set firewall.@defaults[0].fullcone=0
uci set firewall.@zone[1].fullcone=0
uci commit firewall
/etc/init.d/firewall restart
}
}
restart(){
re=1
stop
start
}

View File

@ -0,0 +1,13 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@fullconenat[-1]
add ucitrack fullconenat
set ucitrack.@fullconenat[-1].init=fullconenat
commit ucitrack
EOF
/etc/init.d/fullconenat enable
rm -f /tmp/luci-indexcache
exit 0

View File

@ -0,0 +1,11 @@
{
"luci-app-fullconenat": {
"description": "Grant UCI access for luci-app-fullconenat",
"read": {
"uci": [ "fullconenat" ]
},
"write": {
"uci": [ "fullconenat" ]
}
}
}

153
luci-app-openclash/Makefile Normal file
View File

@ -0,0 +1,153 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-openclash
PKG_VERSION:=0.45.141
PKG_RELEASE:=244
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)/config
config PACKAGE_kmod-inet-diag
default y if PACKAGE_$(PKG_NAME)
config PACKAGE_kmod-nft-tproxy
default y if PACKAGE_firewall4
config PACKAGE_kmod-ipt-nat
default y if ! PACKAGE_firewall4
config PACKAGE_iptables-mod-tproxy
default y if ! PACKAGE_firewall4
config PACKAGE_iptables-mod-extra
default y if ! PACKAGE_firewall4
endef
define Package/$(PKG_NAME)
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI support for clash
PKGARCH:=all
DEPENDS:=+dnsmasq-full +coreutils +coreutils-nohup +bash +curl +ca-bundle +ipset +ip-full \
+libcap +libcap-bin +libcap-bin +ruby +ruby-yaml +kmod-tun +unzip +kmod-inet-diag +kmod-ipt-nat +iptables-mod-tproxy +iptables-mod-extra
MAINTAINER:=vernesong
endef
define Package/$(PKG_NAME)/description
A LuCI support for clash
endef
define Build/Prepare
$(CP) $(CURDIR)/root $(PKG_BUILD_DIR)
$(CP) $(CURDIR)/luasrc $(PKG_BUILD_DIR)
$(foreach po,$(wildcard ${CURDIR}/po/zh-cn/*.po), \
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
sed -i "s/v0.00.00-beta/v$(PKG_VERSION)-beta/g" $(PKG_BUILD_DIR)/root/www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1
chmod 0755 $(PKG_BUILD_DIR)/root/etc/init.d/openclash
chmod -R 0755 $(PKG_BUILD_DIR)/root/usr/share/openclash/
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/config
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/rule_provider
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/backup
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/core
mkdir -p $(PKG_BUILD_DIR)/root/usr/share/openclash/backup
cp -f "$(PKG_BUILD_DIR)/root/etc/config/openclash" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules_2.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_hosts.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_fake_filter.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_domain_dns.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_domain_dns_policy.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_domain_dns_policy.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_fallback_filter.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_fallback_filter.yaml" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_netflix_domains.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_netflix_domains.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_force_sniffing_domain.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_force_sniffing_domain.yaml" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_sniffing_domain_filter.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_sniffing_domain_filter.yaml" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_sniffing_ports_filter.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_sniffing_ports_filter.yaml" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_localnetwork_ipv4.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_localnetwork_ipv4.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_localnetwork_ipv6.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_localnetwork_ipv6.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_chnroute_pass.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_chnroute_pass.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_chnroute6_pass.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_chnroute6_pass.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_firewall_rules.sh" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_firewall_rules.sh" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_overwrite.sh" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_overwrite.sh" >/dev/null 2>&1
exit 0
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/conffiles
endef
define Package/$(PKG_NAME)/preinst
#!/bin/sh
if [ -f "/etc/config/openclash" ]; then
cp -f "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
cp -rf "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1
cp -rf "/usr/share/openclash/ui/yacd" "/tmp/openclash_yacd" >/dev/null 2>&1
cp -rf "/usr/share/openclash/ui/dashboard" "/tmp/openclash_dashboard" >/dev/null 2>&1
fi
exit 0
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
sed -i "s/v0.00.00-beta/v$(PKG_VERSION)-beta/g" /www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1
exit 0
endef
define Package/$(PKG_NAME)/prerm
#!/bin/sh
uci -q set openclash.config.enable=0
uci -q commit openclash
cp -f "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
cp -rf "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1
cp -rf "/usr/share/openclash/ui/yacd" "/tmp/openclash_yacd" >/dev/null 2>&1
cp -rf "/usr/share/openclash/ui/dashboard" "/tmp/openclash_dashboard" >/dev/null 2>&1
exit 0
endef
define Package/$(PKG_NAME)/postrm
#!/bin/sh
dnsmasqconfdir="$(uci -q get dhcp.@dnsmasq[0].confdir || echo '/tmp/dnsmasq.d')"
dnsmasqconfdir="${dnsmasqconfdir%*/}"
rm -rf /etc/openclash >/dev/null 2>&1
rm -rf /tmp/openclash.log >/dev/null 2>&1
rm -rf /tmp/openclash_start.log >/dev/null 2>&1
rm -rf /tmp/openclash_last_version >/dev/null 2>&1
rm -rf /tmp/openclash_config.tmp >/dev/null 2>&1
rm -rf /tmp/openclash.change >/dev/null 2>&1
rm -rf /tmp/Proxy_Group >/dev/null 2>&1
rm -rf /tmp/rules_name >/dev/null 2>&1
rm -rf /tmp/rule_providers_name >/dev/null 2>&1
rm -rf /tmp/clash_last_version >/dev/null 2>&1
rm -rf /usr/share/openclash/backup >/dev/null 2>&1
rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1
rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_chnroute_pass.conf >/dev/null 2>&1
rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_chnroute6_pass.conf >/dev/null 2>&1
rm -rf ${dnsmasqconfdir}/dnsmasq_accelerated-domains.china.conf >/dev/null 2>&1
rm -rf /tmp/dler* >/dev/null 2>&1
rm -rf /tmp/etc/openclash >/dev/null 2>&1
rm -rf /tmp/openclash_edit_file_name >/dev/null 2>&1
rm -rf /tmp/openclash_*_region>/dev/null 2>&1
sed -i '/OpenClash Append/,/OpenClash Append End/d' "/usr/lib/lua/luci/model/network.lua" >/dev/null 2>&1
uci -q delete firewall.openclash
uci -q commit firewall
uci -q delete ucitrack.@openclash[-1]
uci -q commit ucitrack
rm -rf /tmp/luci-*
exit 0
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(INSTALL_DATA) $(PKG_BUILD_DIR)/*.*.lmo $(1)/usr/lib/lua/luci/i18n/
$(CP) $(PKG_BUILD_DIR)/root/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luasrc/* $(1)/usr/lib/lua/luci/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,146 @@
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require("luci.model.uci").cursor()
m = SimpleForm("openclash",translate("OpenClash"))
m.description = translate("A Clash Client For OpenWrt")
m.reset = false
m.submit = false
m:section(SimpleSection).template = "openclash/status"
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e == ".yaml"
end
function IsYmlFile(e)
e=e or""
local e=string.lower(string.sub(e,-4,-1))
return e == ".yml"
end
function config_check(CONFIG_FILE)
local yaml = fs.isfile(CONFIG_FILE)
if yaml then
yaml = SYS.exec(string.format('ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "puts YAML.load_file(\'%s\')" 2>/dev/null',CONFIG_FILE))
if yaml ~= "false\n" and yaml ~= "" then
return "Config Normal"
else
return "Config Abnormal"
end
elseif (yaml ~= 0) then
return "File Not Exist"
end
end
local e,a={}
for t,o in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(o)
if a then
e[t]={}
e[t].num=string.format(t)
e[t].name=fs.basename(o)
BACKUP_FILE="/etc/openclash/backup/".. e[t].name
if fs.mtime(BACKUP_FILE) then
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE))
else
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
end
if uci:get("openclash", "config", "config_path") and string.sub(uci:get("openclash", "config", "config_path"), 23, -1) == e[t].name then
e[t].state=translate("Enable")
else
e[t].state=translate("Disable")
end
e[t].check=translate(config_check(o))
end
end
form = SimpleForm("openclash")
form.reset = false
form.submit = false
tb=form:section(Table,e)
st=tb:option(DummyValue,"state",translate("State"))
nm=tb:option(DummyValue,"name",translate("Config Alias"))
sb=tb:option(DummyValue,"name",translate("Subscription Info"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
ck=tb:option(DummyValue,"check",translate("Grammar Check"))
st.template="openclash/cfg_check"
ck.template="openclash/cfg_check"
sb.template="openclash/sub_info_show"
btnis=tb:option(Button,"switch",translate("Switch Config"))
btnis.template="openclash/other_button"
btnis.render=function(o,t,a)
if not e[t] then return false end
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
a.display=""
else
a.display="none"
end
o.inputstyle="apply"
Button.render(o,t,a)
end
btnis.write=function(a,t)
fs.unlink("/tmp/Proxy_Group")
uci:set("openclash", "config", "config_path", "/etc/openclash/config/"..e[t].name)
uci:set("openclash", "config", "enable", 1)
uci:commit("openclash")
SYS.call("/etc/init.d/openclash restart >/dev/null 2>&1 &")
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "openclash", "client"))
end
s = SimpleForm("openclash")
s.reset = false
s.submit = false
s:section(SimpleSection).template = "openclash/myip"
local t = {
{enable, disable}
}
ap = SimpleForm("openclash")
ap.reset = false
ap.submit = false
ss = ap:section(Table, t)
o = ss:option(Button, "enable", " ")
o.inputtitle = translate("Enable OpenClash")
o.inputstyle = "apply"
o.write = function()
uci:set("openclash", "config", "enable", 1)
uci:commit("openclash")
SYS.call("/etc/init.d/openclash restart >/dev/null 2>&1 &")
end
o = ss:option(Button, "disable", " ")
o.inputtitle = translate("Disable OpenClash")
o.inputstyle = "reset"
o.write = function()
uci:set("openclash", "config", "enable", 0)
uci:commit("openclash")
SYS.call("/etc/init.d/openclash stop >/dev/null 2>&1 &")
end
d = SimpleForm("openclash")
d.title = translate("Credits")
d.reset = false
d.submit = false
d:section(SimpleSection).template = "openclash/developer"
dler = SimpleForm("openclash")
dler.reset = false
dler.submit = false
dler:section(SimpleSection).template = "openclash/dlercloud"
if uci:get("openclash", "config", "dler_token") then
return m, dler, form, s, ap, d
else
return m, form, s, ap, d
end

View File

@ -0,0 +1,603 @@
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require "luci.model.uci".cursor()
local json = require "luci.jsonc"
local datatype = require "luci.cbi.datatypes"
font_green = [[<b style=color:green>]]
font_red = [[<b style=color:red>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
local op_mode = string.sub(luci.sys.exec('uci get openclash.config.operation_mode 2>/dev/null'),0,-2)
if not op_mode then op_mode = "redir-host" end
local lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n' || ip address show $(uci -q -p /tmp/state get network.lan.device || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'")
m = Map("openclash", translate("Overwrite Settings"))
m.pageaction = false
m.description = translate("Note: To restore the default configuration, try accessing:").." <a href='javascript:void(0)' onclick='javascript:restore_config(this)'>http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore</a>"
s = m:section(TypedSection, "openclash")
s.anonymous = true
s:tab("settings", translate("General Settings"))
s:tab("dns", "DNS "..translate("Settings"))
s:tab("meta", translate("Meta Settings"))
s:tab("rules", translate("Rules Setting"))
s:tab("developer", translate("Developer Settings"))
----- General Settings
o = s:taboption("settings", ListValue, "interface_name", translate("Bind Network Interface"))
local de_int = SYS.exec("ip route |grep 'default' |awk '{print $5}' 2>/dev/null") or SYS.exec("/usr/share/openclash/openclash_get_network.lua 'dhcp'")
o.description = translate("Default Interface Name:").." "..font_green..bold_on..de_int..bold_off..font_off..translate(",Try Enable If Network Loopback")
local interfaces = SYS.exec("ls -l /sys/class/net/ 2>/dev/null |awk '{print $9}' 2>/dev/null")
for interface in string.gmatch(interfaces, "%S+") do
o:value(interface)
end
o:value("0", translate("Disable"))
o.default = "0"
o = s:taboption("settings", Value, "tolerance", translate("URL-Test Group Tolerance").."(ms)")
o.description = translate("Switch To The New Proxy When The Delay Difference Between Old and The Fastest Currently is Greater Than This Value")
o:value("0", translate("Disable"))
o:value("100")
o:value("150")
o.datatype = "uinteger"
o.default = "0"
o = s:taboption("settings", Value, "urltest_interval_mod", translate("URL-Test Interval Modify").."(s)")
o.description = translate("Modify The URL-Test Interval In The Config")
o:value("0", translate("Disable"))
o:value("180")
o:value("300")
o.datatype = "uinteger"
o.default = "0"
o = s:taboption("settings", Value, "urltest_address_mod", translate("URL-Test Address Modify"))
o.description = translate("Modify The URL-Test Address In The Config")
o:value("0", translate("Disable"))
o:value("http://www.gstatic.com/generate_204")
o:value("http://cp.cloudflare.com/generate_204")
o:value("https://cp.cloudflare.com/generate_204")
o:value("http://captive.apple.com/generate_204")
o.default = "0"
o = s:taboption("settings", Value, "github_address_mod", translate("Github Address Modify"))
o.description = translate("Modify The Github Address In The Config And OpenClash With Proxy(CDN) To Prevent File Download Faild. Format Reference:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://ghproxy.com/\")'>https://ghproxy.com/</a>"
o:value("0", translate("Disable"))
o:value("https://fastly.jsdelivr.net/")
o:value("https://testingcf.jsdelivr.net/")
o:value("https://raw.fastgit.org/")
o:value("https://cdn.jsdelivr.net/")
o.default = "0"
o = s:taboption("settings", ListValue, "log_level", translate("Log Level"))
o.description = translate("Select Core's Log Level")
o:value("0", translate("Disable"))
o:value("info", translate("Info Mode"))
o:value("warning", translate("Warning Mode"))
o:value("error", translate("Error Mode"))
o:value("debug", translate("Debug Mode"))
o:value("silent", translate("Silent Mode"))
o.default = "0"
o = s:taboption("settings", Value, "dns_port")
o.title = translate("DNS Port")
o.default = "7874"
o.datatype = "port"
o.rmempty = false
o.description = translate("Please Make Sure Ports Available")
o = s:taboption("settings", Value, "proxy_port")
o.title = translate("Redir Port")
o.default = "7892"
o.datatype = "port"
o.rmempty = false
o.description = translate("Please Make Sure Ports Available")
o = s:taboption("settings", Value, "tproxy_port")
o.title = translate("TProxy Port")
o.default = "7895"
o.datatype = "port"
o.rmempty = false
o.description = translate("Please Make Sure Ports Available")
o = s:taboption("settings", Value, "http_port")
o.title = translate("HTTP(S) Port")
o.default = "7890"
o.datatype = "port"
o.rmempty = false
o.description = translate("Please Make Sure Ports Available")
o = s:taboption("settings", Value, "socks_port")
o.title = translate("SOCKS5 Port")
o.default = "7891"
o.datatype = "port"
o.rmempty = false
o.description = translate("Please Make Sure Ports Available")
o = s:taboption("settings", Value, "mixed_port")
o.title = translate("Mixed Port")
o.default = "7893"
o.datatype = "port"
o.rmempty = false
o.description = translate("Please Make Sure Ports Available")
---- DNS Settings
o = s:taboption("dns", Flag, "enable_custom_dns", font_red..bold_on..translate("Custom DNS Setting")..bold_off..font_off)
o.description = font_red..bold_on..translate("Set OpenClash Upstream DNS Resolve Server")..bold_off..font_off
o.default = 0
o = s:taboption("dns", Flag, "append_wan_dns", translate("Append Upstream DNS"))
o.description = translate("Append The Upstream Assigned DNS And Gateway IP To The Nameserver")
o.default = 1
o = s:taboption("dns", Flag, "append_default_dns", translate("Append Default DNS"))
o.description = translate("Automatically Append Compliant DNS to default-nameserver")
o.default = 1
if op_mode == "fake-ip" then
o = s:taboption("dns", Value, "fakeip_range", translate("Fake-IP Range (IPv4 Cidr)"))
o.description = translate("Set Fake-IP Range (IPv4 Cidr)")
o:value("0", translate("Disable"))
o:value("198.18.0.1/16")
o.default = "0"
o.placeholder = "198.18.0.1/16"
function o.validate(self, value)
if value == "0" then
return "0"
end
if datatype.cidr4(value) then
return value
end
return "198.18.0.1/16"
end
o = s:taboption("dns", Flag, "store_fakeip", translate("Persistence Fake-IP"))
o.description = font_red..bold_on..translate("Cache Fake-IP DNS Resolution Records To File, Improve The Response Speed After Startup")..bold_off..font_off
o.default = 1
end
o = s:taboption("dns", Flag, "custom_fallback_filter", translate("Fallback-Filter"))
o.description = translate("Take Effect If Fallback DNS Setted, Prevent DNS Pollution")
o.default = 0
custom_fallback_filter = s:taboption("dns", Value, "custom_fallback_fil")
custom_fallback_filter.template = "cbi/tvalue"
custom_fallback_filter.rows = 20
custom_fallback_filter.wrap = "off"
custom_fallback_filter:depends("custom_fallback_filter", "1")
function custom_fallback_filter.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_custom_fallback_filter.yaml") or ""
end
function custom_fallback_filter.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_custom_fallback_filter.yaml")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_custom_fallback_filter.yaml", value)
end
end
end
if op_mode == "fake-ip" then
o = s:taboption("dns", Flag, "custom_fakeip_filter", translate("Fake-IP-Filter"))
o.default = 0
custom_fake_black = s:taboption("dns", Value, "custom_fake_filter")
custom_fake_black.template = "cbi/tvalue"
custom_fake_black.description = translate("Domain Names In The List Do Not Return Fake-IP, One rule per line")
custom_fake_black.rows = 20
custom_fake_black.wrap = "off"
custom_fake_black:depends("custom_fakeip_filter", "1")
function custom_fake_black.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_custom_fake_filter.list") or ""
end
function custom_fake_black.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_custom_fake_filter.list")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_custom_fake_filter.list", value)
end
end
end
end
o = s:taboption("dns", Flag, "custom_name_policy", translate("Nameserver-Policy"))
o.default = 0
custom_domain_dns_policy = s:taboption("dns", Value, "custom_domain_dns_core")
custom_domain_dns_policy.template = "cbi/tvalue"
custom_domain_dns_policy.description = translate("Domain Names In The List Use The Custom DNS Server, But Still Return Fake-IP Results, One rule per line")
custom_domain_dns_policy.rows = 20
custom_domain_dns_policy.wrap = "off"
custom_domain_dns_policy:depends("custom_name_policy", "1")
function custom_domain_dns_policy.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_custom_domain_dns_policy.list") or ""
end
function custom_domain_dns_policy.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_custom_domain_dns_policy.list")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_custom_domain_dns_policy.list", value)
end
end
end
o = s:taboption("dns", Flag, "custom_host", translate("Hosts"))
o.default = 0
custom_hosts = s:taboption("dns", Value, "custom_hosts")
custom_hosts.template = "cbi/tvalue"
custom_hosts.description = translate("Custom Hosts Here, You May Need to Turn off The Rebinding Protection Option of Dnsmasq When Hosts Has Set a Reserved Address, For More Go:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://lancellc.gitbook.io/clash/clash-config-file/dns/host\")'>https://lancellc.gitbook.io/clash/clash-config-file/dns/host</a>"
custom_hosts.rows = 20
custom_hosts.wrap = "off"
custom_hosts:depends("custom_host", "1")
function custom_hosts.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_custom_hosts.list") or ""
end
function custom_hosts.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_custom_hosts.list")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_custom_hosts.list", value)
end
end
end
-- Meta
o = s:taboption("meta", Flag, "enable_tcp_concurrent", font_red..bold_on..translate("Enable Tcp Concurrent")..bold_off..font_off)
o.description = font_red..bold_on..translate("TCP Concurrent Request IPs, Choose The Lowest Latency One To Connection")..bold_off..font_off
o.default = "0"
o = s:taboption("meta", Flag, "enable_unified_delay", font_red..bold_on..translate("Enable Unified Delay")..bold_off..font_off)
o.description = font_red..bold_on..translate("Change the delay calculation method to remove extra delays such as handshaking")..bold_off..font_off
o.default = "0"
o = s:taboption("meta", ListValue, "find_process_mode", translate("Enable Process Rule"))
o.description = translate("Whether to Enable Process Rules, If You Are Not Sure, Please Choose off Which Useful in Router Environment")
o:value("0", translate("Disable"))
o:value("off", translate("OFF "))
o:value("always", translate("Always "))
o:value("strict", translate("strict "))
o.default = "0"
o = s:taboption("meta", ListValue, "global_client_fingerprint", translate("Client Fingerprint"))
o.description = translate("Change The Client Fingerprint, Only Support TLS Transport in TCP/GRPC/WS/HTTP For Vless/Vmess and Trojan")
o:value("0", translate("Disable"))
o:value("none", translate("None "))
o:value("random", translate("Random"))
o:value("chrome", translate("Chrome"))
o:value("firefox", translate("Firefox"))
o:value("safari", translate("Safari"))
o:value("ios", translate("IOS"))
o:value("android", translate("Android"))
o:value("edge", translate("Edge"))
o:value("360", translate("360"))
o:value("qq", translate("QQ"))
o.default = "0"
o = s:taboption("meta", ListValue, "geodata_loader", translate("Geodata Loader Mode"))
o:value("0", translate("Disable"))
o:value("memconservative", translate("Memconservative"))
o:value("standard", translate("Standard"))
o.default = "0"
o = s:taboption("meta", Flag, "enable_geoip_dat", translate("Enable GeoIP Dat"))
o.description = translate("Replace GEOIP MMDB With GEOIP Dat, Large Size File")..", "..font_red..bold_on..translate("Need Download First")..bold_off..font_off
o.default = 0
o = s:taboption("meta", Flag, "enable_meta_sniffer", font_red..bold_on..translate("Enable Sniffer")..bold_off..font_off)
o.description = font_red..bold_on..translate("Sniffer Will Prevent Domain Name Proxy and DNS Hijack Failure")..bold_off..font_off
o.default = 1
o = s:taboption("meta", Flag, "enable_meta_sniffer_pure_ip", translate("Forced Sniff Pure IP"))
o.description = translate("Forced Sniff Pure IP Connections")
o.default = 1
o:depends("enable_meta_sniffer", "1")
o = s:taboption("meta", Flag, "enable_meta_sniffer_custom", translate("Custom Sniffer Settings"))
o.description = translate("Custom The Force and Skip Sniffing Doamin Lists")
o.default = 0
o:depends("enable_meta_sniffer", "1")
sniffing_domain_force = s:taboption("meta", Value, "sniffing_domain_force")
sniffing_domain_force:depends("enable_meta_sniffer_custom", "1")
sniffing_domain_force.template = "cbi/tvalue"
sniffing_domain_force.description = translate("Will Override Dns Queries If Domains in The List")
sniffing_domain_force.rows = 20
sniffing_domain_force.wrap = "off"
function sniffing_domain_force.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_force_sniffing_domain.yaml") or ""
end
function sniffing_domain_force.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_force_sniffing_domain.yaml")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_force_sniffing_domain.yaml", value)
end
end
end
sniffing_port_filter = s:taboption("meta", Value, "sniffing_port_filter")
sniffing_port_filter:depends("enable_meta_sniffer_custom", "1")
sniffing_port_filter.template = "cbi/tvalue"
sniffing_port_filter.description = translate("Will Only Sniffing If Ports in The List")
sniffing_port_filter.rows = 20
sniffing_port_filter.wrap = "off"
function sniffing_port_filter.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_sniffing_ports_filter.yaml") or ""
end
function sniffing_port_filter.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_sniffing_ports_filter.yaml")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_sniffing_ports_filter.yaml", value)
end
end
end
sniffing_domain_filter = s:taboption("meta", Value, "sniffing_domain_filter")
sniffing_domain_filter:depends("enable_meta_sniffer_custom", "1")
sniffing_domain_filter.template = "cbi/tvalue"
sniffing_domain_filter.description = translate("Will Disable Sniffing If Domains(sni) in The List")
sniffing_domain_filter.rows = 20
sniffing_domain_filter.wrap = "off"
function sniffing_domain_filter.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_sniffing_domain_filter.yaml") or ""
end
function sniffing_domain_filter.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_sniffing_domain_filter.yaml")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_sniffing_domain_filter.yaml", value)
end
end
end
---- Rules Settings
o = s:taboption("rules", Flag, "rule_source", translate("Enable Other Rules"))
o.description = translate("Use Other Rules")
o.default = 0
o = s:taboption("rules", Flag, "enable_rule_proxy", translate("Rule Match Proxy Mode"))
o.description = translate("Append Some Rules to Config, Allow Only Traffic Proxies that Match the Rule, Prevent BT/P2P Passing")
o.default = 0
o = s:taboption("rules", Flag, "enable_custom_clash_rules", font_red..bold_on..translate("Custom Clash Rules")..bold_off..font_off)
o.description = translate("Use Custom Rules")
o.default = 0
custom_rules = s:taboption("rules", Value, "custom_rules")
custom_rules:depends("enable_custom_clash_rules", 1)
custom_rules.template = "cbi/tvalue"
custom_rules.description = font_green..bold_on..translate("(Priority)")..bold_off..font_off.." "..translate("Custom Rules Here, For More Go:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://lancellc.gitbook.io/clash/clash-config-file/rules\")'>https://lancellc.gitbook.io/clash/clash-config-file/rules</a>".." ,"..translate("IP To CIDR:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"http://ip2cidr.com\")'>http://ip2cidr.com</a>"
custom_rules.rows = 20
custom_rules.wrap = "off"
function custom_rules.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_custom_rules.list") or ""
end
function custom_rules.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_custom_rules.list")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_custom_rules.list", value)
end
end
end
custom_rules_2 = s:taboption("rules", Value, "custom_rules_2")
custom_rules_2:depends("enable_custom_clash_rules", 1)
custom_rules_2.template = "cbi/tvalue"
custom_rules_2.description = font_green..bold_on..translate("(Extended)")..bold_off..font_off.." "..translate("Custom Rules Here, For More Go:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://lancellc.gitbook.io/clash/clash-config-file/rules\")'>https://lancellc.gitbook.io/clash/clash-config-file/rules</a>".." ,"..translate("IP To CIDR:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"http://ip2cidr.com\")'>http://ip2cidr.com</a>"
custom_rules_2.rows = 20
custom_rules_2.wrap = "off"
function custom_rules_2.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_custom_rules_2.list") or ""
end
function custom_rules_2.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_custom_rules_2.list")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_custom_rules_2.list", value)
end
end
end
---- developer
o = s:taboption("developer", Value, "ymchange_custom")
o.template = "cbi/tvalue"
o.description = translate("Custom Config Overwrite Scripts Which Will Run After Plugin Own Completely, Please Be Careful, The Wrong Changes May Lead to Exceptions")
o.rows = 30
o.wrap = "off"
function o.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_custom_overwrite.sh") or ""
end
function o.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_custom_overwrite.sh")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_custom_overwrite.sh", value)
end
end
end
-- [[ Edit Custom DNS ]] --
ds = m:section(TypedSection, "dns_servers", translate("Add Custom DNS Servers")..translate("(Take Effect After Choose Above)"))
ds.anonymous = true
ds.addremove = true
ds.sortable = true
ds.template = "openclash/tblsection_dns"
ds.extedit = luci.dispatcher.build_url("admin/services/openclash/custom-dns-edit/%s")
function ds.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(ds.extedit % sid)
return
end
end
---- enable flag
o = ds:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
---- group
o = ds:option(ListValue, "group", translate("DNS Server Group"))
o:value("nameserver", translate("NameServer "))
o:value("fallback", translate("FallBack "))
o:value("default", translate("Default-NameServer"))
o.default = "nameserver"
o.rempty = false
---- IP address
o = ds:option(Value, "ip", translate("DNS Server Address"))
o.placeholder = translate("Not Null")
o.datatype = "or(host, string)"
o.rmempty = true
---- port
o = ds:option(Value, "port", translate("DNS Server Port"))
o.datatype = "port"
o.rempty = true
---- type
o = ds:option(ListValue, "type", translate("DNS Server Type"))
o:value("udp", translate("UDP"))
o:value("tcp", translate("TCP"))
o:value("tls", translate("TLS"))
o:value("https", translate("HTTPS"))
o:value("quic", translate("QUIC ")..translate("(Only Meta Core)"))
o.default = "udp"
o.rempty = false
-- [[ Other Rules Manage ]]--
ss = m:section(TypedSection, "other_rules", translate("Other Rules Edit")..translate("(Take Effect After Choose Above)"))
ss.anonymous = true
ss.addremove = true
ss.sortable = true
ss.template = "cbi/tblsection"
ss.extedit = luci.dispatcher.build_url("admin/services/openclash/other-rules-edit/%s")
function ss.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(ss.extedit % sid)
return
end
end
o = ss:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
o = ss:option(DummyValue, "config", translate("Config File"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = ss:option(DummyValue, "rule_name", translate("Other Rules Name"))
function o.cfgvalue(...)
if Value.cfgvalue(...) == "lhie1" then
return translate("lhie1 Rules")
elseif Value.cfgvalue(...) == "ConnersHua" then
return translate("ConnersHua(Provider-type) Rules")
elseif Value.cfgvalue(...) == "ConnersHua_return" then
return translate("ConnersHua Return Rules")
else
return translate("None")
end
end
o = ss:option(DummyValue, "Note", translate("Note"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
-- [[ Edit Authentication ]] --
s = m:section(TypedSection, "authentication", translate("Set Authentication of SOCKS5/HTTP(S)"))
s.anonymous = true
s.addremove = true
s.sortable = false
s.template = "cbi/tblsection"
s.rmempty = false
---- enable flag
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
---- username
o = s:option(Value, "username", translate("Username"))
o.placeholder = translate("Not Null")
o.rempty = true
---- password
o = s:option(Value, "password", translate("Password"))
o.placeholder = translate("Not Null")
o.rmempty = true
local t = {
{Commit, Apply}
}
a = m:section(Table, t)
o = a:option(Button, "Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit("openclash")
end
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Apply Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:set("openclash", "config", "enable", 1)
m.uci:commit("openclash")
SYS.call("/etc/init.d/openclash restart >/dev/null 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "openclash"))
end
m:append(Template("openclash/config_editor"))
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,213 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local fs = require "luci.openclash"
local sys = require "luci.sys"
local json = require "luci.jsonc"
local sid = arg[1]
font_red = [[<b style=color:red>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
m = Map(openclash, translate("Config Subscribe Edit"))
m.pageaction = false
m.description=translate("Convert Subscribe function of Online is Supported By subconverter Written By tindy X") ..
"<br/>"..
"<br/>"..translate("API By tindy X & lhie1")..
"<br/>"..
"<br/>"..translate("Subconverter external configuration (subscription conversion template) Description: https://github.com/tindy2013/subconverter#external-configuration-file")..
"<br/>"..
"<br/>"..translate("If you need to customize the external configuration file (subscription conversion template), please write it according to the instructions, upload it to the accessible location of the external network, and fill in the address correctly when using it")..
"<br/>"..
"<br/>"..translate("If you have a recommended external configuration file (subscription conversion template), you can modify by following The file format of /usr/share/openclash/res/sub_ini.list and pr")
m.redirect = luci.dispatcher.build_url("admin/services/openclash/config-subscribe")
if m.uci:get(openclash, sid) ~= "config_subscribe" then
luci.http.redirect(m.redirect)
return
end
-- [[ Config Subscribe Setting ]]--
s = m:section(NamedSection, sid, "config_subscribe")
s.anonymous = true
s.addremove = false
---- name
o = s:option(Value, "name", translate("Config Alias"))
o.description = font_red..bold_on..translate("Name For Distinguishing")..bold_off..font_off
o.placeholder = translate("config")
o.rmempty = true
---- address
o = s:option(Value, "address", translate("Subscribe Address"))
o.template = "cbi/tvalue"
o.rows = 10
o.wrap = "off"
o.description = font_red..bold_on..translate("SS/SSR/Vmess or Other Link And Subscription Address is Supported When Online Subscription Conversion is Enabled, Multiple Links Should be One Per Line or Separated By |")..bold_off..font_off
o.placeholder = translate("Not Null")
o.rmempty = false
function o.validate(self, value)
if value then
value = value:gsub("\r\n?", "\n")
value = value:gsub("%c*$", "")
end
return value
end
local sub_path = "/tmp/dler_sub"
local info, token, get_sub, sub_info
local token = uci:get("openclash", "config", "dler_token")
if token then
get_sub = string.format("curl -sL -H 'Content-Type: application/json' --connect-timeout 2 -d '{\"access_token\":\"%s\"}' -X POST https://dler.cloud/api/v1/managed/clash -o %s", token, sub_path)
if not nixio.fs.access(sub_path) then
luci.sys.exec(get_sub)
else
if fs.readfile(sub_path) == "" or not fs.readfile(sub_path) then
luci.sys.exec(get_sub)
end
end
sub_info = fs.readfile(sub_path)
if sub_info then
sub_info = json.parse(sub_info)
end
if sub_info and sub_info.ret == 200 then
o:value(sub_info.smart)
o:value(sub_info.ss)
o:value(sub_info.vmess)
o:value(sub_info.trojan)
else
fs.unlink(sub_path)
end
end
---- subconverter
o = s:option(Flag, "sub_convert", translate("Subscribe Convert Online"))
o.description = translate("Convert Subscribe Online With Template")
o.default = 0
---- Convert Address
o = s:option(Value, "convert_address", translate("Convert Address"))
o.rmempty = true
o.description = font_red..bold_on..translate("Note: There is A Risk of Privacy Leakage in Online Convert")..bold_off..font_off
o:depends("sub_convert", "1")
o:value("https://api.dler.io/sub", translate("api.dler.io")..translate("(Default)"))
o:value("https://subconverter.herokuapp.com/sub", translate("subconverter.herokuapp.com")..translate("(Default)"))
o:value("https://v.id9.cc/sub", translate("v.id9.cc")..translate("(Support Vless By Pinyun)"))
o:value("https://sub.id9.cc/sub", translate("sub.id9.cc"))
o:value("https://api.wcc.best/sub", translate("api.wcc.best"))
o.default = "https://api.dler.io/sub"
---- Template
o = s:option(ListValue, "template", translate("Template Name"))
o.rmempty = true
o:depends("sub_convert", "1")
file = io.open("/usr/share/openclash/res/sub_ini.list", "r");
for l in file:lines() do
if l ~= "" and l ~= nil then
o:value(string.sub(luci.sys.exec(string.format("echo '%s' |awk -F ',' '{print $1}' 2>/dev/null",l)),1,-2))
end
end
file:close()
o:value("0", translate("Custom Template"))
---- Custom Template
o = s:option(Value, "custom_template_url", translate("Custom Template URL"))
o.rmempty = true
o.placeholder = translate("Not Null")
o.datatype = "or(host, string)"
o:depends("template", "0")
---- emoji
o = s:option(ListValue, "emoji", translate("Emoji"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default = "false"
o:depends("sub_convert", "1")
---- udp
o = s:option(ListValue, "udp", translate("UDP Enable"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default = "false"
o:depends("sub_convert", "1")
---- skip-cert-verify
o = s:option(ListValue, "skip_cert_verify", translate("skip-cert-verify"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default = "false"
o:depends("sub_convert", "1")
---- sort
o = s:option(ListValue, "sort", translate("Sort"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default = "false"
o:depends("sub_convert", "1")
---- node type
o = s:option(ListValue, "node_type", translate("Append Node Type"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default = "false"
o:depends("sub_convert", "1")
---- rule provider
o = s:option(ListValue, "rule_provider", translate("Use Rule Provider"))
o.description = font_red..bold_on..translate("Note: Please Make Sure Backend Service Supports This Feature")..bold_off..font_off
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default = "false"
o:depends("sub_convert", "1")
---- key
o = s:option(DynamicList, "keyword", font_red..bold_on..translate("Keyword Match")..bold_off..font_off)
o.description = font_red..bold_on..translate("eg: hk or tw&bgp")..bold_off..font_off
o.rmempty = true
---- exkey
o = s:option(DynamicList, "ex_keyword", font_red..bold_on..translate("Exclude Keyword Match")..bold_off..font_off)
o.description = font_red..bold_on..translate("eg: hk or tw&bgp")..bold_off..font_off
o.rmempty = true
---- de_exkey
o = s:option(MultiValue, "de_ex_keyword", font_red..bold_on..translate("Exclude Keyword Match Default")..bold_off..font_off)
o.rmempty = true
o:depends("sub_convert", 0)
o:value("过期时间")
o:value("剩余流量")
o:value("TG群")
o:value("官网")
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button,"Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,150 @@
local m, s, o
local openclash = "openclash"
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require "luci.model.uci".cursor()
font_red = [[<b style=color:red>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
m = Map("openclash", translate("Config Subscribe"))
m.pageaction = false
s = m:section(TypedSection, "openclash")
s.anonymous = true
---- update Settings
o = s:option(Flag, "auto_update", translate("Auto Update"))
o.description = translate("Auto Update Server subscription")
o.default = 0
o = s:option(ListValue, "config_auto_update_mode", translate("Update Mode"))
o:depends("auto_update", "1")
o:value("0", translate("Appointment Mode"))
o:value("1", translate("Loop Mode"))
o.default = "0"
o.rmempty = true
o = s:option(ListValue, "config_update_week_time", translate("Update Time (Every Week)"))
o:depends("config_auto_update_mode", "0")
o:value("*", translate("Every Day"))
o:value("1", translate("Every Monday"))
o:value("2", translate("Every Tuesday"))
o:value("3", translate("Every Wednesday"))
o:value("4", translate("Every Thursday"))
o:value("5", translate("Every Friday"))
o:value("6", translate("Every Saturday"))
o:value("0", translate("Every Sunday"))
o.default = "1"
o.rmempty = true
o = s:option(ListValue, "auto_update_time", translate("Update time (every day)"))
o:depends("config_auto_update_mode", "0")
for t = 0,23 do
o:value(t, t..":00")
end
o.default = "0"
o.rmempty = true
o = s:option(Value, "config_update_interval", translate("Update Interval(min)"))
o.default = "60"
o.datatype = "integer"
o:depends("config_auto_update_mode", "1")
o.rmempty = true
-- [[ Edit Server ]] --
s = m:section(TypedSection, "config_subscribe", translate("Config Subscribe Edit"))
s.anonymous = true
s.addremove = true
s.sortable = true
s.template = "cbi/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/openclash/config-subscribe-edit/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(s.extedit % sid)
return
end
end
---- enable flag
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
---- name
o = s:option(DummyValue, "name", translate("Config Alias"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("config")
end
---- address
o = s:option(DummyValue, "address", translate("Subscribe Address"))
function o.cfgvalue(...)
if Value.cfgvalue(...) then
if string.len(Value.cfgvalue(...)) <= 50 then
return Value.cfgvalue(...)
else
return string.sub(Value.cfgvalue(...), 1, 50) .. " ..."
end
end
return translate("None")
end
---- template
o = s:option(DummyValue, "template", translate("Template Name"))
function o.cfgvalue(...)
if Value.cfgvalue(...) ~= "0" then
return Value.cfgvalue(...) or translate("None")
else
return translate("Custom Template")
end
end
local t = {
{Commit, Apply}
}
a = m:section(Table, t)
o = a:option(Button, "Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
m.uci:commit("openclash")
end
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Update Config")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
m.uci:set("openclash", "config", "enable", 1)
m.uci:commit("openclash")
uci:foreach("openclash", "config_subscribe",
function(s)
if s.name ~= "" and s.name ~= nil and s.enabled == "1" then
local back_cfg_path_yaml="/etc/openclash/backup/" .. s.name .. ".yaml"
local back_cfg_path_yml="/etc/openclash/backup/" .. s.name .. ".yml"
fs.unlink(back_cfg_path_yaml)
fs.unlink(back_cfg_path_yml)
end
end)
SYS.call("/usr/share/openclash/openclash.sh >/dev/null 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "openclash"))
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,469 @@
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require("luci.model.uci").cursor()
local CHIF = "0"
font_green = [[<b style=color:green>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
align_mid = [[<p align="center">]]
align_mid_off = [[</p>]]
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e == ".yaml"
end
function IsYmlFile(e)
e=e or""
local e=string.lower(string.sub(e,-4,-1))
return e == ".yml"
end
function default_config_set(f)
local cf = uci:get("openclash", "config", "config_path")
if cf == "/etc/openclash/config/"..f or not cf or cf == "" or not fs.isfile(cf) then
if CHIF == "1" and cf == "/etc/openclash/config/"..f then
return
end
local fis = fs.glob("/etc/openclash/config/*")[1]
if fis ~= nil then
fcf = fs.basename(fis)
if fcf then
uci:set("openclash", "config", "config_path", "/etc/openclash/config/"..fcf)
uci:commit("openclash")
end
else
uci:set("openclash", "config", "config_path", "/etc/openclash/config/config.yaml")
uci:commit("openclash")
end
end
end
function config_check(CONFIG_FILE)
local yaml = fs.isfile(CONFIG_FILE)
if yaml then
yaml = SYS.exec(string.format('ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "puts YAML.load_file(\'%s\')" 2>/dev/null',CONFIG_FILE))
if yaml ~= "false\n" and yaml ~= "" then
return "Config Normal"
else
return "Config Abnormal"
end
elseif (yaml ~= 0) then
return "File Not Exist"
end
end
ful = SimpleForm("upload", translate("Config Manage"), nil)
ful.reset = false
ful.submit = false
sul =ful:section(SimpleSection, "")
o = sul:option(FileUpload, "")
o.template = "openclash/upload"
um = sul:option(DummyValue, "", nil)
um.template = "openclash/dvalue"
local dir, fd, clash
clash = "/etc/openclash/clash"
dir = "/etc/openclash/config/"
bakck_dir="/etc/openclash/backup"
proxy_pro_dir="/etc/openclash/proxy_provider/"
rule_pro_dir="/etc/openclash/rule_provider/"
core_dir="/etc/openclash/core/core/"
backup_dir="/tmp/"
create_bakck_dir=fs.mkdir(bakck_dir)
create_proxy_pro_dir=fs.mkdir(proxy_pro_dir)
create_rule_pro_dir=fs.mkdir(rule_pro_dir)
HTTP.setfilehandler(
function(meta, chunk, eof)
local fp = HTTP.formvalue("file_type")
if not fd then
if not meta then return end
if fp == "config" then
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
elseif fp == "proxy-provider" then
if meta and chunk then fd = nixio.open(proxy_pro_dir .. meta.file, "w") end
elseif fp == "rule-provider" then
if meta and chunk then fd = nixio.open(rule_pro_dir .. meta.file, "w") end
elseif fp == "clash" or fp == "clash_tun" or fp == "clash_meta" then
create_core_dir=fs.mkdir(core_dir)
if meta and chunk then fd = nixio.open(core_dir .. meta.file, "w") end
elseif fp == "backup-file" then
if meta and chunk then fd = nixio.open(backup_dir .. meta.file, "w") end
end
if not fd then
um.value = translate("upload file error.")
return
end
end
if chunk and fd then
fd:write(chunk)
end
if eof and fd then
fd:close()
fd = nil
if fp == "config" then
CHIF = "1"
if IsYamlFile(meta.file) then
local yamlbackup="/etc/openclash/backup/" .. meta.file
local c=fs.copy(dir .. meta.file,yamlbackup)
default_config_set(meta.file)
end
if IsYmlFile(meta.file) then
local ymlname=string.lower(string.sub(meta.file,0,-5))
local ymlbackup="/etc/openclash/backup/".. ymlname .. ".yaml"
local c=fs.rename(dir .. meta.file,"/etc/openclash/config/".. ymlname .. ".yaml")
local c=fs.copy("/etc/openclash/config/".. ymlname .. ".yaml",ymlbackup)
local yamlname=ymlname .. ".yaml"
default_config_set(yamlname)
end
um.value = translate("File saved to") .. ' "/etc/openclash/config/"'
elseif fp == "proxy-provider" then
um.value = translate("File saved to") .. ' "/etc/openclash/proxy_provider/"'
elseif fp == "rule-provider" then
um.value = translate("File saved to") .. ' "/etc/openclash/rule_provider/"'
elseif fp == "clash" or fp == "clash_tun" or fp == "clash_meta" then
if string.lower(string.sub(meta.file, -7, -1)) == ".tar.gz" then
os.execute(string.format("tar -C '/etc/openclash/core/core' -xzf %s >/dev/null 2>&1", (core_dir .. meta.file)))
fs.unlink(core_dir .. meta.file)
os.execute(string.format("mv $(echo \"/etc/openclash/core/core/$(ls /etc/openclash/core/core/)\") '/etc/openclash/core/%s' >/dev/null 2>&1", fp))
elseif string.lower(string.sub(meta.file, -3, -1)) == ".gz" then
os.execute(string.format("mv %s '/etc/openclash/core/%s.gz' >/dev/null 2>&1", (core_dir .. meta.file), fp))
os.execute("gzip -fd '/etc/openclash/core/%s.gz' >/dev/null 2>&1" %fp)
fs.unlink("/etc/openclash/core/%s.gz" %fp)
else
os.execute(string.format("mv $(echo \"/etc/openclash/core/core/$(ls /etc/openclash/core/core/)\") '/etc/openclash/core/%s' >/dev/null 2>&1", fp))
end
os.execute("chmod 4755 /etc/openclash/core/%s >/dev/null 2>&1" %fp)
os.execute("rm -rf %s >/dev/null 2>&1" %core_dir)
um.value = translate("File saved to") .. ' "/etc/openclash/core/"'
elseif fp == "backup-file" then
os.execute("tar -C '/etc/openclash/' -xzf %s >/dev/null 2>&1" % (backup_dir .. meta.file))
os.execute("mv /etc/openclash/openclash /etc/config/openclash >/dev/null 2>&1")
fs.unlink(backup_dir .. meta.file)
um.value = translate("Backup File Restore Successful!")
end
fs.unlink("/tmp/Proxy_Group")
end
end
)
if HTTP.formvalue("upload") then
local f = HTTP.formvalue("ulfile")
if #f <= 0 then
um.value = translate("No Specify Upload File")
end
end
local e,a={}
for t,o in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(o)
if a then
e[t]={}
e[t].name=fs.basename(o)
BACKUP_FILE="/etc/openclash/backup/".. e[t].name
if fs.mtime(BACKUP_FILE) then
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE))
else
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
end
if uci:get("openclash", "config", "config_path") and string.sub(uci:get("openclash", "config", "config_path"), 23, -1) == e[t].name then
e[t].state=translate("Enable")
else
e[t].state=translate("Disable")
end
e[t].size=fs.filesize(a.size)
e[t].check=translate(config_check(o))
e[t].remove=0
end
end
form=SimpleForm("config_file_list",translate("Config File List"))
form.reset=false
form.submit=false
tb=form:section(Table,e)
st=tb:option(DummyValue,"state",translate("State"))
nm=tb:option(DummyValue,"name",translate("Config Alias"))
sb=tb:option(DummyValue,"name",translate("Subscription Info"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
sz=tb:option(DummyValue,"size",translate("Size"))
ck=tb:option(DummyValue,"check",translate("Grammar Check"))
st.template="openclash/cfg_check"
ck.template="openclash/cfg_check"
sb.template="openclash/sub_info_show"
btnis=tb:option(Button,"switch",translate("Switch Config"))
btnis.template="openclash/other_button"
btnis.render=function(o,t,a)
if not e[t] then return false end
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
a.display=""
else
a.display="none"
end
o.inputstyle="apply"
Button.render(o,t,a)
end
btnis.write=function(a,t)
fs.unlink("/tmp/Proxy_Group")
uci:set("openclash", "config", "config_path", "/etc/openclash/config/"..e[t].name)
uci:commit("openclash")
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "openclash", "config"))
end
btned=tb:option(Button,"edit",translate("Edit"))
btned.render=function(o,t,a)
o.inputstyle="apply"
Button.render(o,t,a)
end
btned.write=function(a,t)
local file_path = "etc/openclash/config/" .. fs.basename(e[t].name)
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "other-file-edit", "config", "%s") %file_path)
end
btncp=tb:option(Button,"copy",translate("Copy Config"))
btncp.template="openclash/other_button"
btncp.render=function(o,t,a)
if not e[t] then return false end
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
a.display=""
else
a.display="none"
end
o.inputstyle="apply"
Button.render(o,t,a)
end
btncp.write=function(a,t)
local num = 1
while true do
num = num + 1
if not fs.isfile("/etc/openclash/config/"..fs.filename(e[t].name).."("..num..")"..".yaml") then
fs.copy("/etc/openclash/config/"..e[t].name, "/etc/openclash/config/"..fs.filename(e[t].name).."("..num..")"..".yaml")
break
end
end
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "openclash", "config"))
end
btnrn=tb:option(DummyValue,"/etc/openclash/config/",translate("Rename"))
btnrn.template="openclash/input_rename"
btnrn.rawhtml = true
btnrn.render=function(c,t,a)
c.value = e[t].name
Button.render(c,t,a)
end
btndl = tb:option(Button,"download",translate("Download Config"))
btndl.template="openclash/other_button"
btndl.render=function(e,t,a)
e.inputstyle="remove"
Button.render(e,t,a)
end
btndl.write = function (a,t)
local sPath, sFile, fd, block
sPath = "/etc/openclash/config/"..e[t].name
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".tar.gz"
else
fd = nixio.open(sPath, "r")
end
if not fd then
return
end
HTTP.header('Content-Disposition', 'attachment; filename="%s"' % {sFile})
HTTP.prepare_content("application/octet-stream")
while true do
block = fd:read(nixio.const.buffersize)
if (not block) or (#block ==0) then
break
else
HTTP.write(block)
end
end
fd:close()
HTTP.close()
end
btndlr = tb:option(Button,"download_run",translate("Download Running Config"))
btndlr.template="openclash/other_button"
btndlr.render=function(c,t,a)
if nixio.fs.access("/etc/openclash/"..e[t].name) then
a.display=""
else
a.display="none"
end
c.inputstyle="remove"
Button.render(c,t,a)
end
btndlr.write = function (a,t)
local sPath, sFile, fd, block
sPath = "/etc/openclash/"..e[t].name
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".tar.gz"
else
fd = nixio.open(sPath, "r")
end
if not fd then
return
end
HTTP.header('Content-Disposition', 'attachment; filename="%s"' % {sFile})
HTTP.prepare_content("application/octet-stream")
while true do
block = fd:read(nixio.const.buffersize)
if (not block) or (#block ==0) then
break
else
HTTP.write(block)
end
end
fd:close()
HTTP.close()
end
btnrm=tb:option(Button,"remove",translate("Remove"))
btnrm.render=function(e,t,a)
e.inputstyle="reset"
Button.render(e,t,a)
end
btnrm.write=function(a,t)
fs.unlink("/tmp/Proxy_Group")
fs.unlink("/etc/openclash/backup/"..fs.basename(e[t].name))
fs.unlink("/etc/openclash/history/"..fs.filename(e[t].name))
fs.unlink("/etc/openclash/history/"..fs.filename(e[t].name)..".db")
fs.unlink("/etc/openclash/"..fs.basename(e[t].name))
local a=fs.unlink("/etc/openclash/config/"..fs.basename(e[t].name))
default_config_set(fs.basename(e[t].name))
if a then table.remove(e,t)end
HTTP.redirect(DISP.build_url("admin", "services", "openclash","config"))
end
p = SimpleForm("provider_file_manage",translate("Provider File Manage"))
p.reset = false
p.submit = false
local provider_manage = {
{proxy_mg, rule_mg, game_mg}
}
promg = p:section(Table, provider_manage)
o = promg:option(Button, "proxy_mg", " ")
o.inputtitle = translate("Proxy Provider File List")
o.inputstyle = "reload"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "proxy-provider-file-manage"))
end
o = promg:option(Button, "rule_mg", " ")
o.inputtitle = translate("Rule Providers File List")
o.inputstyle = "reload"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "rule-providers-file-manage"))
end
o = promg:option(Button, "game_mg", " ")
o.inputtitle = translate("Game Rules File List")
o.inputstyle = "reload"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "game-rules-file-manage"))
end
m = SimpleForm("openclash",translate("Config File Edit"))
m.reset = false
m.submit = false
local tab = {
{user, default}
}
s = m:section(Table, tab)
s.description = align_mid..translate("Support syntax check, press").." "..font_green..bold_on.."F10"..bold_off..font_off.." "..translate("to control diff option, press").." "..font_green..bold_on.."F11"..bold_off..font_off.." "..translate("to enter full screen editing mode")..align_mid_off
s.anonymous = true
s.addremove = false
local conf = uci:get("openclash", "config", "config_path")
local dconf = "/usr/share/openclash/res/default.yaml"
if not conf then conf = "/etc/openclash/config/config.yaml" end
local conf_name = fs.basename(conf)
if not conf_name then conf_name = "config.yaml" end
local sconf = "/etc/openclash/"..conf_name
sev = s:option(TextValue, "user")
---sev.description = align_mid..translate("Modify Your Config file:").." "..font_green..bold_on..conf_name..bold_off..font_off.." "..translate("Here, Except The Settings That Were Taken Over")..align_mid_off
sev.rows = 40
sev.wrap = "off"
sev.cfgvalue = function(self, section)
return NXFS.readfile(conf) or NXFS.readfile(dconf) or ""
end
sev.write = function(self, section, value)
if (CHIF == "0") then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile(conf)
if value ~= old_value then
NXFS.writefile(conf, value)
end
end
end
def = s:option(TextValue, "default")
if fs.isfile(sconf) then
---def.description = align_mid..translate("Config File Edited By OpenClash For Running")..align_mid_off
else
---def.description = align_mid..translate("Default Config File With Correct Template")..align_mid_off
end
def.rows = 40
def.wrap = "off"
def.readonly = true
def.cfgvalue = function(self, section)
return NXFS.readfile(sconf) or NXFS.readfile(dconf) or ""
end
def.write = function(self, section, value)
end
local t = {
{Commit, Create, Apply}
}
a = m:section(Table, t)
o = a:option(Button, "Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
uci:commit("openclash")
end
o = a:option(DummyValue, "Create", " ")
o.rawhtml = true
o.template = "openclash/input_file_name"
o.value = "/etc/openclash/config/"
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Apply Settings")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
uci:set("openclash", "config", "enable", 1)
uci:commit("openclash")
SYS.call("/etc/init.d/openclash restart >/dev/null 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "openclash"))
end
m:append(Template("openclash/config_editor"))
return ful , form , p , m

View File

@ -0,0 +1,135 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local fs = require "luci.openclash"
local SYS = require "luci.sys"
local sid = arg[1]
font_red = [[<b style=color:red>]]
font_green = [[<b style=color:green>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
m = Map(openclash, translate("Add Custom DNS Servers"))
m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/openclash/config-overwrite")
if m.uci:get(openclash, sid) ~= "dns_servers" then
luci.http.redirect(m.redirect)
return
end
-- [[ Edit Custom DNS ]] --
s = m:section(NamedSection, sid, "dns_servers")
s.anonymous = true
s.addremove = false
---- group
o = s:option(ListValue, "group", translate("DNS Server Group"))
o.description = font_red..bold_on..translate("NameServer Group Must Be Set")..bold_off..font_off
o:value("nameserver", translate("NameServer "))
o:value("fallback", translate("FallBack "))
o:value("default", translate("Default-NameServer"))
o.default = "nameserver"
o.rempty = false
---- IP address
o = s:option(Value, "ip", translate("DNS Server Address"))
o.description = translate("Do Not Add Type Ahead")
o.placeholder = translate("Not Null")
o.datatype = "or(host, string)"
o.rmempty = true
---- port
o = s:option(Value, "port", translate("DNS Server Port"))
o.description = translate("Require When Use Non-Standard Port")
o.datatype = "port"
o.rempty = true
---- type
o = s:option(ListValue, "type", translate("DNS Server Type"))
o.description = translate("Communication protocol")
o:value("udp", translate("UDP"))
o:value("tcp", translate("TCP"))
o:value("tls", translate("TLS"))
o:value("https", translate("HTTPS"))
o:value("quic", translate("QUIC ")..translate("(Only Meta Core)"))
o.default = "udp"
o.rempty = false
---- interface
o = s:option(Value, "interface", translate("Specific Interface"))
o.description = translate("DNS Lookup Only Through The Specific Interface")..translate("(Only TUN Core)")
local interfaces = SYS.exec("ls -l /sys/class/net/ 2>/dev/null |awk '{print $9}' 2>/dev/null")
for interface in string.gmatch(interfaces, "%S+") do
o:value(interface)
end
o:value("Disable", translate("Disable"))
o.default = "Disable"
o.rempty = false
---- Node Domain Resolve
o = s:option(Flag, "node_resolve", translate("Node Domain Resolve"), translate("Use For Node Domain Resolve")..translate("(Only Meta Core)"))
o.rmempty = false
o.default = o.disbled
---- Force HTTP/3
o = s:option(Flag, "http3", translate("Force HTTP/3"), translate("Force HTTP/3 to connect")..translate("(Only Meta Core)"))
o:depends("type", "https")
o.rmempty = false
o.default = o.disbled
---- Proxy group
o = s:option(Value, "specific_group", translate("Specific Group"))
o.description = translate("Group Use For Proxy The DNS")..translate("(Only Meta Core)")
o:depends("group", "nameserver")
o:depends("group", "fallback")
local groupnames,filename
filename = m.uci:get(openclash, "config", "config_path")
if filename then
groupnames = SYS.exec(string.format('ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "YAML.load_file(\'%s\')[\'proxy-groups\'].each do |i| puts i[\'name\']+\'##\' end" 2>/dev/null',filename))
if groupnames then
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
end
end
m.uci:foreach("openclash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil then
o:value(s.name)
end
end)
o:value("DIRECT")
o:value("REJECT")
o:value("Disable", translate("Disable"))
o.default = "Disable"
o.rempty = false
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button,"Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,123 @@
local rule_form
local openclash = "openclash"
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require "luci.model.uci".cursor()
local g,h={}
for n,m in ipairs(fs.glob("/etc/openclash/game_rules/*"))do
h=fs.stat(m)
if h then
g[n]={}
g[n].num=string.format(n)
g[n].name=fs.basename(m)
g[n].mtime=os.date("%Y-%m-%d %H:%M:%S",h.mtime)
g[n].size=fs.filesize(h.size)
g[n].remove=0
g[n].enable=false
end
end
rule_form=SimpleForm("game_rules_file_list",translate("Game Rules File List"))
rule_form.reset=false
rule_form.submit=false
tb2=rule_form:section(Table,g)
nu2=tb2:option(DummyValue,"num",translate("Serial Number"))
nm2=tb2:option(DummyValue,"name",translate("File Name"))
mt2=tb2:option(DummyValue,"mtime",translate("Update Time"))
sz2=tb2:option(DummyValue,"size",translate("Size"))
btned1=tb2:option(Button,"edit",translate("Edit"))
btned1.render=function(g,n,h)
g.inputstyle="apply"
Button.render(g,n,h)
end
btned1.write=function(h,n)
local file_path = "etc/openclash/game_rules/" .. fs.basename(g[n].name)
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "other-file-edit", "game-rules-file-manage", "%s") %file_path)
end
btndl2 = tb2:option(Button,"download2",translate("Download Config"))
btndl2.template="openclash/other_button"
btndl2.render=function(m,n,h)
m.inputstyle="remove"
Button.render(m,n,h)
end
btndl2.write = function (h,n)
local sPath, sFile, fd, block
sPath = "/etc/openclash/game_rules/"..g[n].name
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".tar.gz"
else
fd = nixio.open(sPath, "r")
end
if not fd then
return
end
HTTP.header('Content-Disposition', 'attachment; filename="%s"' % {sFile})
HTTP.prepare_content("application/octet-stream")
while true do
block = fd:read(nixio.const.buffersize)
if (not block) or (#block ==0) then
break
else
HTTP.write(block)
end
end
fd:close()
HTTP.close()
end
btnrm2=tb2:option(Button,"remove2",translate("Remove"))
btnrm2.render=function(g,n,h)
g.inputstyle="reset"
Button.render(g,n,h)
end
btnrm2.write=function(h,n)
local h=fs.unlink("/etc/openclash/game_rules/"..luci.openclash.basename(g[n].name))
if h then table.remove(g,n)end
return h
end
local t = {
{Refresh, Create, Delete_all, Apply}
}
a = rule_form:section(Table, t)
o = a:option(Button, "Refresh", " ")
o.inputtitle = translate("Refresh Page")
o.inputstyle = "apply"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "game-rules-file-manage"))
end
o = a:option(DummyValue, "Create", " ")
o.rawhtml = true
o.template = "openclash/input_file_name"
o.value = "/etc/openclash/game_rules/"
o = a:option(Button, "Delete_all", " ")
o.inputtitle = translate("Delete All File")
o.inputstyle = "remove"
o.write = function()
luci.sys.call("rm -rf /etc/openclash/game_rules/* >/dev/null 2>&1")
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "game-rules-file-manage"))
end
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "config"))
end
rule_form:append(Template("openclash/toolbar_show"))
return rule_form

View File

@ -0,0 +1,100 @@
local form, m
local openclash = "openclash"
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require "luci.model.uci".cursor()
m = SimpleForm("openclash", translate("Game Rules List"))
m.description=translate("Rule Project:").." SSTap-Rule ( https://github.com/FQrabbit/SSTap-Rule )"
m.reset = false
m.submit = false
local t = {
{Refresh, Apply}
}
a = m:section(Table, t)
o = a:option(Button, "Refresh", " ")
o.inputtitle = translate("Refresh Page")
o.inputstyle = "apply"
o.write = function()
SYS.call("rm -rf /tmp/rules_name 2>/dev/null")
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "game-rules-manage"))
end
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "rule-providers-settings"))
end
if not NXFS.access("/tmp/rules_name") then
SYS.call("awk -F ',' '{print $1}' /usr/share/openclash/res/game_rules.list > /tmp/rules_name 2>/dev/null")
end
file = io.open("/tmp/rules_name", "r");
---- Rules List
local e={},o,t
if NXFS.access("/tmp/rules_name") then
for o in file:lines() do
table.insert(e,o)
end
for t,o in ipairs(e) do
e[t]={}
e[t].num=string.format(t)
e[t].name=o
e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $3}' 2>/dev/null",e[t].name)),1,-2)
if e[t].filename == "" then
e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null",e[t].name)),1,-2)
end
RULE_FILE="/etc/openclash/game_rules/".. e[t].filename
if fs.mtime(RULE_FILE) then
e[t].size=fs.filesize(fs.stat(RULE_FILE).size)
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(RULE_FILE))
else
e[t].size="/"
e[t].mtime="/"
end
if fs.isfile(RULE_FILE) then
e[t].exist=translate("Exist")
else
e[t].exist=translate("Not Exist")
end
e[t].remove=0
end
end
file:close()
form=SimpleForm("filelist")
form.reset=false
form.submit=false
tb=form:section(Table,e)
nu=tb:option(DummyValue,"num",translate("Serial Number"))
st=tb:option(DummyValue,"exist",translate("State"))
st.template="openclash/cfg_check"
nm=tb:option(DummyValue,"name",translate("Rule Name"))
fm=tb:option(DummyValue,"filename",translate("File Name"))
sz=tb:option(DummyValue,"size",translate("Size"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
btnis=tb:option(DummyValue,"filename",translate("Download Rule"))
btnis.template="openclash/download_rule"
btnrm=tb:option(Button,"remove",translate("Remove"))
btnrm.render=function(e,t,a)
e.inputstyle="reset"
Button.render(e,t,a)
end
btnrm.write=function(a,t)
fs.unlink("/etc/openclash/game_rules/"..e[t].filename)
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "game-rules-manage"))
end
return m, form

View File

@ -0,0 +1,149 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local fs = require "luci.openclash"
local sys = require "luci.sys"
local sid = arg[1]
font_red = [[<b style=color:red>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e == ".yaml"
end
function IsYmlFile(e)
e=e or""
local e=string.lower(string.sub(e,-4,-1))
return e == ".yml"
end
m = Map(openclash, translate("Edit Group"))
m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/openclash/servers")
if m.uci:get(openclash, sid) ~= "groups" then
luci.http.redirect(m.redirect)
return
end
-- [[ Groups Setting ]]--
s = m:section(NamedSection, sid, "groups")
s.anonymous = true
s.addremove = false
o = s:option(ListValue, "config", translate("Config File"))
o:value("all", translate("Use For All Config File"))
local e,a={}
for t,f in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].name=fs.basename(f)
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
o:value(e[t].name)
end
end
end
o = s:option(ListValue, "type", translate("Group Type"))
o.rmempty = true
o.description = translate("Choose The Operation Mode")
o:value("select", translate("Manual-Select"))
o:value("url-test", translate("URL-Test"))
o:value("fallback", translate("Fallback"))
o:value("load-balance", translate("Load-Balance"))
o:value("relay", translate("Relay-Traffic"))
o = s:option(ListValue, "strategy", translate("Strategy Type"))
o.rmempty = true
o.description = translate("Choose The Load-Balance's Strategy Type")
o:value("consistent-hashing", translate("Consistent-hashing"))
o:value("round-robin", translate("Round-robin"))
o:depends("type", "load-balance")
o = s:option(Value, "name", translate("Group Name"))
o.rmempty = false
o.default = "Group - "..sid
o = s:option(ListValue, "disable_udp", translate("Disable UDP"))
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default = "false"
o.rmempty = false
o = s:option(Value, "test_url", translate("Test URL"))
o:value("http://cp.cloudflare.com/generate_204")
o:value("http://www.gstatic.com/generate_204")
o:value("https://cp.cloudflare.com/generate_204")
o.rmempty = false
o:depends("type", "url-test")
o:depends("type", "fallback")
o:depends("type", "load-balance")
o = s:option(Value, "test_interval", translate("Test Interval(s)"))
o.default = "300"
o.rmempty = false
o:depends("type", "url-test")
o:depends("type", "fallback")
o:depends("type", "load-balance")
o = s:option(Value, "tolerance", translate("Tolerance(ms)"))
o.default = "150"
o.rmempty = true
o:depends("type", "url-test")
o = s:option(Value, "policy_filter", translate("Provider Filter"))
o.rmempty = true
o.placeholder = "bgp|sg"
-- [[ interface-name ]]--
o = s:option(Value, "interface_name", translate("interface-name"))
o.rmempty = true
o.placeholder = translate("eth0")
-- [[ routing-mark ]]--
o = s:option(Value, "routing_mark", translate("routing-mark"))
o.rmempty = true
o.placeholder = translate("2333")
o = s:option(DynamicList, "other_group", translate("Other Group (Support Regex)"))
o.description = font_red..bold_on..translate("The Added Proxy Groups Must Exist Except 'DIRECT' & 'REJECT'")..bold_off..font_off
o:value("all", translate("All Groups"))
uci:foreach("openclash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil and s.name ~= m.uci:get(openclash, sid, "name") then
o:value(s.name)
end
end)
o:value("DIRECT")
o:value("REJECT")
o.rmempty = true
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button,"Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
sys.call("/usr/share/openclash/yml_groups_name_ch.sh")
luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,22 @@
--
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
m = Map("openclash", translate("Server Logs"))
s = m:section(TypedSection, "openclash")
m.pageaction = false
s.anonymous = true
s.addremove=false
log = s:option(TextValue, "clog")
log.readonly=true
log.pollcheck=true
log.template="openclash/log"
log.description = translate("")
log.rows = 29
m:append(Template("openclash/toolbar_show"))
m:append(Template("openclash/config_editor"))
return m

View File

@ -0,0 +1,73 @@
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local fs = require "luci.openclash"
local file_path = ""
local edit_file_name = "/tmp/openclash_edit_file_name"
for i = 2, #(arg) do
file_path = file_path .. "/" .. luci.http.urlencode(arg[i])
end
if not fs.isfile(file_path) and file_path ~= "" then
file_path = luci.http.urldecode(file_path)
end
--re-get file path to save
if NXFS.readfile(edit_file_name) ~= file_path and fs.isfile(file_path) then
NXFS.writefile(edit_file_name, file_path)
else
if not fs.isfile(file_path) and fs.isfile(edit_file_name) then
file_path = NXFS.readfile(edit_file_name)
fs.unlink(edit_file_name)
end
end
m = Map("openclash", translate("File Edit"))
m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/openclash/"..arg[1])
s = m:section(TypedSection, "openclash")
s.anonymous = true
s.addremove=false
o = s:option(TextValue, "edit_file")
o.rows = 50
o.wrap = "off"
function o.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile(file_path)
if value ~= old_value then
NXFS.writefile(file_path, value)
end
end
end
function o.cfgvalue(self, section)
return NXFS.readfile(file_path) or ""
end
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button, "Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
luci.http.redirect(m.redirect)
end
m:append(Template("openclash/config_editor"))
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,451 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local fs = require "luci.openclash"
local sys = require "luci.sys"
local sid = arg[1]
font_red = [[<b style=color:red>]]
font_green = [[<b style=color:green>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e == ".yaml"
end
function IsYmlFile(e)
e=e or""
local e=string.lower(string.sub(e,-4,-1))
return e == ".yml"
end
m = Map(openclash, translate("Other Rules Edit"))
m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/openclash/config-overwrite")
if m.uci:get(openclash, sid) ~= "other_rules" then
luci.http.redirect(m.redirect)
return
end
-- [[ Other Rules Setting ]]--
s = m:section(NamedSection, sid, "other_rules")
s.anonymous = true
s.addremove = false
o = s:option(Value, "Note", translate("Note"))
o.default = "default"
o.rmempty = false
o = s:option(ListValue, "config", translate("Config File"))
local e,a={}
local groupnames,filename
for t,f in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].name=fs.basename(f)
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
o:value(e[t].name)
end
if e[t].name == m.uci:get(openclash, sid, "config") then
filename = e[t].name
groupnames = sys.exec(string.format('ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "YAML.load_file(\'%s\')[\'proxy-groups\'].each do |i| puts i[\'name\']+\'##\' end" 2>/dev/null',f))
end
end
end
o = s:option(Button, translate("Get Group Names"))
o.title = translate("Get Group Names")
o.inputtitle = translate("Get Group Names")
o.description = translate("Get Group Names After Select Config File")
o.inputstyle = "reload"
o.write = function()
m.uci:commit("openclash")
luci.http.redirect(luci.dispatcher.build_url("admin/services/openclash/other-rules-edit/%s") % sid)
end
if groupnames ~= nil and filename ~= nil then
o = s:option(ListValue, "rule_name", translate("Other Rules Name"))
o.rmempty = true
o:value("lhie1", translate("lhie1 Rules"))
o:value("ConnersHua", translate("ConnersHua(Provider-type) Rules"))
o:value("ConnersHua_return", translate("ConnersHua Return Rules"))
o = s:option(ListValue, "GlobalTV", translate("GlobalTV"))
o:depends("rule_name", "lhie1")
o:depends("rule_name", "ConnersHua")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "AsianTV", translate("AsianTV"))
o:depends("rule_name", "lhie1")
o:depends("rule_name", "ConnersHua")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Proxy", translate("Proxy"))
o:depends("rule_name", "lhie1")
o:depends("rule_name", "ConnersHua")
o:depends("rule_name", "ConnersHua_return")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Youtube", translate("Youtube"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Bilibili", translate("Bilibili"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Bahamut", translate("Bahamut"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "HBOMax", translate("HBO Max"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "HBOGo", translate("HBO Go"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Pornhub", translate("Pornhub"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Apple", translate("Apple"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "AppleTV", translate("Apple TV"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "GoogleFCM", translate("Google FCM"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Scholar", translate("Scholar"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Microsoft", translate("Microsoft"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "OpenAI", translate("OpenAI"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Netflix", translate("Netflix"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Disney", translate("Disney Plus"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Discovery", translate("Discovery Plus"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "DAZN", translate("DAZN"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Spotify", translate("Spotify"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Steam", translate("Steam"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "miHoYo", translate("miHoYo"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Speedtest", translate("Speedtest"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Telegram", translate("Telegram"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Crypto", translate("Crypto"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Discord", translate("Discord"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "PayPal", translate("PayPal"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "AdBlock", translate("AdBlock"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "AntiIP", translate("Anti IP"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Domestic", translate("Domestic"))
o:depends("rule_name", "lhie1")
o:depends("rule_name", "ConnersHua")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
o = s:option(ListValue, "Others", translate("Others"))
o:depends("rule_name", "lhie1")
o:depends("rule_name", "ConnersHua")
o:depends("rule_name", "ConnersHua_return")
o.rmempty = true
o.description = translate("Choose Proxy Groups, Base On Your Config File").." ( "..font_green..bold_on..filename..bold_off..font_off.." )"
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")
end
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button,"Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
--luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,144 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local sys = require "luci.sys"
local sid = arg[1]
local fs = require "luci.openclash"
font_red = [[<b style=color:red>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e == ".yaml"
end
function IsYmlFile(e)
e=e or""
local e=string.lower(string.sub(e,-4,-1))
return e == ".yml"
end
m = Map(openclash, translate("Edit Proxy-Provider"))
m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/openclash/servers")
if m.uci:get(openclash, sid) ~= "proxy-provider" then
luci.http.redirect(m.redirect)
return
end
-- [[ Provider Setting ]]--
s = m:section(NamedSection, sid, "proxy-provider")
s.anonymous = true
s.addremove = false
o = s:option(ListValue, "config", translate("Config File"))
o:value("all", translate("Use For All Config File"))
local e,a={}
for t,f in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].name=fs.basename(f)
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
o:value(e[t].name)
end
end
end
o = s:option(Flag, "manual", translate("Custom Tag"))
o.rmempty = false
o.default = "0"
o.description = translate("Mark as Custom Node to Prevent Retention config from being Deleted When Enabled")
o = s:option(ListValue, "type", translate("Provider Type"))
o.rmempty = true
o.description = translate("Choose The Provider Type")
o:value("http")
o:value("file")
o = s:option(Value, "name", translate("Provider Name"))
o.rmempty = false
o.default = "Proxy-provider - "..sid
o = s:option(ListValue, "path", translate("Provider Path"))
o.description = translate("Update Your Proxy Provider File From Config Luci Page")
local p,h={}
for t,f in ipairs(fs.glob("/etc/openclash/proxy_provider/*"))do
h=fs.stat(f)
if h then
p[t]={}
p[t].name=fs.basename(f)
if IsYamlFile(p[t].name) or IsYmlFile(p[t].name) then
o:value("./proxy_provider/"..p[t].name)
end
end
end
o.rmempty = false
o:depends("type", "file")
o = s:option(Value, "provider_url", translate("Provider URL"))
o.rmempty = false
o:depends("type", "http")
o = s:option(Value, "provider_filter", translate("Provider Filter"))
o.rmempty = true
o.placeholder = "bgp|sg"
o = s:option(Value, "provider_interval", translate("Provider Interval(s)"))
o.default = "3600"
o.rmempty = false
o:depends("type", "http")
o = s:option(ListValue, "health_check", translate("Provider Health Check"))
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default = true
o = s:option(Value, "health_check_url", translate("Health Check URL"))
o:value("http://cp.cloudflare.com/generate_204")
o:value("http://www.gstatic.com/generate_204")
o:value("https://cp.cloudflare.com/generate_204")
o.rmempty = false
o = s:option(Value, "health_check_interval", translate("Health Check Interval(s)"))
o.default = "300"
o.rmempty = false
o = s:option(DynamicList, "groups", translate("Proxy Group (Support Regex)"))
o.description = font_red..bold_on..translate("No Need Set when Config Create, The added Proxy Groups Must Exist")..bold_off..font_off
o.rmempty = true
o:value("all", translate("All Groups"))
m.uci:foreach("openclash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil then
o:value(s.name)
end
end)
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button,"Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,123 @@
local proxy_form
local openclash = "openclash"
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require "luci.model.uci".cursor()
local p,r={}
for x,y in ipairs(fs.glob("/etc/openclash/proxy_provider/*"))do
r=fs.stat(y)
if r then
p[x]={}
p[x].num=string.format(x)
p[x].name=fs.basename(y)
p[x].mtime=os.date("%Y-%m-%d %H:%M:%S",r.mtime)
p[x].size=fs.filesize(r.size)
p[x].remove=0
p[x].enable=false
end
end
proxy_form=SimpleForm("proxy_provider_file_list",translate("Proxy Provider File List"))
proxy_form.reset=false
proxy_form.submit=false
tb1=proxy_form:section(Table,p)
nu1=tb1:option(DummyValue,"num",translate("Serial Number"))
nm1=tb1:option(DummyValue,"name",translate("File Name"))
mt1=tb1:option(DummyValue,"mtime",translate("Update Time"))
sz1=tb1:option(DummyValue,"size",translate("Size"))
btned1=tb1:option(Button,"edit",translate("Edit"))
btned1.render=function(p,x,r)
p.inputstyle="apply"
Button.render(p,x,r)
end
btned1.write=function(r,x)
local file_path = "etc/openclash/proxy_provider/" .. fs.basename(p[x].name)
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "other-file-edit", "proxy-provider-file-manage", "%s") %file_path)
end
btndl1 = tb1:option(Button,"download1",translate("Download Config"))
btndl1.template="openclash/other_button"
btndl1.render=function(y,x,r)
y.inputstyle="remove"
Button.render(y,x,r)
end
btndl1.write = function (r,x)
local sPath, sFile, fd, block
sPath = "/etc/openclash/proxy_provider/"..p[x].name
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".tar.gz"
else
fd = nixio.open(sPath, "r")
end
if not fd then
return
end
HTTP.header('Content-Disposition', 'attachment; filename="%s"' % {sFile})
HTTP.prepare_content("application/octet-stream")
while true do
block = fd:read(nixio.const.buffersize)
if (not block) or (#block ==0) then
break
else
HTTP.write(block)
end
end
fd:close()
HTTP.close()
end
btnrm1=tb1:option(Button,"remove1",translate("Remove"))
btnrm1.render=function(p,x,r)
p.inputstyle="reset"
Button.render(p,x,r)
end
btnrm1.write=function(r,x)
local r=fs.unlink("/etc/openclash/proxy_provider/"..luci.openclash.basename(p[x].name))
if r then table.remove(p,x)end
return r
end
local t = {
{Refresh, Create, Delete_all, Apply}
}
a = proxy_form:section(Table, t)
o = a:option(Button, "Refresh", " ")
o.inputtitle = translate("Refresh Page")
o.inputstyle = "apply"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "proxy-provider-file-manage"))
end
o = a:option(DummyValue, "Create", " ")
o.rawhtml = true
o.template = "openclash/input_file_name"
o.value = "/etc/openclash/proxy_provider/"
o = a:option(Button, "Delete_all", " ")
o.inputtitle = translate("Delete All File")
o.inputstyle = "remove"
o.write = function()
luci.sys.call("rm -rf /etc/openclash/proxy_provider/* >/dev/null 2>&1")
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "proxy-provider-file-manage"))
end
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "config"))
end
proxy_form:append(Template("openclash/toolbar_show"))
return proxy_form

View File

@ -0,0 +1,161 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local fs = require "luci.openclash"
local sys = require "luci.sys"
local sid = arg[1]
font_red = [[<b style=color:red>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e == ".yaml"
end
function IsYmlFile(e)
e=e or""
local e=string.lower(string.sub(e,-4,-1))
return e == ".yml"
end
m = Map(openclash, translate("Edit Rule Providers"))
m.pageaction = false
m.description=translate("规则集使用介绍https://lancellc.gitbook.io/clash/clash-config-file/rule-provider")
m.redirect = luci.dispatcher.build_url("admin/services/openclash/rule-providers-settings")
if m.uci:get(openclash, sid) ~= "rule_providers" then
luci.http.redirect(m.redirect)
return
end
-- [[ Rule Providers Setting ]]--
s = m:section(NamedSection, sid, "rule_providers")
s.anonymous = true
s.addremove = false
o = s:option(ListValue, "config", translate("Config File"))
o:value("all", translate("Use For All Config File"))
local e,a={}
for t,f in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].name=fs.basename(f)
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
o:value(e[t].name)
end
end
end
o = s:option(Value, "name", translate("Rule Providers Name"))
o.rmempty = false
o.default = "Rule-provider - "..sid
o = s:option(ListValue, "type", translate("Rule Providers Type"))
o.rmempty = true
o.description = translate("Choose The Rule Providers Type")
o:value("http", translate("http"))
o:value("file", translate("file"))
o = s:option(ListValue, "behavior", translate("Rule Behavior"))
o.rmempty = true
o.description = translate("Choose The Rule Behavior")
o:value("domain")
o:value("ipcidr")
o:value("classical")
o = s:option(ListValue, "format", translate("Rule Format")..translate("(TUN&Meta Core)"))
o.rmempty = true
o.description = translate("Choose The Rule File Format, For More Info:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://github.com/Dreamacro/clash/wiki/Premium%3A-Rule-Providers\")'>https://github.com/Dreamacro/clash/wiki/</a>"
o:value("yaml")
o:value("text")
o = s:option(ListValue, "path", translate("Rule Providers Path"))
o.description = translate("Update Your Rule Providers File From Config Luci Page")
local p,h={}
for t,f in ipairs(fs.glob("/etc/openclash/rule_provider/*"))do
h=fs.stat(f)
if h then
p[t]={}
p[t].name=fs.basename(f)
o:value("./rule_provider/"..p[t].name)
end
end
for t,f in ipairs(fs.glob("/etc/openclash/game_rules/*"))do
h=fs.stat(f)
if h then
p[t]={}
p[t].name=fs.basename(f)
o:value("./game_rules/"..p[t].name)
end
end
o.rmempty = false
o:depends("type", "file")
o = s:option(Value, "url", translate("Rule Providers URL"))
o.rmempty = false
o:depends("type", "http")
o = s:option(Value, "interval", translate("Rule Providers Interval(s)"))
o.default = "86400"
o.rmempty = false
o:depends("type", "http")
o = s:option(ListValue, "position", translate("Append Position"))
o.rmempty = false
o:value("0", translate("Priority Match"))
o:value("1", translate("Extended Match"))
o = s:option(ListValue, "group", translate("Set Proxy Group"))
o.description = font_red..bold_on..translate("The Added Proxy Groups Must Exist Except 'DIRECT' & 'REJECT'")..bold_off..font_off
o.rmempty = true
local groupnames,filename
filename = m.uci:get(openclash, "config", "config_path")
if filename then
groupnames = sys.exec(string.format('ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "YAML.load_file(\'%s\')[\'proxy-groups\'].each do |i| puts i[\'name\']+\'##\' end" 2>/dev/null',filename))
if groupnames then
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
end
end
m.uci:foreach("openclash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil then
o:value(s.name)
end
end)
o:value("DIRECT")
o:value("REJECT")
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button,"Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
sys.call("/usr/share/openclash/yml_groups_name_ch.sh")
luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,123 @@
local rule_form
local openclash = "openclash"
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require "luci.model.uci".cursor()
local g,h={}
for n,m in ipairs(fs.glob("/etc/openclash/rule_provider/*"))do
h=fs.stat(m)
if h then
g[n]={}
g[n].num=string.format(n)
g[n].name=fs.basename(m)
g[n].mtime=os.date("%Y-%m-%d %H:%M:%S",h.mtime)
g[n].size=fs.filesize(h.size)
g[n].remove=0
g[n].enable=false
end
end
rule_form=SimpleForm("rule_provider_file_list",translate("Rule Providers File List"))
rule_form.reset=false
rule_form.submit=false
tb2=rule_form:section(Table,g)
nu2=tb2:option(DummyValue,"num",translate("Serial Number"))
nm2=tb2:option(DummyValue,"name",translate("File Name"))
mt2=tb2:option(DummyValue,"mtime",translate("Update Time"))
sz2=tb2:option(DummyValue,"size",translate("Size"))
btned1=tb2:option(Button,"edit",translate("Edit"))
btned1.render=function(g,n,h)
g.inputstyle="apply"
Button.render(g,n,h)
end
btned1.write=function(h,n)
local file_path = "etc/openclash/rule_provider/" .. fs.basename(g[n].name)
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "other-file-edit", "rule-providers-file-manage", "%s") %file_path)
end
btndl2 = tb2:option(Button,"download2",translate("Download Config"))
btndl2.template="openclash/other_button"
btndl2.render=function(m,n,h)
m.inputstyle="remove"
Button.render(m,n,h)
end
btndl2.write = function (h,n)
local sPath, sFile, fd, block
sPath = "/etc/openclash/rule_provider/"..g[n].name
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".tar.gz"
else
fd = nixio.open(sPath, "r")
end
if not fd then
return
end
HTTP.header('Content-Disposition', 'attachment; filename="%s"' % {sFile})
HTTP.prepare_content("application/octet-stream")
while true do
block = fd:read(nixio.const.buffersize)
if (not block) or (#block ==0) then
break
else
HTTP.write(block)
end
end
fd:close()
HTTP.close()
end
btnrm2=tb2:option(Button,"remove2",translate("Remove"))
btnrm2.render=function(g,n,h)
g.inputstyle="reset"
Button.render(g,n,h)
end
btnrm2.write=function(h,n)
local h=fs.unlink("/etc/openclash/rule_provider/"..luci.openclash.basename(g[n].name))
if h then table.remove(g,n)end
return h
end
local t = {
{Refresh, Create, Delete_all, Apply}
}
a = rule_form:section(Table, t)
o = a:option(Button, "Refresh", " ")
o.inputtitle = translate("Refresh Page")
o.inputstyle = "apply"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "rule-providers-file-manage"))
end
o = a:option(DummyValue, "Create", " ")
o.rawhtml = true
o.template = "openclash/input_file_name"
o.value = "/etc/openclash/rule_provider/"
o = a:option(Button, "Delete_all", " ")
o.inputtitle = translate("Delete All File")
o.inputstyle = "remove"
o.write = function()
luci.sys.call("rm -rf /etc/openclash/rule_provider/* >/dev/null 2>&1")
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "rule-providers-file-manage"))
end
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "config"))
end
rule_form:append(Template("openclash/toolbar_show"))
return rule_form

View File

@ -0,0 +1,107 @@
local form, m
local openclash = "openclash"
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require "luci.model.uci".cursor()
m = SimpleForm("openclash", translate("Other Rule Providers List"))
m.description=translate("Rule Project:").." ConnersHua ( https://github.com/DivineEngine/Profiles )<br/>"..
translate("Rule Project:").." lhie1 ( https://github.com/dler-io/Rules )<br/>"..
translate("Rule Project:").." ACL4SSR ( https://github.com/ACL4SSR/ACL4SSR/tree/master )"
m.reset = false
m.submit = false
local t = {
{Apply}
}
a = m:section(Table, t)
o = a:option(Button, "Refresh", " ")
o.inputtitle = translate("Refresh Page")
o.inputstyle = "apply"
o.write = function()
SYS.call("rm -rf /tmp/rule_providers_name 2>/dev/null")
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "rule-providers-manage"))
end
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "rule-providers-settings"))
end
if not NXFS.access("/tmp/rule_providers_name") then
SYS.call("awk -v d=',' -F ',' '{print $4d$5}' /usr/share/openclash/res/rule_providers.list > /tmp/rule_providers_name 2>/dev/null")
end
file = io.open("/tmp/rule_providers_name", "r");
---- Rules List
local e={},o,t
if NXFS.access("/tmp/rule_providers_name") then
for o in file:lines() do
table.insert(e,o)
end
for t,o in ipairs(e) do
e[t]={}
e[t].num=string.format(t)
e[t].name=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",o)),1,-2)
e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $6}' 2>/dev/null",o)),1,-2)
if e[t].lfilename == "" then
e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $5}' 2>/dev/null",o)),1,-2)
end
e[t].filename=o
e[t].author=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $2}' 2>/dev/null",o)),1,-2)
e[t].rule_type=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $3}' 2>/dev/null",o)),1,-2)
RULE_FILE="/etc/openclash/rule_provider/".. e[t].lfilename
if fs.mtime(RULE_FILE) then
e[t].size=fs.filesize(fs.stat(RULE_FILE).size)
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(RULE_FILE))
else
e[t].size="/"
e[t].mtime="/"
end
if fs.isfile(RULE_FILE) then
e[t].exist=translate("Exist")
else
e[t].exist=translate("Not Exist")
end
e[t].remove=0
end
end
file:close()
form=SimpleForm("filelist")
form.reset=false
form.submit=false
tb=form:section(Table,e)
nu=tb:option(DummyValue,"num",translate("Serial Number"))
st=tb:option(DummyValue,"exist",translate("State"))
st.template="openclash/cfg_check"
tp=tb:option(DummyValue,"rule_type",translate("Rule Type"))
nm=tb:option(DummyValue,"name",translate("Rule Name"))
au=tb:option(DummyValue,"author",translate("Rule Author"))
fm=tb:option(DummyValue,"lfilename",translate("File Name"))
sz=tb:option(DummyValue,"size",translate("Size"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
btnis=tb:option(DummyValue,"filename",translate("Download Rule"))
btnis.template="openclash/download_rule"
btnrm=tb:option(Button,"remove",translate("Remove"))
btnrm.render=function(e,t,a)
e.inputstyle="reset"
Button.render(e,t,a)
end
btnrm.write=function(a,t)
fs.unlink("/etc/openclash/rule_provider/"..e[t].lfilename)
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "rule-providers-manage"))
end
return m, form

View File

@ -0,0 +1,289 @@
local m, s, o
local openclash = "openclash"
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.openclash"
local uci = require "luci.model.uci".cursor()
m = Map(openclash, translate("Rule Providers Append"))
m.pageaction = false
m.description=translate("Attention:")..
"<br/>"..translate("The game proxy is a test function and does not guarantee the availability of rules")..
"<br/>"..translate("Preparation steps:")..
"<br/>"..translate("1. In the <server and policy group management> page, create the policy group and node you are going to use, and apply the configuration (when adding nodes, you must select the policy group you want to join). Policy group type suggestion: fallback, game nodes must be support UDP and not a Vmess")..
"<br/>"..translate("2. Click the <manage third party game rules> or <manage third party rule set> button to enter the rule list and download the rules you want to use")..
"<br/>"..translate("3. On this page, set the corresponding configuration file and policy group of the rule you have downloaded, and save the settings")..
"<br/>"..translate("4. Install the TUN or Meta core")..
"<br/>"..
"<br/>"..translate("When setting this page, if the groups is empty, please go to the <server and group management> page to add")..
"<br/>"..
"<br/>"..translate("Introduction to rule set usage: https://lancellc.gitbook.io/clash/clash-config-file/rule-provider")
function IsRuleFile(e)
e=e or""
local e=string.lower(string.sub(e,-6,-1))
return e==".rules"
end
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e == ".yaml"
end
function IsYmlFile(e)
e=e or""
local e=string.lower(string.sub(e,-4,-1))
return e == ".yml"
end
-- [[ Edit Game Rule ]] --
s = m:section(TypedSection, "game_config", translate("Game Rules Append (Only TUN & Meta Core Support)"))
s.anonymous = true
s.addremove = true
s.sortable = true
s.template = "openclash/tblsection"
s.rmempty = false
---- enable flag
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
---- config
o = s:option(ListValue, "config", translate("Config File"))
o:value("all", translate("Use For All Config File"))
local e,a={}
for t,f in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].name=fs.basename(f)
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
o:value(e[t].name)
end
end
end
---- rule name
o = s:option(DynamicList, "rule_name", translate("Game Rule's Name"))
local e,a={}
for t,f in ipairs(fs.glob("/etc/openclash/game_rules/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].filename=fs.basename(f)
if IsRuleFile(e[t].filename) then
e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "")
if e[t].name ~= "" and e[t].name ~= nil then
o:value(e[t].name)
end
end
end
end
o.rmempty = true
---- Proxy Group
o = s:option(ListValue, "group", translate("Select Proxy Group"))
local groupnames,filename
filename = m.uci:get(openclash, "config", "config_path")
if filename then
groupnames = SYS.exec(string.format('ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "YAML.load_file(\'%s\')[\'proxy-groups\'].each do |i| puts i[\'name\']+\'##\' end" 2>/dev/null',filename))
if groupnames then
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
end
end
uci:foreach("openclash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil then
o:value(s.name)
end
end)
o:value("DIRECT")
o:value("REJECT")
o.rmempty = true
-- [[ Edit Other Rule Provider ]] --
s = m:section(TypedSection, "rule_provider_config", translate("Other Rule Providers Append (Only TUN & Meta Core Support)"))
s.anonymous = true
s.addremove = true
s.sortable = true
s.template = "openclash/tblsection"
s.rmempty = false
---- enable flag
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
---- config
o = s:option(ListValue, "config", translate("Config File"))
o:value("all", translate("Use For All Config File"))
local e,a={}
for t,f in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].name=fs.basename(f)
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
o:value(e[t].name)
end
end
end
---- rule name
o = s:option(DynamicList, "rule_name", translate("Rule Provider's Name"))
local e,a={}
for t,f in ipairs(fs.glob("/etc/openclash/rule_provider/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].filename=fs.basename(f)
if IsYamlFile(e[t].filename) or IsYmlFile(e[t].filename) then
e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "")
if e[t].name ~= "" and e[t].name ~= nil then
o:value(e[t].name)
end
end
end
end
o.rmempty = true
---- Proxy Group
o = s:option(ListValue, "group", translate("Select Proxy Group"))
local groupnames,filename
filename = m.uci:get(openclash, "config", "config_path")
if filename then
groupnames = SYS.exec(string.format('ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "YAML.load_file(\'%s\')[\'proxy-groups\'].each do |i| puts i[\'name\']+\'##\' end" 2>/dev/null',filename))
if groupnames then
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
end
end
uci:foreach("openclash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil then
o:value(s.name)
end
end)
o:value("DIRECT")
o:value("REJECT")
o.rmempty = true
o = s:option(Value, "interval", translate("Rule Providers Interval(s)"))
o.default = "86400"
o.rmempty = false
---- position
o = s:option(ListValue, "position", translate("Append Position"))
o.rmempty = false
o:value("0", translate("Priority Match"))
o:value("1", translate("Extended Match"))
-- [[ Edit Custom Rule Provider ]] --
s = m:section(TypedSection, "rule_providers", translate("Custom Rule Providers Append (Only TUN & Meta Core Support)"))
s.anonymous = true
s.addremove = true
s.sortable = true
s.template = "openclash/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/openclash/rule-providers-config/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(s.extedit % sid)
return
end
end
---- enable flag
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
o = s:option(DummyValue, "config", translate("Config File"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("all")
end
o = s:option(DummyValue, "name", translate("Rule Providers Name"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(ListValue, "position", translate("Append Position"))
o.rmempty = false
o:value("0", translate("Priority Match"))
o:value("1", translate("Extended Match"))
local rm = {
{rule_mg, pro_mg}
}
rmg = m:section(Table, rm)
o = rmg:option(Button, "rule_mg", " ")
o.inputtitle = translate("Game Rules Manage")
o.inputstyle = "reload"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "game-rules-manage"))
end
o = rmg:option(Button, "pro_mg", " ")
o.inputtitle = translate("Other Rule Provider Manage")
o.inputstyle = "reload"
o.write = function()
HTTP.redirect(DISP.build_url("admin", "services", "openclash", "rule-providers-manage"))
end
local t = {
{Commit, Apply}
}
ss = m:section(Table, t)
o = ss:option(Button, "Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit("openclash")
end
o = ss:option(Button, "Apply", " ")
o.inputtitle = translate("Apply Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:set("openclash", "config", "enable", 1)
m.uci:commit("openclash")
SYS.call("/etc/init.d/openclash restart >/dev/null 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "openclash"))
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,927 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local fs = require "luci.openclash"
local sys = require "luci.sys"
local sid = arg[1]
local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
font_red = [[<b style=color:red>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e == ".yaml"
end
function IsYmlFile(e)
e=e or""
local e=string.lower(string.sub(e,-4,-1))
return e == ".yml"
end
local encrypt_methods_ss = {
-- stream
"rc4-md5",
"aes-128-cfb",
"aes-192-cfb",
"aes-256-cfb",
"aes-128-ctr",
"aes-192-ctr",
"aes-256-ctr",
"aes-128-gcm",
"aes-192-gcm",
"aes-256-gcm",
"chacha20-ietf",
"xchacha20",
"chacha20-ietf-poly1305",
"xchacha20-ietf-poly1305",
"2022-blake3-aes-128-gcm",
"2022-blake3-aes-256-gcm",
"2022-blake3-chacha20-poly1305"
}
local encrypt_methods_ssr = {
"rc4-md5",
"aes-128-cfb",
"aes-192-cfb",
"aes-256-cfb",
"aes-128-ctr",
"aes-192-ctr",
"aes-256-ctr",
"chacha20-ietf",
"xchacha20"
}
local securitys = {
"auto",
"none",
"zero",
"aes-128-gcm",
"chacha20-poly1305"
}
local protocols = {
"origin",
"auth_sha1_v4",
"auth_aes128_md5",
"auth_aes128_sha1",
"auth_chain_a",
"auth_chain_b"
}
local hysteria_protocols = {
"udp",
"wechat-video",
"faketcp"
}
local obfs = {
"plain",
"http_simple",
"http_post",
"random_head",
"tls1.2_ticket_auth",
"tls1.2_ticket_fastauth"
}
m = Map(openclash, translate("Edit Server"))
m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/openclash/servers")
if m.uci:get(openclash, sid) ~= "servers" then
luci.http.redirect(m.redirect)
return
end
-- [[ Servers Setting ]] --
s = m:section(NamedSection, sid, "servers")
s.anonymous = true
s.addremove = false
o = s:option(DummyValue, "server_url", "SS/SSR/VMESS/TROJAN URL")
o.rawhtml = true
o.template = "openclash/server_url"
o.value = sid
o = s:option(ListValue, "config", translate("Config File"))
o:value("all", translate("Use For All Config File"))
local e,a={}
for t,f in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].name=fs.basename(f)
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
o:value(e[t].name)
end
end
end
o = s:option(Flag, "manual", translate("Custom Tag"))
o.rmempty = false
o.default = "0"
o.description = translate("Mark as Custom Node to Prevent Retention config from being Deleted When Enabled")
o = s:option(ListValue, "type", translate("Server Node Type"))
o:value("ss", translate("Shadowsocks"))
o:value("ssr", translate("ShadowsocksR"))
o:value("vmess", translate("Vmess"))
o:value("trojan", translate("trojan"))
o:value("vless", translate("Vless ")..translate("(Only Meta Core)"))
o:value("hysteria", translate("Hysteria ")..translate("(Only Meta Core)"))
o:value("wireguard", translate("WireGuard")..translate("(TUN&Meta Core)"))
o:value("tuic", translate("Tuic")..translate("(Only Meta Core)"))
o:value("snell", translate("Snell"))
o:value("socks5", translate("Socks5"))
o:value("http", translate("HTTP(S)"))
o.description = translate("Using incorrect encryption mothod may causes service fail to start")
o = s:option(Value, "name", translate("Server Alias"))
o.rmempty = false
o.default = "Server - "..sid
o = s:option(Value, "server", translate("Server Address"))
o.datatype = "host"
o.rmempty = true
o = s:option(Value, "port", translate("Server Port"))
o.datatype = "port"
o.rmempty = false
o.default = "443"
o = s:option(Value, "ports", translate("Port Hopping"))
o.datatype = "portrange"
o.rmempty = true
o.default = "20000-40000"
o.placeholder = translate("20000-40000")
o:depends("type", "hysteria")
o = s:option(Value, "password", translate("Password"))
o.password = true
o.rmempty = false
o:depends("type", "ss")
o:depends("type", "ssr")
o:depends("type", "trojan")
-- [[ Tuic ]]--
o = s:option(Value, "tc_ip", translate("Server IP"))
o.rmempty = true
o.placeholder = translate("127.0.0.1")
o.datatype = "or(ip4addr, ip6addr)"
o:depends("type", "tuic")
o = s:option(Value, "tc_token", translate("Token"))
o.rmempty = true
o:depends("type", "tuic")
o = s:option(ListValue, "udp_relay_mode", translate("UDP Relay Mode"))
o.rmempty = true
o.default = "native"
o:value("native")
o:value("quic")
o:depends("type", "tuic")
o = s:option(ListValue, "congestion_controller", translate("Congestion Controller"))
o.rmempty = true
o.default = "cubic"
o:value("cubic")
o:value("bbr")
o:value("new_reno")
o:depends("type", "tuic")
o = s:option(DynamicList, "tc_alpn", translate("Alpn"))
o.rmempty = true
o:value("h3")
o:value("h2")
o:depends("type", "tuic")
o = s:option(ListValue, "disable_sni", translate("Disable SNI"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends("type", "tuic")
o = s:option(ListValue, "reduce_rtt", translate("Reduce RTT"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends("type", "tuic")
o = s:option(Value, "heartbeat_interval", translate("Heartbeat Interval"))
o.rmempty = true
o:depends("type", "tuic")
o.default = "8000"
o = s:option(Value, "request_timeout", translate("Request Timeout"))
o.rmempty = true
o.default = "8000"
o:depends("type", "tuic")
o = s:option(Value, "max_udp_relay_packet_size", translate("Max UDP Relay Packet Size"))
o.rmempty = true
o.default = "1500"
o:depends("type", "tuic")
o = s:option(Value, "max_open_streams", translate("Max Open Streams"))
o.rmempty = true
o.default = "100"
o:depends("type", "tuic")
-- [[ Wireguard ]]--
o = s:option(Value, "wg_ip", translate("IP"))
o.rmempty = true
o.placeholder = translate("127.0.0.1")
o.datatype = "ip4addr"
o:depends("type", "wireguard")
o = s:option(Value, "wg_ipv6", translate("IPv6"))
o.rmempty = true
o.placeholder = translate("your_ipv6")
o.datatype = "ip6addr"
o:depends("type", "wireguard")
o = s:option(Value, "private_key", translate("Private Key"))
o.rmempty = true
o.placeholder = translate("eCtXsJZ27+4PbhDkHnB923tkUn2Gj59wZw5wFA75MnU=")
o:depends("type", "wireguard")
o = s:option(Value, "public_key", translate("Public Key"))
o.rmempty = true
o.placeholder = translate("Cr8hWlKvtDt7nrvf+f0brNQQzabAqrjfBvas9pmowjo=")
o:depends("type", "wireguard")
o = s:option(Value, "preshared_key", translate("Preshared Key"))
o.rmempty = true
o.placeholder = translate("base64")
o:depends("type", "wireguard")
o = s:option(DynamicList, "wg_dns", translate("DNS"))
o.rmempty = true
o:value("1.1.1.1")
o:value("8.8.8.8")
o:depends("type", "wireguard")
o = s:option(Value, "wg_mtu", translate("MTU"))
o.rmempty = true
o.default = "1420"
o.placeholder = translate("1420")
o:depends("type", "wireguard")
o = s:option(ListValue, "hysteria_protocol", translate("Protocol"))
for _, v in ipairs(hysteria_protocols) do o:value(v) end
o.rmempty = false
o:depends("type", "hysteria")
o = s:option(Value, "hysteria_up", translate("up"))
o.rmempty = false
o.description = translate("Required")
o:depends("type", "hysteria")
o = s:option(Value, "hysteria_down", translate("down"))
o.rmempty = false
o.description = translate("Required")
o:depends("type", "hysteria")
o = s:option(Value, "psk", translate("Psk"))
o.rmempty = true
o:depends("type", "snell")
o = s:option(ListValue, "snell_version", translate("Version"))
o:value("2")
o:value("3")
o:depends("type", "snell")
o = s:option(ListValue, "cipher", translate("Encrypt Method"))
for _, v in ipairs(encrypt_methods_ss) do o:value(v) end
o.description = translate("Only Meta Core Support SS2022")
o.rmempty = true
o:depends("type", "ss")
o = s:option(ListValue, "cipher_ssr", translate("Encrypt Method"))
for _, v in ipairs(encrypt_methods_ssr) do o:value(v) end
o:value("dummy", "none")
o.rmempty = true
o:depends("type", "ssr")
o = s:option(ListValue, "protocol", translate("Protocol"))
for _, v in ipairs(protocols) do o:value(v) end
o.rmempty = true
o:depends("type", "ssr")
o = s:option(Value, "protocol_param", translate("Protocol param(optional)"))
o:depends("type", "ssr")
o = s:option(ListValue, "securitys", translate("Encrypt Method"))
for _, v in ipairs(securitys) do o:value(v) end
o.rmempty = true
o:depends("type", "vmess")
o = s:option(ListValue, "obfs_ssr", translate("Obfs"))
for _, v in ipairs(obfs) do o:value(v) end
o.rmempty = true
o:depends("type", "ssr")
o = s:option(Value, "obfs_param", translate("Obfs param(optional)"))
o:depends("type", "ssr")
-- AlterId
o = s:option(Value, "alterId", translate("AlterId"))
o.default = "32"
o.rmempty = true
o:depends("type", "vmess")
-- VmessId
o = s:option(Value, "uuid", translate("UUID"))
o.rmempty = true
o.default = uuid
o:depends("type", "vmess")
o:depends("type", "vless")
o = s:option(ListValue, "udp", translate("UDP Enable"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends("type", "ss")
o:depends("type", "ssr")
o:depends("type", "vmess")
o:depends("type", "vless")
o:depends("type", "socks5")
o:depends("type", "trojan")
o:depends({type = "snell", snell_version = "3"})
o:depends("type", "wireguard")
o = s:option(ListValue, "udp_over_tcp", translate("udp-over-tcp"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("type", "ss")
o = s:option(ListValue, "xudp", translate("XUDP Enable")..translate("(Only Meta Core)"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends({type = "vmess", udp = "true"})
o:depends({type = "vless", udp = "true"})
o = s:option(ListValue, "obfs", translate("obfs-mode"))
o.rmempty = true
o.default = "none"
o:value("none")
o:value("tls")
o:value("http")
o:value("websocket", translate("websocket (ws)"))
o:value("shadow-tls", translate("shadow-tls")..translate("(Only Meta Core)"))
o:value("restls", translate("restls")..translate("(Only Meta Core)"))
o:depends("type", "ss")
o = s:option(ListValue, "obfs_snell", translate("obfs-mode"))
o.rmempty = true
o.default = "none"
o:value("none")
o:value("tls")
o:value("http")
o:depends("type", "snell")
o = s:option(ListValue, "obfs_vless", translate("obfs-mode"))
o.rmempty = true
o.default = "tcp"
o:value("tcp", translate("tcp"))
o:value("ws", translate("websocket (ws)"))
o:value("grpc", translate("grpc"))
o:depends("type", "vless")
o = s:option(ListValue, "obfs_vmess", translate("obfs-mode"))
o.rmempty = true
o.default = "none"
o:value("none")
o:value("websocket", translate("websocket (ws)"))
o:value("http", translate("http"))
o:value("h2", translate("h2"))
o:value("grpc", translate("grpc"))
o:depends("type", "vmess")
o = s:option(ListValue, "obfs_trojan", translate("obfs-mode"))
o.rmempty = true
o.default = "none"
o:value("none")
o:value("ws", translate("websocket (ws)"))
o:value("grpc", translate("grpc"))
o:depends("type", "trojan")
o = s:option(Value, "host", translate("obfs-hosts"))
o.datatype = "host"
o.placeholder = translate("example.com")
o.rmempty = true
o:depends("obfs", "tls")
o:depends("obfs", "http")
o:depends("obfs", "websocket")
o:depends("obfs", "shadow-tls")
o:depends("obfs", "restls")
o:depends("obfs_snell", "tls")
o:depends("obfs_snell", "http")
o = s:option(Value, "obfs_password", translate("obfs-password"))
o.rmempty = true
o:depends("obfs", "shadow-tls")
o:depends("obfs", "restls")
o = s:option(ListValue, "obfs_version_hint", translate("version-hint"))
o.rmempty = true
o:value("tls13")
o:value("tls12")
o:depends("obfs", "restls")
o = s:option(Value, "obfs_restls_script", translate("restls-script"))
o.rmempty = true
o:depends("obfs", "restls")
o.placeholder = translate("1000?100<1,500~100,350~100,600~100,400~200")
-- vmess路径
o = s:option(Value, "path", translate("path"))
o.rmempty = true
o.placeholder = translate("/")
o:depends("obfs", "websocket")
o = s:option(DynamicList, "h2_host", translate("host"))
o.rmempty = true
o.placeholder = translate("http.example.com")
o.datatype = "host"
o:depends("obfs_vmess", "h2")
o = s:option(Value, "h2_path", translate("path"))
o.rmempty = true
o.default = "/"
o:depends("obfs_vmess", "h2")
o = s:option(DynamicList, "http_path", translate("path"))
o.rmempty = true
o:value("/")
o:value("/video")
o:depends("obfs_vmess", "http")
o = s:option(Value, "custom", translate("headers"))
o.rmempty = true
o.placeholder = translate("v2ray.com")
o:depends("obfs", "websocket")
o = s:option(Value, "ws_opts_path", translate("ws-opts-path"))
o.rmempty = true
o.placeholder = translate("/path")
o:depends("obfs_vmess", "websocket")
o:depends("obfs_vless", "ws")
o = s:option(DynamicList, "ws_opts_headers", translate("ws-opts-headers"))
o.rmempty = true
o.placeholder = translate("Host: v2ray.com")
o:depends("obfs_vmess", "websocket")
o:depends("obfs_vless", "ws")
o = s:option(Value, "vless_flow", translate("flow"))
o.rmempty = true
o.default = "xtls-rprx-direct"
o:value("xtls-rprx-direct")
o:value("xtls-rprx-origin")
o:value("xtls-rprx-vision")
o:depends("obfs_vless", "tcp")
-- [[ grpc ]]--
o = s:option(Value, "grpc_service_name", translate("grpc-service-name"))
o.rmempty = true
o.datatype = "host"
o.placeholder = translate("example")
o:depends("obfs_trojan", "grpc")
o:depends("obfs_vmess", "grpc")
o:depends("obfs_vless", "grpc")
-- [[ reality-public-key ]]--
o = s:option(Value, "reality_public_key", translate("public-key(reality)"))
o.rmempty = true
o.placeholder = translate("CrrQSjAG_YkHLwvM2M-7XkKJilgL5upBKCp0od0tLhE")
o:depends("obfs_vless", "grpc")
o:depends("obfs_vless", "tcp")
-- [[ reality-short-id ]]--
o = s:option(Value, "reality_short_id", translate("short-id(reality)"))
o.rmempty = true
o.placeholder = translate("10f897e26c4b9478")
o:depends("obfs_vless", "grpc")
o:depends("obfs_vless", "tcp")
o = s:option(Value, "max_early_data", translate("max-early-data"))
o.rmempty = true
o.placeholder = translate("2048")
o:depends("obfs_vmess", "websocket")
o = s:option(Value, "early_data_header_name", translate("early-data-header-name"))
o.rmempty = true
o.placeholder = translate("Sec-WebSocket-Protocol")
o:depends("obfs_vmess", "websocket")
-- [[ skip-cert-verify ]]--
o = s:option(ListValue, "skip_cert_verify", translate("skip-cert-verify"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "none")
o:depends("obfs_vmess", "websocket")
o:depends("obfs_vmess", "grpc")
o:depends("type", "socks5")
o:depends("type", "http")
o:depends("type", "trojan")
o:depends("type", "vless")
o:depends("type", "hysteria")
o:depends("type", "tuic")
-- [[ TLS ]]--
o = s:option(ListValue, "tls", translate("TLS"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
o:depends("type", "vmess")
o:depends("type", "vless")
o:depends("type", "socks5")
o:depends("type", "http")
o = s:option(Value, "servername", translate("servername"))
o.rmempty = true
o.datatype = "host"
o.placeholder = translate("example.com")
o:depends({obfs_vmess = "websocket", tls = "true"})
o:depends({obfs_vmess = "grpc", tls = "true"})
o:depends({obfs_vmess = "none", tls = "true"})
o:depends("type", "vless")
o = s:option(Value, "keep_alive", translate("keep-alive"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends("obfs_vmess", "http")
-- [[ MUX ]]--
o = s:option(ListValue, "mux", translate("mux"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
-- [[ sni ]]--
o = s:option(Value, "sni", translate("sni"))
o.datatype = "host"
o.placeholder = translate("example.com")
o.rmempty = true
o:depends("type", "trojan")
o:depends("type", "http")
o:depends("type", "hysteria")
-- [[ headers ]]--
o = s:option(DynamicList, "http_headers", translate("headers"))
o.rmempty = true
o.placeholder = translate("User-Agent: okhttp/3.11.0 Dalvik/2.1.0 ...... ")
o:depends("type", "http")
-- 验证用户名
o = s:option(Value, "auth_name", translate("Auth Username"))
o:depends("type", "socks5")
o:depends("type", "http")
o.rmempty = true
-- 验证密码
o = s:option(Value, "auth_pass", translate("Auth Password"))
o:depends("type", "socks5")
o:depends("type", "http")
o.rmempty = true
-- [[ alpn ]]--
o = s:option(DynamicList, "alpn", translate("alpn"))
o.rmempty = true
o:value("h2")
o:value("http/1.1")
o:depends("type", "trojan")
-- [[ alpn ]]--
o = s:option(DynamicList, "hysteria_alpn", translate("alpn"))
o.rmempty = false
o:value("h3")
o:value("h2")
o:depends("type", "hysteria")
-- [[ trojan-ws-path ]]--
o = s:option(Value, "trojan_ws_path", translate("Path"))
o.rmempty = true
o.placeholder = translate("/path")
o:depends("obfs_trojan", "ws")
-- [[ trojan-ws-headers ]]--
o = s:option(DynamicList, "trojan_ws_headers", translate("Headers"))
o.rmempty = true
o.placeholder = translate("Host: v2ray.com")
o:depends("obfs_trojan", "ws")
-- [[ hysteria_obfs ]]--
o = s:option(Value, "hysteria_obfs", translate("obfs"))
o.rmempty = true
o.placeholder = translate("yourpassword")
o:depends("type", "hysteria")
-- [[ hysteria_auth ]]--
--o = s:option(Value, "hysteria_auth", translate("auth"))
--o.rmempty = true
--o.placeholder = translate("[BASE64]")
--o:depends("type", "hysteria")
-- [[ hysteria_auth_str ]]--
o = s:option(Value, "hysteria_auth_str", translate("auth_str"))
o.rmempty = true
o.placeholder = translate("yubiyubi")
o:depends("type", "hysteria")
-- [[ hysteria_ca ]]--
o = s:option(Value, "hysteria_ca", translate("ca"))
o.rmempty = true
o.placeholder = translate("./my.ca")
o:depends("type", "hysteria")
-- [[ hysteria_ca_str ]]--
o = s:option(Value, "hysteria_ca_str", translate("ca_str"))
o.rmempty = true
o.placeholder = translate("xyz")
o:depends("type", "hysteria")
-- [[ recv_window_conn ]]--
o = s:option(Value, "recv_window_conn", translate("recv_window_conn"))
o.rmempty = true
o.placeholder = translate("QUIC stream receive window")
o.datatype = "uinteger"
o:depends("type", "hysteria")
-- [[ recv_window ]]--
o = s:option(Value, "recv_window", translate("recv_window"))
o.rmempty = true
o.placeholder = translate("QUIC connection receive window")
o.datatype = "uinteger"
o:depends("type", "hysteria")
-- [[ disable_mtu_discovery ]]--
o = s:option(ListValue, "disable_mtu_discovery", translate("disable_mtu_discovery"))
o.rmempty = true
o:value("true")
o:value("false")
o.default = "false"
o:depends("type", "hysteria")
-- [[ hop_interval ]]--
o = s:option(Value, "hop_interval", translate("Hop Interval"))
o.rmempty = true
o.default = "10"
o:depends("type", "hysteria")
o = s:option(ListValue, "packet-addr", translate("Packet-Addr")..translate("(Only Meta Core)"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends({type = "vless", xudp = "false"})
o = s:option(Value, "packet_encoding", translate("Packet-Encoding")..translate("(Only Meta Core)"))
o.rmempty = true
o:depends("type", "vmess")
o:depends("type", "vless")
o = s:option(ListValue, "global_padding", translate("Global-Padding")..translate("(Only Meta Core)"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("type", "vmess")
o = s:option(ListValue, "authenticated_length", translate("Authenticated-Length")..translate("(Only Meta Core)"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("type", "vmess")
-- [[ TFO ]]--
o = s:option(ListValue, "fast_open", translate("Fast Open"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends("type", "hysteria")
o:depends("type", "tuic")
-- [[ TFO ]]--
o = s:option(ListValue, "tfo", translate("TFO")..translate("(Only Meta Core)"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends("type", "http")
o:depends("type", "socks5")
o:depends("type", "trojan")
o:depends("type", "vless")
o:depends("type", "vmess")
o:depends("type", "ss")
o:depends("type", "ssr")
o:depends("type", "snell")
-- [[ fingerprint ]]--
o = s:option(Value, "fingerprint", translate("Fingerprint")..translate("(Only Meta Core)"))
o.rmempty = true
o:depends("type", "hysteria")
o:depends("type", "socks5")
o:depends("type", "http")
o:depends("type", "trojan")
o:depends("type", "vless")
o:depends({type = "ss", obfs = "websocket"})
o:depends({type = "ss", obfs = "shadow-tls"})
o:depends({type = "vmess", obfs_vmess = "websocket"})
o:depends({type = "vmess", obfs_vmess = "h2"})
o:depends({type = "vmess", obfs_vmess = "grpc"})
-- [[ client-fingerprint ]]--
o = s:option(ListValue, "client_fingerprint", translate("Client Fingerprint")..translate("(Only Meta Core)"))
o.rmempty = true
o:value("none")
o:value("chrome")
o:value("firefox")
o:value("safari")
o:value("ios")
o.default = "none"
o:depends("type", "vless")
o:depends({type = "ss", obfs = "restls"})
o:depends({type = "ss", obfs = "shadow-tls"})
o:depends({type = "trojan", obfs_vmess = "grpc"})
o:depends({type = "vmess", obfs_vmess = "websocket"})
o:depends({type = "vmess", obfs_vmess = "http"})
o:depends({type = "vmess", obfs_vmess = "h2"})
o:depends({type = "vmess", obfs_vmess = "grpc"})
-- [[ ip version ]]--
o = s:option(ListValue, "ip_version", translate("IP Version")..translate("(Only Meta Core)"))
o.rmempty = true
o:value("dual")
o:value("ipv4")
o:value("ipv4-prefer")
o:value("ipv6")
o:value("ipv6-prefer")
o.default = "dual"
-- [[ smux ]]--
o = s:option(ListValue, "multiplex", translate("Multiplex")..translate("(Only Meta Core)"))
o.rmempty = false
o:value("true")
o:value("false")
o.default = "false"
o = s:option(ListValue, "multiplex_protocol", translate("Protocol"))
o.rmempty = true
o:value("smux")
o:value("yamux")
o:value("h2mux")
o.default = "smux"
o:depends("multiplex", "true")
o = s:option(Value, "multiplex_max_connections", translate("Max-connections"))
o.rmempty = true
o.placeholder = "4"
o.default = "4"
o.datatype = "uinteger"
o:depends("multiplex", "true")
o = s:option(Value, "multiplex_min_streams", translate("Min-streams"))
o.rmempty = true
o.placeholder = "4"
o.default = "4"
o.datatype = "uinteger"
o:depends("multiplex", "true")
o = s:option(Value, "multiplex_max_streams", translate("Max-streams"))
o.rmempty = true
o.placeholder = "0"
o.default = "0"
o.datatype = "uinteger"
o:depends("multiplex", "true")
o = s:option(ListValue, "multiplex_padding", translate("Padding"))
o.rmempty = false
o:value("true")
o:value("false")
o.default = "false"
o:depends("multiplex", "true")
o = s:option(ListValue, "multiplex_statistic", translate("Statistic"))
o.rmempty = false
o:value("true")
o:value("false")
o.default = "false"
o:depends("multiplex", "true")
o = s:option(ListValue, "multiplex_only_tcp", translate("Only-tcp"))
o.rmempty = false
o:value("true")
o:value("false")
o.default = "false"
o:depends("multiplex", "true")
-- [[ interface-name ]]--
o = s:option(Value, "interface_name", translate("interface-name"))
o.rmempty = true
o.placeholder = translate("eth0")
-- [[ routing-mark ]]--
o = s:option(Value, "routing_mark", translate("routing-mark"))
o.rmempty = true
o.placeholder = translate("2333")
-- [[ other-setting ]]--
o = s:option(Value, "other_parameters", translate("Other Parameters"))
o.template = "cbi/tvalue"
o.rows = 20
o.wrap = "off"
o.description = font_red..bold_on..translate("Edit Your Other Parameters Here")..bold_off..font_off
o.rmempty = true
function o.cfgvalue(self, section)
if self.map:get(section, "other_parameters") == nil then
return "# Example:\n"..
"# Only support YAML, four spaces need to be reserved at the beginning of each line to maintain formatting alignment\n"..
"# 示例:\n"..
"# 仅支持 YAML, 每行行首需要多保留四个空格以使脚本处理后能够与上方配置保持格式对齐\n"..
"# type: ss\n"..
"# server: \"127.0.0.1\"\n"..
"# port: 443\n"..
"# cipher: rc4-md5\n"..
"# password: \"123456\"\n"..
"# udp: true\n"..
"# udp-over-tcp: false\n"..
"# ip-version: \"dual\"\n"..
"# tfo: true\n"..
"# smux:\n"..
"# enabled: false\n"..
"# plugin-opts:\n"..
"# mode: tls\n"..
"# host: world.taobao.com"
else
return Value.cfgvalue(self, section)
end
end
function o.validate(self, value)
if value then
value = value:gsub("\r\n?", "\n")
value = value:gsub("%c*$", "")
end
return value
end
o = s:option(DynamicList, "groups", translate("Proxy Group (Support Regex)"))
o.description = font_red..bold_on..translate("No Need Set when Config Create, The added Proxy Groups Must Exist")..bold_off..font_off
o.rmempty = true
o:value("all", translate("All Groups"))
m.uci:foreach("openclash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil then
o:value(s.name)
end
end)
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button,"Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
end
m:append(Template("openclash/toolbar_show"))
return m

View File

@ -0,0 +1,286 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local fs = require "luci.openclash"
font_red = [[<b style=color:red>]]
font_off = [[</b>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
m = Map(openclash, translate("Onekey Create (Servers&Groups manage)"))
m.pageaction = false
m.description=translate("Attention:")..
"<br/>"..translate("1. Before modifying the configuration file, please click the button below to read the configuration file")..
"<br/>"..translate("2. Proxy-providers address can be directly filled in the subscription link")..
"<br/>"..
"<br/>"..translate("Introduction to proxy usage: https://lancellc.gitbook.io/clash/clash-config-file/proxies")..
"<br/>"..translate("Introduction to proxy-provider usage: https://lancellc.gitbook.io/clash/clash-config-file/proxy-provider")
s = m:section(TypedSection, "openclash")
s.anonymous = true
o = s:option(Flag, "create_config", translate("Create Config"))
o.description = font_red .. bold_on .. translate("Create Config By One-Click Only Need Proxies") .. bold_off .. font_off
o.default = 0
o = s:option(ListValue, "rule_sources", translate("Choose Template For Create Config"))
o.description = translate("Use Other Rules To Create Config")
o:depends("create_config", 1)
o:value("lhie1", translate("lhie1 Rules"))
o:value("ConnersHua", translate("ConnersHua(Provider-type) Rules"))
o:value("ConnersHua_return", translate("ConnersHua Return Rules"))
o = s:option(Flag, "mix_proxies", translate("Mix Proxies"))
o.description = font_red .. bold_on .. translate("Mix This Page's Proxies") .. bold_off .. font_off
o:depends("create_config", 1)
o.default = 0
o = s:option(Flag, "servers_update", translate("Keep Settings"))
o.description = font_red .. bold_on .. translate("Only Update Servers Below When Subscription") .. bold_off .. font_off
o.default = 0
o = s:option(DynamicList, "new_servers_group", translate("New Servers Group (Support Regex)"))
o.description = translate("Set The New Subscribe Server's Default Proxy Groups")
o.rmempty = true
o:depends("servers_update", 1)
o:value("all", translate("All Groups"))
m.uci:foreach("openclash", "groups",
function(s)
o:value(s.name)
end)
-- [[ Groups Manage ]]--
s = m:section(TypedSection, "groups", translate("Proxy Groups(No Need Set when Config Create)"))
s.anonymous = true
s.addremove = true
s.sortable = true
s.template = "openclash/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/openclash/groups-config/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(s.extedit % sid)
return
end
end
---- enable flag
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
o = s:option(DummyValue, "config", translate("Config File"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("all")
end
o = s:option(DummyValue, "type", translate("Group Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "name", translate("Group Name"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
-- [[ Proxy-Provider Manage ]]--
s = m:section(TypedSection, "proxy-provider", translate("Proxy-Provider"))
s.anonymous = true
s.addremove = true
s.sortable = true
s.template = "openclash/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/openclash/proxy-provider-config/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(s.extedit % sid)
return
end
end
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
o = s:option(Flag, "manual", translate("Custom Tag"))
o.rmempty = false
o.default = "0"
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "0"
end
o = s:option(DummyValue, "config", translate("Config File"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("all")
end
o = s:option(DummyValue, "type", translate("Provider Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "name", translate("Provider Name"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
-- [[ Servers Manage ]]--
s = m:section(TypedSection, "servers", translate("Proxies"))
s.anonymous = true
s.addremove = true
s.sortable = true
s.template = "openclash/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/openclash/servers-config/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(s.extedit % sid)
return
end
end
---- enable flag
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
o = s:option(Flag, "manual", translate("Custom Tag"))
o.rmempty = false
o.default = "0"
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "0"
end
o = s:option(DummyValue, "config", translate("Config File"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("all")
end
o = s:option(DummyValue, "type", translate("Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "name", translate("Server Alias"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "server", translate("Server Address"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "port", translate("Server Port"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "udp", translate("UDP Support"))
function o.cfgvalue(...)
if Value.cfgvalue(...) == "true" then
return translate("Enable")
elseif Value.cfgvalue(...) == "false" then
return translate("Disable")
else
return translate("None")
end
end
local tt = {
{Delete_Unused_Servers, Delete_Servers, Delete_Proxy_Provider, Delete_Groups}
}
b = m:section(Table, tt)
o = b:option(Button,"Delete_Unused_Servers", " ")
o.inputtitle = translate("Delete Unused Servers")
o.inputstyle = "reset"
o.write = function()
m.uci:set("openclash", "config", "enable", 0)
m.uci:commit("openclash")
luci.sys.call("sh /usr/share/openclash/cfg_unused_servers_del.sh 2>/dev/null")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash", "servers"))
end
o = b:option(Button,"Delete_Servers", " ")
o.inputtitle = translate("Delete Servers")
o.inputstyle = "reset"
o.write = function()
m.uci:set("openclash", "config", "enable", 0)
m.uci:delete_all("openclash", "servers", function(s) return true end)
m.uci:commit("openclash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash", "servers"))
end
o = b:option(Button,"Delete_Proxy_Provider", " ")
o.inputtitle = translate("Delete Proxy Providers")
o.inputstyle = "reset"
o.write = function()
m.uci:set("openclash", "config", "enable", 0)
m.uci:delete_all("openclash", "proxy-provider", function(s) return true end)
m.uci:commit("openclash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash", "servers"))
end
o = b:option(Button,"Delete_Groups", " ")
o.inputtitle = translate("Delete Groups")
o.inputstyle = "reset"
o.write = function()
m.uci:set("openclash", "config", "enable", 0)
m.uci:delete_all("openclash", "groups", function(s) return true end)
m.uci:commit("openclash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash", "servers"))
end
local t = {
{Load_Config, Commit, Apply}
}
a = m:section(Table, t)
o = a:option(Button,"Load_Config", " ")
o.inputtitle = translate("Read Config")
o.inputstyle = "apply"
o.write = function()
m.uci:set("openclash", "config", "enable", 0)
m.uci:commit("openclash")
luci.sys.call("/usr/share/openclash/yml_groups_get.sh 2>/dev/null &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash"))
end
o = a:option(Button, "Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
m.uci:set("openclash", "config", "enable", 0)
m.uci:commit("openclash")
end
o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Apply Settings")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
m.uci:set("openclash", "config", "enable", 0)
m.uci:commit("openclash")
luci.sys.call("/usr/share/openclash/yml_groups_set.sh >/dev/null 2>&1 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash"))
end
m:append(Template("openclash/toolbar_show"))
return m

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,264 @@
--[[
LuCI - Filesystem tools
Description:
A module offering often needed filesystem manipulation functions
FileId:
$Id$
License:
Copyright 2008 Steven Barth <steven@midlink.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]--
local io = require "io"
local os = require "os"
local ltn12 = require "luci.ltn12"
local fs = require "nixio.fs"
local nutil = require "nixio.util"
local type = type
local string = string
--- LuCI filesystem library.
module "luci.openclash"
--- Test for file access permission on given path.
-- @class function
-- @name access
-- @param str String value containing the path
-- @return Number containing the return code, 0 on sucess or nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
access = fs.access
--- Evaluate given shell glob pattern and return a table containing all matching
-- file and directory entries.
-- @class function
-- @name glob
-- @param filename String containing the path of the file to read
-- @return Table containing file and directory entries or nil if no matches
-- @return String containing the error description (if no matches)
-- @return Number containing the os specific errno (if no matches)
function glob(...)
local iter, code, msg = fs.glob(...)
if iter then
return nutil.consume(iter)
else
return nil, code, msg
end
end
--- Checks wheather the given path exists and points to a regular file.
-- @param filename String containing the path of the file to test
-- @return Boolean indicating wheather given path points to regular file
function isfile(filename)
return fs.stat(filename, "type") == "reg"
end
--- Checks wheather the given path exists and points to a directory.
-- @param dirname String containing the path of the directory to test
-- @return Boolean indicating wheather given path points to directory
function isdirectory(dirname)
return fs.stat(dirname, "type") == "dir"
end
--- Read the whole content of the given file into memory.
-- @param filename String containing the path of the file to read
-- @return String containing the file contents or nil on error
-- @return String containing the error message on error
readfile = fs.readfile
--- Write the contents of given string to given file.
-- @param filename String containing the path of the file to read
-- @param data String containing the data to write
-- @return Boolean containing true on success or nil on error
-- @return String containing the error message on error
writefile = fs.writefile
--- Copies a file.
-- @param source Source file
-- @param dest Destination
-- @return Boolean containing true on success or nil on error
copy = fs.datacopy
--- Renames a file.
-- @param source Source file
-- @param dest Destination
-- @return Boolean containing true on success or nil on error
rename = fs.move
--- Get the last modification time of given file path in Unix epoch format.
-- @param path String containing the path of the file or directory to read
-- @return Number containing the epoch time or nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
function mtime(path)
return fs.stat(path, "mtime")
end
--- Set the last modification time of given file path in Unix epoch format.
-- @param path String containing the path of the file or directory to read
-- @param mtime Last modification timestamp
-- @param atime Last accessed timestamp
-- @return 0 in case of success nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
function utime(path, mtime, atime)
return fs.utimes(path, atime, mtime)
end
--- Return the last element - usually the filename - from the given path with
-- the directory component stripped.
-- @class function
-- @name basename
-- @param path String containing the path to strip
-- @return String containing the base name of given path
-- @see dirname
basename = fs.basename
--- Return the directory component of the given path with the last element
-- stripped of.
-- @class function
-- @name dirname
-- @param path String containing the path to strip
-- @return String containing the directory component of given path
-- @see basename
dirname = fs.dirname
--- Return a table containing all entries of the specified directory.
-- @class function
-- @name dir
-- @param path String containing the path of the directory to scan
-- @return Table containing file and directory entries or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function dir(...)
local iter, code, msg = fs.dir(...)
if iter then
local t = nutil.consume(iter)
t[#t+1] = "."
t[#t+1] = ".."
return t
else
return nil, code, msg
end
end
--- Create a new directory, recursively on demand.
-- @param path String with the name or path of the directory to create
-- @param recursive Create multiple directory levels (optional, default is true)
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function mkdir(path, recursive)
return recursive and fs.mkdirr(path) or fs.mkdir(path)
end
--- Remove the given empty directory.
-- @class function
-- @name rmdir
-- @param path String containing the path of the directory to remove
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
rmdir = fs.rmdir
local stat_tr = {
reg = "regular",
dir = "directory",
lnk = "link",
chr = "character device",
blk = "block device",
fifo = "fifo",
sock = "socket"
}
--- Get information about given file or directory.
-- @class function
-- @name stat
-- @param path String containing the path of the directory to query
-- @return Table containing file or directory properties or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function stat(path, key)
local data, code, msg = fs.stat(path)
if data then
data.mode = data.modestr
data.type = stat_tr[data.type] or "?"
end
return key and data and data[key] or data, code, msg
end
--- Set permissions on given file or directory.
-- @class function
-- @name chmod
-- @param path String containing the path of the directory
-- @param perm String containing the permissions to set ([ugoa][+-][rwx])
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
chmod = fs.chmod
--- Create a hard- or symlink from given file (or directory) to specified target
-- file (or directory) path.
-- @class function
-- @name link
-- @param path1 String containing the source path to link
-- @param path2 String containing the destination path for the link
-- @param symlink Boolean indicating wheather to create a symlink (optional)
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function link(src, dest, sym)
return sym and fs.symlink(src, dest) or fs.link(src, dest)
end
--- Remove the given file.
-- @class function
-- @name unlink
-- @param path String containing the path of the file to remove
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
unlink = fs.unlink
--- Retrieve target of given symlink.
-- @class function
-- @name readlink
-- @param path String containing the path of the symlink to read
-- @return String containing the link target or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
readlink = fs.readlink
function filename(str)
local idx = str:match(".+()%.%w+$")
if(idx) then
return str:sub(1, idx-1)
else
return str
end
end
function filesize(e)
local t=0
local a={' KB',' MB',' GB',' TB'}
repeat
e=e/1024
t=t+1
until(e<=1024)
return string.format("%.1f",e)..a[t]
end

View File

@ -0,0 +1,18 @@
<%+cbi/valueheader%>
<div>
<%
local val = self:cfgvalue(section)
if val == translate("Enable") or val == translate("Config Normal") or val == translate("Exist") then
%>
<div style="color: green; font-weight:bold;">
<%
else
%>
<div style="color: red; font-weight:bold;">
<%
end
write(pcdata(val))
%>
</div>
</div>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,465 @@
<style>
.CodeMirror {
text-align: left !important;
font-size: 15px;
line-height: 150%;
resize: both !important;
}
.CodeMirror-merge-r-chunk {
background: #0095ff2e !important;
}
.CodeMirror-merge-r-chunk-end {
border-bottom: unset !important;
}
.CodeMirror-merge-r-chunk-start {
border-top: unset !important;
}
.CodeMirror-merge-2pane .CodeMirror-merge-gap {
height: 700px !important;
}
.CodeMirror-merge-r-connect {
fill: #0095ff2e !important;
stroke: #0095ff2e !important;
}
.CodeMirror-vscrollbar-oc {
display: none !important;
}
</style>
<link rel="stylesheet" href="/luci-static/resources/openclash/lib/codemirror.css"/>
<link rel="stylesheet" href="/luci-static/resources/openclash/theme/material.css"/>
<link rel="stylesheet" href="/luci-static/resources/openclash/theme/idea.css"/>
<link rel="stylesheet" href="/luci-static/resources/openclash/addon/fold/foldgutter.css"/>
<link rel="stylesheet" href="/luci-static/resources/openclash/addon/lint/lint.css">
<link rel="stylesheet" href="/luci-static/resources/openclash/addon/display/fullscreen.css">
<link rel="stylesheet" href="/luci-static/resources/openclash/addon/dialog/dialog.css">
<link rel="stylesheet" href="/luci-static/resources/openclash/addon/search/matchesonscrollbar.css">
<script src="/luci-static/resources/openclash/lib/codemirror.js"></script>
<script src="/luci-static/resources/openclash/mode/yaml/yaml.js"></script>
<script src="/luci-static/resources/openclash/mode/lua/lua.js"></script>
<script src="/luci-static/resources/openclash/mode/shell/shell.js"></script>
<script src="/luci-static/resources/openclash/addon/fold/foldcode.js"></script>
<script src="/luci-static/resources/openclash/addon/fold/foldgutter.js"></script>
<script src="/luci-static/resources/openclash/addon/fold/indent-fold.js"></script>
<script src="/luci-static/resources/openclash/addon/edit/matchbrackets.js"></script>
<script src="/luci-static/resources/openclash/addon/selection/active-line.js"></script>
<script src="/luci-static/resources/openclash/addon/lint/lint.js"></script>
<script src="/luci-static/resources/openclash/addon/lint/yaml-lint.js"></script>
<script src="/luci-static/resources/openclash/addon/lint/js-yaml.min.js"></script>
<script src="/luci-static/resources/openclash/addon/display/fullscreen.js"></script>
<script src="/luci-static/resources/openclash/addon/display/autorefresh.js"></script>
<script src="/luci-static/resources/openclash/addon/dialog/dialog.js"></script>
<script src="/luci-static/resources/openclash/addon/search/searchcursor.js"></script>
<script src="/luci-static/resources/openclash/addon/search/search.js"></script>
<script src="/luci-static/resources/openclash/addon/scroll/annotatescrollbar.js"></script>
<script src="/luci-static/resources/openclash/addon/search/matchesonscrollbar.js"></script>
<script src="/luci-static/resources/openclash/addon/search/jump-to-line.js"></script>
<script src="/luci-static/resources/openclash/addon/merge/diff_match_patch.js"></script>
<script src="/luci-static/resources/openclash/addon/merge/merge.js"></script>
<link rel=stylesheet href="/luci-static/resources/openclash/addon/merge/merge.css">
<%-
local uci = require("luci.model.uci").cursor()
local fs = require "luci.openclash"
local conf = uci:get("openclash", "config", "config_path")
if not conf then conf = "/etc/openclash/config/config.yaml" end
local conf_name = fs.basename(conf)
if not conf_name then conf_name = "config.yaml" end
local sconf = "/etc/openclash/"..conf_name
-%>
<table id="my_editor_div" style="width: 100%; text-align: center; display: none;">
<tr>
<td style="width: 50%; overflow: hidden;"><%:Modify Your Config file:%> <b style=color:green><%=conf_name%></b> <%:Here, Except The Settings That Were Taken Over%></td>
<%-
if fs.isfile(sconf) then
-%>
<td style="width: 50%; overflow: hidden;"><%:Config File Edited By OpenClash For Running%></td>
<%-
else
-%>
<td style="width: 50%; overflow: hidden;"><%:Default Config File With Correct Template%></td>
<%-
end
-%>
</tr>
</table>
<script type="text/javascript">//<![CDATA[
function merge_editor(id, id2, target, target2, readOnly, readOnly2, wid, height)
{
var value, orig1, orig2, merge_editor, descr, gap, vscrollbar, vscrollbar_oc, panes = 2, highlight = true, connect = null, collapse = false;
descr = document.getElementById("my_editor_div");
target.parentNode.parentNode.parentNode.insertBefore(descr, target.parentNode.parentNode);
descr.style.display="inline-table"
value = id.value;
if (value == null) {
editor(id, readOnly, wid, height);
editor(id2, readOnly2, wid, height);
}
else {
target2.parentNode.style.display="none";
orig1 = '';
orig2 = id2.value;
target.style.height= "700px"
id.style.display = "none";
id2.style.display = "none";
merge_editor = CodeMirror.MergeView(target, {
mode: "text/yaml",
value: value,
origLeft: panes == 3 ? orig1 : null,
orig: orig2,
theme: "material",
lineNumbers: true,
autoRefresh: true,
styleActiveLine: true,
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
lint: true,
highlightDifferences: highlight,
connect: connect,
collapseIdentical: collapse,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"],
extraKeys: {
"F10": function() {
merge_editor.setShowDifferences(highlight = !highlight);
},
"F11": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
gap = document.getElementsByClassName("CodeMirror-merge-gap")[0];
vscrollbar = document.getElementsByClassName("CodeMirror-vscrollbar")[0];
vscrollbar_oc = document.getElementsByClassName("CodeMirror-vscrollbar-oc")[0];
if (cm.getOption("fullScreen")) {
console.log(gap.style.display)
gap.style.display = "none";
vscrollbar.className = "CodeMirror-vscrollbar-oc";
}
else {
gap.style.display = "";
vscrollbar_oc.className = "CodeMirror-vscrollbar";
};
},
"Esc": function(cm) {
gap = document.getElementsByClassName("CodeMirror-merge-gap")[0];
vscrollbar = document.getElementsByClassName("CodeMirror-vscrollbar")[0];
vscrollbar_oc = document.getElementsByClassName("CodeMirror-vscrollbar-oc")[0];
if (cm.getOption("fullScreen")) {
cm.setOption("fullScreen", false);
gap.style.display = "";
vscrollbar_oc.className = "CodeMirror-vscrollbar";
};
},
"Tab": function(cm) {
if (cm.somethingSelected()) {
cm.indentSelection('add')
} else {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ")
cm.replaceSelection(spaces)
}
}
}
});
merge_editor.edit.on("change", function(cm) {
id.value = cm.getValue();
});
if (wid && height) {
merge_editor.editor().setSize(wid, height);
merge_editor.rightOriginal().setSize(wid, height);
};
};
};
function editor(id, readOnly, wid, height)
{
var editor = CodeMirror.fromTextArea(id, {
mode: "text/yaml",
autoRefresh: true,
styleActiveLine: true,
lineNumbers: true,
theme: "material",
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
lint: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"],
extraKeys: {
"F11": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
},
"Tab": function(cm) {
if (cm.somethingSelected()) {
cm.indentSelection('add')
} else {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ")
cm.replaceSelection(spaces)
}
}
}
});
if (readOnly == "true") {
editor.setOption("readOnly","true");
};
if (wid && height) {
editor.setSize(wid, height);
};
};
function shell_editor(id, readOnly, wid, height)
{
var editor = CodeMirror.fromTextArea(id, {
mode: "shell",
autoRefresh: true,
styleActiveLine: true,
lineNumbers: true,
theme: "material",
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
extraKeys: {
"F11": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
},
"Tab": function(cm) {
if (cm.somethingSelected()) {
cm.indentSelection('add')
} else {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ")
cm.replaceSelection(spaces)
}
}
}
});
if (wid && height) {
editor.setSize(wid, height);
};
};
function other_editor(id, readOnly, wid, height)
{
var editor = CodeMirror.fromTextArea(id, {
mode: "lua",
autoRefresh: true,
styleActiveLine: true,
lineNumbers: true,
theme: "material",
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
extraKeys: {
"F11": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
},
"Tab": function(cm) {
if (cm.somethingSelected()) {
cm.indentSelection('add')
} else {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ")
cm.replaceSelection(spaces)
}
}
}
});
if (wid && height) {
editor.setSize(wid, height);
};
};
function other_log_area(id, readOnly, wid, height)
{
var other_log_area = CodeMirror.fromTextArea(id, {
mode: "lua",
autoRefresh: true,
styleActiveLine: true,
lineNumbers: true,
theme: "idea",
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
extraKeys: {
"F11": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
if (readOnly == "true") {
other_log_area.setOption("readOnly","true");
};
if (wid && height) {
other_log_area.setSize(wid, height);
};
other_log_area.markText({line:0,ch:0},{line:9999,ch:9999}, {css: 'font-size:13px'});
};
var custom_firewall = document.getElementById("cbid.openclash.config.firewall_custom");
var custom_ymchange = document.getElementById("cbid.openclash.config.ymchange_custom");
if (custom_firewall) {
shell_editor(custom_firewall, 'false', "100%", '300px');
};
if (custom_ymchange) {
shell_editor(custom_ymchange, 'false', "100%", '300px');
};
var myEditor_use = document.getElementById("cbid.table.1.user");
var myEditor_def = document.getElementById("cbid.table.1.default");
if (myEditor_use && myEditor_def) {
var myEditor_div_use = document.getElementById("cbi-table-1-user");
var myEditor_div_def = document.getElementById("cbi-table-1-default");
myEditor_div_def.parentNode.parentNode.style.cssText="text-align: left !important"
myEditor_div_def.parentNode.className='cbi-value';
myEditor_div_def.parentNode.style.display="revert"
myEditor_div_def.parentNode.style.width="100%"
myEditor_div_use.parentNode.className='cbi-value';
myEditor_div_use.parentNode.style.display="revert"
myEditor_div_use.parentNode.style.width="100%"
merge_editor(myEditor_use, myEditor_def, myEditor_div_use, myEditor_div_def, 'true', 'false', 'auto', '700px');
};
var myEditor_hosts = document.getElementById("cbid.openclash.config.custom_hosts");
var myEditor_fall_fil = document.getElementById("cbid.openclash.config.custom_fallback_fil");
var myEditor_name_pol = document.getElementById("cbid.openclash.config.custom_domain_dns_core");
var myEditor_name_cus_r1 = document.getElementById("cbid.openclash.config.custom_rules_2");
var myEditor_name_cus_r2 = document.getElementById("cbid.openclash.config.custom_rules");
var myEditor_fake_filter = document.getElementById("cbid.openclash.config.custom_fake_filter");
var myEditor_custom_domain_dns = document.getElementById("cbid.openclash.config.custom_domain_dns");
var myEditor_edit_file = document.getElementById("cbid.openclash.config.edit_file");
var myEditor_sniffing_domain_force = document.getElementById("cbid.openclash.config.sniffing_domain_force");
var myEditor_sniffing_domain_filter = document.getElementById("cbid.openclash.config.sniffing_domain_filter");
var myEditor_sniffing_port_filter = document.getElementById("cbid.openclash.config.sniffing_port_filter");
if (myEditor_hosts) {
editor(myEditor_hosts, 'false', '100%', '300px');
};
if (myEditor_edit_file) {
editor(myEditor_edit_file, 'false', '100%', '700px');
};
if (myEditor_fall_fil) {
editor(myEditor_fall_fil, 'false', '100%', '300px');
};
if (myEditor_name_pol) {
editor(myEditor_name_pol, 'false', '100%', '300px');
};
if (myEditor_name_cus_r1) {
editor(myEditor_name_cus_r1, 'false', '100%', '300px');
editor(myEditor_name_cus_r2, 'false', '100%', '300px');
};
if (myEditor_fake_filter) {
other_editor(myEditor_fake_filter, 'false', '100%', '300px');
};
if (myEditor_custom_domain_dns) {
other_editor(myEditor_custom_domain_dns, 'false', '100%', '300px');
};
if (myEditor_sniffing_domain_force) {
other_editor(myEditor_sniffing_domain_force, 'false', '100%', '300px');
};
if (myEditor_sniffing_domain_filter) {
other_editor(myEditor_sniffing_domain_filter, 'false', '100%', '300px');
};
if (myEditor_sniffing_port_filter) {
other_editor(myEditor_sniffing_port_filter, 'false', '100%', '300px');
};
var core_log = document.getElementById("core_log");
var oc_log = document.getElementById("cbid.openclash.config.clog");
if (core_log && oc_log) {
var core_editor = CodeMirror.fromTextArea(core_log, {
mode: "lua",
autoRefresh: true,
styleActiveLine: true,
lineNumbers: true,
theme: "idea",
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
extraKeys: {
"F11": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
var oc_editor = CodeMirror.fromTextArea(oc_log, {
mode: "lua",
autoRefresh: true,
styleActiveLine: true,
lineNumbers: true,
theme: "idea",
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
extraKeys: {
"F11": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
core_editor.setSize("100%", "540px");
core_editor.setOption("readOnly","true");
oc_editor.setSize("100%", "540px");
oc_editor.setOption("readOnly","true");
};
var proxy_mg = document.getElementById('cbi-table-1-proxy_mg');
var rule_mg = document.getElementById('cbi-table-1-rule_mg');
var game_mg = document.getElementById('cbi-table-1-game_mg');
var Commit = document.getElementById('cbi-table-1-Commit');
var Apply = document.getElementById('cbi-table-1-Apply');
var Create = document.getElementById('cbi-table-1-Create');
if (proxy_mg) {
proxy_mg.style.textAlign="center";
rule_mg.style.textAlign="center";
game_mg.style.textAlign="center";
Commit.style.textAlign="center";
Apply.style.textAlign="center";
Create.style.textAlign="center";
};
//]]>
</script>

View File

@ -0,0 +1,218 @@
<%#
Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%
local diag_host = "www.instagram.com"
local dns_host = "www.instagram.com"
%>
<style>
#diag-rc-output > pre {
background-color: #f5f5f5;
display: block;
padding: 8.5px;
margin: 0 0 18px;
line-height: 1.5rem;
-moz-border-radius: 3px;
white-space: pre-wrap;
word-wrap: break-word;
font-size: 1.4rem;
color: #404040;
}
#dns-rc-output > pre {
background-color: #f5f5f5;
display: block;
padding: 8.5px;
margin: 0 0 18px;
line-height: 1.5rem;
-moz-border-radius: 3px;
white-space: pre-wrap;
word-wrap: break-word;
font-size: 1.4rem;
color: #404040;
}
</style>
<script type="text/javascript">//<![CDATA[
function show_diag_info(addr)
{
var addr = addr;
var legend = document.getElementById('diag-rc-legend');
var output = document.getElementById('diag-rc-output');
if (legend && output)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "diag_connection")%>', {addr: addr}, function(x, status) {
if (x && x.status == 200 && x.responseText != "")
{
legend.style.display = 'none';
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
}
else if (x.status == 500)
{
legend.style.display = 'none';
output.innerHTML = '<span class="error"><%:Bad address specified!%></span>';
}
else
{
legend.style.display = 'none';
output.innerHTML = '<span class="error"><%:Could not find any connection logs!%></br></br><%:1. It may be that the plugin is not running%></br></br><%:2. It may be that the cache causes the browser to directly use the IP for access%></br></br><%:3. It may be that DNS hijacking did not take effect, so clash unable to reverse the domain name%></br></br><%:4. It may be that the filled address cannot be resolved and connected%></span>';
}
});
}
}
function update_status(field)
{
var addr = field.value;
var legend = document.getElementById('diag-rc-legend');
var output = document.getElementById('diag-rc-output');
if (legend && output)
{
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Waiting for command to complete...%>';
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
}
let HTTP = {
checker: (domain) => {
let img = new Image;
let timeout = setTimeout(() => {
img.onerror = img.onload = null;
show_diag_info(addr);
}, 10000);
img.onerror = () => {
clearTimeout(timeout);
show_diag_info(addr);
}
img.onload = () => {
clearTimeout(timeout);
show_diag_info(addr);
}
img.src = `https://${domain}/favicon.ico?${+(new Date)}`
},
runcheck: () => {
HTTP.checker(addr);
}
};
HTTP.runcheck();
}
function diag_dns(field)
{
var addr = field.value;
var legend = document.getElementById('dns-rc-legend');
var output = document.getElementById('dns-rc-output');
if (legend && output)
{
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Waiting for command to complete...%>';
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
}
if (legend && output)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "diag_dns")%>', {addr: addr}, function(x, status) {
if (x && x.status == 200 && x.responseText != "")
{
legend.style.display = 'none';
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
}
else if (x.status == 500)
{
legend.style.display = 'none';
output.innerHTML = '<span class="error"><%:Bad address specified!%></span>';
}
else
{
legend.style.display = 'none';
output.innerHTML = '<span class="error"><%:No Response Found!%></span>';
}
});
}
}
function gen_debug_logs()
{
var legend = document.getElementById('debug-rc-legend');
var output = document.getElementById('debug-rc-output');
if (legend && output)
{
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Waiting for command to complete...%>';
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "gen_debug_logs")%>', null, function(x, status) {
if (x && x.status == 200 && x.responseText != "")
{
legend.style.display = 'none';
output.innerHTML = '<textarea class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="30" cols="60" readonly="readonly" >'+x.responseText+'</textarea>';
}
else
{
legend.style.display = 'none';
output.innerHTML = '<span class="error"><%:Some error occurred!%></span>';
}
}
);
}
}
//]]></script>
<form>
<fieldset>
<div style="width:33%; float: left; text-align: center;">
<%:Connection Test (Current Browser)%>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" value="<%=diag_host%>" name="diag" />
<input type="button" value="<%:Click to Test%>" class="btn cbi-button cbi-button-apply" onclick="update_status(this.form.diag)" />
</div>
<div style="width:33%; float: left; text-align: center;">
<%:DNS Test (Clash Response)%>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" value="<%=dns_host%>" name="dns_host" />
<input type="button" value="<%:Click to Test%>" class="btn cbi-button cbi-button-apply" onclick="diag_dns(this.form.dns_host)" />
</div>
<div style="width:33%; float: left; text-align: center;">
<%:Generate Logs%>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="<%:Click to Generate%>" class="btn cbi-button cbi-button-apply" onclick="gen_debug_logs(this)" />
</div>
</fieldset>
<fieldset style="display:none">
<legend id="diag-rc-legend"><%:Collecting data...%></legend>
<br />
<span id="diag-rc-output"></span>
</fieldset>
<fieldset style="display:none">
<legend id="dns-rc-legend"><%:Collecting data...%></legend>
<br />
<span id="dns-rc-output"></span>
</fieldset>
<fieldset style="display:none">
<legend id="debug-rc-legend"><%:Collecting data...%></legend>
<br />
<span id="debug-rc-output"></span>
</fieldset>
</form>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,111 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function dler_login(btn,option)
{
btn.disabled = true;
if (option == "dler_login") {
var s = document.getElementById(option+'-status');
var e = document.getElementsByName('cbid.openclash.config.dler_email');
var p = document.getElementsByName('cbid.openclash.config.dler_passwd');
var c = document.getElementsByName('cbid.openclash.config.dler_checkin');
if (!e[0].value || !p[0].value) {
btn.disabled = false;
s.innerHTML ="<font color='red'><strong>"+"<%:Error Login Info%>"+"</strong></font>";
return false;
};
if (c[0] && c[0].checked) {
c = "1";
var i = document.getElementsByName('cbid.openclash.config.dler_checkin_interval');
var m = document.getElementsByName('cbid.openclash.config.dler_checkin_multiple');
if (!i[0].value || !(/(^[1-9]\d*$)/.test(i[0].value))) { i = "1"} else {i = i[0].value};
if (!m[0].value || !(/(^[1-9]\d*$)/.test(m[0].value)))
{
btn.disabled = false;
s.innerHTML ="<font color='red'><strong>"+"<%:Multiple Must Be a Positive Integer and No More Than 50%>"+"</strong></font>";
return false;
}
else if (m[0].value < 1)
{
btn.disabled = false;
s.innerHTML ="<font color='red'><strong>"+"<%:Multiple Must Be a Positive Integer and No More Than 50%>"+"</strong></font>";
return false;
}
else if (m[0].value > 50)
{
btn.disabled = false;
s.innerHTML ="<font color='red'><strong>"+"<%:Multiple Must Be a Positive Integer and No More Than 50%>"+"</strong></font>";
return false;
}
else {
m = m[0].value;
};
}
else {
c = "0";
var i = "1";
var m = "1";
};
btn.value = '<%:Login...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "dler_login_info_save")%>', {email: e[0].value, passwd : p[0].value, checkin: c, interval: i, multiple: m}, function(x, status) {
if (x && x.status == 200) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "dler_login")%>', null, function(x, status) {
if (s)
{
if (x && x.status == 200 && status.dler_login == 200) {
s.innerHTML ="<font color='green'><strong>"+"<%:Dler Cloud Login Successful%>"+"</strong></font>";
window.location.href='<%="settings?tab.openclash.config=dlercloud"%>';
}
else {
s.innerHTML ="<font color='red'><strong>"+"<%:Dler Cloud Login Faild%>"+"</strong></font>";
if (status.dler_login) {
alert("<%:Dler Cloud Login Faild%>: "+status.dler_login)
}
window.location.href='<%="settings?tab.openclash.config=dlercloud"%>';
}
}
btn.disabled = false;
btn.value = '<%:Login Account%>';
});
}
});
};
if (option == "dler_logout") {
var s = document.getElementById('dler_login-status');
btn.value = '<%:Logout...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "dler_logout")%>', null, function(x, status) {
if (s)
{
if (x && x.status == 200 && status.dler_logout == 200) {
s.innerHTML ="<font color='green'><strong>"+"<%:Dler Cloud Logout Successful%>"+"</strong></font>";
window.location.href='<%="settings?tab.openclash.config=dlercloud"%>';
}
else {
s.innerHTML ="<font color='red'><strong>"+"<%:Dler Cloud Logout Faild%>"+"</strong></font>";
if (status.dler_logout) {
alert("<%:Dler Cloud Logout Faild%>: "+status.dler_logout)
}
}
}
btn.disabled = false;
btn.value = '<%:Logout Account%>';
}
);
};
return false;
}
function web_dler(btn)
{
btn.disabled = true;
url='https://bit.ly/32mrABp';
window.open(url);
btn.disabled = false;
return false;
}
//]]></script>
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Login Account%>" onclick="return dler_login(this,'dler_login')" />
<input type="button" class="btn cbi-button cbi-button-remove" value="<%:Logout Account%>" onclick="return dler_login(this,'dler_logout')" />
<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Official Website%>" onclick="return web_dler(this)" />
<span id="<%=self.option%>-status"><%=self.value%></span>
<%+cbi/valuefooter%>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,41 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function act_download_rule(btn,filename)
{
btn.disabled = true;
btn.value = '<%:Downloading Rule...%> ';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash","download_rule")%>',
{
filename: filename
},
function(x,status)
{
if ( x && x.status == 200 ) {
if(status.rule_download_status=="0")
{
btn.value = '<%:Download Failed%>';
}
else if (status.rule_download_status=="1")
{
btn.value = '<%:Download Successful%>';
}
else if (status.rule_download_status=="2")
{
btn.value = '<%:Rule No Change%>';
}
}
else {
btn.value = '<%:Download Timeout%>';
}
}
);
btn.disabled = false;
return false;
}
//]]></script>
<input type="button" class="btn cbi-button cbi-input-reload" value="<%:Click to Update%>" onclick="return act_download_rule(this,'<%=self:cfgvalue(section)%>')" />
<%+cbi/valuefooter%>

View File

@ -0,0 +1,152 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
var catch_num;
var catch_timeout;
var catch_out;
function act_download_disney_rule(btn)
{
btn.disabled = true;
btn.value = '<%:Downloading Rule...%> ';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash","download_disney_domains")%>',
null,
function(x,status)
{
if ( x && x.status == 200 ) {
if(status.rule_download_status=="0")
{
btn.value = '<%:Download Failed%>';
}
else if (status.rule_download_status=="1")
{
btn.value = '<%:Download Successful%>';
}
else if (status.rule_download_status=="2")
{
btn.value = '<%:Rule No Change%>';
}
}
else {
btn.value = '<%:Download Timeout%>';
}
}
);
btn.disabled = false;
return false;
};
function act_download_netflix_rule(btn)
{
btn.disabled = true;
btn.value = '<%:Downloading Rule...%> ';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash","download_netflix_domains")%>',
null,
function(x,status)
{
if ( x && x.status == 200 ) {
if(status.rule_download_status=="0")
{
btn.value = '<%:Downloading Fail%>';
}
else if (status.rule_download_status=="1")
{
btn.value = '<%:Downloading Successful%>';
}
else if (status.rule_download_status=="2")
{
btn.value = '<%:Rule No Change%>';
}
}
else {
btn.value = '<%:Downloading Timeout%>';
}
}
);
btn.disabled = false;
return false;
};
function catch_netflix_domains()
{
var legend = document.getElementById('catch-netflix-state');
var output = document.getElementById('catch-netflix-output');
var r = confirm("<%:Attention:%>\n<%:The catch result will be automatically saved%>\n\n1. <%:Please make sure the OpenClash works normally%>\n2. <%:The domains catch time is one minute%>\n3. <%:About to open fast.com%>\n4. <%:You can also try to catch while unlocking device playing%>");
if (r == true) {
winOpen("https://fast.com/");
if (legend && output)
{
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Waiting for command to complete...%>';
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
catch_num = 0;
catch_out = "";
get_netflix_domains();
}
}
};
function strUnique(str){
var ret = [];
str.replace(/[^,]+/g, function($1, $2) {
(str.indexOf($1) == $2) && ret.push($1);
});
return ret.join('\n');
}
function get_netflix_domains()
{
var legend = document.getElementById('catch-netflix-state');
var output = document.getElementById('catch-netflix-output');
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "catch_netflix_domains")%>', null, function(x, status) {
if (x && x.status == 200 && x.responseText != "")
{
if (catch_out != "") {
catch_out = catch_out + x.responseText;
}
else
{
catch_out = x.responseText;
}
}
}
);
catch_num = catch_num + 1;
if ( catch_num < 20 ) {
catch_timeout = setTimeout("get_netflix_domains()", 3000);
}
else {
clearTimeout(catch_timeout);
if (catch_out != "")
{
legend.style.display = 'none';
output.innerHTML = '<textarea class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="10" cols="50" readonly="readonly" >'+strUnique(catch_out)+'</textarea>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "write_netflix_domains")%>', {domains: strUnique(catch_out)}, function(x, status) {});
}
else
{
legend.style.display = 'none';
output.innerHTML = '<span class="error"><%:No domain names were catched...%></span>';
}
}
};
//]]></script>
<input type="button" class="btn cbi-button cbi-input-reload" value="<%:Netflix%>" onclick="return act_download_netflix_rule(this)" />
<input type="button" class="btn cbi-button cbi-input-reload" value="<%:Disney Plus%>" onclick="return act_download_disney_rule(this)" />
<input type="button" class="btn cbi-button cbi-input-reload" value="<%:Catch Netflix%>" onclick="return catch_netflix_domains(this)" />
<fieldset style="display: none;margin: 0 auto;">
<legend id="catch-netflix-state"><%:Collecting data...%></legend>
<br />
<span id="catch-netflix-output"></span>
</fieldset>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,13 @@
<%+cbi/valueheader%>
<div style="text-align: center; margin:0 auto; display: block; width: 100%; height: 50px; text-overflow: ellipsis;">
<div>
<%:Note: Please Upload File According To File Type, File Will Be Saved To The Prompt Path%>
</div>
<div style="color: green; transform:translateY(100%);">
<%
local val = self:cfgvalue(section) or self.default or ""
write(pcdata(val))
%>
</div>
</div>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,37 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function act_flush_fakeip_cache(btn)
{
btn.disabled = true;
btn.value = '<%:Flushing...%> ';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash","flush_fakeip_cache")%>',
null,
function(x,status)
{
if ( x && x.status == 200 ) {
if(status.flush_status == "0" || status.flush_status != "")
{
btn.value = '<%:Flush Failed%>';
}
else
{
btn.value = '<%:Flush Successful%>';
}
}
else {
btn.value = '<%:Flush Timeout%>';
}
}
);
btn.disabled = false;
return false;
};
//]]></script>
<input type="button" class="btn cbi-button cbi-input-reload" value="<%:Flush%>" onclick="return act_flush_fakeip_cache(this)" />
<%+cbi/valuefooter%>

View File

@ -0,0 +1,19 @@
<%+cbi/valueheader%>
<script type="text/javascript">
//<![CDATA[
function import_file_name(btn, option, file_path) {
var file_name = prompt("<%:Paste the name of the new file (including the extension) here:%>", "");
if (file_name == null || file_name == "") {
return false;
}
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "create_file")%>', {filename: file_name, filepath: file_path}, function(x, status) {
if (x && x.status == 200)
{
location.reload();
}
});
}
//]]>
</script>
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Create File%>" onclick="return import_file_name(this, '<%=self.option%>', '<%=self.value%>')" />
<%+cbi/valuefooter%>

View File

@ -0,0 +1,23 @@
<%+cbi/valueheader%>
<script type="text/javascript">
//<![CDATA[
function import_new_file_name(btn, file_path, file_name) {
var new_file_name = prompt("<%:Paste the new file name (including the extension) here:%>", "");
if (new_file_name == null || new_file_name == "") {
return false;
}
if (file_path == "/etc/openclash/config/" && new_file_name.split('.').pop() != "yaml" && new_file_name.split('.').pop() != "yml") {
alert('<%:Illegal extension!%>')
return false;
}
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "rename_file")%>', {new_file_name: new_file_name, file_path: file_path, file_name: file_name}, function(x, status) {
if (x && x.status == 200)
{
location.reload();
}
});
}
//]]>
</script>
<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Rename%>" onclick="return import_new_file_name(this, '<%=self.option%>', '<%=self.value%>')" />
<%+cbi/valuefooter%>

View File

@ -0,0 +1,321 @@
<%+cbi/valueheader%>
<style type="text/css">
*{margin: 0;padding: 0;}
ul{
list-style: none;
}
#tab{
width: 100%;
height: 100%;
border: 1px solid #ddd;
box-shadow: 0 0 2px #ddd;
overflow: hidden;
}
#tab-header{
min-height: 35px;
text-align: center;
position: relative;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tab-header ul{
left: -1px;
width: 100%;
padding: unset !important;
margin: unset !important;
}
#tab-header ul li{
float: left;
width: 160px;
line-height: 35px;
padding: 0 1px;
border-right: 1px solid #dddddd;
cursor: pointer;
}
#tab-header ul li a{
float: unset !important;
padding: unset !important;
vertical-align: middle;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tab-header ul li.cbi-tab > a{
font-weight: bolder;
color: unset;
}
#tab-header ul li a:hover{
color: orangered;
}
#tab-content .dom{
display: none;
}
#tab-content .dom ul li{
float: left;
margin: 15px 10px;
width: 225px;
}
.radio-button{
width: fit-content;
text-align: center;
overflow: auto;
margin: 10px auto;
background-color: #d1d1d1;
border-radius: 4px;
}
.radio-button input[type="radio"] {
display: none;
}
.radio-button label {
display: inline-block;
padding: 4px 11px;
font-size: 18px;
color: white;
cursor: pointer;
border-radius: 4px;
}
.radio-button input[type="radio"]:checked+label {
background-color: #1080c1;
}
</style>
<body>
<div id="tab" class="cbi-section">
<div id="tab-header" class="cbi-tabmenu">
<ul class="cbi-tabmenu">
<li name="tab-header" class="cbi-tab"><a><%:OpenClash Log%></a></li>
<li name="tab-header" class="cbi-tab-disabled"><a><%:Core Log%></a></li>
</ul>
</div>
<div id="tab-content">
<div class="dom" style="display: block;">
<textarea id="cbid.openclash.config.clog" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="32" cols="60" readonly="readonly" ></textarea>
</div>
<div class="dom">
<textarea id="core_log" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="32" cols="60" readonly="readonly" ></textarea>
<div class="radio-button">
<input type="radio" id="info" name="radios" value="info" checked onclick="return switch_log_level(this.value)"/>
<label for="info">Info</label>
<input type="radio" id="warning" name="radios" value="warning" onclick="return switch_log_level(this.value)"/>
<label for="warning">Warning</label>
<input type="radio" id="error" name="radios" value="error" onclick="return switch_log_level(this.value)"/>
<label for="error">Error</label>
<input type="radio" id="debug" name="radios" value="debug" onclick="return switch_log_level(this.value)"/>
<label for="debug">Debug</label>
<input type="radio" id="silent" name="radios" value="silent" onclick="return switch_log_level(this.value)"/>
<label for="silent">Silent</label>
</div>
</div>
</div>
</div>
<fieldset style="text-align: center; width: 100%" class="cbi-section">
<table>
<tr>
<td style="text-align: center; width: 25%">
<input type="button" class="btn cbi-button cbi-button-apply" id="stop_refresh_button" value="<%:Stop Refresh Log%>" onclick=" return stop_refresh() "/>
</td>
<td style="text-align: center; width: 25%">
<input type="button" class="btn cbi-button cbi-button-apply" id="start_refresh_button" value="<%:Start Refresh Log%>" onclick=" return start_refresh() "/>
</td>
<td style="text-align: center; width: 25%">
<input type="button" class="btn cbi-button cbi-button-apply" id="del_log_button" value="<%:Clean Log%>" style=" display:inline;" onclick=" return del_log() " />
</td>
<td style="text-align: center; width: 25%">
<input type="button" class="btn cbi-button cbi-button-apply" id="down_log_button" value="<%:Download Log%>" style=" display:inline;" onclick=" return download_log() " />
</td>
</tr>
</table>
</fieldset>
</body>
<script type="text/javascript">//<![CDATA[
var r;
var s;
var log_len = 0;
var lv = document.getElementById('cbid.openclash.config.clog');
var cl = document.getElementById('core_log');
function get_log_level() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "log_level")%>', null, function(x, status) {
if (x && x.status == 200 && status.log_level != "") {
var radio = document.getElementsByName("radios");
for (i=0; i<radio.length; i++) {
if (radio[i].value == status.log_level && ! radio[i].checked) {
radio[i].checked = true;
}
}
}
});
s=setTimeout("get_log_level()",5000);
};
function switch_log_level(value)
{
clearTimeout(s);
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "switch_log")%>', {log_level: value}, function(x, status) {
if (x && x.status == 200) {
alert(' <%:Log Level%>: ' + value + ' <%:switching succeeded!%>');
get_log_level();
}
else {
alert(' <%:Log Level%>: ' + value + ' <%:switching failed!%>');
get_log_level();
}
});
};
function stop_refresh() {
clearTimeout(r);
return
};
function start_refresh() {
clearTimeout(r);
r=setTimeout("poll_log()",1000*2);
return
};
function createAndDownloadFile(fileName, content) {
var aTag = document.createElement('a');
var blob = new Blob([content]);
aTag.download = fileName;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(blob);
};
function download_log(){
var dt = new Date();
var timestamp = dt.getFullYear()+"-"+(dt.getMonth()+1)+"-"+dt.getDate()+"-"+dt.getHours()+"-"+dt.getMinutes()+"-"+dt.getSeconds();
createAndDownloadFile("OpenClash-"+timestamp+".log","<%:OpenClash Log%>:\n"+lv.innerHTML+"\n<%:Core Log%>:\n"+cl.innerHTML)
return
};
function del_log() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "del_log")%>',null,function(x, data){
lv.innerHTML="";
cl.innerHTML="";
log_len = 0;
oc_editor.setValue(lv.value);
core_editor.setValue(cl.value);
core_editor.refresh();
oc_editor.refresh();
});
return
};
function p(s) {
return s < 10 ? '0' + s: s;
};
function line_tolocal(str){
var strt=new Array();
var cstrt=new Array();
var cn = 0;
var sn = 0;
str.trim().split('\n').forEach(function(v, i) {
var regex = /"([^"]*)"/g;
var res = regex.exec(v);
if (res) {
var dt = new Date(res[1]);
}
else {
var dtt = new Date(v.substring(0,19));
}
if (dt && dt != "Invalid Date"){
if (v.indexOf("level=") != -1) {
var log_info = v.substring(res[1].length + 7);
}
else {
var log_info = v.substring(res[1].length + 2);
}
cstrt[cn]=dt.getFullYear()+"-"+p(dt.getMonth()+1)+"-"+p(dt.getDate())+" "+p(dt.getHours())+":"+p(dt.getMinutes())+":"+p(dt.getSeconds())+log_info;
cn = cn + 1;
}
else if (dtt && dtt != "Invalid Date" && v.substring(28,33).indexOf(" ERR ") == -1) {
strt[sn]=v;
sn = sn + 1;
}
else{
cstrt[cn]=v;
cn = cn + 1;
}
})
return [strt,cstrt]
};
function poll_log(){
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "refresh_log")%>', {log_len: log_len},
function(x, status) {
if ( x && x.status == 200 ) {
if (status && status.log != "" && lv && cl) {
var log = line_tolocal(status.log);
var lines = log[0];
var clines = log[1];
if (lines != "" || clines != "") {
if (lines != "") {
lv.innerHTML = lines.join('\n')+ (log_len != 0 ? '\n' : '') + lv.innerHTML;
oc_editor.setValue(lv.value);
oc_editor.refresh();
}
if (clines != "") {
if (lines[0] != "..." && lines[lines.length-1] != "...") {
cl.innerHTML = clines.join('\n') + (log_len != 0 ? '\n' : '') + cl.innerHTML;
}
else {
cl.innerHTML = clines.join('\n') + (log_len != 0 ? '\n' : cl.innerHTML + '\n...');
}
core_editor.setValue(cl.value);
core_editor.refresh();
}
log_len = status.len;
//lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
}
}
}
}
);
r=setTimeout("poll_log()",1000*2);
};
window.onload = function(){
var titles = document.getElementsByName('tab-header');
var divs = document.getElementsByClassName('dom');
if(titles.length != divs.length) return;
for(var i=0; i<titles.length; i++){
var li = titles[i];
li.id = i;
li.onclick = function(){
for(var j=0; j<titles.length; j++){
titles[j].className = 'cbi-tab-disabled';
divs[j].style.display = 'none';
}
this.className = 'cbi-tab';
divs[this.id].style.display = 'block';
}
li.onTouchStart = function(){
for(var j=0; j<titles.length; j++){
titles[j].className = 'cbi-tab-disabled';
divs[j].style.display = 'none';
}
this.className = 'cbi-tab';
divs[this.id].style.display = 'block';
}
}
get_log_level();
poll_log();
};
//]]>
</script>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,471 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-dns-prefetch-control" content="on">
<link rel="dns-prefetch" href="//cdn.jsdelivr.net">
<link rel="dns-prefetch" href="//whois.pconline.com.cn/ipJson.jsp">
<link rel="dns-prefetch" href="//www.taobao.com/help/getip.php">
<link rel="dns-prefetch" href="//api-ipv4.ip.sb">
<link rel="dns-prefetch" href="//api.ipify.org">
<link rel="dns-prefetch" href="//api.ttt.sh">
<link rel="dns-prefetch" href="//qqwry.api.skk.moe">
<link rel="dns-prefetch" href="//d.skk.moe">
<link rel="preconnect" href="https://www.taobao.com/help/getip.php">
<link rel="preconnect" href="https://whois.pconline.com.cn/ipJson.jsp">
<link rel="preconnect" href="https://api-ipv4.ip.sb">
<link rel="preconnect" href="https://api.ipify.org">
<link rel="preconnect" href="https://api.ttt.sh">
<link rel="preconnect" href="https://qqwry.api.skk.moe">
<link rel="preconnect" href="https://d.skk.moe">
<meta name="referrer" content="no-referrer">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,minimal-ui">
<title>IP 地址查询</title>
<style>
.title-ip {
margin: 10px -2% 15px 8%;
padding: 0px !important;
text-align: left;
font-size: 20px;
font-weight: bold;
}
.title-http {
margin: 10px 0 15px 5%;;
padding: 0px !important;
text-align: left;
font-size: 20px;
font-weight: bold;
}
.ip-title {
font-weight: bold;
font-size:15px;
display: inline-block;
width: 25%;
overflow: hidden;
text-overflow: ellipsis;
vertical-align:bottom;
}
.ip-state_title {
font-weight: bold;
font-size:15px;
display: inline-block;
width: 42%;
vertical-align:bottom;
overflow: hidden;
text-overflow: ellipsis;
}
.ip-result {
font-size:15px;
margin:0px 0px 0px 5%;
white-space: nowrap; /*强制span不换行*/
display: inline-block; /*将span当做块级元素对待*/
width: 32%; /*限制宽度*/
overflow: hidden; /*超出宽度部分隐藏*/
text-overflow: ellipsis; /*超出部分以点号代替*/
vertical-align:bottom;
}
.ip-geo {
font-size:15px;
line-height:20px;
white-space: nowrap; /*强制span不换行*/
display: inline-block; /*将span当做块级元素对待*/
width: 35%; /*限制宽度*/
overflow: hidden; /*超出宽度部分隐藏*/
text-overflow: ellipsis; /*超出部分以点号代替*/
text-align: right;
vertical-align:bottom;
}
.ip-checking {
font-size:15px;
line-height:20px;
display: inline-block;
vertical-align:bottom;
width: 29%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sk-text-success {
color: #32b643;
font-size:15px;
line-height:20px;
display: inline-block;
vertical-align:bottom;
width: 30%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: left;
}
.sk-load-success {
font-size:15px;
line-height:20px;
display: inline-block;
vertical-align:bottom;
width: 18%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: right;
}
.sk-text-error {
color: #e85600;
font-size:15px;
line-height:20px;
display: inline-block;
vertical-align:bottom;
width: 30%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: left;
}
</style>
</head>
<body>
<fieldset class="cbi-section">
<table width="100%">
<tr><td>
<div style="display: flex; min-width: 820px;">
<div style="width: 48%">
<p style="margin: 20px 0 20px 8%; padding: 0px !important; text-align: left; font-size: 25px; font-weight: bold;"><%:IP Address%>
<span style="float: right;"><img src="/luci-static/resources/openclash/img/eye-light.svg" height="20px" title="<%:Hide IP%>" alt="<%:Hide IP%>" id="eye-icon" onclick="return privacy_my_ip(this)" /></span>
</p>
<p style="margin: 10px -2% 0 8%; text-align: left; padding-left: 0px !important; padding-right: 0px !important;">
<span class="ip-title">IP.TB&nbsp;&nbsp;&nbsp;&nbsp;<%:Mainland%>:</span><span class="ip-result" id="ip-taobao"></span> <span class="ip-geo" id="ip-taobao-geo"></span>
</p>
<p style="margin: 10px -2% 0 8%; text-align: left; padding-left: 0px !important; padding-right: 0px !important;">
<span class="ip-title">IP.PC&nbsp;&nbsp;&nbsp;&nbsp;<%:Mainland%>:</span><span class="ip-result" id="ip-pcol"></span> <span class="ip-geo" id="ip-pcol-geo"></span>
</p>
<p style="margin: 10px -2% 0 8%; text-align: left; padding-left: 0px !important; padding-right: 0px !important;">
<span class="ip-title">IP.SB&nbsp;&nbsp;&nbsp;&nbsp;<%:Abroad%>:</span><span class="ip-result" id="ip-ipsb"></span> <span class="ip-geo" id="ip-ipsb-geo"></span>
</p>
<p style="margin: 10px -2% 0 8%; text-align: left; padding-left: 0px !important; padding-right: 0px !important;">
<span class="ip-title">IPIFY&nbsp;&nbsp;&nbsp;&nbsp;<%:Abroad%>:</span><span class="ip-result" id="ip-ipify"></span> <span class="ip-geo" id="ip-ipify-geo"></span>
</p>
</div>
<div style="width: 52%">
<p style="margin: 20px 0 20px 8%; padding: 0px !important;text-align: left; font-size: 25px; font-weight: bold;"><%:Website Access Check%>
<span style="float: right; margin: 0 10% 0 0;"><img src="/luci-static/resources/openclash/img/arrow-clockwise-light.svg" height="20px" title="<%:Refresh%>" alt="<%:Refresh%>" onclick="return refresh_myip(this)" /></span>
</p>
<p style="margin: 10px 0 0 8%; text-align: left; padding-left: 0px !important; padding-right: 0px !important;">
<span class="ip-state_title"><%:Baidu Search%>:</span><span id="http-baidu"></span><span id="ldtime-baidu"></span>
</p>
<p style="margin: 10px 0 0 8%; text-align: left; padding-left: 0px !important; padding-right: 0px !important;">
<span class="ip-state_title"><%:NetEase Music%>:</span><span id="http-163"></span><span id="ldtime-163"></span>
</p>
<p style="margin: 10px 0 0 8%; text-align: left; padding-left: 0px !important; padding-right: 0px !important;">
<span class="ip-state_title">GitHub:</span><span id="http-github"></span><span id="ldtime-github"></span>
</p>
<p style="margin: 10px 0 0 8%; text-align: left; padding-left: 0px !important; padding-right: 0px !important;">
<span class="ip-state_title">YouTube:</span><span id="http-youtube"></span><span id="ldtime-youtube"></span>
</p>
</div>
</div>
<div>
<p style="float: right; margin: 0.5% 2.5% 0 0; font-size:15px; line-height: 20px; padding-left: 0px !important; padding-right: 0px !important;">Powered by <a style="text-decoration: none; color: #666" onclick="return ip_skk()" href="javascript:void(0);">ip.skk.moe</a></p>
</div>
</td></tr>
</table>
</fieldset>
</body>
<script>
function ip_skk()
{
url2='https://ip.skk.moe';
window.open(url2);
}
const $$ = document;
var ip_pcol_ip;
var ip_ipsb_ip;
var ip_taobao_ip;
var ip_ipify_ip;
var refresh_http;
var refresh_ip;
$$.getElementById('ip-pcol').innerHTML = '<%:Querying...%>';
$$.getElementById('ip-ipify').innerHTML = '<%:Querying...%>';
$$.getElementById('ip-taobao').innerHTML = '<%:Querying...%>';
$$.getElementById('ip-ipsb').innerHTML = '<%:Querying...%>';
let random = parseInt(Math.random() * 100000000);
let IP = {
get: (url, type) =>
fetch(url, { method: 'GET' }).then((resp) => {
if (type === 'text')
return Promise.all([resp.ok, resp.status, resp.text(), resp.headers]);
else {
return Promise.all([resp.ok, resp.status, resp.json(), resp.headers]);
}
}).then(([ok, status, data, headers]) => {
if (ok) {
let json = {
ok,
status,
data,
headers
}
return json;
} else {
throw new Error(JSON.stringify(json.error));
}
}).catch(error => {
throw error;
}),
parseIPIpip: (ip, elID) => {
const v4 = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}';
const v4Exact = new RegExp(`^${v4}$`);
const anonymizedIp = (() => {
if (v4Exact.test(ip)) {
const [a, b, c] = ip.split('.');
return `${a}.${b}.${c}.0`;
}
return ip;
})();
fetch(`https://qqwry.api.skk.moe/${anonymizedIp}`, {
referrerPolicy: 'no-referrer-when-downgrade',
}).then(r => r.json())
.then(resp => {
$$.getElementById(elID).innerHTML = resp.geo;
//$$.getElementById(elID).innerHTML = `${resp.data.country} ${resp.data.regionName} ${resp.data.city} ${resp.data.isp}`;
})
},
getIpipnetIP: () => {
IP.get(window.location.protocol+`//myip.ipip.net/?z=${random}`, 'text')
.then((resp) => {
let data = resp.data.replace('当前 IP', '').split(' 来自于:');
if (localStorage.getItem('privacy_my_ip') != 'true') {
$$.getElementById('ip-ipipnet').innerHTML = `${data[0]}`;
};
$$.getElementById('ip-ipipnet-geo').innerHTML = `${data[1]}`;
});
},
getIPApiIP: () => {
IP.get(`https://ipapi.co/json?z=${random}`, 'json')
.then(resp => {
if (localStorage.getItem('privacy_my_ip') != 'true') {
$$.getElementById('ip-ipapi').innerHTML = resp.data.ip;
};
IP.parseIPIpip(resp.data.ip, 'ip-ipapi-geo');
})
},
getSpeedIP: () => {
IP.get(`https://forge.speedtest.cn/api/location/info?z=${random}`, 'json')
.then(resp => {
if (localStorage.getItem('privacy_my_ip') != 'true') {
$$.getElementById('ip-speedtest').innerHTML = resp.data.ip;
};
$$.getElementById('ip-speedtest-geo').innerHTML = resp.data.country + resp.data.province + resp.data.city + (resp.data.distinct == "null" ? resp.data.distinct : '') + ' ' + (resp.data.isp == "null" ? resp.data.isp : '');
//IP.parseIPIpip(resp.data.ip, 'ip-speedtest-geo');
})
},
getIpifyIP: () => {
IP.get(`https://api.ipify.org/?format=json&z=${random}`, 'json')
.then(resp => {
if (localStorage.getItem('privacy_my_ip') != 'true') {
$$.getElementById('ip-ipify').innerHTML = resp.data.ip;
};
return resp.data.ip;
})
.then(ip => {
IP.parseIPIpip(ip, 'ip-ipify-geo');
})
}
};
$$.getElementById('http-baidu').innerHTML = '<span class="ip-checking"><%:Testing...%></span>';
$$.getElementById('http-163').innerHTML = '<span class="ip-checking"><%:Testing...%></span>';
$$.getElementById('http-github').innerHTML = '<span class="ip-checking"><%:Testing...%></span>';
$$.getElementById('http-youtube').innerHTML = '<span class="ip-checking"><%:Testing...%></span>';
let HTTP = {
checker: (domain, cbElID, cbLoID) => {
let img = new Image;
let img_start_time = (+new Date());
let timeout = setTimeout(() => {
img.onerror = img.onload = null;
$$.getElementById(cbLoID).style.display = 'none';
$$.getElementById(cbElID).innerHTML = '<span class="sk-text-error"><%:Access Timed Out%></span>'
}, 5000);
img.onerror = () => {
clearTimeout(timeout);
$$.getElementById(cbLoID).style.display = 'none';
$$.getElementById(cbElID).innerHTML = '<span class="sk-text-error"><%:Access Denied%></span>'
}
img.onload = () => {
clearTimeout(timeout);
let img_load_time = (new Date())- img_start_time;
if ($$.getElementById(cbLoID).style.display == 'none') {
$$.getElementById(cbLoID).style.display = '';
}
if (img_load_time <= 500) {
$$.getElementById(cbLoID).innerHTML = '<span class="sk-load-success">' + img_load_time + ' ms</span>'
$$.getElementById(cbLoID).style.color = '#32b643';
}
else if (img_load_time > 500 && img_load_time <= 1000) {
$$.getElementById(cbLoID).innerHTML = '<span class="sk-load-success">' + img_load_time + ' ms</span>'
$$.getElementById(cbLoID).style.color = 'orange';
}
else {
$$.getElementById(cbLoID).innerHTML = '<span class="sk-load-success">' + img_load_time + ' ms</span>'
$$.getElementById(cbLoID).style.color = '#e85600';
}
$$.getElementById(cbElID).innerHTML = '<span class="sk-text-success"><%:Access Normal%></span>'
}
img.src = `https://${domain}/favicon.ico?${+(new Date)}`
},
runcheck: () => {
HTTP.checker('www.baidu.com', 'http-baidu', 'ldtime-baidu');
HTTP.checker('s1.music.126.net/style', 'http-163', 'ldtime-163');
HTTP.checker('github.com', 'http-github', 'ldtime-github');
HTTP.checker('www.youtube.com', 'http-youtube', 'ldtime-youtube');
}
};
function getPcolIP(data){
let pcisp = data.addr.split(' ');
if (localStorage.getItem('privacy_my_ip') != 'true') {
$$.getElementById('ip-pcol').innerHTML = data.ip;
};
$$.getElementById('ip-pcol-geo').innerHTML = `${data.pro}${data.city}${data.region} ${pcisp[1]}`;
};
function getIpsbIP(data){
if (localStorage.getItem('privacy_my_ip') != 'true') {
$$.getElementById('ip-ipsb').innerHTML = data.ip;
};
IP.parseIPIpip(data.ip, 'ip-ipsb-geo');
};
function ipCallback(data){
if (localStorage.getItem('privacy_my_ip') != 'true') {
$$.getElementById('ip-taobao').innerHTML = data.ip;
};
IP.parseIPIpip(data.ip, 'ip-taobao-geo');
};
function delete_ip_script()
{
var scripts = document.getElementsByTagName('script');
for (var i = scripts.length; i--; ) {
if (document.getElementsByTagName("script")[i]['src'].indexOf('whois.pconline.com.cn') > -1
|| document.getElementsByTagName("script")[i]['src'].indexOf('api-ipv4.ip.sb') > -1
|| document.getElementsByTagName("script")[i]['src'].indexOf('www.taobao.com') > -1) {
scripts[i].parentNode.removeChild(scripts[i]);
};
};
};
function myip_Load()
{
delete_ip_script();
var mypage = document.getElementsByTagName('HEAD').item(0);
var pcipScript= document.createElement("script");
var random = parseInt(Math.random() * 100000000);
pcipScript.defer = "defer";
pcipScript.src=`https://whois.pconline.com.cn/ipJson.jsp?callback=getPcolIP&z=${random}`;
mypage.appendChild(pcipScript);
var sbipScript= document.createElement("script");
sbipScript.defer = "defer";
sbipScript.src='https://api-ipv4.ip.sb/jsonip?callback=getIpsbIP';
mypage.appendChild(sbipScript);
var tbipScript= document.createElement("script");
tbipScript.defer = "defer";
tbipScript.src='https://www.taobao.com/help/getip.php?callback=ipCallback';
mypage.appendChild(tbipScript);
//HTTP.runcheck();
IP.getIpifyIP();
//IP.getSpeedIP();
};
function show_my_ip()
{
if (localStorage.getItem('privacy_my_ip') == 'true') {
$$.getElementById('eye-icon').src='/luci-static/resources/openclash/img/eye-slash-light.svg';
$$.getElementById('eye-icon').title='<%:Show IP%>';
$$.getElementById('eye-icon').alt='<%:Show IP%>';
ip_pcol_ip = $$.getElementById('ip-pcol').innerHTML;
ip_ipsb_ip = $$.getElementById('ip-ipsb').innerHTML;
ip_taobao_ip = $$.getElementById('ip-taobao').innerHTML;
ip_ipify_ip = $$.getElementById('ip-ipify').innerHTML;
$$.getElementById('ip-pcol').innerHTML = '***.***.***.***';
$$.getElementById('ip-ipsb').innerHTML = '***.***.***.***';
$$.getElementById('ip-taobao').innerHTML = '***.***.***.***';
$$.getElementById('ip-ipify').innerHTML = '***.***.***.***';
}
else {
refresh_http = setInterval("HTTP.runcheck()", Math.floor(Math.random()*(10-5+1)+5)*1000);
refresh_ip = setInterval("myip_Load()", Math.floor(Math.random()*(30-10+1)+10)*1000);
};
};
function privacy_my_ip(imgobj)
{
if (imgobj.getAttribute("src") == "/luci-static/resources/openclash/img/eye-light.svg") {
delete_ip_script();
clearInterval(refresh_ip);
localStorage.setItem('privacy_my_ip', 'true');
imgobj.src='/luci-static/resources/openclash/img/eye-slash-light.svg';
imgobj.title='<%:Show IP%>';
imgobj.alt='<%:Show IP%>';
ip_pcol_ip = $$.getElementById('ip-pcol').innerHTML;
ip_ipsb_ip = $$.getElementById('ip-ipsb').innerHTML;
ip_taobao_ip = $$.getElementById('ip-taobao').innerHTML;
ip_ipify_ip = $$.getElementById('ip-ipify').innerHTML;
$$.getElementById('ip-pcol').innerHTML = '***.***.***.***';
$$.getElementById('ip-ipsb').innerHTML = '***.***.***.***';
$$.getElementById('ip-taobao').innerHTML = '***.***.***.***';
$$.getElementById('ip-ipify').innerHTML = '***.***.***.***';
}
else {
imgobj.src='/luci-static/resources/openclash/img/eye-light.svg';
imgobj.title='<%:Hide IP%>';
imgobj.alt='<%:Hide IP%>';
$$.getElementById('ip-pcol').innerHTML = ip_pcol_ip;
$$.getElementById('ip-ipsb').innerHTML = ip_ipsb_ip;
$$.getElementById('ip-taobao').innerHTML = ip_taobao_ip;
$$.getElementById('ip-ipify').innerHTML = ip_ipify_ip;
localStorage.removeItem('privacy_my_ip');
myip_Load();
refresh_ip = setInterval("myip_Load()", Math.floor(Math.random()*(30-10+1)+10)*1000);
};
};
function refresh_myip(imgobj)
{
clearInterval(refresh_http);
clearInterval(refresh_ip);
myip_Load();
HTTP.runcheck();
refresh_http = setInterval("HTTP.runcheck()", Math.floor(Math.random()*(10-5+1)+5)*1000);
refresh_ip = setInterval("myip_Load()", Math.floor(Math.random()*(30-10+1)+10)*1000);
};
HTTP.runcheck();
IP.getIpifyIP();
//IP.getSpeedIP();
show_my_ip();
</script>
<script type="text/javascript">
document.write('<script defer="defer" src="https://whois.pconline.com.cn/ipJson.jsp?callback=getPcolIP&z='+parseInt(Math.random() * 100000000)+'" type="text/javascript"><\/script>');
</script>
<script defer="defer" src="https://api-ipv4.ip.sb/jsonip?callback=getIpsbIP"></script>
<script defer="defer" src="https://www.taobao.com/help/getip.php?callback=ipCallback"></script>
</html>

View File

@ -0,0 +1,7 @@
<%+cbi/valueheader%>
<% if self:cfgvalue(section) ~= false then %>
<input class="btn cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="display: <%= display %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.inputtitle or self.title)%> />
<% else %>
-
<% end %>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,88 @@
<%+cbi/valueheader%>
<%
local stream_id_name = string.gsub(self.value, "%W", "")
%>
<script type="text/javascript">//<![CDATA[
function act_manual_unlock_test_<%=stream_id_name%>(btn, type)
{
var manual_<%=stream_id_name%>_type_legend = document.getElementById('manual-<%=stream_id_name%>-test-state');
var manual_<%=stream_id_name%>_type_output = document.getElementById('manual-<%=stream_id_name%>-test-output');
var r = confirm("<%:Network instability may occur during testing, Are you sure want to start test?%>")
if (r == true) {
if (manual_<%=stream_id_name%>_type_legend && manual_<%=stream_id_name%>_type_output)
{
manual_<%=stream_id_name%>_type_output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Waiting for command to complete...%>';
manual_<%=stream_id_name%>_type_legend.parentNode.style.display = 'block';
manual_<%=stream_id_name%>_type_legend.style.display = 'inline';
};
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "manual_stream_unlock_test")%>', {type: type}, function(x, status) {
if (x && x.status == 200 && x.responseText != "")
{
manual_<%=stream_id_name%>_type_legend.style.display = 'none';
manual_<%=stream_id_name%>_type_output.innerHTML = '<textarea id="manual_<%=stream_id_name%>_type_output" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="10" cols="50" readonly="readonly" >'+x.responseText+'</textarea>';
other_log_area(document.getElementById("manual_<%=stream_id_name%>_type_output"), 'true', manual_<%=stream_id_name%>_type_output.offsetWidth, '250px');
}
else
{
manual_<%=stream_id_name%>_type_legend.style.display = 'none';
manual_<%=stream_id_name%>_type_output.innerHTML = '<span class="error"><%:Something Wrong While Testing...%></span>';
}
}
);
};
};
function act_all_proxies_test_<%=stream_id_name%>(btn, type)
{
var all_<%=stream_id_name%>_legend = document.getElementById('all-<%=stream_id_name%>-test-state');
var all_<%=stream_id_name%>_output = document.getElementById('all-<%=stream_id_name%>-test-output');
var r = confirm("<%:Network instability may occur during testing, Are you sure want to start test?%>")
if (r == true) {
if (all_<%=stream_id_name%>_legend && all_<%=stream_id_name%>_output)
{
all_<%=stream_id_name%>_output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Waiting for command to complete...%>';
all_<%=stream_id_name%>_legend.parentNode.style.display = 'block';
all_<%=stream_id_name%>_legend.style.display = 'inline';
};
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "all_proxies_stream_test")%>', {type: type}, function(x, status) {
if (x && x.status == 200 && x.responseText != "")
{
all_<%=stream_id_name%>_legend.style.display = 'none';
all_<%=stream_id_name%>_output.innerHTML = '<textarea id="all_<%=stream_id_name%>_output" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="10" cols="50" readonly="readonly" >'+x.responseText+'</textarea>';
other_log_area(document.getElementById("all_<%=stream_id_name%>_output"), 'true', all_<%=stream_id_name%>_output.offsetWidth, '250px');
}
else
{
all_<%=stream_id_name%>_legend.style.display = 'none';
all_<%=stream_id_name%>_output.innerHTML = '<span class="error"><%:Something Wrong While Testing...%></span>';
}
}
);
};
};
//]]></script>
<input type="button" class="btn cbi-button cbi-input-reload" value="<%:Unlock Test(Select)%>" onclick="return act_manual_unlock_test_<%=stream_id_name%>(this, '<%=self.value%>')" />
<input type="button" class="btn cbi-button cbi-input-reload" value="<%:All Proxies Test%>" onclick="return act_all_proxies_test_<%=stream_id_name%>(this, '<%=self.value%>')" />
<fieldset style="display: none;margin: 0 auto;">
<legend id="manual-<%=stream_id_name%>-test-state"><%:Collecting data...%></legend>
<br />
<span id="manual-<%=stream_id_name%>-test-output"></span>
</fieldset>
<fieldset style="display: none;margin: 0 auto;">
<legend id="all-<%=stream_id_name%>-test-state"><%:Collecting data...%></legend>
<br />
<span id="all-<%=stream_id_name%>-test-output"></span>
</fieldset>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,316 @@
<%+cbi/valueheader%>
<script type="text/javascript">
//<![CDATA[
function padright(str, cnt, pad) {
return str + Array(cnt + 1).join(pad);
}
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
function b64encutf8safe(str) {
return b64EncodeUnicode(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '');
}
function b64DecodeUnicode(str) {
return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function b64decutf8safe(str) {
var l;
str = str.replace(/-/g, "+").replace(/_/g, "/");
l = str.length;
l = (4 - l % 4) % 4;
if (l) str = padright(str, l, "=");
return b64DecodeUnicode(str);
}
function b64encsafe(str) {
return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '')
}
function b64decsafe(str) {
var l;
str = str.replace(/-/g, "+").replace(/_/g, "/");
l = str.length;
l = (4 - l % 4) % 4;
if (l) str = padright(str, l, "=");
return atob(str);
}
function dictvalue(d, key) {
var v = d[key];
if (typeof (v) == 'undefined' || v == '') return '';
return b64decsafe(v);
}
function export_ssr_url(btn, urlname, sid) {
var s = document.getElementById(urlname + '-status');
if (!s) return false;
var v_server = document.getElementsByName('cbid.openclash.' + sid + '.server')[0];
var v_port = document.getElementsByName('cbid.openclash.' + sid + '.port')[0];
var v_protocol = document.getElementsByName('cbid.openclash.' + sid + '.protocol')[0];
var v_method = document.getElementsByName('cbid.openclash.' + sid + '.cipher_ssr')[0];
var v_obfs = document.getElementsByName('cbid.openclash.' + sid + '.obfs_ssr')[0];
var v_password = document.getElementsByName('cbid.openclash.' + sid + '.password')[0];
var v_obfs_param = document.getElementsByName('cbid.openclash.' + sid + '.obfs_param')[0];
var v_protocol_param = document.getElementsByName('cbid.openclash.' + sid + '.protocol_param')[0];
var v_alias = document.getElementsByName('cbid.openclash.' + sid + '.name')[0];
var ssr_str = v_server.value + ":" + v_port.value + ":" + v_protocol.value + ":" + v_method.value + ":" + v_obfs.value + ":" + b64encsafe(v_password.value) + "/?obfsparam=" + b64encsafe(v_obfs_param.value) + "&protoparam=" + b64encsafe(v_protocol_param.value) + "&remarks=" + b64encutf8safe(v_alias.value);
var textarea = document.createElement("textarea");
textarea.textContent = "ssr://" + b64encsafe(ssr_str);
textarea.style.position = "fixed";
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand("copy"); // Security exception may be thrown by some browsers.
s.innerHTML = "<font style=\"color:green\"><%:Copy SSR to clipboard successfully.%></font>";
} catch (ex) {
s.innerHTML = "<font style=\"color:red\"><%:Unable to copy SSR to clipboard.%></font>";
} finally {
document.body.removeChild(textarea);
}
return false;
}
function import_ssr_url(btn, urlname, sid) {
var s = document.getElementById(urlname + '-status');
if (!s) return false;
var ssrurl = prompt("<%:Paste sharing link here%>", "");
if (ssrurl == null || ssrurl == "") {
s.innerHTML = "<font style=\"color:red\"><%:User cancelled.%></font>";
return false;
}
s.innerHTML = "";
//var ssu = ssrurl.match(/ssr:\/\/([A-Za-z0-9_-]+)/i);
var ssu = ssrurl.split('://');
//console.log(ssu.length);
var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
switch (ssu[0]) {
case "ss":
var url0, param = "";
var sipIndex = ssu[1].indexOf("@");
var ploc = ssu[1].indexOf("#");
if (ploc > 0) {
url0 = ssu[1].substr(0, ploc);
param = ssu[1].substr(ploc + 1);
} else {
url0 = ssu[1];
}
if (sipIndex != -1) {
// SIP002
var userInfo = b64decsafe(url0.substr(0, sipIndex));
var temp = url0.substr(sipIndex + 1).split("/?");
var serverInfo = temp[0].split(":");
var server = serverInfo[0];
var port = serverInfo[1];
var method, password, plugin, pluginOpts, pluginObfs, pluginObfsHost, pluginObfsPath, pluginObfsHeaders;
if (temp[1]) {
var pluginInfo = decodeURIComponent(temp[1]);
var pluginIndex = pluginInfo.indexOf(";");
var pluginNameInfo = pluginInfo.substr(0, pluginIndex);
plugin = pluginNameInfo.substr(pluginNameInfo.indexOf("=") + 1);
pluginOpts = pluginInfo.substr(pluginIndex + 1);
if (pluginOpts.indexOf("obfs=") != -1) {
pluginObfs = pluginOpts.split("obfs=")[1].split(";")[0];
if (pluginObfs == "ws") {
pluginObfs = "websocket"
}
if (pluginOpts.indexOf("obfs-host=") != -1) {
pluginObfsHost = pluginOpts.split("obfs-host=")[1].split("&group=")[0] || pluginOpts.split("obfs-host=")[1].split(";")[0];
}
if (pluginOpts.indexOf("path=") != -1) {
pluginObfsPath = pluginOpts.split("path=")[1].split(";")[0];
}
if (pluginOpts.indexOf("headers=") != -1) {
pluginObfsHeaders = pluginOpts.split("headers=")[1].split(";")[0];
}
}
}
var userInfoSplitIndex = userInfo.indexOf(":");
if (userInfoSplitIndex != -1) {
method = userInfo.substr(0, userInfoSplitIndex);
password = userInfo.substr(userInfoSplitIndex + 1);
}
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].value = ssu[0];
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].dispatchEvent(event);
document.getElementsByName('cbid.openclash.' + sid + '.server')[0].value = server;
document.getElementsByName('cbid.openclash.' + sid + '.port')[0].value = port;
document.getElementsByName('cbid.openclash.' + sid + '.password')[0].value = password || "";
document.getElementsByName('cbid.openclash.' + sid + '.cipher')[0].value = method || "";
document.getElementsByName('cbid.openclash.' + sid + '.obfs')[0].value = pluginObfs || "none";
document.getElementsByName('cbid.openclash.' + sid + '.obfs')[0].dispatchEvent(event);
if (plugin != undefined) {
document.getElementsByName('cbid.openclash.' + sid + '.host')[0].value = pluginObfsHost || "";
if (pluginObfs == "websocket") {
document.getElementsByName('cbid.openclash.' + sid + '.custom')[0].value = pluginObfsHeaders || "";
document.getElementsByName('cbid.openclash.' + sid + '.path')[0].value = pluginObfsPath || "";
}
}
if (param != undefined) {
document.getElementsByName('cbid.openclash.' + sid + '.name')[0].value = decodeURI(param);
}
s.innerHTML = "<font style=\"color:green\"><%:Import configuration information successfully.%></font>";
} else {
var sstr = b64decsafe(url0);
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].value = ssu[0];
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].dispatchEvent(event);
var team = sstr.split('@');
var part1 = team[0].split(':');
var part2 = team[1].split(':');
document.getElementsByName('cbid.openclash.' + sid + '.server')[0].value = part2[0];
document.getElementsByName('cbid.openclash.' + sid + '.port')[0].value = part2[1];
document.getElementsByName('cbid.openclash.' + sid + '.password')[0].value = part1[1];
document.getElementsByName('cbid.openclash.' + sid + '.cipher')[0].value = part1[0];
if (param != undefined) {
document.getElementsByName('cbid.openclash.' + sid + '.name')[0].value = decodeURI(param);
}
s.innerHTML = "<font style=\"color:green\"><%:Import configuration information successfully.%></font>";
}
return false;
case "ssr":
var sstr = b64decsafe(ssu[1]);
var ploc = sstr.indexOf("/?");
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].value = ssu[0];
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].dispatchEvent(event);
var url0, param = "";
if (ploc > 0) {
url0 = sstr.substr(0, ploc);
param = sstr.substr(ploc + 2);
}
var ssm = url0.match(/^(.+):([^:]+):([^:]*):([^:]+):([^:]*):([^:]+)/);
if (!ssm || ssm.length < 7) return false;
var pdict = {};
if (param.length > 2) {
var a = param.split('&');
for (var i = 0; i < a.length; i++) {
var b = a[i].split('=');
pdict[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
}
}
document.getElementsByName('cbid.openclash.' + sid + '.server')[0].value = ssm[1];
document.getElementsByName('cbid.openclash.' + sid + '.port')[0].value = ssm[2];
document.getElementsByName('cbid.openclash.' + sid + '.protocol')[0].value = ssm[3];
document.getElementsByName('cbid.openclash.' + sid + '.cipher_ssr')[0].value = (ssm[4] == "none" ? "dummy" : ssm[4]);
document.getElementsByName('cbid.openclash.' + sid + '.obfs_ssr')[0].value = ssm[5];
document.getElementsByName('cbid.openclash.' + sid + '.password')[0].value = b64decsafe(ssm[6]);
document.getElementsByName('cbid.openclash.' + sid + '.obfs_param')[0].value = dictvalue(pdict, 'obfsparam');
document.getElementsByName('cbid.openclash.' + sid + '.protocol_param')[0].value = dictvalue(pdict, 'protoparam');
var rem = pdict['remarks'];
if (typeof (rem) != 'undefined' && rem != '' && rem.length > 0) document.getElementsByName('cbid.openclash.' + sid + '.name')[0].value = b64decutf8safe(rem);
s.innerHTML = "<font style=\"color:green\"><%:Import configuration information successfully.%></font>";
return false;
case "trojan":
var url0, param = "";
var ploc = ssu[1].indexOf("#");
if (ploc > 0) {
url0 = ssu[1].substr(0, ploc);
param = ssu[1].substr(ploc + 1);
} else {
url0 = ssu[1]
}
var sstr = url0;
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].value = "trojan";
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].dispatchEvent(event);
var team = sstr.split('@');
var password = team[0]
var serverPart = team[1].split(':');
var others = serverPart[1].split('?');
var port = parseInt(others[0]);
var queryParam = {}
if (others.length > 1) {
var queryParams = others[1]
var queryArray = queryParams.split('&');
for (i = 0; i < queryArray.length; i++) {
var params = queryArray[i].split('=');
queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || '');
}
}
document.getElementsByName('cbid.openclash.' + sid + '.server')[0].value = serverPart[0];
document.getElementsByName('cbid.openclash.' + sid + '.port')[0].value = port || '443';
document.getElementsByName('cbid.openclash.' + sid + '.password')[0].value = password;
document.getElementsByName('cbid.openclash.' + sid + '.sni')[0].value = queryParam.sni || '';
if (queryParam.type != undefined) {
for (i = 0; i < document.getElementById('cbi.combobox.cbid.openclash.' + sid + '.alpn.1').getElementsByTagName("option").length; i++) {
if ( document.getElementById('cbi.combobox.cbid.openclash.' + sid + '.alpn.1').getElementsByTagName("option")[i].value == queryParam.type ) {
document.getElementById('cbi.combobox.cbid.openclash.' + sid + '.alpn.1').getElementsByTagName("option")[i].selected=true;
}
}
}
if (param != undefined) {
document.getElementsByName('cbid.openclash.' + sid + '.name')[0].value = decodeURI(param);
}
s.innerHTML = "<font style=\"color:green\"><%:Import configuration information successfully.%></font>";
return false;
case "vmess":
var sstr = b64DecodeUnicode(ssu[1]);
var ploc = sstr.indexOf("/?");
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].value = "vmess";
document.getElementsByName('cbid.openclash.' + sid + '.type')[0].dispatchEvent(event);
var url0, param = "";
if (ploc > 0) {
url0 = sstr.substr(0, ploc);
param = sstr.substr(ploc + 2);
}
var ssm = JSON.parse(sstr);
document.getElementsByName('cbid.openclash.' + sid + '.name')[0].value = ssm.ps;
document.getElementsByName('cbid.openclash.' + sid + '.server')[0].value = ssm.add;
document.getElementsByName('cbid.openclash.' + sid + '.port')[0].value = ssm.port;
document.getElementsByName('cbid.openclash.' + sid + '.alterId')[0].value = ssm.aid;
document.getElementsByName('cbid.openclash.' + sid + '.uuid')[0].value = ssm.id;
document.getElementsByName('cbid.openclash.' + sid + '.obfs_vmess')[0].value = ssm.net;
document.getElementsByName('cbid.openclash.' + sid + '.obfs_vmess')[0].dispatchEvent(event);
if (ssm.method) {
document.getElementsByName('cbid.openclash.' + sid + '.securitys')[0].value = ssm.method;
}
if (ssm.net == "tcp") {
if (ssm.type && ssm.type != "http") {
ssm.type = "none"
document.getElementsByName('cbid.openclash.' + sid + '.obfs_vmess')[0].value = ssm.type;
document.getElementsByName('cbid.openclash.' + sid + '.obfs_vmess')[0].dispatchEvent(event);
} else {
document.getElementsByName('cbid.openclash.' + sid + '.obfs_vmess')[0].value = "http";
document.getElementsByName('cbid.openclash.' + sid + '.obfs_vmess')[0].dispatchEvent(event);
document.getElementsByName('cbid.openclash.' + sid + '.http_path')[0].value = ssm.path;
}
}
if (ssm.net == "ws") {
document.getElementsByName('cbid.openclash.' + sid + '.obfs_vmess')[0].value = "websocket";
document.getElementsByName('cbid.openclash.' + sid + '.obfs_vmess')[0].dispatchEvent(event);
document.getElementsByName('cbid.openclash.' + sid + '.ws_opts_path')[0].value = ssm.path;
document.getElementsByName('cbid.openclash.' + sid + '.ws_opts_headers')[0].value = "Host: " + ssm.host;
if (ssm.maxearlydata) {
document.getElementsByName('cbid.openclash.' + sid + '.max_early_data')[0].value = ssm.maxearlydata;
}
if (ssm.earlydataheadername) {
document.getElementsByName('cbid.openclash.' + sid + '.early_data_header_name')[0].value = ssm.earlydataheadername;
}
}
if (ssm.net == "h2") {
document.getElementsByName('cbid.openclash.' + sid + '.h2_host')[0].value = ssm.host;
document.getElementsByName('cbid.openclash.' + sid + '.h2_path')[0].value = ssm.path;
}
if (ssm.tls == "tls") {
document.getElementsByName('cbid.openclash.' + sid + '.tls')[0].value = "true";
}
if (ssm.sni) {
document.getElementsByName('cbid.openclash.' + sid + '.servername')[0].value = ssm.sni;
}
s.innerHTML = "<font style=\"color:green\"><%:Import configuration information successfully.%></font>";
return false;
default:
s.innerHTML = "<font style=\"color:red\"><%:Invalid format.%></font>";
return false;
}
}
//]]>
</script>
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Import%>" onclick="return import_ssr_url(this, '<%=self.option%>', '<%=self.value%>')" />
<span id="<%=self.option%>-status"></span>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,942 @@
<head>
<style>
.dot-typing{position:relative;left:-9999px;width:10px;height:10px;border-radius:5px;background-color:#9880ff;color:#9880ff;box-shadow:9984px 0 0 0 #9880ff,9999px 0 0 0 #9880ff,10014px 0 0 0 #9880ff;animation:dotTyping 1.5s infinite linear}@keyframes dotTyping{0%{box-shadow:9984px 0 0 0 #9880ff,9999px 0 0 0 #9880ff,10014px 0 0 0 #9880ff}16.667%{box-shadow:9984px -10px 0 0 #9880ff,9999px 0 0 0 #9880ff,10014px 0 0 0 #9880ff}33.333%{box-shadow:9984px 0 0 0 #9880ff,9999px 0 0 0 #9880ff,10014px 0 0 0 #9880ff}50%{box-shadow:9984px 0 0 0 #9880ff,9999px -10px 0 0 #9880ff,10014px 0 0 0 #9880ff}66.667%{box-shadow:9984px 0 0 0 #9880ff,9999px 0 0 0 #9880ff,10014px 0 0 0 #9880ff}83.333%{box-shadow:9984px 0 0 0 #9880ff,9999px 0 0 0 #9880ff,10014px -10px 0 0 #9880ff}100%{box-shadow:9984px 0 0 0 #9880ff,9999px 0 0 0 #9880ff,10014px 0 0 0 #9880ff}}
.radio-button{
display: none;
white-space: nowrap;
background-color: #d1d1d1;
border-radius: 4px;
}
.radio-button input[type="radio"] {
display: none;
}
.radio-button label {
display: inline-block;
font-size: 14px;
padding: 4px 5px;
color: white;
cursor: pointer;
border-radius: 4px;
}
.radio-button input[type="radio"]:checked+label {
background-color: #1080c1;
}
</style>
</head>
<%
local uci = require("luci.model.uci").cursor()
local RELEASE_BRANCH = uci:get("openclash", "config", "release_branch")
local random = tostring(os.time()):reverse():sub(1, 9)
%>
<fieldset class="cbi-section">
<table width="100%">
<tr>
<td colspan="4" width="100%">
<p style="margin: 10px 0; text-align: center">
<%
if uci:get("openclash", "config", "enable_meta_core") ~= '1' then
%>
<img id="_logo" src="/luci-static/resources/openclash/img/logo.png?<%=random%>" loading="lazy" onload="return logo_check(this,this.src,'https://ftp.jaist.ac.jp/pub/sourceforge.jp/storage/g/o/op/openclash/<%=RELEASE_BRANCH%>/img/logo.png')" onerror="return logo_error(this,'/luci-static/resources/openclash/img/logo.png?<%=random%>')" title="Hello, World!" alt="OpenClash" onclick="return homepage()" />
<%
else
%>
<img id="_logo" src="/luci-static/resources/openclash/img/meta.png?<%=random%>" loading="lazy" onload="return logo_check(this,this.src,'https://ftp.jaist.ac.jp/pub/sourceforge.jp/storage/g/o/op/openclash/<%=RELEASE_BRANCH%>/img/meta.png')" onerror="return logo_error(this,'/luci-static/resources/openclash/img/meta.png?<%=random%>')" title="Hello, World!" alt="OpenClash" onclick="return homepage()" />
<%
end
%>
</p>
<p id="_clashversion" style="margin: 10px 0; text-align: center">
<img src="/luci-static/resources/openclash/img/version.svg?<%=random%>" onerror="return imgerrorfuns(this,'https://ftp.jaist.ac.jp/pub/sourceforge.jp/storage/g/o/op/openclash/<%=RELEASE_BRANCH%>/img/version.png')" alt="currentversion" height="21px" onclick="return go_update()">
</p>
</td></tr>
<tr><td colspan="4" width="100%">
<p style="margin: 10px 0; text-align: center">
<img id="gitbook" src="/luci-static/resources/openclash/img/Wiki.svg?<%=random%>" loading="lazy" alt="GitBook" width="50px" height="20px" onerror="return imgerrorfuns(this,'https://img.shields.io/badge/Wiki--lightgrey?logo=GitBook&style=social')" onclick="return gitbookpage()" />
&nbsp;&nbsp;&nbsp;
<img id="wiki" src="/luci-static/resources/openclash/img/Tutorials.svg?<%=random%>" loading="lazy" alt="Wiki" width="75px" height="20px" onerror="return imgerrorfuns(this,'https://img.shields.io/badge/Tutorials--lightgrey?logo=Wikipedia&style=social')" onclick="return wikipage()" />
&nbsp;&nbsp;&nbsp;
<img id="star" src="/luci-static/resources/openclash/img/Star.svg?<%=random%>g" loading="lazy" alt="star" width="50px" height="20px" onerror="return imgerrorfuns(this,'https://img.shields.io/badge/Star--lightgrey?logo=github&style=social')" onclick="return homepage()" />
&nbsp;&nbsp;&nbsp;
<img id="telegram" src="/luci-static/resources/openclash/img/Telegram.svg?<%=random%>" loading="lazy" alt="Telegram" onerror="return imgerrorfuns(this,'https://img.shields.io/badge/Telegram--lightgrey?logo=Telegram&style=social')" onclick="return telegrampage()" />
&nbsp;&nbsp;&nbsp;
<img id="sponsor" src="/luci-static/resources/openclash/img/Sponsor.svg?<%=random%>" loading="lazy" alt="Sponsor" width="73px" height="20px" onerror="return imgerrorfuns(this,'https://img.shields.io/badge/Sponsor--lightgrey?logo=ko-fi&style=social')" onclick="return sponsorpage()" />
</p>
</td></tr>
<tr><td width="100%" colspan="4">
<div style="margin: 10px 0; text-align: center" id="_clashstart">
<b><%:Tip: after started, please wait patiently until the connection is normal%></b>
</div>
</td></tr>
<tr><td width="25%"><%:Main Program%></td><td width="25%" align="left"><span id="_clash"><%:Collecting data...%></span><span id="_watchdog"></span></td><td width="25%"><%:Control Panel Login IP%></td><td width="25%" align="left" id="_daip"><%:Collecting data...%></td></tr>
<tr><td width="20%"><%:Running Mode%></td><td width="30%" align="left"><span id="_mode"><%:Collecting data...%></span><span id="radio-ru-mode" class="radio-button">
<input type="radio" id="normal" name="radios-ru" value="" checked onclick="return switch_run_mode(this.value)"/>
<label for="normal" id="run_normal"><%:Compatible%></label>
<input type="radio" id="tun" name="radios-ru" value="-tun" onclick="return switch_run_mode(this.value)"/>
<label for="tun"><%:TUN%></label>
<input type="radio" id="mix" name="radios-ru" value="-mix" onclick="return switch_run_mode(this.value)"/>
<label for="mix"><%:Mix%></label>
</span></td><td width="25%"><%:Control Panel Login Port%></td><td width="25%" align="left" id="_dapo"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:Proxy Mode%></td><td width="25%" align="left"><span id="radio-de"><%:Collecting data...%></span><span id="radio-mode" class="radio-button">
<input type="radio" id="rule" name="radios" value="rule" checked onclick="return switch_rule_mode(this.value)"/>
<label for="rule">Rule</label>
<input type="radio" id="global" name="radios" value="global" onclick="return switch_rule_mode(this.value)"/>
<label for="global">Global</label>
<input type="radio" id="direct" name="radios" value="direct" onclick="return switch_rule_mode(this.value)"/>
<label for="direct">Direct</label>
</span></td><td width="25%"><%:Control Panel Login Secret%></td><td width="25%" align="left" id="_dase"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:Yacd Control Panel%></td><td width="25%" align="left" id="_web"><%:Collecting data...%></td><td width="25%"><%:Dashboard Control Panel%></td><td width="25%" align="left" id="_webo"><%:Collecting data...%></td></tr>
<tr id="tool_label2"><td colspan="4"><div style="margin: 10px 0; text-align: center">
<span>
&nbsp;&nbsp;<%:Up:%>&nbsp;
<span id="upload_">
<font style=color:green>
0 KB/S
</font>
</span>
</span>
<span>
&nbsp;&nbsp;<%:Down:%>&nbsp;
<span id="download_">
<font style=color:green>
0 KB/S
</font>
</span>
</span>
<span>
&nbsp;&nbsp;<%:Up Total:%>&nbsp;
<span id="uploadtotal_">
<font style=color:green>
0 KB
</font>
</span>
</span>
<span>
&nbsp;&nbsp;<%:Down Total:%>&nbsp;
<span id="downloadtotal_">
<font style=color:green>
0 KB
</font>
</span>
</span>
<span>
&nbsp;&nbsp;<%:Connections:%>&nbsp;
<span id="connect_t">
<font style=color:green>
0
</font>
</span>
</span>
<span>
&nbsp;&nbsp;<%:Ram:%>&nbsp;
<span id="mem_t">
<font style=color:green>
0 KB
</font>
</span>
</span>
<span>
&nbsp;&nbsp;<%:CPU:%>&nbsp;
<span id="cpu_t">
<font style=color:green>
0 %
</font>
</span>
&nbsp;&nbsp;
</span>
</div></td></tr>
<tr height="50px">
<td width="100%" colspan="4">
<div id="hid_btn" style="height: 25px;width: 100px;margin: 0 auto;" onclick="hid_btn_action()">
<div style="margin: 0 auto; top: 50%;" class="dot-typing"></div>
</div>
</td>
</tr>
<tr id="hid_1"><td width="100%" colspan="4"><p style="margin: 10px 0; text-align: center"><b><%:Quick Operation%></b></p></td></tr>
<tr id="hid_2">
<td width="25%" align="center"><p style="margin: 10px 0; text-align: center" id="_close_all_connection"><%:Collecting data...%></p></td>
<td width="25%" align="center"><p style="margin: 10px 0; text-align: center" id="_reload_firewall"><%:Collecting data...%></p></td>
<td width="25%" align="center"><p style="margin: 10px 0; text-align: center" id="_flush_fakeip_cache"><%:Collecting data...%></p></td>
<td width="25%" align="center"><p style="margin: 10px 0; text-align: center" id="_update_subscribe"><%:Collecting data...%></p></td>
</tr>
<tr id="hid_3">
<td width="25%" align="center"><p style="margin: 10px 0; text-align: center" id="_update_other_rules"><%:Collecting data...%></p></td>
<td width="25%" align="center"><p style="margin: 10px 0; text-align: center" id="_update_geoip"><%:Collecting data...%></p></td>
<td width="25%" align="center"><p style="margin: 10px 0; text-align: center" id="_update_geosite"><%:Collecting data...%></p></td>
<td width="25%" align="center"><p style="margin: 10px 0; text-align: center" id="_one_key_update"><%:Collecting data...%></p></td>
</tr>
</table>
</fieldset>
<fieldset id="state" class="cbi-section">
<table>
<tr><td width="100%" colspan="4">
<p style="margin: 10px 0; text-align: center">
<b><%:Please ensure that all items are displayed normally before running. If you need to update, please go to the global settings page%></b>
</p>
</td></tr>
<tr><td width="25%"><%:Node Select Backup%></td><td width="25%" align="left" id="_historychecktime"><%:Collecting data...%></td><td width="25%"><%:lhie1 Rule Update%></td><td width="25%" align="left" id="_lhie1"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:ConnersHua Rule Update%></td><td width="25%" align="left" id="_ConnersHua"><%:Collecting data...%></td><td width="25%"><%:ConnersHua Return Rule Update%></td><td width="25%" align="left" id="_ConnersHua_return"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:Mainland IP Update%></td><td width="25%" align="left" id="_chnroute"><%:Collecting data...%></td><td width="25%"><%: Mainland IPv6 Update%></td><td width="25%" align="left" id="_chnroutev6"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:GEOIP Data Update%></td><td width="25%" align="left" id="_ipdb"><%:Collecting data...%></td><td width="25%"><%:GeoSite Data Update%></td><td width="25%" align="left" id="_geosite"><%:Collecting data...%></td></tr>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
var clash = document.getElementById('_clash');
var mode = document.getElementById('_mode');
var web = document.getElementById('_web');
var webo = document.getElementById('_webo');
var watchdog = document.getElementById('_watchdog');
var daip = document.getElementById('_daip');
var dase = document.getElementById('_dase');
var dapo = document.getElementById('_dapo');
var startlog = document.getElementById('_clashstart');
var clashversion = document.getElementById('_clashversion');
var close_all_connection = document.getElementById('_close_all_connection');
var reload_firewall = document.getElementById('_reload_firewall');
var one_key_update = document.getElementById('_one_key_update');
var update_subscribe = document.getElementById('_update_subscribe');
var update_other_rules = document.getElementById('_update_other_rules');
var update_geoip = document.getElementById('_update_geoip');
var update_geosite = document.getElementById('_update_geosite');
var flush_fakeip_cache= document.getElementById('_flush_fakeip_cache');
var ipdb = document.getElementById('_ipdb');
var geosite = document.getElementById('_geosite');
var lhie1 = document.getElementById('_lhie1');
var ConnersHua = document.getElementById('_ConnersHua');
var ConnersHua_return = document.getElementById('_ConnersHua_return');
var chnroute = document.getElementById('_chnroute');
var chnroutev6 = document.getElementById('_chnroutev6');
var historychecktime = document.getElementById('_historychecktime');
var hid_1 = document.getElementById("hid_1");
var hid_2 = document.getElementById("hid_2");
var hid_3 = document.getElementById("hid_3");
var state = document.getElementById("state");
var hid_btn = document.getElementById("hid_btn");
var tool_label2 = document.getElementById('tool_label2');
var radio_mode = document.getElementById('radio-mode');
var radio = document.getElementsByName("radios");
var radio_de = document.getElementById('radio-de');
var radio_ru_mode = document.getElementById('radio-ru-mode');
var radio_ru = document.getElementsByName("radios-ru");
var radio_run_normal = document.getElementById("run_normal");
var script_radio;
var script_radio_label;
var hid_btn_if = true;
var ws_connect = false;
var ws_error = false;
var ws_retry = 0;
var luci_protocol;
var ws_t;
var ws_c;
var state_refresh;
var s;
var gr;
hid_1.style.display = "none";
hid_2.style.display = "none";
hid_3.style.display = "none";
state.style.display="none";
XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.restricted_mode != "1" )
{
clash.innerHTML = status.clash ? '<b style=color:green><%:Running%></b>' : '<b style=color:red><%:Not Running%></b>';
}
else
{
clash.innerHTML = status.clash ? '<b style=color:green><%:Running%> <%:<Limited State>%></b>' : '<b style=color:red><%:Not Running%></b>';
}
watchdog.innerHTML = status.watchdog ? '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<%:Daemons%>:&nbsp;&nbsp;&nbsp;<b style=color:green><%:Running%></b>' : '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<%:Daemons%>:&nbsp;&nbsp;&nbsp;<b style=color:red><%:Not Running%></b>';
dase.innerHTML = status.dase ? "<b style=color:green>"+status.dase+"</b>" : "<b style=color:red>"+"<%:Not Set%>"+"</b>";
web.innerHTML = status.web ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Open Panel%>" onclick="return ycad_dashboard(this)"/>' : '<b style=color:red><%:Not Running%></b>';
webo.innerHTML = status.web ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Open Panel%>" onclick="return net_dashboard(this)"/>' : '<b style=color:red><%:Not Running%></b>';
close_all_connection.innerHTML = status.clash ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Close All Connections%>" onclick="return b_close_all_connection(this)"/>' : '<b style=color:red><%:Not Running%></b>';
reload_firewall.innerHTML = status.clash ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Reload Firewall Rules%>" onclick="return b_reload_firewall(this)"/>' : '<b style=color:red><%:Not Running%></b>';
flush_fakeip_cache.innerHTML = status.clash ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Flush Fake-IP Cache%>" onclick="return b_flush_fakeip_cache(this)"/>' : '<b style=color:red><%:Not Running%></b>';
one_key_update.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check All Components Update%>" onclick="return all_one_key_update(this)"/>';
update_subscribe.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check Config Update%>" onclick="return b_update_subscribe(this)"/>';
update_other_rules.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check Third Party Rules Update%>" onclick="return b_update_other_rules(this)"/>';
update_geoip.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check GEOIP Data Update%>" onclick="return b_update_geoip(this)"/>';
update_geosite.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check GeoSite Data Update%>" onclick="return b_update_geosite(this)"/>';
if (status.daip && window.location.hostname == status.daip) {
daip.innerHTML = status.daip ? "<b style=color:green>"+status.daip+"</b>" : "<b style=color:red>"+"<%:Not Set%>"+"</b>";
dapo.innerHTML = status.cn_port ? "<b style=color:green>"+status.cn_port+"</b>" : "<b style=color:red>"+"<%:Not Set%>"+"</b>";
luci_protocol = (window.location.protocol == "http:" ? "ws://" : "wss://") + status.daip + ":" + status.cn_port;
}
else if (status.daip && window.location.hostname != status.daip && status.db_foward_domain && status.db_foward_port)
{
daip.innerHTML = status.db_foward_domain ? "<b style=color:green>"+status.db_foward_domain+"</b>" : "<b style=color:red>"+"<%:Not Set%>"+"</b>";
dapo.innerHTML = status.db_foward_port ? "<b style=color:green>"+status.db_foward_port+"</b>" : "<b style=color:red>"+"<%:Not Set%>"+"</b>";
luci_protocol = (window.location.protocol == "http:" ? "ws://" : "wss://") + status.db_foward_domain + ":" + status.db_foward_port;
}
else {
daip.innerHTML = status.daip ? "<b style=color:green>"+status.daip+"</b>" : "<b style=color:red>"+"<%:Not Set%>"+"</b>";
dapo.innerHTML = status.cn_port ? "<b style=color:green>"+status.cn_port+"</b>" : "<b style=color:red>"+"<%:Not Set%>"+"</b>";
luci_protocol = (window.location.protocol == "http:" ? "ws://" : "wss://") + status.daip + ":" + status.cn_port;
};
if (status.clash && status.watchdog) {
radio_mode.style.display = "inline-block";
radio_de.style.display = "none";
}
else {
radio_mode.style.display = "none";
radio_de.style.display = "";
radio_de.innerHTML = "<b style=color:red><%:Not Running%></b>";
};
if (status.clash && status.watchdog) {
radio_ru_mode.style.display = "inline-block";
}
else {
radio_ru_mode.style.display = "none";
};
function ws_open() {
ws_t = new WebSocket(luci_protocol+"/traffic?token="+status.dase);
ws_c = new WebSocket(luci_protocol+"/connections?token="+status.dase);
ws_t.onmessage = ws_tmessage;
ws_c.onmessage = ws_cmessage;
ws_t.onerror = ws_terror;
ws_t.onopen = function (event) {
ws_connect = true;
ws_error = false;
};
};
if (status.watchdog && status.clash) {
if (!ws_connect) {
if (!ws_error) {
ws_open();
}
else if (ws_retry < 3)
{
ws_retry=ws_retry+1;
ws_open();
}
else
{
ws_terror();
};
};
}
else
{
ws_connect = false;
ws_error = false;
if (status.clash) {
ws_terror();
};
};
};
});
XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "startlog")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.startlog.match("level=fatal") || status.startlog.indexOf("FTL [Config]") != "-1" ) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "del_start_log")%>', null, function(x) {});
if ( status.startlog.match("level=fatal") ) {
alert('<%:OpenClash Start Failed%> :\n\n' + status.startlog.split('msg=')[1]);
}
else {
alert('<%:OpenClash Start Failed%> :\n\n' + status.startlog.split('FTL [Config] ')[1]);
};
}
else if ( status.startlog != "\n" && status.startlog != "" ) {
if ( status.startlog.match("Tip:") || status.startlog.match("提示:")) {
startlog.innerHTML = '<b style=color:#ff6f00>'+status.startlog+'</b>';
}
else if ( status.startlog.match("Error:") || status.startlog.match("错误:")) {
startlog.innerHTML = '<b style=color:#FF0000>'+status.startlog+'</b>';
}
else if ( status.startlog.match("Warning:") || status.startlog.match("警告:")) {
startlog.innerHTML = '<b style=color:#ff00bb>'+status.startlog+'</b>';
}
else if ( status.startlog.match("Watchdog:") || status.startlog.match("守护程序:")) {
startlog.innerHTML = '<b style=color:#b300ff>'+status.startlog+'</b>';
}
else {
startlog.innerHTML = '<b style=color:green>'+status.startlog+'</b>';
};
};
};
});
XHR.poll(6, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "startlog")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.startlog == "\n" || status.startlog == "" ) {
var rdmdl=Math.floor(Math.random()*16)+1;
if(rdmdl==1)
{
startlog.innerHTML = '<b><font><%:Tip: You can modify the profile on the profile page (for content that is not taken over)%></font></b>';
}
if(rdmdl==2)
{
startlog.innerHTML = '<b><font><%:Tip: click the version icon above to jump to the client publishing page%></font></b>';
}
if(rdmdl==3)
{
startlog.innerHTML = '<b><font><%:Tip: do not write configuration files? Try to create one click on the server page%></font></b>';
}
if(rdmdl==4)
{
startlog.innerHTML = '<b><font><%:Tip: some website are abnormal? Try switching modes or using third-party rules%></font></b>';
}
if(rdmdl==5)
{
startlog.innerHTML = '<b><font><%:Tip: using the fake IP mode can get a faster access experience%></font></b>';
}
if(rdmdl==6)
{
startlog.innerHTML = '<b><font><%:Tip: query DNS by TLS & TCP & HTTPS can get better anti pollution effect%></font></b>';
}
if(rdmdl==7)
{
startlog.innerHTML = '<b><font><%:Tip: openlash will check the configuration file parameters to ensure that it works properly%></font></b>';
}
if(rdmdl==8)
{
startlog.innerHTML = '<b><font><%:Tip: the nameserver group must have at least one server set when using custom DNS%></font></b>';
}
if(rdmdl==9)
{
startlog.innerHTML = '<b><font><%:Tip: the website access check shows the connection of the device currently logged in to the Luci page%></font></b>';
}
if(rdmdl==10)
{
startlog.innerHTML = '<b><font><%:Tip: after started, please wait patiently until the connection is normal%></font></b>';
}
if(rdmdl==11)
{
startlog.innerHTML = '<b><font><%:Tip: if you don not use IPv6, please turn off the DHCP service of IPv6, otherwise the connection will be abnormal%></font></b>';
}
if(rdmdl==12)
{
startlog.innerHTML = '<b><font><%:Tip: you can update the version in the global settings page%></font></b>';
}
if(rdmdl==13)
{
startlog.innerHTML = '<b><font><%:Note: It is not recommended to enable IPv6 and related services for routing. Most of the network connection problems reported so far are related to it%></font></b>';
}
if(rdmdl==14)
{
startlog.innerHTML = '<b><font><%:Note: Turning on secure DNS in the browser will cause abnormal shunting, please be careful to turn it off%></font></b>';
}
if(rdmdl==15)
{
startlog.innerHTML = '<b><font><%:Note: Some software will modify the device HOSTS, which will cause abnormal shunt, please pay attention to check%></font></b>';
}
if(rdmdl==16)
{
startlog.innerHTML = '<b><font><%:Note: The default proxy routes local traffic, BT, PT download, etc., please use redir mode as much as possible and pay attention to traffic avoidance%></font></b>';
}
}
}
});
get_rule_mode();
get_run_mode();
state_get();
clashversion_check();
function get_rule_mode() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "rule_mode")%>', null, function(x, status) {
if (x && x.status == 200 && status.mode != "") {
if (status.core_type == "TUN" && radio.length != 4) {
script_radio = document.createElement("input")
script_radio.setAttribute("type", "radio");
script_radio.setAttribute("id", "script");
script_radio.setAttribute("name", "radios");
script_radio.setAttribute("value", "script");
script_radio.setAttribute("onclick", "javascript:return switch_rule_mode(this.value);");
script_radio_label = document.createElement("label")
script_radio_label.setAttribute("for", "script");
script_radio_label.innerHTML = "Script";
radio_mode.appendChild(script_radio);
radio_mode.appendChild(script_radio_label);
}
else if (status.core_type != "TUN" && radio.length == 4) {
radio_mode.removeChild(script_radio)
radio_mode.removeChild(script_radio_label)
}
for (i=0; i<radio.length; i++) {
if (radio[i].value == status.mode && ! radio[i].checked) {
radio[i].checked = true;
break
}
}
}
});
s = setTimeout("get_rule_mode()",5000);
};
function switch_rule_mode(value)
{
clearTimeout(s);
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "switch_rule_mode")%>', {rule_mode: value}, function(x, status) {
if (x && x.status == 200) {
alert(' <%:Proxy Mode%>: ' + value + ' <%:switching succeeded!%>');
get_rule_mode();
}
else {
alert(' <%:Proxy Mode%>: ' + value + ' <%:switching failed!%>');
get_rule_mode();
}
});
};
function get_run_mode() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "get_run_mode")%>', null, function(x, status) {
if (x && x.status == 200 && status.mode) {
if (status.mode == "fake-ip" || status.mode == "fake-ip-tun" || status.mode == "fake-ip-mix")
{
mode.innerHTML = status.clash && status.watchdog ? "<b style=color:green><%:Fake-IP%></b>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" : '<b style=color:red><%:Not Running%></b>&nbsp;&nbsp;&nbsp;';
radio_run_normal.innerHTML = "<%:Enhance%>"
}
else if (status.mode == "redir-host" || status.mode == "redir-host-tun" || status.mode == "redir-host-mix")
{
mode.innerHTML = status.clash && status.watchdog ? "<b style=color:green><%:Redir-Host%></b>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" : '<b style=color:red><%:Not Running%></b>&nbsp;&nbsp;&nbsp;';
radio_run_normal.innerHTML = "<%:Compatible%>"
};
for (i=0; i<radio_ru.length; i++) {
if (radio_ru[i].value == (status["mode"].split("-")[2] == undefined ? "" : ("-" + status["mode"].split("-")[2])) && ! radio_ru[i].checked) {
radio_ru[i].checked = true;
}
};
};
});
gr = setTimeout("get_run_mode()",2000);
};
function switch_run_mode(value)
{
var r = confirm("<%:Are you sure want to switch the running mode?%>")
if (r == true) {
clearTimeout(gr);
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "switch_run_mode")%>', {run_mode: value}, function(x, status) {
if (x && x.status == 200) {
get_run_mode();
}
else {
get_run_mode();
}
});
}
};
function state_get() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "state")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
ipdb.innerHTML = status.ipdb ? "<b style=color:green>"+status.ipdb+"</b>" : "<b style=color:red>"+"<%:File Not Exist%>"+"</b>";
geosite.innerHTML = status.geosite ? "<b style=color:green>"+status.geosite+"</b>" : "<b style=color:red>"+"<%:File Not Exist%>"+"</b>";
lhie1.innerHTML = status.lhie1 ? "<b style=color:green>"+status.lhie1+"</b>" : "<b style=color:red>"+"<%:File Not Exist%>"+"</b>";
ConnersHua.innerHTML = status.ConnersHua ? "<b style=color:green>"+status.ConnersHua+"</b>" : "<b style=color:red>"+"<%:File Not Exist%>"+"</b>";
ConnersHua_return.innerHTML = status.ConnersHua_return ? "<b style=color:green>"+status.ConnersHua_return+"</b>" : "<b style=color:red>"+"<%:File Not Exist%>"+"</b>";
chnroute.innerHTML = status.chnroute ? "<b style=color:green>"+status.chnroute+"</b>" : "<b style=color:red>"+"<%:File Not Exist%>"+"</b>";
chnroutev6.innerHTML = status.chnroutev6 ? "<b style=color:green>"+status.chnroutev6+"</b>" : "<b style=color:red>"+"<%:File Not Exist%>"+"</b>";
if ( status.historychecktime != "0" ) {
historychecktime.innerHTML = "<b style=color:green>"+status.historychecktime+"</b>";
}
else {
historychecktime.innerHTML = "<b style=color:green>"+"<%:No Backup%>"+"</b>";
}
}
});
};
function hid_btn_action() {
if (hid_btn_if) {
hid_1.style.display = "";
hid_2.style.display = "";
hid_3.style.display = "";
state.style.display = "block";
hid_btn_if = false;
clearInterval(state_refresh);
state_refresh=setInterval("state_get()",1000*2);
} else {
hid_1.style.display = "none";
hid_2.style.display = "none";
hid_3.style.display = "none";
state.style.display = "none";
hid_btn_if = true;
clearInterval(state_refresh);
}
};
function winOpen(url)
{
var winOpen = window.open(url);
if(winOpen == null || typeof(winOpen) == 'undefined'){
window.location.href=url;
}
};
function ws_terror() {
ws_error = true;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "toolbar_show")%>', null, function(x, status) {
if (x && x.status == 200 && x.responseText != "") {
document.getElementById("upload_").innerHTML = "<font style=\"color:green\">"+status.up+"</font>";
document.getElementById("download_").innerHTML = "<font style=\"color:green\">"+status.down+"</font>";
document.getElementById("uploadtotal_").innerHTML = "<font style=\"color:green\">"+status.up_total+"</font>";
document.getElementById("downloadtotal_").innerHTML = "<font style=\"color:green\">"+status.down_total+"</font>";
document.getElementById("mem_t").innerHTML = "<font style=\"color:green\">"+status.mem+"</font>";
document.getElementById("connect_t").innerHTML = "<font style=\"color:green\">"+status.connections+"</font>";
if (status.cpu <= 50) {
document.getElementById("cpu_t").innerHTML = "<font style=\"color:green\">"+status.cpu+" %</font>";
}
else if (status.cpu >= 50 && status.cpu <= 80) {
document.getElementById("cpu_t").innerHTML = "<font style=\"color:orange\">"+status.cpu+" %</font>";
}
else if (status.cpu <= 100) {
document.getElementById("cpu_t").innerHTML = "<font style=\"color:red\">"+status.cpu+" %</font>";
}
else {
document.getElementById("cpu_t").innerHTML = "<font style=\"color:green\">0 %</font>";
}
}
else {
document.getElementById("upload_").innerHTML = "<font style=\"color:green\">0 B/S</font>";
document.getElementById("download_").innerHTML = "<font style=\"color:green\">0 B/S</font>";
document.getElementById("uploadtotal_").innerHTML = "<font style=\"color:green\">0 KB</font>";
document.getElementById("downloadtotal_").innerHTML = "<font style=\"color:green\">0 KB</font>";
document.getElementById("mem_t").innerHTML = "<font style=\"color:green\">0 KB</font>";
document.getElementById("cpu_t").innerHTML = "<font style=\"color:green\">0 %</font>";
document.getElementById("connect_t").innerHTML = "<font style=\"color:green\">0</font>";
}
});
};
function show_sys() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "toolbar_show_sys")%>', null, function(x, status) {
if (x && x.status == 200 && x.responseText != "") {
document.getElementById("mem_t").innerHTML = "<font style=\"color:green\">"+status.mem+"</font>";
if (status.cpu <= 50) {
document.getElementById("cpu_t").innerHTML = "<font style=\"color:green\">"+status.cpu+" %</font>";
}
else if (status.cpu >= 50 && status.cpu <= 80) {
document.getElementById("cpu_t").innerHTML = "<font style=\"color:orange\">"+status.cpu+" %</font>";
}
else if (status.cpu <= 100) {
document.getElementById("cpu_t").innerHTML = "<font style=\"color:red\">"+status.cpu+" %</font>";
}
else {
document.getElementById("cpu_t").innerHTML = "<font style=\"color:green\">0 %</font>";
}
}
else {
document.getElementById("mem_t").innerHTML = "<font style=\"color:green\">0 KB</font>";
document.getElementById("cpu_t").innerHTML = "<font style=\"color:green\">0 %</font>";
}
});
};
function ws_tmessage(event) {
var data = JSON.parse(event.data)
document.getElementById("upload_").innerHTML = "<font style=\"color:green\">"+bytesToSize(data.up)+"/S</font>";
document.getElementById("download_").innerHTML = "<font style=\"color:green\">"+bytesToSize(data.down)+"/S</font>";
};
function ws_cmessage(event) {
var data = JSON.parse(event.data)
document.getElementById("uploadtotal_").innerHTML = "<font style=\"color:green\">"+bytesToSize(data.uploadTotal)+"</font>";
document.getElementById("downloadtotal_").innerHTML = "<font style=\"color:green\">"+bytesToSize(data.downloadTotal)+"</font>";
document.getElementById("connect_t").innerHTML = "<font style=\"color:green\">"+Object.keys(data.connections).length+"</font>";
show_sys();
};
function bytesToSize(bytes) {
var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0 B';
var i = Math.floor(Math.log(bytes) / Math.log(1024));
return i == 0 ? (bytes / Math.pow(1024, i)) + ' ' + sizes[i] : (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
};
function all_one_key_update(btn)
{
btn.value = '<%:Check All Components Update%>';
btn.disabled = true;
var r = confirm("<%:Check and update all Cores and plug-ins?%>")
if (r == true) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update_check")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.corever != "0" ) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update")%>', null, function(x, status) {
if ( x && x.status != 200 ) {
alert('<%:Check failed, Please try again later!%>')
}
});
}
else {
alert('<%:No compiled version is selected. Please configure it in the General Settings tab!%>')
}
}
else {
alert('<%:Check failed, Please try again later!%>')
}
});
}
else {
}
btn.disabled = false;
return false;
};
function b_update_other_rules(btn)
{
btn.disabled = true;
btn.value = '<%:Checking...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_other_rules")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:Check Third Party Rules Update%>';
}
else {
btn.disabled = false;
btn.value = '<%:Check Third Party Rules Update%>';
}
return false;
});
};
function b_update_geoip(btn)
{
btn.disabled = true;
btn.value = '<%:Checking...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_geoip")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:Check GEOIP Data Update%>';
}
else {
btn.disabled = false;
btn.value = '<%:Check GEOIP Data Update%>';
}
return false;
});
};
function b_update_geosite(btn)
{
btn.disabled = true;
btn.value = '<%:Checking...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_geosite")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:Check GeoSite Data Update%>';
}
else {
btn.disabled = false;
btn.value = '<%:Check GeoSite Data Update%>';
}
return false;
});
};
function b_flush_fakeip_cache(btn)
{
btn.disabled = true;
btn.value = '<%:Flushing...%> ';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash","flush_fakeip_cache")%>',
null,
function(x,status)
{
if ( x && x.status == 200 ) {
if(status.flush_status == "0" || status.flush_status != "")
{
btn.value = '<%:Flush Failed%>';
}
else
{
btn.value = '<%:Flush Successful%>';
}
}
else {
btn.value = '<%:Flush Timeout%>';
}
}
);
btn.disabled = false;
return false;
};
function b_update_subscribe(btn)
{
btn.disabled = true;
btn.value = '<%:Checking...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_subscribe")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:Check Config Update%>';
}
else {
btn.disabled = false;
btn.value = '<%:Check Config Update%>';
}
return false;
});
};
function b_reload_firewall(btn)
{
btn.disabled = true;
btn.value = '<%:Reloading...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "reload_firewall")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:Reload Firewall Rules%>';
}
else {
btn.disabled = false;
btn.value = '<%:Firewall Rules Reset Failed%>';
}
return false;
});
};
function b_close_all_connection(btn)
{
btn.disabled = true;
btn.value = '<%:Reloading...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "close_all_connection")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:Close All Connections%>';
}
else {
btn.disabled = false;
btn.value = '<%:Close All Connections Failed%>';
}
return false;
});
};
function ycad_dashboard(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Open Panel%>';
if (status.daip && window.location.hostname == status.daip) {
url1='<%="http://'+window.location.hostname+':'+status.cn_port+'/ui/yacd/?hostname='+ window.location.hostname + '&port=' + status.cn_port + '&secret=' + status.dase +'"%>';
}
else if (status.daip && window.location.hostname != status.daip && status.db_foward_domain && status.db_foward_port) {
var ui_proto = status.db_forward_ssl == 0 ? 'http://' : 'https://';
url1='<%="'+ui_proto+status.db_foward_domain+':'+status.db_foward_port+'/ui/yacd/?hostname='+ status.db_foward_domain + '&port=' + status.db_foward_port + '&secret=' + status.dase +'"%>';
}
else {
url1='<%="http://'+window.location.hostname+':'+status.cn_port+'/ui/yacd/"%>';
}
winOpen(url1);
return false;
});
};
function net_dashboard(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Open Panel%>';
if (status.daip && window.location.hostname == status.daip) {
url2='<%="http://'+window.location.hostname+':'+status.cn_port+'/ui/dashboard/#/?host='+ window.location.hostname + '&port=' + status.cn_port + '&secret=' + status.dase +'"%>';
}
else if (status.daip && window.location.hostname != status.daip && status.db_foward_domain && status.db_foward_port) {
var ui_proto = status.db_forward_ssl == 0 ? 'http://' : 'https://';
url2='<%="'+ui_proto+status.db_foward_domain+':'+status.db_foward_port+'/ui/dashboard/#/?host='+ status.db_foward_domain + '&port=' + status.db_foward_port + '&secret=' + status.dase +'"%>';
}
else {
url2='<%="http://'+window.location.hostname+':'+status.cn_port+'/ui/dashboard/"%>';
}
winOpen(url2);
return false;
});
};
function homepage()
{
url3='https://github.com/vernesong/OpenClash';
winOpen(url3);
};
function gitbookpage()
{
url8='https://lancellc.gitbook.io/clash';
winOpen(url8);
};
function wikipage()
{
url5='https://github.com/vernesong/OpenClash/wiki';
winOpen(url5);
};
function telegrampage()
{
url6='https://t.me/ctcgfw_openwrt_discuss';
winOpen(url6);
};
function sponsorpage()
{
url7='https://ko-fi.com/vernesong';
winOpen(url7);
};
function logo_check(imgobj,imgSrc,imgNewSrc)
{
var newimg = new Image();
newimg.src = imgNewSrc;
newimg.onload = function() {
imgobj.src = imgNewSrc;
imgobj.onload = function() {};
};
newimg.onerror = function() {
imgobj.onload = function() {};
imgerrorfuns(imgobj,imgSrc);
};
};
function clashversion_check()
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "lastversion")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.lastversion != "" )
{
clashversion.innerHTML = '<img id="lastver" src="'+status.lastversion+'" alt="lastversion" onerror="return clashversion_error()" onclick="return go_update()">';
}
}
});
};
function clashversion_error()
{
clashversion.innerHTML = '<img id="clashversion" src="/luci-static/resources/openclash/img/version.svg?<%=random%>" alt="currentversion" height="21px" onerror="return imgerrorfuns(this,\'https://ftp.jaist.ac.jp/pub/sourceforge.jp/storage/g/o/op/openclash/<%=RELEASE_BRANCH%>/img/version.png\')" onclick="return go_update()">';
};
function logo_error(imgobj,imgSrc)
{
imgobj.src=imgSrc;
};
function imgerrorfuns(imgobj,imgSrc){
setTimeout(function(){
imgobj.src=imgSrc;
},1000*10);
};
function go_update()
{
url4='https://github.com/vernesong/OpenClash/releases';
winOpen(url4);
};
//]]></script>

View File

@ -0,0 +1,150 @@
<%+cbi/valueheader%>
<style>
.sub_tab{
display: inline-block;
white-space: nowrap;
font-size: 12px;
margin: 0 auto;
opacity: 0;
vertical-align: middle;
}
.sub_tab_show{
display: inline-block;
white-space: nowrap;
color: var(--gray-dark);
font-size: 12px;
margin: 0 auto;
-webkit-transition: all 1.5s;
-moz-transition: all 1.5s;
-ms-transition: all 1.5s;
-o-transition: all 1.5s;
transition: all 1s;
opacity: 1;
vertical-align: middle;
}
.sub_setting{
display: inline-block;
white-space: nowrap;
margin: 0 auto;
opacity: 1;
vertical-align: middle;
}
.sub_div{
white-space: nowrap;
}
</style>
<%
local fs = require "luci.openclash"
local val = self:cfgvalue(section)
local filename = fs.filename(val)
local idname = math.random(1000)..(string.match(filename, "[%w_]+") or "")
%>
<div class="sub_div"><span id='<%=idname%>' class="sub_tab"></span>&nbsp;&nbsp;&nbsp;<span class="sub_setting"><img src='/luci-static/resources/openclash/img/arrow-clockwise-light.svg' height="20px" title='<%:Refresh%>' alt='<%:Refresh%>' onclick='return sub_info_refresh_<%=idname%>(this)'></span>&nbsp;<span class="sub_setting"><img src='/luci-static/resources/openclash/img/wrench-light.svg' height="20px" title='<%:Specify URL%>' alt='<%:Specify URL%>' onclick='return set_subinfo_url_<%=idname%>(this,"<%=filename%>")'></span></div>
<script type="text/javascript">//<![CDATA[
var retry_<%=idname%> = 0;
var s_<%=idname%>;
sub_info_get_<%=idname%>();
function progressbar_<%=idname%>(v, m, pc, np, f, t, tr) {
return String.format(
'<div style="width:250px; max-width:500px; position:relative; border:1px solid #999999; border-radius: 6px">' +
(pc >= 50 ? '<div style="background-color:#9edd9e; width:%d%%; height:36px; border-radius: 6px">' : (pc < 50 && pc >= 20 ? '<div style="background-color:#ffc99f; width:%d%%; height:35px">' : '<div style="background-color:#ffb9b9; width:%d%%; height:35px">')) +
'<div style="position:absolute; left:0;' + (tr == "null" ? 'top:12px;' : 'top:0;') + 'text-align:center; width:100%%">' +
'<small>%s '+ (f ? f : '/') +' %s ' + (np ? "" : '(%s%%)') + (tr == "null" ? '<div style="visibility: hidden;">' : '<div style="visibility: visible;">') + '%s (<%:Remaining%> %s <%:days%>)</small>' +
'</div>' +
'</div>' +
'</div>', pc, v, m, pc, t, tr
);
};
function sub_info_refresh_<%=idname%>()
{
if (s_<%=idname%>) { clearTimeout(s_<%=idname%>);};
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "sub_info_get")%>', {filename: "<%=filename%>"}, function(x, status) {
if (x && x.status == 200 && status.sub_info != "" && status.sub_info != "No Sub Info Found") {
retry_<%=idname%> = 0;
localStorage.setItem("<%=filename%>",JSON.stringify(status));
document.getElementById('<%=idname%>').className = "sub_tab_show";
document.getElementById('<%=idname%>').innerHTML = progressbar_<%=idname%>((status.used), (status.total), (status.percent), false, false, (status.expire), (status.day_left));
//document.getElementById('<%=idname%>').innerHTML = "<%:Plan Traffic%>" + ": " + "<span style=color:green>" + status.used + "</span> | <span style=color:green>" + status.total + "</span> <br/> <%:Plan Expiration Time%>: " + "<span style=color:green>" + status.expire + "</span>";
}
else if ( x && x.status == 200 && status.sub_info == "No Sub Info Found" ) {
retry_<%=idname%> = 0;
localStorage.setItem("<%=filename%>",JSON.stringify(status));
document.getElementById('<%=idname%>').className = "sub_tab_show";
document.getElementById('<%=idname%>').innerHTML = "<span><%:No Sub Info Found%></span>";
}
else {
if (document.getElementById('<%=idname%>').innerHTML == "" || retry_<%=idname%> > 2) {
document.getElementById('<%=idname%>').className = "sub_tab_show";
document.getElementById('<%=idname%>').innerHTML = "<span style=color:red><%:Sub Info Get Error%></span>";
}
if (retry_<%=idname%> > 2) {
retry_<%=idname%> = 0;
localStorage.removeItem("<%=filename%>");
}
else {
retry_<%=idname%> ++;
s_<%=idname%> = setTimeout("sub_info_refresh_<%=idname%>()",1000*120);
return
}
};
s_<%=idname%> = setTimeout("sub_info_refresh_<%=idname%>()",1000*1800);
});
};
function sub_info_get_<%=idname%>()
{
if (localStorage.getItem("<%=filename%>")) {
var save_info = JSON.parse(localStorage.getItem("<%=filename%>"));
document.getElementById('<%=idname%>').className = "sub_tab_show";
if (save_info.sub_info == "No Sub Info Found") {
document.getElementById('<%=idname%>').innerHTML = "<span><%:No Sub Info Found%></span>";
}
else {
//document.getElementById('<%=idname%>').innerHTML = "<%:Plan Traffic%>" + ": " + "<span style=color:green>" + save_info.used + "</span> | <span style=color:green>" + save_info.total + "</span> <br/> <%:Plan Expiration Time%>: " + "<span style=color:green>" + save_info.expire + "</span>";
document.getElementById('<%=idname%>').innerHTML = progressbar_<%=idname%>((save_info.used), (save_info.total), (save_info.percent ? save_info.percent : 0), false, false, (save_info.expire), (save_info.day_left ? save_info.day_left : 0));
}
}
else {
sub_info_refresh_<%=idname%>();
};
s_<%=idname%> = setTimeout("sub_info_refresh_<%=idname%>()",1000*30);
};
function set_subinfo_url_<%=idname%>(btn, filename) {
var new_url = prompt("<%:Paste the new url of subscribe infos sources here:%>", "");
if (filename == null || filename == "") {
return false;
}
if (new_url == null) {
return false;
}
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "set_subinfo_url")%>', {filename: filename, url: new_url}, function(x, status) {
if (x && x.status == 200 && status.info == "Success")
{
sub_info_refresh_<%=idname%>();
alert("<%:Specify subscribe infos sources url successfully!%>");
}
else if (x && x.status == 200 && status.info == "Delete success")
{
sub_info_refresh_<%=idname%>();
alert("<%:Delete Specify Subscribe infos sources url successfully!%>");
}
else
{
alert("<%:Specify subscribe infos sources url failed:%>\n" + status.info);
}
});
};
//]]></script>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,70 @@
<%+cbi/valueheader%>
<div class="cbi-value-field" id="switch_dashboard_<%=self.option%>">
<%:Collecting data...%>
</div>
<script type="text/javascript">//<![CDATA[
var btn_type_<%=self.option%> = "<%=self.option%>";
var switch_dashboard_<%=self.option%> = document.getElementById('switch_dashboard_<%=self.option%>');
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "dashboard_type")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( btn_type_<%=self.option%> == "Dashboard" ) {
if ( status.dashboard_type == "Meta" ) {
switch_dashboard_<%=self.option%>.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch To Official Version%>" onclick="return switch_dashboard(this, btn_type_<%=self.option%>, \'Official\')"/>';
}
else {
switch_dashboard_<%=self.option%>.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch To Meta Version%>" onclick="return switch_dashboard(this, btn_type_<%=self.option%>, \'Meta\')"/>';
}
}
if ( btn_type_<%=self.option%> == "Yacd" ) {
if ( status.yacd_type == "Meta" ) {
switch_dashboard_<%=self.option%>.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch To Official Version%>" onclick="return switch_dashboard(this, btn_type_<%=self.option%>, \'Official\')"/>';
}
else {
switch_dashboard_<%=self.option%>.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch To Meta Version%>" onclick="return switch_dashboard(this, btn_type_<%=self.option%>, \'Meta\')"/>';
}
}
}
});
function switch_dashboard(btn, name, type)
{
btn.disabled = true;
btn.value = '<%:Downloading File...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "switch_dashboard")%>', {name: name, type : type}, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.download_state == "1" ) {
if ( type == "Meta" ) {
if ( name == "Dashboard" ) {
document.getElementById("switch_dashboard_"+name).innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch Successful%> - <%:Switch To Official Version%>" onclick="return switch_dashboard(this, \'Dashboard\', \'Official\')"/>';
}
else
{
document.getElementById("switch_dashboard_"+name).innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch Successful%> - <%:Switch To Official Version%>" onclick="return switch_dashboard(this, \'Yacd\', \'Official\')"/>';
}
}
else {
if ( name == "Dashboard" ) {
document.getElementById("switch_dashboard_"+name).innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch Successful%> - <%:Switch To Meta Version%>" onclick="return switch_dashboard(this, \'Dashboard\', \'Meta\')"/>';
}
else
{
document.getElementById("switch_dashboard_"+name).innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch Successful%> - <%:Switch To Meta Version%>" onclick="return switch_dashboard(this, \'Yacd\', \'Meta\')"/>';
}
}
}
else if ( status.download_state == "2" ) {
btn.value = '<%:Unzip Error%>';
}
else {
btn.value = '<%:Switch Failed%>';
}
}
});
btn.disabled = false;
return false;
}
//]]></script>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,45 @@
<fieldset class="cbi-section">
<table width="100%">
<tr><td width="100%" colspan="4">
<p align="center" id="switch_mode">
<%:Collecting data...%>
</p>
</td></tr>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
var switch_mode = document.getElementById('switch_mode');
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "op_mode")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.op_mode == "redir-host" ) {
switch_mode.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch page to Fake-IP mode%>" onclick="return switch_modes(this)"/>';
}
else {
switch_mode.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch page to Redir-Host mode%>" onclick="return switch_modes(this)"/>';
}
}
});
function switch_modes(btn)
{
btn.disabled = true;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "switch_mode")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.switch_mode == "redir-host" ) {
alert('<%:Page has been switched to Fake-IP mode!%>')
window.location.href='<%="settings"%>';
}
else {
alert('<%:Page has been switched to Redir-Host mode!%>')
window.location.href='<%="settings"%>';
}
}
});
btn.disabled = false;
return false;
}
//]]></script>

View File

@ -0,0 +1,375 @@
<%-
local rowcnt = 1
local uci = require("luci.model.uci").cursor()
local fs = require "luci.openclash"
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
end
function width(o)
if o.width then
if type(o.width) == 'number' then
return ' style="width:%dpx"' % o.width
end
return ' style="width:%s"' % o.width
end
return ''
end
function table_include(table, value)
if table == nil then
return false
end
for k, v in pairs(table) do
if v == value then
return true
end
end
return false
end
local head_width
local a={}
local e={}
for t,o in ipairs(fs.glob("/etc/openclash/config/*"))do
a=fs.stat(o)
if a then
e[t]={}
e[t].name=fs.basename(o)
end
end
if not table_include(e, "all") then
table.insert(e, 1, {name="all"})
end
if #e > 4 then
head_width = (95 / #e).."%"
else
head_width = "120px"
end
local cfg_name
if uci:get("openclash", "config", "config_path") then
cfg_name = fs.basename(uci:get("openclash", "config", "config_path"))
end
local sectiontype = "_"..self.config.."_"..string.match(self.sectiontype, "[%w_]+") or "self.sectiontype"
-%>
<style type="text/css">
*{margin: 0;padding: 0;}
ul{
list-style: none;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%>{
min-height: 35px;
text-align: center;
position: relative;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul{
left: -1px;
width: 100%;
padding: unset !important;
margin: unset !important;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul li{
float: left;
width: <%=head_width%>;
line-height: 35px;
padding: 0 1px;
border-right: 1px solid #dddddd;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul li a{
float: unset !important;
padding: unset !important;
vertical-align: middle;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul li.cbi-tab > a{
font-weight: bolder;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul li a:hover{
color: orangered;
}
#tab-content .dom-<%=self.config%>-<%=self.sectiontype%>{
display: none;
}
#tab-content .dom-<%=self.config%>-<%=self.sectiontype%> ul li{
float: left;
margin: 15px 10px;
width: 225px;
}
</style>
<!-- tblsection -->
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<%- if self.sortable then -%>
<input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
<%- end -%>
<div class="cbi-section-descr"><%=self.description%></div>
<%- local count = 0 -%>
<div id="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tabmenu">
<ul class="cbi-tabmenu">
<%-
if #e ~= 1 then
for t,o in ipairs(e)do
if o.name == cfg_name and cfg_name then
-%>
<li name="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tab"><a><%=o.name%></a></li>
<%- elseif not cfg_name and o.name == "all" then -%>
<li name="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tab"><a>ALL</a></li>
<%- elseif o.name == "all" then -%>
<li name="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tab-disabled"><a>ALL</a></li>
<%- else -%>
<li name="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tab-disabled"><a><%=o.name%></a></li>
<%- end -%>
<%- end -%>
<%- else -%>
<li name="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tab"><a>ALL</a></li>
<%- end -%>
</ul>
</div>
<div id="tab-content">
<%- for t,o in ipairs(e)do
if #e ~= 1 and o.name == cfg_name and cfg_name then
-%>
<div class="dom-<%=self.config%>-<%=self.sectiontype%>" style="display: block;">
<%- elseif #e ~= 1 and o.name == "all" and not cfg_name then -%>
<div class="dom-<%=self.config%>-<%=self.sectiontype%>" style="display: block;">
<%- elseif #e == 1 then -%>
<div class="dom-<%=self.config%>-<%=self.sectiontype%>" style="display: block;">
<%- else -%>
<div class="dom-<%=self.config%>-<%=self.sectiontype%>">
<%- end -%>
<table class="cbi-section-table">
<tr class="cbi-section-table-titles">
<%- if not self.anonymous then -%>
<%- if self.sectionhead then -%>
<th class="cbi-section-table-cell"><%=self.sectionhead%></th>
<%- else -%>
<th>&#160;</th>
<%- end -%>
<%- end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<%- if i == 1 then -%>
<th class="cbi-section-table-cell"><%:Serial Number%></th>
<%- end -%>
<th class="cbi-section-table-cell"<%=width(k)%>>
<%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
<%-=k.title-%>
<%- if k.titleref then -%></a><%- end -%>
</th>
<%- count = count + 1; end; end; if self.sortable then -%>
<th class="cbi-section-table-cell"><%:Sort%></th>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell">&#160;</th>
<%- count = count + 1; end -%>
</tr>
<tr class="cbi-section-table-descr">
<%- if not self.anonymous then -%>
<%- if self.sectiondesc then -%>
<th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
<%- else -%>
<th></th>
<%- end -%>
<%- end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<th class="cbi-section-table-cell"<%=width(k)%>><%=k.description%></th>
<%- end; end; if self.sortable then -%>
<th class="cbi-section-table-cell"></th>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell"></th>
<%- end -%>
</tr>
<%- local isempty = true
local num = 1
for i, k in ipairs(self:cfgsections()) do
section = k
while true do
if not uci:get("openclash", section, "config") then
uci:set("openclash", section, "config", "all")
uci:save("openclash")
end
if uci:get("openclash", section, "config") ~= o.name then
break
end
isempty = false
scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
-%>
<tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
<% if not self.anonymous then -%>
<th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
<%- end %>
<td class="cbi-section-table-cell">
<p><%=num%></p>
<% num = num + 1 -%>
</td>
<%-
for k, node in ipairs(self.children) do
if not node.optional then
node:render(section, scope or {})
end
end
-%>
<%- if self.sortable then -%>
<td class="cbi-section-table-cell">
<input class="cbi-button cbi-button-up" type="button" value="<%:∧%>" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move up%>" title="<%:Move up%>" />
<input class="cbi-button cbi-button-down" type="button" value="<%:%>" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move down%>" title="<%:Move down%>" />
</td>
<%- end -%>
<%- if self.extedit or self.addremove then -%>
<td class="cbi-section-table-cell">
<%- if self.extedit then -%>
<input class="btn cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
<%- if type(self.extedit) == "string" then
%> onclick="location.href='<%=self.extedit:format(section)%>';return switch_to_tab<%=sectiontype%>()"
<%- elseif type(self.extedit) == "function" then
%> onclick="location.href='<%=self:extedit(section)%>';return switch_to_tab<%=sectiontype%>()"
<%- end
%> alt="<%:Edit%>" title="<%:Edit%>" />
<%- end; if self.addremove then %>
<input class="btn cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return switch_to_tab<%=sectiontype%>()" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
<%- end -%>
</td>
<%- end -%>
<%-
break
end
-%>
</tr>
<%- end -%>
<%- if isempty then -%>
<tr class="cbi-section-table-row">
<td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
</tr>
<%- end -%>
</table>
<% if self.error then %>
<div class="cbi-section-error">
<ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
<li><%=pcdata(e):gsub("\n","<br />")%></li>
<%- end end %></ul>
</div>
<% end %>
<%- if self.addremove then -%>
<% if self.template_addremove then include(self.template_addremove) else -%>
<div class="cbi-section-create cbi-tblsection-create">
<% if self.anonymous then %>
<input class="btn cbi-button cbi-button-add" type="submit" onclick="return switch_to_tab<%=sectiontype%>('create')" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
<% else %>
<% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
<input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" />
<input class="btn cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
<% if self.invalid_cts then -%>
<br /><%:Invalid%></div>
<%- end %>
<% end %>
</div>
<%- end %>
<%- end -%>
</div>
<%- end -%>
</div>
</fieldset>
<!-- /tblsection -->
<script type="text/javascript">//<![CDATA[
window.addEventListener('load', onload<%=sectiontype%>, false);
var titles<%=sectiontype%> = document.getElementsByName('tab-header-<%=self.config%>-<%=self.sectiontype%>');
var divs<%=sectiontype%> = document.getElementsByClassName('dom-<%=self.config%>-<%=self.sectiontype%>');
function switch_to_tab<%=sectiontype%>(type){
if(titles<%=sectiontype%>.length != divs<%=sectiontype%>.length) return;
if ( type == 'create' ) {
for(var j=0; j < titles<%=sectiontype%>.length; j++){
titles<%=sectiontype%>[j].className = 'cbi-tab-disabled';
divs<%=sectiontype%>[j].style.display = 'none';
};
titles<%=sectiontype%>[0].className = 'cbi-tab';
divs<%=sectiontype%>[0].style.display = 'block';
localStorage.setItem("titles<%=sectiontype%>",0);
};
localStorage.setItem("id<%=sectiontype%>",'cbi-<%=self.config%>-<%=self.sectiontype%>');
return true;
};
function onload<%=sectiontype%>() {
if(titles<%=sectiontype%>.length != divs<%=sectiontype%>.length) return;
if (localStorage.getItem("id<%=sectiontype%>")) {
if (document.getElementById(localStorage.getItem("id<%=sectiontype%>"))) {
document.getElementById(localStorage.getItem("id<%=sectiontype%>")).scrollIntoView();
};
localStorage.removeItem("id<%=sectiontype%>");
};
if (localStorage.getItem("titles<%=sectiontype%>")) {
if (titles<%=sectiontype%>[localStorage.getItem("titles<%=sectiontype%>")]) {
for(var j=0; j < titles<%=sectiontype%>.length; j++){
titles<%=sectiontype%>[j].className = 'cbi-tab-disabled';
divs<%=sectiontype%>[j].style.display = 'none';
};
titles<%=sectiontype%>[localStorage.getItem("titles<%=sectiontype%>")].className = 'cbi-tab';
divs<%=sectiontype%>[localStorage.getItem("titles<%=sectiontype%>")].style.display = 'block';
};
localStorage.removeItem("titles<%=sectiontype%>");
};
for(var i=0; i < titles<%=sectiontype%>.length; i++){
var li<%=sectiontype%> = titles<%=sectiontype%>[i];
li<%=sectiontype%>.id = i;
li<%=sectiontype%>.onclick = function(){
for(var j=0; j < titles<%=sectiontype%>.length; j++){
titles<%=sectiontype%>[j].className = 'cbi-tab-disabled';
divs<%=sectiontype%>[j].style.display = 'none';
};
this.className = 'cbi-tab';
divs<%=sectiontype%>[this.id].style.display = 'block';
localStorage.setItem("titles<%=sectiontype%>",this.id);
};
li<%=sectiontype%>.onTouchStart = function(){
for(var j=0; j < titles<%=sectiontype%>.length; j++){
titles<%=sectiontype%>[j].className = 'cbi-tab-disabled';
divs<%=sectiontype%>[j].style.display = 'none';
};
this.className = 'cbi-tab';
divs<%=sectiontype%>[this.id].style.display = 'block';
localStorage.setItem("titles<%=sectiontype%>",this.id);
};
};
};
//]]>
</script>

View File

@ -0,0 +1,320 @@
<%-
local rowcnt = 1
local uci = require("luci.model.uci").cursor()
local fs = require "luci.openclash"
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
end
function width(o)
if o.width then
if type(o.width) == 'number' then
return ' style="width:%dpx"' % o.width
end
return ' style="width:%s"' % o.width
end
return ''
end
local head_width
local e={}
table.insert(e, {group="nameserver"})
table.insert(e, {group="fallback"})
table.insert(e, {group="default"})
local sectiontype = "_"..self.config.."_"..string.match(self.sectiontype, "[%w_]+") or "self.sectiontype"
-%>
<style type="text/css">
*{margin: 0;padding: 0;}
ul{
list-style: none;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%>{
min-height: 35px;
text-align: center;
position: relative;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul{
left: -1px;
width: 100%;
padding: unset !important;
margin: unset !important;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul li{
float: left;
width: 160px;
line-height: 35px;
padding: 0 1px;
border-right: 1px solid #dddddd;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul li a{
float: unset !important;
padding: unset !important;
vertical-align: middle;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul li.cbi-tab > a{
font-weight: bolder;
}
#tab-header-<%=self.config%>-<%=self.sectiontype%> ul li a:hover{
color: orangered;
}
#tab-content .dom-<%=self.config%>-<%=self.sectiontype%>{
display: none;
}
#tab-content .dom-<%=self.config%>-<%=self.sectiontype%> ul li{
float: left;
margin: 15px 10px;
width: 225px;
}
</style>
<!-- tblsection -->
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<%- if self.sortable then -%>
<input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
<%- end -%>
<div class="cbi-section-descr"><%=self.description%></div>
<%- local count = 0 -%>
<div id="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tabmenu">
<ul class="cbi-tabmenu">
<li name="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tab"><a>NameServer</a></li>
<li name="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tab-disabled"><a>FallBack</a></li>
<li name="tab-header-<%=self.config%>-<%=self.sectiontype%>" class="cbi-tab-disabled"><a>Default-NameServer</a></li>
</ul>
</div>
<div id="tab-content">
<%- for t,o in ipairs(e)do
if o.group == "nameserver" then
-%>
<div class="dom-<%=self.config%>-<%=self.sectiontype%>" style="display: block;">
<%- else -%>
<div class="dom-<%=self.config%>-<%=self.sectiontype%>">
<%- end -%>
<table class="cbi-section-table">
<tr class="cbi-section-table-titles">
<%- if not self.anonymous then -%>
<%- if self.sectionhead then -%>
<th class="cbi-section-table-cell"><%=self.sectionhead%></th>
<%- else -%>
<th>&#160;</th>
<%- end -%>
<%- end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<%- if i == 1 then -%>
<th class="cbi-section-table-cell"><%:Serial Number%></th>
<%- end -%>
<th class="cbi-section-table-cell"<%=width(k)%>>
<%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
<%-=k.title-%>
<%- if k.titleref then -%></a><%- end -%>
</th>
<%- count = count + 1; end; end; if self.sortable then -%>
<th class="cbi-section-table-cell"><%:Sort%></th>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell">&#160;</th>
<%- count = count + 1; end -%>
</tr>
<tr class="cbi-section-table-descr">
<%- if not self.anonymous then -%>
<%- if self.sectiondesc then -%>
<th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
<%- else -%>
<th></th>
<%- end -%>
<%- end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<th class="cbi-section-table-cell"<%=width(k)%>><%=k.description%></th>
<%- end; end; if self.sortable then -%>
<th class="cbi-section-table-cell"></th>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell"></th>
<%- end -%>
</tr>
<%- local isempty = true
local num = 1
for i, k in ipairs(self:cfgsections()) do
section = k
while true do
if uci:get("openclash", section, "group") ~= o.group then
break
end
isempty = false
scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
-%>
<tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
<% if not self.anonymous then -%>
<th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
<%- end %>
<td class="cbi-section-table-cell">
<p><%=num%></p>
<% num = num + 1 -%>
</td>
<%-
for k, node in ipairs(self.children) do
if not node.optional then
node:render(section, scope or {})
end
end
-%>
<%- if self.sortable then -%>
<td class="cbi-section-table-cell">
<input class="cbi-button cbi-button-up" type="button" value="<%:∧%>" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move up%>" title="<%:Move up%>" />
<input class="cbi-button cbi-button-down" type="button" value="<%:%>" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move down%>" title="<%:Move down%>" />
</td>
<%- end -%>
<%- if self.extedit or self.addremove then -%>
<td class="cbi-section-table-cell">
<%- if self.extedit then -%>
<input class="btn cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
<%- if type(self.extedit) == "string" then
%> onclick="location.href='<%=self.extedit:format(section)%>';return switch_to_tab<%=sectiontype%>()"
<%- elseif type(self.extedit) == "function" then
%> onclick="location.href='<%=self:extedit(section)%>';return switch_to_tab<%=sectiontype%>()"
<%- end
%> alt="<%:Edit%>" title="<%:Edit%>" />
<%- end; if self.addremove then %>
<input class="btn cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section';return switch_to_tab<%=sectiontype%>()" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
<%- end -%>
</td>
<%- end -%>
<%-
break
end
-%>
</tr>
<%- end -%>
<%- if isempty then -%>
<tr class="cbi-section-table-row">
<td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
</tr>
<%- end -%>
</table>
<% if self.error then %>
<div class="cbi-section-error">
<ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
<li><%=pcdata(e):gsub("\n","<br />")%></li>
<%- end end %></ul>
</div>
<% end %>
<%- if self.addremove then -%>
<% if self.template_addremove then include(self.template_addremove) else -%>
<div class="cbi-section-create cbi-tblsection-create">
<% if self.anonymous then %>
<input class="btn cbi-button cbi-button-add" type="submit" onclick="return switch_to_tab<%=sectiontype%>('create')" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
<% else %>
<% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
<input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" />
<input class="btn cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
<% if self.invalid_cts then -%>
<br /><%:Invalid%></div>
<%- end %>
<% end %>
</div>
<%- end %>
<%- end -%>
</div>
<%- end -%>
</div>
</fieldset>
<!-- /tblsection -->
<script type="text/javascript">//<![CDATA[
window.addEventListener('load', onload<%=sectiontype%>, false);
var titles<%=sectiontype%> = document.getElementsByName('tab-header-<%=self.config%>-<%=self.sectiontype%>');
var divs<%=sectiontype%> = document.getElementsByClassName('dom-<%=self.config%>-<%=self.sectiontype%>');
function switch_to_tab<%=sectiontype%>(type){
if(titles<%=sectiontype%>.length != divs<%=sectiontype%>.length) return;
if ( type == 'create' ) {
for(var j=0; j < titles<%=sectiontype%>.length; j++){
titles<%=sectiontype%>[j].className = 'cbi-tab-disabled';
divs<%=sectiontype%>[j].style.display = 'none';
};
titles<%=sectiontype%>[0].className = 'cbi-tab';
divs<%=sectiontype%>[0].style.display = 'block';
localStorage.setItem("titles<%=sectiontype%>",0);
};
localStorage.setItem("id<%=sectiontype%>",'cbi-<%=self.config%>-<%=self.sectiontype%>');
return true;
};
function onload<%=sectiontype%>() {
if(titles<%=sectiontype%>.length != divs<%=sectiontype%>.length) return;
if (localStorage.getItem("id<%=sectiontype%>")) {
if (document.getElementById(localStorage.getItem("id<%=sectiontype%>"))) {
document.getElementById(localStorage.getItem("id<%=sectiontype%>")).scrollIntoView();
};
localStorage.removeItem("id<%=sectiontype%>");
};
if (localStorage.getItem("titles<%=sectiontype%>")) {
if (titles<%=sectiontype%>[localStorage.getItem("titles<%=sectiontype%>")]) {
for(var j=0; j < titles<%=sectiontype%>.length; j++){
titles<%=sectiontype%>[j].className = 'cbi-tab-disabled';
divs<%=sectiontype%>[j].style.display = 'none';
};
titles<%=sectiontype%>[localStorage.getItem("titles<%=sectiontype%>")].className = 'cbi-tab';
divs<%=sectiontype%>[localStorage.getItem("titles<%=sectiontype%>")].style.display = 'block';
};
localStorage.removeItem("titles<%=sectiontype%>");
};
for(var i=0; i < titles<%=sectiontype%>.length; i++){
var li<%=sectiontype%> = titles<%=sectiontype%>[i];
li<%=sectiontype%>.id = i;
li<%=sectiontype%>.onclick = function(){
for(var j=0; j < titles<%=sectiontype%>.length; j++){
titles<%=sectiontype%>[j].className = 'cbi-tab-disabled';
divs<%=sectiontype%>[j].style.display = 'none';
};
this.className = 'cbi-tab';
divs<%=sectiontype%>[this.id].style.display = 'block';
localStorage.setItem("titles<%=sectiontype%>",this.id);
};
li<%=sectiontype%>.onTouchStart = function(){
for(var j=0; j < titles<%=sectiontype%>.length; j++){
titles<%=sectiontype%>[j].className = 'cbi-tab-disabled';
divs<%=sectiontype%>[j].style.display = 'none';
};
this.className = 'cbi-tab';
divs<%=sectiontype%>[this.id].style.display = 'block';
localStorage.setItem("titles<%=sectiontype%>",this.id);
};
};
};
//]]>
</script>

View File

@ -0,0 +1,173 @@
<head>
<style>
.tabs > li {
vertical-align: middle !important;;
}
.tool_label:hover {
border-color: rgba(0, 0, 0, 0) !important;;
background-color: unset !important;;
color: unset !important;;
cursor: unset !important;;
}
.tool_label::after {
border-color: rgba(0, 0, 0, 0) !important;;
background-color: unset !important;;
color: unset !important;;
cursor: unset !important;;
content: unset !important;;
}
.tool_label_span {
display: inline-block;
white-space: nowrap;
}
.tool_label_select {
width: auto;
}
</style>
</head>
<li id="tool_label" class="tool_label">
<span class="tool_label_span">
&nbsp;&nbsp;<%:Current Config File%>:&nbsp;
<select class="tool_label_select" id="cfg_name">
</select>&nbsp;&nbsp;
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Switch Config%>" onclick="return switch_config(this)" />
&nbsp;
</span>
</li>
<script type="text/javascript">//<![CDATA[
var config_name = document.getElementById('cfg_name');
var tool_label = document.getElementById('tool_label');
var Commit = document.getElementById('cbi-table-1-Commit');
var Apply = document.getElementById('cbi-table-1-Apply');
var Back = document.getElementById('cbi-table-1-Back');
var Load_Config = document.getElementById('cbi-table-1-Load_Config');
var Delete_Unused_Servers = document.getElementById('cbi-table-1-Delete_Unused_Servers');
var Delete_Servers = document.getElementById('cbi-table-1-Delete_Servers');
var Delete_Proxy_Provider = document.getElementById('cbi-table-1-Delete_Proxy_Provider');
var Delete_Groups = document.getElementById('cbi-table-1-Delete_Groups');
var rule_mg = document.getElementById('cbi-table-1-rule_mg');
var pro_mg = document.getElementById('cbi-table-1-pro_mg');
setTimeout("get_header()",100);
if (Commit) {
Commit.style.textAlign="center";
}
if (Apply) {
Apply.style.textAlign="center";
}
if (Back) {
Back.style.textAlign="center";
}
if (Load_Config) {
Load_Config.style.textAlign="center";
Delete_Unused_Servers.style.textAlign="center";
Delete_Servers.style.textAlign="center";
Delete_Proxy_Provider.style.textAlign="center";
Delete_Groups.style.textAlign="center";
}
if (rule_mg) {
rule_mg.style.textAlign="center";
pro_mg.style.textAlign="center";
}
if (tool_label.style.display != "none") {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "config_name")%>', null, function(x, status) {
if (x && x.status == 200 && status.config_name != "") {
for(var i in status.config_name){
config_name.options.add(new Option(status.config_name[i].name,status.config_name[i].name));
}
if (status.config_path != "") {
config_name.value = status.config_path;
}
else
{
config_name.options.add(new Option("<%:Not Select%>",""));
config_name.value = "";
}
}
else if (x && x.status == 200 && status.config_path != "") {
config_name.options.add(new Option(status.config_path,status.config_path));
config_name.value = status.config_path;
}
else {
tool_label.style.display = "none";
}
});
};
function get_header() {
var header = document.getElementsByClassName("tabmenu-item-log ")[0];
if (header) {
insertAfter(tool_label,header);
}
else {
setTimeout("get_header()",100);
}
}
function insertAfter(newElement, targetElement) {
var parent = targetElement.parentNode;
if (parent.lastChild == targetElement) {
parent.appendChild(newElement, targetElement);
}
else {
parent.insertBefore(newElement, targetElement.nextSibling);
};
};
function switch_config(btn)
{
if (config_name.value && config_name.value != "") {
btn.disabled = true;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "switch_config")%>', {config_name: config_name.value}, function(x, status) {
if (x && x.status == 200) {
btn.disabled = false;
alert(' <%:Config File%>: ' + config_name.value + ' <%:switching succeeded!%>')
window.location.href=location.pathname;
}
else {
alert(' <%:Config File%>: ' + config_name.value + ' <%:switching failed!%>')
}
});
return false;
}
}
function restore_config(btn)
{
btn.value = '<%:Restore Default Config%>';
btn.disabled = true;
var r = confirm("<%:Are you sure want to restore the default config?%>")
if (r == true) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "restore")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
alert('<%:Restore succeeded!%>')
window.location.href='<%="settings"%>';
}
else {
alert('<%:Restore failed!%>')
window.location.href='<%="settings"%>';
}
});
}
btn.disabled = false;
return false;
}
function winOpen(url)
{
var winOpen = window.open(url);
if(winOpen == null || typeof(winOpen) == 'undefined'){
window.location.href=url;
}
}
//]]></script>

View File

@ -0,0 +1,542 @@
<fieldset class="cbi-section">
<table width="100%">
<tr><td width="100%" colspan="4">
<p align="center" id="update_tip">
<b><%:Note: if the update fails, you can manually download and upload%></b>
</p>
</td></tr>
<tr><td width="25%"><%:Compiled Version Selected (Auto-save when you click to update or download)%></td>
<td width="25%" align="left"><select id="CORE_VERSION">
<option value="linux-386"><%:linux-386%></option>
<option value="linux-amd64"><%:linux-amd64(x86-64)%></option>
<option value="linux-amd64-v3"><%:linux-amd64-v3(x86-64)%></option>
<option value="linux-armv5"><%:linux-armv5%></option>
<option value="linux-armv6"><%:linux-armv6%></option>
<option value="linux-armv7"><%:linux-armv7%></option>
<option value="linux-arm64"><%:linux-arm64(armv8)%></option>
<option value="linux-mips-hardfloat"><%:linux-mips-hardfloat%></option>
<option value="linux-mips-softfloat"><%:linux-mips-softfloat%></option>
<option value="linux-mips64"><%:linux-mips64%></option>
<option value="linux-mips64le"><%:linux-mips64le%></option>
<option value="linux-mipsle-softfloat"><%:linux-mipsle-softfloat%></option>
<option value="linux-mipsle-hardfloat"><%:linux-mipsle-hardfloat%></option>
<option value="0"><%:Not Set%></option>
</select></td>
<td width="25%"><%:Release Branch Selected (Auto-save when you click to update or download)%></td>
<td width="25%" align="left"><select id="RELEASE_BRANCH">
<option value="master">Master</option>
<option value="dev">Developer</option>
</select></td>
</tr>
<tr>
<td width="25%"><%:CPU Architecture%></td><td width="25%" align="left" id="CPU_MODEL"><%:Collecting data...%></td>
<td width="25%"><%:Last Check Update%></td><td width="25%" align="left" id="CHECKTIME"><%:Collecting data...%></td>
</tr>
<tr><td width="100%" colspan="4">
<p align="center">
<b><%:Core path:%>/etc/openclash/core/clash</b>
</p>
</td></tr>
<tr><td width="25%">[Dev] <%:Current Core%></td><td width="25%" align="left" id="CORE_CV"><%:Collecting data...%></td><td width="25%">[Dev] <%:Latest Core%></td><td width="25%" align="left" id="CORE_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:Update Core%></td><td width="25%" align="left" id="core_up"><%:Collecting data...%></td><td width="25%"><%:Download Latest Core%></td><td width="25%" align="left" id="ma_core_up"><%:Collecting data...%></td></tr>
<tr><td width="100%" colspan="4">
<p align="center">
<b><%:Core path:%>/etc/openclash/core/clash_tun</b>
</p>
</td></tr>
<tr><td width="25%">[TUN] <%:Current Core%></td><td width="25%" align="left" id="CORE_TUN_CV"><%:Collecting data...%></td><td width="25%">[TUN] <%:Latest Core%></td><td width="25%" align="left" id="CORE_TUN_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:Update Core%></td><td width="25%" align="left" id="core_tun_up"><%:Collecting data...%></td><td width="25%"><%:Download Latest Core%></td><td width="25%" align="left" id="ma_core_tun_up"><%:Collecting data...%></td></tr>
<tr><td width="100%" colspan="4">
<p align="center">
<b><%:Core path:%>/etc/openclash/core/clash_meta</b>
</p>
</td></tr>
<tr><td width="25%">[Meta] <%:Current Core%></td><td width="25%" align="left" id="CORE_META_CV"><%:Collecting data...%></td><td width="25%">[Meta] <%:Latest Core%></td><td width="25%" align="left" id="CORE_META_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:Update Core%></td><td width="25%" align="left" id="core_meta_up"><%:Collecting data...%></td><td width="25%"><%:Download Latest Core%></td><td width="25%" align="left" id="ma_core_meta_up"><%:Collecting data...%></td></tr>
</table>
</fieldset>
<fieldset class="cbi-section">
<table width="100%">
<tr><td width="100%" colspan="4">
<p align="center">
<b><%:Client Update%></b>
</p>
</td></tr>
<tr><td width="25%"><%:Current Client%></td><td width="25%" align="left" id="OP_CV"><%:Collecting data...%></td><td width="25%"><%:Latest Client%></td><td width="25%" align="left" id="OP_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"><%:Update Client%></td><td width="25%" align="left" id="op_up"><%:Collecting data...%></td><td width="25%"><%:Download Latest Client%></td><td width="25%" align="left" id="ma_op_up"><%:Collecting data...%></td></tr>
</table>
</fieldset>
<fieldset class="cbi-section">
<table width="100%">
<tr>
<td width="25%">
<p align="center" id="restore">
<%:Collecting data...%>
</p>
</td>
<td width="25%">
<p align="center" id="remove_core">
<%:Collecting data...%>
</p>
</td>
<td width="25%">
<p align="center" id="one_key_update">
<%:Collecting data...%>
</p>
</td>
</tr>
</table>
</fieldset>
<fieldset class="cbi-section">
<table width="100%">
<tr><td width="100%" colspan="4">
<p align="center">
<b><%:Backup Section%></b>
</p>
</td></tr>
<tr>
<td width="25%">
<p align="center" id="backup">
<%:Collecting data...%>
</p>
</td>
<td width="25%">
<p align="center" id="backup_ex_core">
<%:Collecting data...%>
</p>
</td>
<td width="25%">
<p align="center" id="backup_core_only">
<%:Collecting data...%>
</p>
</td>
</tr>
<tr>
<td width="25%">
<p align="center" id="backup_config_only">
<%:Collecting data...%>
</p>
</td>
<td width="25%">
<p align="center" id="backup_rule_only">
<%:Collecting data...%>
</p>
</td>
<td width="25%">
<p align="center" id="backup_proxy_only">
<%:Collecting data...%>
</p>
</td>
</tr>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
var core_version = document.getElementById('CORE_VERSION');
var checktime = document.getElementById('CHECKTIME');
var cpu_model = document.getElementById('CPU_MODEL');
var core_cv = document.getElementById('CORE_CV');
var core_lv = document.getElementById('CORE_LV');
var core_tun_cv = document.getElementById('CORE_TUN_CV');
var core_tun_lv = document.getElementById('CORE_TUN_LV');
var core_meta_cv = document.getElementById('CORE_META_CV');
var core_meta_lv = document.getElementById('CORE_META_LV');
var op_cv = document.getElementById('OP_CV');
var op_lv = document.getElementById('OP_LV');
var core_up = document.getElementById('core_up');
var core_tun_up = document.getElementById('core_tun_up');
var core_meta_up = document.getElementById('core_meta_up');
var op_up = document.getElementById('op_up');
var update_tip = document.getElementById('update_tip');
var ma_core_up = document.getElementById('ma_core_up');
var ma_core_tun_up = document.getElementById('ma_core_tun_up');
var ma_core_meta_up = document.getElementById('ma_core_meta_up');
var ma_op_up = document.getElementById('ma_op_up');
var restore = document.getElementById('restore');
var backup = document.getElementById('backup');
var backup_ex_core = document.getElementById('backup_ex_core');
var backup_core_only = document.getElementById('backup_core_only');
var backup_config_only = document.getElementById('backup_config_only');
var backup_rule_only = document.getElementById('backup_rule_only');
var backup_proxy_only = document.getElementById('backup_proxy_only');
var one_key_update = document.getElementById('one_key_update');
var remove_core = document.getElementById('remove_core');
var release_branch = document.getElementById('RELEASE_BRANCH');
core_up.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check And Update%>" onclick="return core_update(this,\'Dev\')"/>';
core_tun_up.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check And Update%>" onclick="return core_update(this,\'TUN\')"/>';
core_meta_up.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check And Update%>" onclick="return core_update(this,\'Meta\')"/>';
op_up.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check And Update%>" onclick="return op_update(this)"/>';
ma_core_up.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Download%>" onclick="return ma_core_update(this,\'Dev\')"/>';
ma_core_tun_up.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Download%>" onclick="return ma_core_update(this,\'TUN\')"/>';
ma_core_meta_up.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Download%>" onclick="return ma_core_update(this,\'Meta\')"/>';
ma_op_up.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Download%>" onclick="return ma_op_update(this)"/>';
restore.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Restore Default Config%>" onclick="return restore_config(this)"/>';
one_key_update.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:One Click Check Update%>" onclick="return all_one_key_update(this)"/>';
remove_core.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Remove Core%>" onclick="return remove_all_core(this)"/>';
backup.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Backup OpenClash%>" onclick="return backup_all_file(this)"/>';
backup_ex_core.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Backup Exclude Cores%>" onclick="return backup_no_core(this)"/>';
backup_core_only.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Backup Core%>" onclick="return backup_only_core(this)"/>';
backup_config_only.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Backup Config%>" onclick="return backup_only_config(this)"/>';
backup_rule_only.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Backup Rule Provider%>" onclick="return backup_only_rule(this)"/>';
backup_proxy_only.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Backup Proxy Provider%>" onclick="return backup_only_proxy(this)"/>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_info")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.corever != "0" && status.corever != "" ) {
core_version.value = status.corever;
}
else {
core_version.value = "0";
}
if ( status.release_branch != "" ) {
release_branch.value = status.release_branch;
}
else {
release_branch.value = "master";
}
}
else {
core_version.value = "0";
release_branch.value = "master";
}
});
XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "update")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
cpu_model.innerHTML = status.coremodel ? "<b style=color:green>"+status.coremodel+"</b>" : "<b style=color:red><%:Model Not Found%></b>";
if ( status.upchecktime != "1" ) {
checktime.innerHTML = "<b style=color:green>"+status.upchecktime+"</b>";
}
else {
checktime.innerHTML = "<b style=color:red><%:Check Failed%></b>";
}
if ( status.corecv == "0" ) {
core_cv.innerHTML = "<b style=color:red><%:File Not Exist%></b>";
}
else if (status.corecv != "") {
core_cv.innerHTML = "<b style=color:green>"+status.corecv+"</b>";
}
else {
core_cv.innerHTML = "<b style=color:red><%:Unknown%></b>";
}
if ( status.coretuncv == "0" ) {
core_tun_cv.innerHTML = "<b style=color:red><%:File Not Exist%></b>";
}
else if (status.coretuncv != "") {
core_tun_cv.innerHTML = "<b style=color:green>"+status.coretuncv+"</b>";
}
else {
core_tun_cv.innerHTML = "<b style=color:red><%:Unknown%></b>";
}
if ( status.coremetacv == "0" ) {
core_meta_cv.innerHTML = "<b style=color:red><%:File Not Exist%></b>";
}
else if (status.coremetacv != "") {
core_meta_cv.innerHTML = "<b style=color:green>"+status.coremetacv+"</b>";
}
else {
core_meta_cv.innerHTML = "<b style=color:red><%:Unknown%></b>";
}
var corelv = status.corelv;
var arr_core = corelv.split(",");
var corelvis = arr_core[0];
var coretunlvis = arr_core[1];
var coremetalvis = arr_core[2];
if (corelvis != status.corecv && corelvis != "" && corelvis != "\n") {
core_lv.innerHTML = "<b style=color:green>"+corelvis+"<%:<New>%></b>";
}
else if (corelvis != "" && corelvis == status.corecv && corelvis != "\n") {
core_lv.innerHTML = "<b style=color:green>"+corelvis+"</b>";
}
else {
core_lv.innerHTML = "<b style=color:red><%:Unknown%></b>";
}
if (coretunlvis != status.coretuncv && coretunlvis != "" && coretunlvis != "\n") {
core_tun_lv.innerHTML = "<b style=color:green>"+coretunlvis+"<%:<New>%></b>";
}
else if (coretunlvis != "" && coretunlvis == status.coretuncv && coretunlvis != "\n") {
core_tun_lv.innerHTML = "<b style=color:green>"+coretunlvis+"</b>";
}
else {
core_tun_lv.innerHTML = "<b style=color:red><%:Unknown%></b>";
}
if (coremetalvis != status.coremetacv && coremetalvis != "" && coremetalvis != "\n") {
core_meta_lv.innerHTML = "<b style=color:green>"+coremetalvis+"<%:<New>%></b>";
}
else if (coremetalvis != "" && coremetalvis == status.coremetacv && coremetalvis != "\n") {
core_meta_lv.innerHTML = "<b style=color:green>"+coremetalvis+"</b>";
}
else {
core_meta_lv.innerHTML = "<b style=color:red><%:Unknown%></b>";
}
var oplv = status.oplv;
var arr_op = oplv.split(",");
var oplvis = arr_op[0];
var new_op = arr_op[1];
op_cv.innerHTML = status.opcv ? "<b style=color:green>"+status.opcv+"</b>" : "<b style=color:red><%:Unknown%></b>";
if ( new_op == "2" && oplvis != "" && oplvis != "\n") {
op_lv.innerHTML = "<b style=color:green>"+oplvis+"<%:<New>%></b>";
}
else if (oplvis != "" && oplvis != "\n") {
op_lv.innerHTML = "<b style=color:green>"+oplvis+"</b>";
}
else {
op_lv.innerHTML = "<b style=color:red><%:Unknown%></b>";
}
}
});
XHR.poll(7, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "startlog")%>', status.startlog, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.startlog == "\n" || status.startlog == "" ) {
var rdmdl=Math.floor(Math.random()*2)+1;
if(rdmdl==1)
{
update_tip.innerHTML = '<b><font><%:Note: if the update fails, you can manually download and upload%></font></b>';
}
if(rdmdl==2)
{
update_tip.innerHTML = '<b><font><%:Note: the client may not support update, because the firmware with squashfs format will not release flash space after updating%></font></b>';
}
}
}
});
XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "startlog")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.startlog.match("level=fatal") || status.startlog.indexOf("FTL [Config]") != "-1" ) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "del_start_log")%>', null, function(x) {});
if ( status.startlog.match("level=fatal") ) {
alert('<%:OpenClash Start Failed%> :\n\n' + status.startlog.split('msg=')[1]);
}
else {
alert('<%:OpenClash Start Failed%> :\n\n' + status.startlog.split('FTL [Config] ')[1]);
};
}
else if ( status.startlog != "\n" && status.startlog != "" ) {
if ( status.startlog.match("Tip:") || status.startlog.match("提示:")) {
update_tip.innerHTML = '<b style=color:#ff6f00>'+status.startlog+'</b>';
}
else if ( status.startlog.match("Error:") || status.startlog.match("错误:")) {
update_tip.innerHTML = '<b style=color:#FF0000>'+status.startlog+'</b>';
}
else if ( status.startlog.match("Warning:") || status.startlog.match("警告:")) {
update_tip.innerHTML = '<b style=color:#ff00bb>'+status.startlog+'</b>';
}
else if ( status.startlog.match("Watchdog:") || status.startlog.match("守护程序:")) {
update_tip.innerHTML = '<b style=color:#b300ff>'+status.startlog+'</b>';
}
else {
update_tip.innerHTML = '<b style=color:green>'+status.startlog+'</b>';
};
};
};
});
function core_update(btn,type)
{
var v = core_version.value;
var r = release_branch.value;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "save_corever_branch")%>', {core_ver: v, release_branch: r}, function(x, status) {
if (x && x.status == 200) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "coreupdate")%>', {core_type: type}, function(x, status) {
btn.value = '<%:Check And Update%>';
btn.disabled = false;
return false;
});
}
});
}
function op_update(btn)
{
var r = release_branch.value;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "save_corever_branch")%>', {release_branch: r}, function(x, status) {
if (x && x.status == 200) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "opupdate")%>', null, function(x, status) {
btn.value = '<%:Check And Update%>';
btn.disabled = false;
return false;
});
}
});
}
function ma_core_update(btn,type)
{
var v = core_version.value;
var r = release_branch.value;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "save_corever_branch")%>', {core_ver: v, release_branch: r}, function(x, status) {
if (x && x.status == 200) {
btn.value = '<%:Download%>';
btn.disabled = false;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_ma")%>', status.corever, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.corever != "0" ) {
if (type == "Dev") {
url1='https://raw.githubusercontent.com/vernesong/OpenClash/core/'+r+'/dev/clash-'+status.corever+'.tar.gz';
window.location.href=url1;
}
if (type == "TUN") {
var corelv = status.corelv;
var arr_core = corelv.split(",");
var coretunlvis = arr_core[1];
if ( coretunlvis != "" ) {
url3='https://raw.githubusercontent.com/vernesong/OpenClash/core/'+r+'/premium/clash-'+status.corever+'-'+coretunlvis+'.gz';
window.location.href=url3;
}
else {
alert('<%:Failed to get the latest version. Please try again later!%>')
}
}
if (type == "Meta") {
url4='https://raw.githubusercontent.com/vernesong/OpenClash/core/'+r+'/meta/clash-'+status.corever+'.tar.gz';
window.location.href=url4;
}
}
else {
alert('<%:No Compiled Version is Selected, Please Select on The Top and Try Again!%>')
}
}
});
return false;
}
});
}
function ma_op_update(btn)
{
btn.value = '<%:Download%>';
btn.disabled = false;
var r = release_branch.value;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "save_corever_branch")%>', {release_branch: r}, function(x, status) {
if (x && x.status == 200) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_ma")%>', status.oplv, function(x, status) {
if ( x && x.status == 200 ) {
var oplv = status.oplv;
var oplvis = oplv.substring(oplv.indexOf("v") + 1,oplv.indexOf(","));
if ( oplvis != "" ) {
url2='https://raw.githubusercontent.com/vernesong/OpenClash/package/'+r+'/luci-app-openclash_'+oplvis+'_all.ipk';
window.location.href=url2;
}
else {
alert('<%:Failed to get the latest version. Please try again later!%>')
}
}
});
}
});
return false;
}
function remove_all_core(btn)
{
btn.value = '<%:Remove Core%>';
btn.disabled = true;
var r = confirm("<%:Are you sure want to remove all core files?%>")
if (r == true) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "remove_all_core")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
alert('<%:Remove succeeded!%>')
window.location.href='<%="settings?tab.openclash.config=version_update"%>';
}
else {
alert('<%:Remove failed!%>')
}
});
} else {
}
btn.disabled = false;
return false;
}
function backup_all_file(btn)
{
btn.value = '<%:Backup OpenClash%>';
btn.disabled = true;
window.location.href='<%="backup"%>';
btn.disabled = false;
return false;
}
function backup_no_core(btn)
{
btn.value = '<%:Backup Exclude Cores%>';
btn.disabled = true;
window.location.href='<%="backup_ex_core"%>';
btn.disabled = false;
return false;
}
function backup_only_core(btn)
{
btn.value = '<%:Backup Core%>';
btn.disabled = true;
window.location.href='<%="backup_only_core"%>';
btn.disabled = false;
return false;
}
function backup_only_config(btn)
{
btn.value = '<%:Backup Config%>';
btn.disabled = true;
window.location.href='<%="backup_only_config"%>';
btn.disabled = false;
return false;
}
function backup_only_rule(btn)
{
btn.value = '<%:Backup Rule Provider%>';
btn.disabled = true;
window.location.href='<%="backup_only_rule"%>';
btn.disabled = false;
return false;
}
function backup_only_proxy(btn)
{
btn.value = '<%:Backup Proxy Provider%>';
btn.disabled = true;
window.location.href='<%="backup_only_proxy"%>';
btn.disabled = false;
return false;
}
function all_one_key_update(btn)
{
var v = core_version.value;
var r = release_branch.value;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "save_corever_branch")%>', {core_ver: v, release_branch: r}, function(x, status) {
if (x && x.status == 200) {
btn.value = '<%:One Click Check Update%>';
btn.disabled = true;
var r = confirm("<%:Check and update all Cores and plug-ins?%>")
if (r == true) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update_check")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.corever != "0" ) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update")%>', null, function(x, status) {
if ( x && x.status != 200 ) {
alert('<%:Check failed, Please try again later!%>')
}
});
}
else {
alert('<%:No Compiled Version is Selected, Please Select on The Top and Try Again!%>')
}
}
else {
alert('<%:Check failed, Please try again later!%>')
}
});
}
btn.disabled = false;
return false;
}
});
}
//]]></script>

View File

@ -0,0 +1,30 @@
<%+cbi/valueheader%>
<div style="text-align: center; margin:0 auto; display:block; white-space: nowrap;">
<label class="cbi-value" style="display:inline-block; width: 100%;" for="ulfile"><%:Upload File Type%>&nbsp;<%:(Click to select)%>&nbsp;&nbsp;&nbsp;
<select name="file_type" style="width:auto">&nbsp;&nbsp;&nbsp;
<option value="config" selected="selected"><%:Config File%> (.yaml)</option>
<option value="proxy-provider"><%:Proxy Provider File%></option>
<option value="rule-provider"><%:Rule Provider File%></option>
<option value="clash">[Dev] <%:Core File%> (.tar.gz)</option>
<option value="clash_tun">[TUN] <%:Core File%> (.gz)</option>
<option value="clash_meta">[Meta] <%:Core File%> (.tar.gz)</option>
<option value="backup-file"><%:Backup File%> (.tar.gz)</option>
</select>
<input class="cbi-input-file" style="width: 30%" type="file" id="ulfile" name="ulfile" />
<input type="submit" class="btn cbi-button cbi-input-reload" name="upload" value="<%:Upload%>" />
<input type="submit" class="btn cbi-button cbi-button-reset" value="<%:Backup%>" onclick="return backup_all_file(this)"/>
</div>
<%+cbi/valuefooter%>
<script type="text/javascript">//<![CDATA[
function backup_all_file(btn)
{
btn.value = '<%:Backup%>';
btn.disabled = true;
window.location.href='<%="backup"%>';
btn.disabled = false;
return false;
};
//]]></script>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
zh-cn

View File

@ -0,0 +1,231 @@
config openclash 'config'
option proxy_port '7892'
option tproxy_port '7895'
option mixed_port '7893'
option socks_port '7891'
option http_port '7890'
option dns_port '7874'
option enable '0'
option update '0'
option en_mode '0'
option auto_update '0'
option auto_update_time '0'
option cn_port '9090'
option dashboard_password '123456'
option dashboard_forward_ssl '0'
option rule_source '0'
option enable_custom_dns '0'
option ipv6_enable '0'
option ipv6_dns '0'
option enable_custom_clash_rules '0'
option other_rule_auto_update '0'
option core_version '0'
option en_mode 'redir-host'
option enable_redirect_dns '1'
option servers_if_update '0'
option disable_masq_cache '1'
option servers_update '0'
option log_level '0'
option proxy_mode 'rule'
option intranet_allowed '1'
option enable_udp_proxy '1'
option disable_udp_quic '1'
option lan_ac_mode '0'
option operation_mode 'redir-host'
option enable_rule_proxy '0'
option redirect_dns '0'
option cachesize_dns '0'
option filter_aaaa_dns '0'
option small_flash_memory '0'
option interface_name '0'
option common_ports '0'
option log_size '1024'
option tolerance '0'
option store_fakeip '0'
option custom_fallback_filter '0'
option custom_fakeip_filter '0'
option custom_host '0'
option custom_name_policy '0'
option append_wan_dns '0'
option stream_domains_prefetch '0'
option stream_auto_select '0'
option bypass_gateway_compatible '0'
option github_address_mod '0'
option urltest_address_mod '0'
option urltest_interval_mod '0'
option delay_start '0'
option router_self_proxy '1'
option release_branch 'master'
option enable_meta_core '0'
option dashboard_type 'Official'
option yacd_type 'Official'
option append_default_dns '0'
option geo_custom_url 'https://testingcf.jsdelivr.net/gh/alecthw/mmdb_china_ip_list@release/lite/Country.mmdb'
option geosite_custom_url 'https://testingcf.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat'
option geoip_custom_url 'https://testingcf.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat'
option chnr_custom_url 'https://ispip.clang.cn/all_cn.txt'
option chnr6_custom_url 'https://ispip.clang.cn/all_cn_ipv6.txt'
option cndomain_custom_url 'https://testingcf.jsdelivr.net/gh/felixonmars/dnsmasq-china-list@master/accelerated-domains.china.conf'
config dns_servers
option group 'nameserver'
option type 'udp'
option ip '114.114.114.114'
option enabled '1'
config dns_servers
option group 'nameserver'
option type 'udp'
option ip '119.29.29.29'
option enabled '1'
config dns_servers
option group 'nameserver'
option type 'udp'
option ip '119.28.28.28'
option enabled '0'
config dns_servers
option group 'nameserver'
option type 'udp'
option ip '223.5.5.5'
option enabled '0'
config dns_servers
option type 'https'
option ip 'doh.pub/dns-query'
option group 'nameserver'
option enabled '1'
config dns_servers
option type 'https'
option ip 'dns.alidns.com/dns-query'
option group 'nameserver'
option enabled '1'
config dns_servers
option type 'https'
option group 'fallback'
option ip 'dns.cloudflare.com/dns-query'
option enabled '1'
config dns_servers
option group 'fallback'
option ip 'dns.google'
option port '853'
option type 'tls'
option enabled '0'
config dns_servers
option group 'fallback'
option type 'https'
option ip '1.1.1.1/dns-query'
option enabled '0'
config dns_servers
option group 'fallback'
option ip '1.1.1.1'
option port '853'
option type 'tls'
option enabled '0'
config dns_servers
option enabled '0'
option group 'fallback'
option ip '8.8.8.8'
option port '853'
option type 'tls'
config dns_servers
option type 'udp'
option group 'fallback'
option ip '2001:4860:4860::8888'
option port '53'
option enabled '0'
config dns_servers
option type 'udp'
option group 'fallback'
option ip '2001:4860:4860::8844'
option port '53'
option enabled '0'
config dns_servers
option type 'udp'
option group 'fallback'
option ip '2001:da8::666'
option port '53'
option enabled '0'
config dns_servers
option group 'fallback'
option type 'https'
option ip 'public.dns.iij.jp/dns-query'
option enabled '1'
config dns_servers
option group 'fallback'
option type 'https'
option ip 'jp.tiar.app/dns-query'
option enabled '0'
config dns_servers
option group 'fallback'
option type 'https'
option ip 'jp.tiarap.org/dns-query'
option enabled '0'
config dns_servers
option group 'fallback'
option ip 'jp.tiar.app'
option type 'tls'
option enabled '0'
config dns_servers
option group 'fallback'
option ip 'dot.tiar.app'
option type 'tls'
option enabled '0'
config dns_servers
option enabled '0'
option group 'fallback'
option type 'https'
option ip 'doh.dnslify.com/dns-query'
config dns_servers
option enabled '0'
option group 'fallback'
option ip 'dns.twnic.tw/dns-query'
option type 'https'
config dns_servers
option enabled '1'
option group 'fallback'
option ip 'dns.oszx.co/dns-query'
option type 'https'
config dns_servers
option enabled '0'
option group 'fallback'
option ip 'doh.applied-privacy.net/query'
option type 'https'
config dns_servers
option enabled '0'
option group 'fallback'
option ip 'dnsforge.de/dns-query'
option type 'https'
config dns_servers
option enabled '0'
option group 'fallback'
option ip 'doh.ffmuc.net/dns-query'
option type 'https'
config dns_servers
option enabled '0'
option group 'fallback'
option type 'https'
option ip 'doh.mullvad.net/dns-query'

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
#baidu.com
#2400:da00::dbf:0:100

View File

@ -0,0 +1,4 @@
#baidu.com
#114.114.114.114
##解决绕过大陆后谷歌商店无法更新
services.googleapis.cn

View File

@ -0,0 +1,2 @@
#'www.baidu.com': '114.114.114.114'
#'+.internal.crop.com': '10.0.0.1'

View File

@ -0,0 +1,139 @@
#LAN
*.lan
*.localdomain
*.example
*.invalid
*.localhost
*.test
*.local
*.home.arpa
#放行NTP服务
time.*.com
time.*.gov
time.*.edu.cn
time.*.apple.com
time-ios.apple.com
time1.*.com
time2.*.com
time3.*.com
time4.*.com
time5.*.com
time6.*.com
time7.*.com
ntp.*.com
ntp1.*.com
ntp2.*.com
ntp3.*.com
ntp4.*.com
ntp5.*.com
ntp6.*.com
ntp7.*.com
*.time.edu.cn
*.ntp.org.cn
+.pool.ntp.org
time1.cloud.tencent.com
#放行网易云音乐
music.163.com
*.music.163.com
*.126.net
#百度音乐
musicapi.taihe.com
music.taihe.com
#酷狗音乐
songsearch.kugou.com
trackercdn.kugou.com
#酷我音乐
*.kuwo.cn
#JOOX音乐
api-jooxtt.sanook.com
api.joox.com
joox.com
#QQ音乐
y.qq.com
*.y.qq.com
streamoc.music.tc.qq.com
mobileoc.music.tc.qq.com
isure.stream.qqmusic.qq.com
dl.stream.qqmusic.qq.com
aqqmusic.tc.qq.com
amobile.music.tc.qq.com
#虾米音乐
*.xiami.com
#咪咕音乐
*.music.migu.cn
music.migu.cn
#win10本地连接检测
+.msftconnecttest.com
+.msftncsi.com
#QQ登录
localhost.ptlogin2.qq.com
localhost.sec.qq.com
+.qq.com
+.tencent.com
#Game
#Nintendo Switch
+.srv.nintendo.net
*.n.n.srv.nintendo.net
#Sony PlayStation
+.stun.playstation.net
#Microsoft Xbox
xbox.*.*.microsoft.com
*.*.xboxlive.com
xbox.*.microsoft.com
xnotify.xboxlive.com
#Wotgame
+.battlenet.com.cn
+.wotgame.cn
+.wggames.cn
+.wowsgame.cn
+.wargaming.net
#Golang
proxy.golang.org
#STUN
stun.*.*
stun.*.*.*
+.stun.*.*
+.stun.*.*.*
+.stun.*.*.*.*
+.stun.*.*.*.*.*
#Linksys Router
heartbeat.belkin.com
*.linksys.com
*.linksyssmartwifi.com
#ASUS Router
*.router.asus.com
#Apple Software Update Service
mesu.apple.com
swscan.apple.com
swquery.apple.com
swdownload.apple.com
swcdn.apple.com
swdist.apple.com
#Google
lens.l.google.com
stun.l.google.com
na.b.g-tun.com
#Netflix
+.nflxvideo.net
#FinalFantasy XIV Worldwide Server & CN Server
*.square-enix.com
*.finalfantasyxiv.com
*.ffxiv.com
*.ff14.sdo.com
ff.dorado.sdo.com
#Bilibili
*.mcdn.bilivideo.cn
#Disney Plus
+.media.dssott.com
#shark007 Codecs
shark007.net
#Mijia
Mijia Cloud
#招商银行
+.cmbchina.com
+.cmbimg.com
#AdGuard
local.adguard.org
#迅雷
+.sandai.net
+.n0808.com

View File

@ -0,0 +1,40 @@
# If IP addresses resolved with servers in `nameservers` are in the specified
# subnets below, they are considered invalid and results from `fallback`
# servers are used instead.
#
# IP address resolved with servers in `nameserver` is used when
# `fallback-filter.geoip` is true and when GEOIP of the IP address is `CN`.
#
# If `fallback-filter.geoip` is false, results from `nameserver` nameservers
# are always used if not match `fallback-filter.ipcidr`.
#
# This is a countermeasure against DNS pollution attacks.
fallback-filter:
geoip: true
geoip-code: CN
ipcidr:
- 0.0.0.0/8
- 10.0.0.0/8
- 100.64.0.0/10
- 127.0.0.0/8
- 169.254.0.0/16
- 172.16.0.0/12
- 192.0.0.0/24
- 192.0.2.0/24
- 192.88.99.0/24
- 192.168.0.0/16
- 198.18.0.0/15
- 198.51.100.0/24
- 203.0.113.0/24
- 224.0.0.0/4
- 240.0.0.0/4
- 255.255.255.255/32
domain:
- "+.google.com"
- "+.facebook.com"
- "+.youtube.com"
- "+.githubusercontent.com"
- "+.googlevideo.com"
- "+.msftconnecttest.com"
- "+.msftncsi.com"

View File

@ -0,0 +1,10 @@
#!/bin/sh
. /usr/share/openclash/log.sh
. /lib/functions.sh
# This script is called by /etc/init.d/openclash
# Add your custom firewall rules here, they will be added after the end of the OpenClash iptables rules
LOG_OUT "Tip: Start Add Custom Firewall Rules..."
exit 0

View File

@ -0,0 +1,10 @@
# Static hosts for DNS server and connection establishment (like /etc/hosts)
#
# Wildcard hostnames are supported (e.g. *.clash.dev, *.foo.*.example.com)
# Non-wildcard domain names have a higher priority than wildcard domain names
# e.g. foo.example.com > *.example.com > .example.com
# P.S. +.foo.com equals to .foo.com and foo.com
# '*.clash.dev': 127.0.0.1
# '.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'

View File

@ -0,0 +1,9 @@
0.0.0.0/8
10.0.0.0/8
100.64.0.0/10
127.0.0.0/8
169.254.0.0/16
172.16.0.0/12
192.168.0.0/16
224.0.0.0/4
240.0.0.0/4

View File

@ -0,0 +1,13 @@
::/128
::1/128
::ffff:0:0/96
::ffff:0:0:0/96
64:ff9b::/96
100::/64
2001::/32
2001:20::/28
2001:db8::/32
2002::/16
fc00::/7
fe80::/10
ff00::/8

Some files were not shown because too many files have changed in this diff Show More