mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-29 23:25:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,4 @@
|
||||
dist/*
|
||||
*.lmo
|
||||
*.o
|
||||
tools/po2lmo/src/po2lmo
|
||||
@@ -0,0 +1,622 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://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
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# Copyright (C) 2016-2018 Jian Chang <aa65535@live.com>
|
||||
# 2017-2023 honwen https://github.com/honwen
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-shadowsocks
|
||||
PKG_VERSION:=2.0.6
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=honwen <https://github.com/honwen>
|
||||
|
||||
LUCI_TITLE:=LuCI Support for shadowsocks-rust
|
||||
LUCI_DEPENDS:=+iptables +ipset +curl +ip +iptables-mod-tproxy
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/shadowsocks
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
if [ -f /etc/uci-defaults/luci-shadowsocks ]; then
|
||||
( . /etc/uci-defaults/luci-shadowsocks ) && \
|
||||
rm -f /etc/uci-defaults/luci-shadowsocks
|
||||
fi
|
||||
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,91 @@
|
||||
OpenWrt LuCI for Shadowsocks-Rust
|
||||
===
|
||||
|
||||
[![Latest release][release_badge]][release_url]
|
||||
|
||||
简介
|
||||
---
|
||||
|
||||
本软件包是 [shadowsocks-rust][openwrt-shadowsocks] 的 LuCI 控制界面,
|
||||
方便用户控制和使用「透明代理」「SOCKS5 代理」「端口转发」功能.
|
||||
|
||||
软件包文件结构:
|
||||
```
|
||||
/
|
||||
├── etc/
|
||||
│ ├── config/
|
||||
│ │ └── shadowsocks // UCI 配置文件
|
||||
│ │── init.d/
|
||||
│ │ └── shadowsocks // init 脚本
|
||||
│ └── uci-defaults/
|
||||
│ └── luci-shadowsocks // uci-defaults 脚本
|
||||
└── usr/
|
||||
├── bin/
|
||||
│ └── ss-rules // 生成代理转发规则的脚本
|
||||
└── lib/
|
||||
└── lua/
|
||||
└── luci/ // LuCI 部分
|
||||
├── controller/
|
||||
│ └── shadowsocks.lua // LuCI 菜单配置
|
||||
├── i18n/ // LuCI 语言文件目录
|
||||
│ └── shadowsocks.zh-cn.lmo
|
||||
└── model/
|
||||
└── cbi/
|
||||
└── shadowsocks/
|
||||
├── general.lua // LuCI 基本设置
|
||||
├── servers.lua // LuCI 服务器列表
|
||||
├── servers-details.lua // LuCI 服务器编辑
|
||||
└── access-control.lua // LuCI 访问控制
|
||||
```
|
||||
|
||||
依赖
|
||||
---
|
||||
|
||||
软件包的正常使用需要依赖 `iptables` 和 `ipset`.
|
||||
软件包不显式依赖 `shadowsocks-rust`, 会根据用户添加的可执行文件启用相应的功能.
|
||||
- `TCP Fast-Open` 依赖版本 v1.11.0 或更高
|
||||
- GFW-List模式 正常使用需要依赖 [dnsmasq-extra][openwrt-dnsmasq-extra], 其中包括`DNS防污染`和`GFW-List`
|
||||
|
||||
可执行文件可通过安装 [openwrt-shadowsocks][openwrt-shadowsocks] 中提供的 `shadowsocks-rust` 获得.
|
||||
只有当文件存在时, 相应的功能才可被使用, 并显示相应的 LuCI 设置界面.
|
||||
|
||||
可执行文件 | 可选 | 功能 | TCP协议 | UDP协议
|
||||
------------|------|-------------|---------|-----------------------------------
|
||||
`sslocal` | 是 | 透明代理 | 支持 | 需安装 `iptables-mod-tproxy`, `ip`
|
||||
|
||||
注: 可执行文件在 `$PATH` 环境变量所表示的搜索路径中, 都可被正确调用.
|
||||
|
||||
配置
|
||||
---
|
||||
|
||||
软件包的配置文件路径: `/etc/config/shadowsocks`
|
||||
此文件为 UCI 配置文件, 配置方式可参考 [Wiki -> Use-UCI-system][Use-UCI-system] 和 [OpenWrt Wiki][uci]
|
||||
透明代理的访问控制功能设置可参考 [Wiki -> LuCI-Access-Control][LuCI-Access-Control]
|
||||
|
||||
编译
|
||||
---
|
||||
|
||||
从 OpenWrt 的 [SDK][openwrt-sdk] 编译
|
||||
```bash
|
||||
# 解压下载好的 SDK
|
||||
tar xjf OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2
|
||||
cd OpenWrt-SDK-ar71xx-*
|
||||
# Clone 项目
|
||||
git clone https://github.com/honwen/luci-app-shadowsocks-rust.git package/luci-app-shadowsocks-rust
|
||||
# Clone Luci 项目
|
||||
git clone https://github.com/openwrt/luci.git feeds/luci
|
||||
# 选择要编译的包 LuCI -> 3. Applications
|
||||
make menuconfig
|
||||
# 开始编译
|
||||
make package/luci-app-shadowsocks-rust/compile V=99
|
||||
```
|
||||
|
||||
[release_badge]: https://img.shields.io/github/release/honwen/luci-app-shadowsocks-rust.svg
|
||||
[release_url]: https://github.com/honwen/luci-app-shadowsocks-rust/releases
|
||||
[openwrt-shadowsocks]: https://github.com/honwen/openwrt-shadowsocks
|
||||
[openwrt-sdk]: https://wiki.openwrt.org/doc/howto/obtain.firmware.sdk
|
||||
[ss-rules]: https://github.com/shadowsocks/luci-app-shadowsocks/wiki/Instruction-of-ss-rules
|
||||
[Use-UCI-system]: https://github.com/shadowsocks/luci-app-shadowsocks/wiki/Use-UCI-system
|
||||
[uci]: https://wiki.openwrt.org/doc/uci
|
||||
[LuCI-Access-Control]: https://github.com/shadowsocks/luci-app-shadowsocks/wiki/LuCI-Access-Control
|
||||
[openwrt-dnsmasq-extra]: https://github.com/honwen/openwrt-dnsmasq-extra
|
||||
@@ -0,0 +1,93 @@
|
||||
-- Copyright (C) 2014-2017 Jian Chang <aa65535@live.com>
|
||||
-- Copyright (C) 2020-2023 honwen <https://github.com/honwen>
|
||||
-- Licensed to the public under the GNU General Public License v3.
|
||||
|
||||
module("luci.controller.shadowsocks", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/shadowsocks") then
|
||||
return
|
||||
end
|
||||
|
||||
page = entry({"admin", "services", "shadowsocks"},
|
||||
alias("admin", "services", "shadowsocks", "general"),
|
||||
_("ShadowSocks"), 10)
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-shadowsocks" }
|
||||
|
||||
page = entry({"admin", "services", "shadowsocks", "general"},
|
||||
cbi("shadowsocks/general"),
|
||||
_("General Settings"), 10)
|
||||
page.leaf = true
|
||||
page.acl_depends = { "luci-app-shadowsocks" }
|
||||
|
||||
page = entry({"admin", "services", "shadowsocks", "status"},
|
||||
call("action_status"))
|
||||
page.leaf = true
|
||||
page.acl_depends = { "luci-app-shadowsocks" }
|
||||
|
||||
page = entry({"admin", "services", "shadowsocks", "servers"},
|
||||
arcombine(cbi("shadowsocks/servers"), cbi("shadowsocks/servers-details")),
|
||||
_("Servers Manage"), 20)
|
||||
page.leaf = true
|
||||
page.acl_depends = { "luci-app-shadowsocks" }
|
||||
|
||||
if luci.sys.call("command -v sslocal >/dev/null") ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
page = entry({"admin", "services", "shadowsocks", "access-control"},
|
||||
cbi("shadowsocks/access-control"),
|
||||
_("Access Control"), 30)
|
||||
page.leaf = true
|
||||
page.acl_depends = { "luci-app-shadowsocks" }
|
||||
|
||||
entry({"admin", "services", "shadowsocks", "log"},
|
||||
call("action_log"),
|
||||
_("System Log"), 90)
|
||||
page.leaf = true
|
||||
page.acl_depends = { "luci-app-shadowsocks" }
|
||||
|
||||
if luci.sys.call("command -v /etc/init.d/dnsmasq-extra >/dev/null") ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
page = entry({"admin", "services", "shadowsocks", "gfwlist"},
|
||||
call("action_gfw"),
|
||||
_("GFW-List"), 60)
|
||||
page.leaf = true
|
||||
page.acl_depends = { "luci-app-shadowsocks" }
|
||||
|
||||
page = entry({"admin", "services", "shadowsocks", "custom"},
|
||||
cbi("shadowsocks/gfwlist-custom"),
|
||||
_("Custom-List"), 50)
|
||||
page.leaf = true
|
||||
page.acl_depends = { "luci-app-shadowsocks" }
|
||||
|
||||
end
|
||||
|
||||
local function is_running(name)
|
||||
return luci.sys.call("pgrep -f '%s' >/dev/null" %{name}) == 0
|
||||
end
|
||||
|
||||
function action_status()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({
|
||||
ss_redir = is_running("/var/run/ss-redir"),
|
||||
ss_http = is_running("/var/run/ss-local-http"),
|
||||
ss_socks = is_running("/var/run/ss-local-socks"),
|
||||
ss_tunnel = is_running("/var/run/ss-tunnel")
|
||||
})
|
||||
end
|
||||
|
||||
function action_log()
|
||||
local conffile = "/var/log/shadowsocks_healthcheck.log"
|
||||
local healthcheck = nixio.fs.readfile(conffile) or ""
|
||||
luci.template.render("shadowsocks/plain", {content=healthcheck})
|
||||
end
|
||||
|
||||
function action_gfw()
|
||||
local conffile = "/etc/dnsmasq-extra.d/gfwlist"
|
||||
local gfwlist = nixio.fs.readfile(conffile) or luci.sys.exec("cat %s.gz | gunzip -c" %{conffile}) or ""
|
||||
luci.template.render("shadowsocks/plain", {content=gfwlist})
|
||||
end
|
||||
@@ -0,0 +1,136 @@
|
||||
-- Copyright (C) 2016-2017 Jian Chang <aa65535@live.com>
|
||||
-- Licensed to the public under the GNU General Public License v3.
|
||||
|
||||
local m, s, o
|
||||
local shadowsocks = "shadowsocks"
|
||||
local uci = luci.model.uci.cursor()
|
||||
local nwm = require("luci.model.network").init()
|
||||
local gfwroute = luci.sys.call("command -v /etc/init.d/dnsmasq-extra >/dev/null") == 0
|
||||
local chnroute = gfwroute and "/etc/chinadns_chnroute.txt" or uci:get_first("chinadns", "chinadns", "chnroute")
|
||||
local lan_ifaces = {}
|
||||
local io = require "io"
|
||||
|
||||
local function ipv4_hints(callback)
|
||||
local hosts = {}
|
||||
uci:foreach("dhcp", "dnsmasq", function(s)
|
||||
if s.leasefile and nixio.fs.access(s.leasefile) then
|
||||
for e in io.lines(s.leasefile) do
|
||||
mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
|
||||
if mac and ip then
|
||||
hosts[ip] = name ~= "*" and name or mac:upper()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
uci:foreach("dhcp", "host", function(s)
|
||||
for mac in luci.util.imatch(s.mac) do
|
||||
if s.ip then
|
||||
hosts[s.ip] = s.name or mac:upper()
|
||||
end
|
||||
end
|
||||
end)
|
||||
for ip, name in pairs(hosts) do
|
||||
callback(ip, name)
|
||||
end
|
||||
end
|
||||
|
||||
for _, net in ipairs(nwm:get_networks()) do
|
||||
if net:name() ~= "loopback" and string.find(net:name(), "wan") ~= 1 then
|
||||
net = nwm:get_network(net:name())
|
||||
local device = net and net:get_interface()
|
||||
if device then
|
||||
lan_ifaces[device:name()] = device:get_i18n()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
m = Map(shadowsocks, "%s - %s" %{translate("ShadowSocks"), translate("Access Control")})
|
||||
|
||||
-- [[ Zone WAN ]]--
|
||||
s = m:section(TypedSection, "access_control", translate("Zone WAN"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Value, "wan_bp_list", translate("Bypassed IP List"))
|
||||
o:value("/dev/null", translate("NULL - As Global Proxy"))
|
||||
if gfwroute then o:value("/dev/flag_gfwlist", translate("Only Proxy GFW-List")) end
|
||||
if chnroute then o:value(chnroute, translate("ChinaDNS CHNRoute")) end
|
||||
-- o.datatype = "or(file, '/dev/null')"
|
||||
o.default = "/dev/null"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(DynamicList, "wan_bp_ips", translate("Bypassed IP"))
|
||||
o.datatype = "ip4addr"
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(Value, "wan_fw_list", translate("Forwarded IP List"))
|
||||
o.datatype = "or(file, '/dev/null')"
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(DynamicList, "wan_fw_ips", translate("Forwarded IP"))
|
||||
o.datatype = "ip4addr"
|
||||
o.rmempty = true
|
||||
|
||||
-- [[ Zone LAN ]]--
|
||||
s = m:section(TypedSection, "access_control", translate("Zone LAN"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(MultiValue, "lan_ifaces", translate("Interface"))
|
||||
function o.cfgvalue(...)
|
||||
local v = MultiValue.cfgvalue(...)
|
||||
if v then
|
||||
return v
|
||||
else
|
||||
local names = {}
|
||||
for name, _ in pairs(lan_ifaces) do
|
||||
names[#names+1] = name
|
||||
end
|
||||
return table.concat(names, " ")
|
||||
end
|
||||
end
|
||||
for name, i18n in pairs(lan_ifaces) do
|
||||
o:value(name, i18n)
|
||||
end
|
||||
|
||||
o = s:option(ListValue, "lan_target", translate("Proxy Type"))
|
||||
o:value("SS_SPEC_WAN_AC", translate("Normal"))
|
||||
o:value("RETURN", translate("Direct"))
|
||||
o:value("SS_SPEC_WAN_FW", translate("Global"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "self_proxy", translate("Self Proxy"))
|
||||
o:value("1", translate("Normal"))
|
||||
o:value("0", translate("Direct"))
|
||||
o:value("2", translate("Global"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "ipt_ext", translate("Extra arguments"),
|
||||
translate("Passes additional arguments to iptables. Use with care!"))
|
||||
o:value("", translate("None"))
|
||||
o:value("--dport 22:1023", translatef("Proxy port numbers %s only", "22~1023"))
|
||||
o:value("-m multiport --dport 22:1023,8000:8443", translatef("Proxy port numbers %s only", "22~1023,8000~8443"))
|
||||
o:value("-m multiport --dports 53,80,443,853", translatef("Proxy port numbers %s only", "53,80,443,853"))
|
||||
|
||||
-- [[ LAN Hosts ]]--
|
||||
s = m:section(TypedSection, "lan_hosts", translate("LAN Hosts"))
|
||||
s.template = "cbi/tblsection"
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Value, "host", translate("Host"))
|
||||
ipv4_hints(function(ip, name)
|
||||
o:value(ip, "%s (%s)" %{ip, name})
|
||||
end)
|
||||
o.datatype = "ip4addr"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "type", translate("Proxy Type"))
|
||||
o:value("b", translate("Direct"))
|
||||
o:value("g", translate("Global"))
|
||||
o:value("n", translate("Normal"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "enable", translate("Enable"))
|
||||
o.default = "1"
|
||||
o.rmempty = false
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,203 @@
|
||||
-- Copyright (C) 2014-2018 Jian Chang <aa65535@live.com>
|
||||
-- Copyright (C) 2020-2023 honwen <https://github.com/honwen>
|
||||
-- Licensed to the public under the GNU General Public License v3.
|
||||
|
||||
local m, s, o
|
||||
local shadowsocks = "shadowsocks"
|
||||
local uci = luci.model.uci.cursor()
|
||||
local servers = {}
|
||||
|
||||
local function has_bin(name)
|
||||
return luci.sys.call("command -v %s >/dev/null" %{name}) == 0
|
||||
end
|
||||
|
||||
local function has_udp_relay()
|
||||
return luci.sys.call("lsmod | grep -q TPROXY && command -v ip >/dev/null") == 0
|
||||
end
|
||||
|
||||
local function support_fast_open()
|
||||
local bit = luci.sys.exec("cat /proc/sys/net/ipv4/tcp_fastopen 2>/dev/null"):trim()
|
||||
return bit == "1" or bit == "3"
|
||||
end
|
||||
|
||||
local has_ss = has_bin("sslocal")
|
||||
|
||||
if not has_ss then
|
||||
return Map(shadowsocks, "%s - %s" %{translate("ShadowSocks"),
|
||||
translate("General Settings")}, '<b style="color:red">shadowsocks-rust binary file not found.</b>')
|
||||
end
|
||||
|
||||
local function is_running(name)
|
||||
return luci.sys.call("pgrep -f '%s' >/dev/null" %{name}) == 0
|
||||
end
|
||||
|
||||
local function get_status(name)
|
||||
return is_running(name) and translate("RUNNING") or translate("NOT RUNNING")
|
||||
end
|
||||
|
||||
uci:foreach(shadowsocks, "servers", function(s)
|
||||
if s.server and s.server_port then
|
||||
servers[#servers+1] = {name = s[".name"], alias = s.alias or "%s:%s" %{s.server, s.server_port}}
|
||||
end
|
||||
end)
|
||||
|
||||
m = Map(shadowsocks, "%s - %s" %{translate("ShadowSocks"), translate("General Settings")})
|
||||
m.template = "shadowsocks/general"
|
||||
|
||||
-- [[ Running Status ]]--
|
||||
s = m:section(TypedSection, "general", translate("Running Status"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(DummyValue, "_redir_status", translate("Transparent Proxy"))
|
||||
o.value = "<span id=\"_redir_status\">%s</span>" %{get_status("/var/run/ss-redir")}
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "http_status", translate("HTTP Proxy"))
|
||||
o.value = "<span id=\"_http_status\">%s</span>" %{get_status("/var/run/ss-local-http")}
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "socks_status", translate("SOCKS5 Proxy"))
|
||||
o.value = "<span id=\"_socks_status\">%s</span>" %{get_status("/var/run/ss-local-socks")}
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "_tunnel_status", translate("Port Forward"))
|
||||
o.value = "<span id=\"_tunnel_status\">%s</span>" %{get_status("/var/run/ss-tunnel")}
|
||||
o.rawhtml = true
|
||||
|
||||
s = m:section(TypedSection, "general", translate("Global Settings"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Value, "startup_delay", translate("Startup Delay"))
|
||||
o:value(0, translate("Not enabled"))
|
||||
for _, v in ipairs({3, 5, 10, 15, 25, 40}) do
|
||||
o:value(v, translatef("%u seconds", v))
|
||||
end
|
||||
o.datatype = "uinteger"
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "udp_timeout", translate("Timeout for UDP Associations"))
|
||||
for _, v in ipairs({10, 30, 60, 120, 180, 300, 600, 1800}) do
|
||||
o:value(v, translatef("%u seconds", v))
|
||||
end
|
||||
o.default = 300
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "udp_max_associations", translate("Maximum UDP Associations"))
|
||||
o:value(0, translate("Unlimited"))
|
||||
for _, v in ipairs({64, 256, 1024, 5120, 8192, 32768}) do
|
||||
o:value(v)
|
||||
end
|
||||
o.default = 512
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "no_dns_injection", translate("Disable DNS Auto-Injection"))
|
||||
o.rmempty = false
|
||||
|
||||
-- [[ Transparent Proxy ]]--
|
||||
s = m:section(TypedSection, "transparent_proxy", translate("Transparent Proxy"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "no_delay", translate("TCP no-delay"))
|
||||
o.rmempty = false
|
||||
if support_fast_open() then
|
||||
o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
|
||||
o.rmempty = false
|
||||
end
|
||||
|
||||
o = s:option(DynamicList, "main_server", translate("Main Server"))
|
||||
o:value("nil", translate("Disable"))
|
||||
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
|
||||
o.default = "nil"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "udp_relay_server", translate("UDP-Relay Server"))
|
||||
if has_udp_relay() then
|
||||
o:value("nil", translate("Disable"))
|
||||
o:value("same", translate("Same as Main Server"))
|
||||
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
|
||||
else
|
||||
o:value("nil", translate("Unusable - Missing iptables-mod-tproxy or ip"))
|
||||
end
|
||||
o.default = "nil"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "local_port", translate("Local Port"))
|
||||
o.datatype = "port"
|
||||
o.default = 1234
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "no_healthcheck", translate("Disable HealthCheck"))
|
||||
o.rmempty = false
|
||||
|
||||
-- [[ HTTP Proxy ]]--
|
||||
s = m:section(TypedSection, "http_proxy", translate("HTTP Proxy"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "no_delay", translate("TCP no-delay"))
|
||||
o.rmempty = false
|
||||
if support_fast_open() then
|
||||
o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
|
||||
o.rmempty = false
|
||||
end
|
||||
|
||||
o = s:option(DynamicList, "server", translate("Server"))
|
||||
o:value("nil", translate("Disable"))
|
||||
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
|
||||
o.default = "nil"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "local_port", translate("Local Port"))
|
||||
o.datatype = "port"
|
||||
o.default = 1080
|
||||
o.rmempty = false
|
||||
|
||||
-- [[ SOCKS5 Proxy ]]--
|
||||
s = m:section(TypedSection, "socks_proxy", translate("SOCKS5 Proxy"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "no_delay", translate("TCP no-delay"))
|
||||
o.rmempty = false
|
||||
if support_fast_open() then
|
||||
o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
|
||||
o.rmempty = false
|
||||
end
|
||||
|
||||
o = s:option(DynamicList, "server", translate("Server"))
|
||||
o:value("nil", translate("Disable"))
|
||||
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
|
||||
o.default = "nil"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "local_port", translate("Local Port"))
|
||||
o.datatype = "port"
|
||||
o.default = 1080
|
||||
o.rmempty = false
|
||||
|
||||
-- [[ Port Forward ]]--
|
||||
s = m:section(TypedSection, "port_forward", translate("Port Forward"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "no_delay", translate("TCP no-delay"))
|
||||
o.rmempty = false
|
||||
if support_fast_open() then
|
||||
o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
|
||||
o.rmempty = false
|
||||
end
|
||||
|
||||
o = s:option(DynamicList, "server", translate("Server"))
|
||||
o:value("nil", translate("Disable"))
|
||||
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
|
||||
o.default = "nil"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "local_port", translate("Local Port"))
|
||||
o.datatype = "port"
|
||||
o.default = 5300
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "destination", translate("Destination"))
|
||||
o.default = "8.8.4.4:53"
|
||||
o.rmempty = false
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,23 @@
|
||||
local fs = require "nixio.fs"
|
||||
local conffile = "/etc/dnsmasq-extra.d/custom.conf"
|
||||
|
||||
f = SimpleForm("custom", translate("Be Careful!"), translate("Dnsmasq Config for Shadowsocks. This may CRASH DNSMASQ!"))
|
||||
|
||||
t = f:field(TextValue, "conf")
|
||||
t.rmempty = true
|
||||
t.rows = 30
|
||||
function t.cfgvalue()
|
||||
return fs.readfile(conffile) or ""
|
||||
end
|
||||
|
||||
function f.handle(self, state, data)
|
||||
if state == FORM_VALID then
|
||||
if data.conf then
|
||||
fs.writefile(conffile, data.conf:gsub("\r\n", "\n"))
|
||||
luci.sys.call("/etc/init.d/dnsmasq-extra restart")
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return f
|
||||
@@ -0,0 +1,92 @@
|
||||
-- Copyright (C) 2016-2017 Jian Chang <aa65535@live.com>
|
||||
-- Copyright (C) 2020-2023 honwen <https://github.com/honwen>
|
||||
-- Licensed to the public under the GNU General Public License v3.
|
||||
|
||||
local m, s, o
|
||||
local shadowsocks = "shadowsocks"
|
||||
local sid = arg[1]
|
||||
local encrypt_methods = {
|
||||
"aes-256-gcm",
|
||||
"aes-128-gcm",
|
||||
"chacha20-ietf-poly1305",
|
||||
"2022-blake3-aes-128-gcm",
|
||||
"2022-blake3-aes-256-gcm",
|
||||
"2022-blake3-chacha20-poly1305",
|
||||
"rc4-md5",
|
||||
"aes-128-cfb",
|
||||
"aes-192-cfb",
|
||||
"aes-256-cfb",
|
||||
"aes-128-ctr",
|
||||
"aes-192-ctr",
|
||||
"aes-256-ctr",
|
||||
"camellia-128-cfb",
|
||||
"camellia-192-cfb",
|
||||
"camellia-256-cfb",
|
||||
"chacha20-ietf",
|
||||
"plain",
|
||||
"none",
|
||||
}
|
||||
|
||||
m = Map(shadowsocks, "%s - %s" %{translate("ShadowSocks"), translate("Edit Server")})
|
||||
m.redirect = luci.dispatcher.build_url("admin/services/shadowsocks/servers")
|
||||
m.sid = sid
|
||||
m.template = "shadowsocks/servers-details"
|
||||
|
||||
if m.uci:get(shadowsocks, sid) ~= "servers" then
|
||||
luci.http.redirect(m.redirect)
|
||||
return
|
||||
end
|
||||
|
||||
-- [[ Edit Server ]]--
|
||||
s = m:section(NamedSection, sid, "servers")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
o = s:option(Value, "alias", translate("Alias(optional)"))
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(Value, "server", translate("Server Address"))
|
||||
o.datatype = "host"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "server_port", translate("Server Port"))
|
||||
o.datatype = "port"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "timeout", translate("TCP Connection Timeout"))
|
||||
o.datatype = "uinteger"
|
||||
o.default = 60
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "password", translate("Password"))
|
||||
o.password = true
|
||||
|
||||
o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
|
||||
for _, v in ipairs(encrypt_methods) do o:value(v, v:upper()) end
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "plugin", translate("Plugin Name"))
|
||||
o.placeholder = "eg: v2ray-plugin"
|
||||
|
||||
o = s:option(Value, "plugin_opts", translate("Plugin Arguments"))
|
||||
o.placeholder = "eg: tls;host=www.bing.com;path=/websocket"
|
||||
|
||||
o = s:option(ListValue, "tcp_weight", translate("TCP Weight"))
|
||||
o.datatype = "ufloat"
|
||||
o:value(0, translate("0%(UDP ONLY)"))
|
||||
for _, v in ipairs({0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9, 0.95, 1.0}) do
|
||||
o:value(v, translatef("%u%%", v*100.0))
|
||||
end
|
||||
o.default = 1.0
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "udp_weight", translate("UDP Weight"))
|
||||
o.datatype = "ufloat"
|
||||
o:value(0, translate("0%(TCP ONLY)"))
|
||||
for _, v in ipairs({0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9, 0.95, 1.0}) do
|
||||
o:value(v, translatef("%u%%", v * 100.0))
|
||||
end
|
||||
o.default = 1.0
|
||||
o.rmempty = false
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,50 @@
|
||||
-- Copyright (C) 2016-2017 Jian Chang <aa65535@live.com>
|
||||
-- Licensed to the public under the GNU General Public License v3.
|
||||
|
||||
local m, s, o
|
||||
local shadowsocks = "shadowsocks"
|
||||
|
||||
m = Map(shadowsocks, "%s - %s" %{translate("ShadowSocks"), translate("Servers Manage")})
|
||||
|
||||
-- [[ Servers Manage ]]--
|
||||
s = m:section(TypedSection, "servers")
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.sortable = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = luci.dispatcher.build_url("admin/services/shadowsocks/servers/%s")
|
||||
function s.create(...)
|
||||
local sid = TypedSection.create(...)
|
||||
if sid then
|
||||
luci.http.redirect(s.extedit % sid)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "alias", translate("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 "?"
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "server_port", translate("Server Port"))
|
||||
function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or "?"
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "encrypt_method", translate("Encrypt Method"))
|
||||
function o.cfgvalue(...)
|
||||
local v = Value.cfgvalue(...)
|
||||
return v and v:upper() or "?"
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "plugin", translate("Plugin"))
|
||||
function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or translate("None")
|
||||
end
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,92 @@
|
||||
<%#
|
||||
Copyright (C) 2017-2018 Jian Chang <aa65535@live.com>
|
||||
Copyright (C) 2020-2023 honwen <https://github.com/honwen>
|
||||
Licensed to the public under the GNU General Public License v3.
|
||||
-%>
|
||||
|
||||
<% include("cbi/map") %>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
(function() {
|
||||
window.cbi_combobox = function(id, values, def, man, focus) {
|
||||
var selid = "cbi.combobox." + id;
|
||||
if (document.getElementById(selid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var obj = document.getElementById(id);
|
||||
var sel = document.createElement("select");
|
||||
sel.id = selid;
|
||||
sel.index = obj.index;
|
||||
sel.className = obj.className.replace(/cbi-input-text/, 'cbi-input-select');
|
||||
|
||||
if (obj.nextSibling) {
|
||||
obj.parentNode.insertBefore(sel, obj.nextSibling);
|
||||
} else {
|
||||
obj.parentNode.appendChild(sel);
|
||||
}
|
||||
|
||||
var dt = obj.getAttribute('cbi_datatype');
|
||||
var op = obj.getAttribute('cbi_optional');
|
||||
|
||||
if (!values[obj.value]) {
|
||||
if (obj.value != "") {
|
||||
var opt = document.createElement("option");
|
||||
opt.value = obj.value;
|
||||
opt.selected = "selected";
|
||||
opt.appendChild(document.createTextNode(obj.value));
|
||||
sel.appendChild(opt);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in values) {
|
||||
var opt = document.createElement("option");
|
||||
opt.value = i;
|
||||
|
||||
if (obj.value == i) {
|
||||
opt.selected = "selected";
|
||||
}
|
||||
|
||||
opt.appendChild(document.createTextNode(values[i]));
|
||||
sel.appendChild(opt);
|
||||
}
|
||||
|
||||
obj.style.display = "none";
|
||||
|
||||
if (dt)
|
||||
cbi_validate_field(sel, op == 'true', dt);
|
||||
|
||||
cbi_bind(sel, "change", function() {
|
||||
obj.value = sel.options[sel.selectedIndex].value;
|
||||
|
||||
try {
|
||||
cbi_d_update();
|
||||
} catch (e) {
|
||||
//Do nothing
|
||||
}
|
||||
})
|
||||
|
||||
// Retrigger validation in select
|
||||
if (focus !== false) {
|
||||
sel.focus();
|
||||
sel.blur();
|
||||
}
|
||||
};
|
||||
|
||||
var elements = {
|
||||
ss_redir: document.getElementById("_redir_status"),
|
||||
ss_http: document.getElementById("_http_status"),
|
||||
ss_socks: document.getElementById("_socks_status"),
|
||||
ss_tunnel: document.getElementById("_tunnel_status"),
|
||||
};
|
||||
XHR.poll(5, "<%=luci.dispatcher.build_url("admin", "services", "shadowsocks", "status")%>", null, function(xhr, status) {
|
||||
if (xhr.status === 200) {
|
||||
for (var k in elements) {
|
||||
if (elements[k]) {
|
||||
elements[k].textContent = status[k] ? "<%:RUNNING%>" : "<%:NOT RUNNING%>";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}());
|
||||
//]]></script>
|
||||
@@ -0,0 +1,9 @@
|
||||
<%+header%>
|
||||
<textarea
|
||||
style="background: #fafafa; color: #666; width: 100%;"
|
||||
readonly="readonly"
|
||||
wrap="off"
|
||||
rows="<%=content:cmatch("\n")+2%>">
|
||||
<%=content:pcdata()%>
|
||||
</textarea>
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,35 @@
|
||||
<%#
|
||||
Copyright (C) 2017-2018 Jian Chang <aa65535@live.com>
|
||||
Licensed to the public under the GNU General Public License v3.
|
||||
-%>
|
||||
|
||||
<% include("cbi/map") %>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
(function($) {
|
||||
var password = $("password");
|
||||
var key = $("key");
|
||||
var form = key.form;
|
||||
var checkCryptoConfig = function() {
|
||||
password.className = password.className.replace(/ cbi-input-invalid/g, "");
|
||||
key.className = key.className.replace(/ cbi-input-invalid/g, "");
|
||||
if (password.value.length == 0 && key.value.length == 0) {
|
||||
password.className += " cbi-input-invalid";
|
||||
key.className += " cbi-input-invalid";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
password.onkeyup = checkCryptoConfig;
|
||||
key.onkeyup = checkCryptoConfig;
|
||||
if (form) {
|
||||
if (!form.cbi_validators) {
|
||||
form.cbi_validators = [];
|
||||
}
|
||||
form.cbi_validators.push(checkCryptoConfig);
|
||||
}
|
||||
checkCryptoConfig();
|
||||
}(function(id) {
|
||||
return document.getElementById("cbid.<%=self.config%>.<%=self.sid%>." + id);
|
||||
}));
|
||||
//]]></script>
|
||||
@@ -0,0 +1,206 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "%u seconds"
|
||||
msgstr "%u 秒"
|
||||
|
||||
msgid "Access Control"
|
||||
msgstr "访问控制"
|
||||
|
||||
msgid "Alias"
|
||||
msgstr "别名"
|
||||
|
||||
msgid "Alias(optional)"
|
||||
msgstr "别名(可选)"
|
||||
|
||||
msgid "Bypassed IP List"
|
||||
msgstr "被忽略IP列表"
|
||||
|
||||
msgid "Bypassed IP"
|
||||
msgstr "额外被忽略IP"
|
||||
|
||||
msgid "ChinaDNS CHNRoute"
|
||||
msgstr "ChinaDNS路由表"
|
||||
|
||||
msgid "Connection Timeout"
|
||||
msgstr "连接超时"
|
||||
|
||||
msgid "Destination"
|
||||
msgstr "目标地址"
|
||||
|
||||
msgid "Direct"
|
||||
msgstr "直接连接"
|
||||
|
||||
msgid "Directly Key"
|
||||
msgstr "直接密钥"
|
||||
|
||||
msgid "Disable"
|
||||
msgstr "停用"
|
||||
|
||||
msgid "Disable DNS Auto-Injection"
|
||||
msgstr "停用DNS自动注入"
|
||||
|
||||
msgid "Disable HealthCheck"
|
||||
msgstr "停用健康检查"
|
||||
|
||||
msgid "Edit Server"
|
||||
msgstr "编辑服务器"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Encrypt Method"
|
||||
msgstr "加密方式"
|
||||
|
||||
msgid "Extra arguments"
|
||||
msgstr "附加参数"
|
||||
|
||||
msgid "Forwarded IP List"
|
||||
msgstr "走代理IP列表"
|
||||
|
||||
msgid "Forwarded IP"
|
||||
msgstr "强制走代理IP"
|
||||
|
||||
msgid "Global"
|
||||
msgstr "全局代理"
|
||||
|
||||
msgid "Global Settings"
|
||||
msgstr "全局设置"
|
||||
|
||||
msgid "Host"
|
||||
msgstr "主机"
|
||||
|
||||
msgid "HTTP Proxy"
|
||||
msgstr "HTTP代理"
|
||||
|
||||
msgid "LAN Hosts"
|
||||
msgstr "内网主机"
|
||||
|
||||
msgid "Local Port"
|
||||
msgstr "本地端口"
|
||||
|
||||
msgid "Main Server"
|
||||
msgstr "主服务器"
|
||||
|
||||
msgid "Maximum UDP Associations"
|
||||
msgstr "UDP协商数上限"
|
||||
|
||||
msgid "None"
|
||||
msgstr "无"
|
||||
|
||||
msgid "Normal"
|
||||
msgstr "正常代理"
|
||||
|
||||
msgid "Not enabled"
|
||||
msgstr "未启用"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "NULL - As Global Proxy"
|
||||
msgstr "留空 - 作为全局代理"
|
||||
|
||||
msgid "Passes additional arguments to iptables. Use with care!"
|
||||
msgstr "传递到iptables的额外参数。小心使用!"
|
||||
|
||||
msgid "Password"
|
||||
msgstr "密码"
|
||||
|
||||
msgid "Plugin"
|
||||
msgstr "插件"
|
||||
|
||||
msgid "Plugin Arguments"
|
||||
msgstr "插件参数"
|
||||
|
||||
msgid "Plugin Name"
|
||||
msgstr "插件名称"
|
||||
|
||||
msgid "Port Forward"
|
||||
msgstr "端口转发"
|
||||
|
||||
msgid "Proxy port numbers %s only"
|
||||
msgstr "仅代理 %s 端口"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "Running Status"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "Same as Main Server"
|
||||
msgstr "与主服务器相同"
|
||||
|
||||
msgid "Self Proxy"
|
||||
msgstr "代理自身"
|
||||
|
||||
msgid "Server"
|
||||
msgstr "服务器"
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr "服务器地址"
|
||||
|
||||
msgid "Servers Manage"
|
||||
msgstr "服务器管理"
|
||||
|
||||
msgid "Server Port"
|
||||
msgstr "服务器端口"
|
||||
|
||||
msgid "ShadowSocks"
|
||||
msgstr "影梭"
|
||||
|
||||
msgid "SOCKS5 Proxy"
|
||||
msgstr "SOCKS5代理"
|
||||
|
||||
msgid "Startup Delay"
|
||||
msgstr "自启动延时"
|
||||
|
||||
msgid "TCP Connection Timeout"
|
||||
msgstr "TCP 连接超时"
|
||||
|
||||
msgid "TCP Fast Open"
|
||||
msgstr "TCP快速打开"
|
||||
|
||||
msgid "TCP no-delay"
|
||||
msgstr "TCP无延时"
|
||||
|
||||
msgid "Transparent Proxy"
|
||||
msgstr "透明代理"
|
||||
|
||||
msgid "Timeout for UDP Associations"
|
||||
msgstr "UDP协商超时"
|
||||
|
||||
msgid "Proxy Type"
|
||||
msgstr "代理类型"
|
||||
|
||||
msgid "UDP-Relay Server"
|
||||
msgstr "UDP服务器"
|
||||
|
||||
msgid "Unlimited"
|
||||
msgstr "无限制"
|
||||
|
||||
msgid "Unusable - Missing iptables-mod-tproxy or ip"
|
||||
msgstr "不可用 - iptables-mod-tproxy 或 ip 缺失"
|
||||
|
||||
msgid "Zone LAN"
|
||||
msgstr "内网区域"
|
||||
|
||||
msgid "Zone WAN"
|
||||
msgstr "外网区域"
|
||||
|
||||
msgid "GFW-List"
|
||||
msgstr "GFW 列表"
|
||||
|
||||
msgid "Custom-List"
|
||||
msgstr "自定义列表"
|
||||
|
||||
msgid "Be Careful!"
|
||||
msgstr "注意"
|
||||
|
||||
msgid "TCP Weight"
|
||||
msgstr "TCP权重"
|
||||
|
||||
msgid "UDP Weight"
|
||||
msgstr "UDP权重"
|
||||
|
||||
msgid "Dnsmasq Config for Shadowsocks. This may CRASH DNSMASQ!"
|
||||
msgstr "自定义 DNSMASQ 的 Shadowsocks 列表, 这可能让DNSMASQ崩溃, 请参考以下的格式"
|
||||
+1
@@ -0,0 +1 @@
|
||||
zh-cn
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
config general
|
||||
option startup_delay '0'
|
||||
|
||||
config transparent_proxy
|
||||
list main_server 'nil'
|
||||
option udp_relay_server 'nil'
|
||||
option local_port '1234'
|
||||
|
||||
config http_proxy
|
||||
list server 'nil'
|
||||
option local_port '8080'
|
||||
|
||||
config socks_proxy
|
||||
list server 'nil'
|
||||
option local_port '1080'
|
||||
|
||||
config port_forward
|
||||
list server 'nil'
|
||||
option local_port '5300'
|
||||
option destination '8.8.4.4:53'
|
||||
|
||||
config servers
|
||||
option alias 'sample'
|
||||
option server '127.0.0.1'
|
||||
option server_port '8388'
|
||||
option timeout '60'
|
||||
option password 'barfoo!'
|
||||
option encrypt_method 'aes-256-gcm'
|
||||
|
||||
config access_control
|
||||
option self_proxy '1'
|
||||
+450
@@ -0,0 +1,450 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2014-2017 Jian Chang <aa65535@live.com>
|
||||
# 2018-2023 honwen <https://github.com/honwen>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
START=90
|
||||
STOP=15
|
||||
|
||||
NAME=shadowsocks
|
||||
EXTRA_COMMANDS="rules healthcheck"
|
||||
EXTRA_HELP=" rules Start IPTABLES inject\n healthcheck Check if service health"
|
||||
CRON_FILE=/etc/crontabs/root
|
||||
WATCHDOG_ENDPOINT='accounts.gstatic.com'
|
||||
# WATCHDOG_ENDPOINT='cp.cloudflare.com'
|
||||
|
||||
DNSMASQDIR=$(sed -n 's+conf-dir=++p' /var/etc/dnsmasq.conf.* 2>/dev/null)
|
||||
[ "V$DNSMASQDIR" = "V" ] && DNSMASQDIR=/var/dnsmasq.d
|
||||
|
||||
uci_get_by_name() {
|
||||
local ret=$(uci get $NAME.$1.$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get $NAME.@$1[0].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
uci_bool_by_name() {
|
||||
case "$(uci_get_by_name $1 $2)" in
|
||||
1 | on | true | yes | enabled) return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
uci_bool_by_type() {
|
||||
case "$(uci_get_by_type $1 $2)" in
|
||||
1 | on | true | yes | enabled) return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
validate_server() {
|
||||
[ "$(uci get $NAME.$1 2>/dev/null)" = "servers" ]
|
||||
}
|
||||
|
||||
has_valid_server() {
|
||||
for server in $@; do
|
||||
validate_server $server && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
get_arg_udp() {
|
||||
local server=$(uci_get_by_type transparent_proxy udp_relay_server)
|
||||
[ "$server" = "same" ] || validate_server $server && echo "-u"
|
||||
}
|
||||
|
||||
get_arg_out() {
|
||||
case "$(uci_get_by_type access_control self_proxy 1)" in
|
||||
1) echo "-o" ;;
|
||||
2) echo "-O" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_arg_tnd() {
|
||||
uci_bool_by_type $1 no_delay && echo "--tcp-no-delay"
|
||||
uci_bool_by_type $1 fast_open && echo "--tcp-fast-open"
|
||||
}
|
||||
|
||||
get_server_ips() {
|
||||
echo $(uci_get_by_name $1 server)
|
||||
}
|
||||
|
||||
get_lan_hosts() {
|
||||
uci_bool_by_name $1 enable &&
|
||||
echo "$(uci_get_by_name $1 type),$(uci_get_by_name $1 host)"
|
||||
}
|
||||
|
||||
get_plugin_config() {
|
||||
local plugin=$(uci_get_by_name $1 plugin)
|
||||
local plugin_opts=$(uci_get_by_name $1 plugin_opts)
|
||||
if [ -n "$plugin" ]; then
|
||||
echo $plugin >>/var/run/ss-plugin
|
||||
echo -e "\n \"plugin\": \"$plugin\","
|
||||
if [ -n "$plugin_opts" ]; then
|
||||
echo " \"plugin_opts\": \"$plugin_opts\","
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_crypto_config() {
|
||||
local key=$(uci_get_by_name $1 key)
|
||||
local password=$(uci_get_by_name $1 password)
|
||||
if [ -n "$key" ]; then
|
||||
echo "\"key\": \"$key\","
|
||||
elif [ -n "$password" ]; then
|
||||
echo "\"password\": \"$password\","
|
||||
else
|
||||
logger -st $NAME -p3 "The password or key is not set."
|
||||
fi
|
||||
}
|
||||
|
||||
get_mode_weight_config() {
|
||||
local tcp_weight=$(uci_get_by_name $1 tcp_weight 1)
|
||||
local udp_weight=$(uci_get_by_name $1 udp_weight 1)
|
||||
[ "V$tcp_weight" = "V0" -a "V$udp_weight" = "V0" ] && return # failsafe with no config
|
||||
echo
|
||||
if [ "V$tcp_weight" = "V0" ]; then
|
||||
echo " \"mode\": \"udp_only\","
|
||||
echo " \"udp_weight\": $udp_weight,"
|
||||
elif [ "V$udp_weight" = "V0" ]; then
|
||||
echo " \"mode\": \"tcp_only\","
|
||||
echo " \"tcp_weight\": $tcp_weight,"
|
||||
else
|
||||
echo " \"tcp_weight\": $tcp_weight,"
|
||||
echo " \"udp_weight\": $udp_weight,"
|
||||
fi
|
||||
}
|
||||
|
||||
get_udp_config() {
|
||||
udp_max_associations=$(uci_get_by_type general udp_max_associations 512)
|
||||
echo -e "\n \"udp_timeout\": $(uci_get_by_type general udp_timeout 300),"
|
||||
if [ $udp_max_associations -gt 0 ]; then
|
||||
echo " \"udp_max_associations\": ${udp_max_associations},"
|
||||
fi
|
||||
}
|
||||
|
||||
gen_server_config() {
|
||||
validate_server $1 && cat <<-EOF
|
||||
{
|
||||
"address": "$(uci_get_by_name $1 server)",
|
||||
"port": $(uci_get_by_name $1 server_port),
|
||||
"method": "$(uci_get_by_name $1 encrypt_method)",
|
||||
$(get_crypto_config $1)$(get_plugin_config $1)$(get_mode_weight_config $1)
|
||||
"timeout": $(uci_get_by_name $1 timeout 60)
|
||||
},
|
||||
EOF
|
||||
}
|
||||
|
||||
gen_config_file() {
|
||||
local config_file=/var/etc/$NAME.$2.json
|
||||
local protocol=$2
|
||||
local mode='tcp_and_udp'
|
||||
case "$protocol" in
|
||||
http) mode='tcp_only' ;;
|
||||
redir) mode='tcp_only' ;;
|
||||
redir-U) protocol='redir' ;;
|
||||
redir-u)
|
||||
protocol='redir'
|
||||
mode='udp_only'
|
||||
;;
|
||||
esac
|
||||
|
||||
cat <<-EOF | sed 's+},__$+}+g' >$config_file
|
||||
{
|
||||
"servers": [
|
||||
$(for server in $1; do gen_server_config $server; done)__
|
||||
],
|
||||
"locals": [{
|
||||
"mode": "$mode",
|
||||
"protocol": "$protocol",
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": $3
|
||||
}],$(get_udp_config)
|
||||
"outbound_fwmark": 255,
|
||||
"nofile": 51200
|
||||
}
|
||||
EOF
|
||||
echo $config_file
|
||||
}
|
||||
|
||||
ss_cleandns() {
|
||||
uci_bool_by_type general no_dns_injection && return 0
|
||||
|
||||
rm -f $DNSMASQDIR/ss.conf $DNSMASQDIR/ss-servers.conf 2>/dev/null
|
||||
([ -x /etc/init.d/dnsmasq-extra ] && /etc/init.d/dnsmasq reload || /etc/init.d/dnsmasq restart) >/dev/null 2>&1
|
||||
}
|
||||
|
||||
ss_injectdns() {
|
||||
uci_bool_by_type general no_dns_injection && return 0
|
||||
|
||||
echo >&2 "# Info: $NAME dnsmasq injecting..."
|
||||
|
||||
mkdir -p $DNSMASQDIR
|
||||
DNSconf=$DNSMASQDIR/ss-servers.conf
|
||||
tmpDNSconf=$DNSMASQDIR/ss.conf
|
||||
echo "all-servers" >$tmpDNSconf
|
||||
config_load $NAME
|
||||
for server in $(config_foreach get_server_ips servers | sort -u | grep -v '[0-9]$'); do
|
||||
cat <<-EOF >>$tmpDNSconf
|
||||
ipset=/${server}/ss_spec_dst_sp
|
||||
server=/${server}/#
|
||||
server=/${server}/223.5.5.5
|
||||
server=/${server}/119.29.29.29
|
||||
server=/${server}/114.114.114.114
|
||||
server=/${server}/80.80.80.80
|
||||
server=/${server}/208.67.222.222#443
|
||||
server=/${server}/208.67.220.220#5353
|
||||
EOF
|
||||
done
|
||||
|
||||
(grep -q 'no-resolv' /etc/dnsmasq.conf /etc/dnsmasq.d/* /var/dnsmasq.d/* /var/etc/dnsmasq.conf.* 2 >/dev/null) &&
|
||||
sed "/\/#$/d" -i $tmpDNSconf
|
||||
sort -u $tmpDNSconf | sed '/\/\//d; /\/127.0.0.1\//d' >$DNSconf
|
||||
rm -f $tmpDNSconf
|
||||
|
||||
echo "server=/${WATCHDOG_ENDPOINT}/127.0.0.1#$(uci_get_by_type port_forward local_port 5300)" >>$DNSconf
|
||||
[ -x /etc/init.d/dnsmasq-extra ] || {
|
||||
echo "server=/${WATCHDOG_ENDPOINT}/208.67.222.222#443" >>$DNSconf
|
||||
echo "server=/${WATCHDOG_ENDPOINT}/114.114.115.115" >>$DNSconf
|
||||
echo "server=/${WATCHDOG_ENDPOINT}/80.80.80.80" >>$DNSconf
|
||||
}
|
||||
|
||||
DNSPROBE_DOMAIN='t.cn'
|
||||
cat <<-EOF >>$DNSconf
|
||||
server=/$DNSPROBE_DOMAIN/223.5.5.5
|
||||
server=/$DNSPROBE_DOMAIN/119.29.29.29
|
||||
server=/$DNSPROBE_DOMAIN/114.114.114.114
|
||||
EOF
|
||||
|
||||
/etc/init.d/dnsmasq reload >/dev/null 2>&1
|
||||
# wait-for-dns, timeout 10s
|
||||
if which wait4x >/dev/null 2>&1; then # use [wait4x]
|
||||
wait4x http http://$DNSPROBE_DOMAIN --no-redirect -q
|
||||
elif which wait-for >/dev/null 2>&1; then # use [wait-for]
|
||||
wait-for -t=10s http --url=http://$DNSPROBE_DOMAIN >/dev/null 2>&1
|
||||
else # use [ping]
|
||||
for _ in $(seq 10); do if ping -4 -q -c 1 -s 0 -W 1 -w 1 $DNSPROBE_DOMAIN >/dev/null 2>&1; then break; fi; done
|
||||
fi
|
||||
echo >&2 "# Info: $NAME dnsmasq injected."
|
||||
}
|
||||
|
||||
start_rules() {
|
||||
config_load $NAME
|
||||
/usr/bin/ss-rules \
|
||||
-s "$(config_foreach get_server_ips servers | sort -u)" \
|
||||
-l "$(uci_get_by_type transparent_proxy local_port 1234)" \
|
||||
-B "$(uci_get_by_type access_control wan_bp_list)" \
|
||||
-b "$(uci_get_by_type access_control wan_bp_ips)" \
|
||||
-W "$(uci_get_by_type access_control wan_fw_list)" \
|
||||
-w "$(uci_get_by_type access_control wan_fw_ips)" \
|
||||
-I "$(uci_get_by_type access_control lan_ifaces)" \
|
||||
-d "$(uci_get_by_type access_control lan_target)" \
|
||||
-a "$(config_foreach get_lan_hosts lan_hosts)" \
|
||||
-e "$(uci_get_by_type access_control ipt_ext)" \
|
||||
$(get_arg_out) $(get_arg_udp)
|
||||
}
|
||||
|
||||
rules() {
|
||||
pidof sslocal >/dev/null || return 0
|
||||
start_rules || /usr/bin/ss-rules -f
|
||||
}
|
||||
|
||||
start_redir() {
|
||||
has_valid_server $1 || return 0
|
||||
cd /var/run/ssservice
|
||||
sslocal -d $(get_arg_tnd transparent_proxy) \
|
||||
-c=$(gen_config_file "$1" "redir$2" $(uci_get_by_type transparent_proxy local_port 1234)) \
|
||||
--daemonize-pid=/var/run/ss-redir$2.pid
|
||||
cd - >/dev/null
|
||||
for _ in $(seq 10); do if pgrep -f sslocal >/dev/null; then break; else sleep 1; fi; done
|
||||
}
|
||||
|
||||
ss_redir() {
|
||||
command -v sslocal >/dev/null 2>&1 || return 1
|
||||
local main_server=$(uci_get_by_type transparent_proxy main_server)
|
||||
has_valid_server "$main_server" || return 1
|
||||
local udp_relay_server=$(uci_get_by_type transparent_proxy udp_relay_server)
|
||||
if [ "$udp_relay_server" = "same" ]; then
|
||||
start_redir "$main_server" -U
|
||||
else
|
||||
start_redir "$main_server"
|
||||
start_redir "$udp_relay_server" -u
|
||||
fi
|
||||
}
|
||||
|
||||
start_local() {
|
||||
has_valid_server $1 || return 0
|
||||
cd /var/run/ssservice
|
||||
sslocal -d $(get_arg_tnd ${2}_proxy) \
|
||||
-c=$(gen_config_file "$1" "$2" $(uci_get_by_type ${2}_proxy local_port 1080)) \
|
||||
--daemonize-pid=/var/run/ss-local-$2.pid
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
ss_local() {
|
||||
command -v sslocal >/dev/null 2>&1 || return 0
|
||||
start_local "$(uci_get_by_type http_proxy server)" "http"
|
||||
start_local "$(uci_get_by_type socks_proxy server)" "socks"
|
||||
}
|
||||
|
||||
start_tunnel() {
|
||||
has_valid_server $1 || return 0
|
||||
cd /var/run/ssservice
|
||||
local config=$(gen_config_file "$1" "tunnel" $(uci_get_by_type port_forward local_port 5300))
|
||||
uci_get_by_type port_forward destination '8.8.4.4:53' | sed 's+:+ +g' | while read addr port; do
|
||||
sed -i $config \
|
||||
-e "/local_address/i\ \"forward_address\": \"$addr\"," \
|
||||
-e "/local_address/i\ \"forward_port\": $port,"
|
||||
done
|
||||
sslocal -d $(get_arg_tnd port_forward) \
|
||||
-c=$config --daemonize-pid=/var/run/ss-tunnel.pid
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
ss_tunnel() {
|
||||
command -v sslocal >/dev/null 2>&1 || return 0
|
||||
start_tunnel "$(uci_get_by_type port_forward server)"
|
||||
}
|
||||
|
||||
start() {
|
||||
pidof sslocal >/dev/null && return 0
|
||||
mkdir -p /var/run/ssservice /var/etc
|
||||
local t0=$(date '+%s')
|
||||
echo >&2 "# Info: starting..."
|
||||
|
||||
has_valid_server $(uci_get_by_type transparent_proxy main_server) && ss_injectdns
|
||||
ss_redir && rules
|
||||
ss_local
|
||||
ss_tunnel
|
||||
has_valid_server $(uci_get_by_type transparent_proxy main_server) && add_cron
|
||||
echo >&2 "# Info: started. CostTime: $(($(date '+%s') - $t0))s"
|
||||
}
|
||||
|
||||
boot() {
|
||||
echo 'exit 0' >/var/etc/$NAME.include
|
||||
sysctl -w net.ipv4.tcp_fastopen=3
|
||||
local delay=$(uci_get_by_type general startup_delay 0)
|
||||
(sleep $delay && start >/dev/null 2>&1) &
|
||||
return 0
|
||||
}
|
||||
|
||||
kill_all() {
|
||||
for it in $@; do
|
||||
kill -9 $(pgrep -f $it) >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
|
||||
stop() {
|
||||
/usr/bin/ss-rules -f
|
||||
kill_all sslocal
|
||||
if [ -f /var/run/ss-plugin ]; then
|
||||
kill_all $(sort -u /var/run/ss-plugin)
|
||||
rm -f /var/run/ss-plugin
|
||||
fi
|
||||
rm -rf /var/run/ssservice
|
||||
ss_cleandns
|
||||
del_cron
|
||||
}
|
||||
|
||||
add_cron() {
|
||||
[ -f $CRON_FILE ] || return 0
|
||||
uci_bool_by_type transparent_proxy no_healthcheck && return 0
|
||||
|
||||
sed -i '/shadowsocks_healthcheck/d' $CRON_FILE
|
||||
echo '0 */3 * * * rm -f /var/log/shadowsocks_healthcheck.log 2>&1' >>$CRON_FILE
|
||||
echo '* * * * * /etc/init.d/shadowsocks healthcheck >> /var/log/shadowsocks_healthcheck.log 2>&1' >>$CRON_FILE
|
||||
/etc/init.d/cron restart
|
||||
}
|
||||
|
||||
del_cron() {
|
||||
[ -f $CRON_FILE ] || return 0
|
||||
uci_bool_by_type transparent_proxy no_healthcheck && return 0
|
||||
|
||||
sed -i '/shadowsocks_healthcheck/d' $CRON_FILE
|
||||
/etc/init.d/cron restart
|
||||
}
|
||||
|
||||
healthcheck() {
|
||||
command -v sslocal >/dev/null 2>&1 || return 1
|
||||
has_valid_server $(uci_get_by_type transparent_proxy main_server) || return 1
|
||||
uci_bool_by_type transparent_proxy no_healthcheck && return 0
|
||||
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
pgrep -f "sslocal" >/dev/null 2>&1 || {
|
||||
echo "[${LOGTIME}] Problem decteted, restarting ${NAME}..."
|
||||
stop >/dev/null 2>&1
|
||||
start >/dev/null 2>&1
|
||||
return 0
|
||||
}
|
||||
iptables -n -t nat -L PREROUTING | grep -q '_SPEC_LAN_DG' || {
|
||||
echo "[${LOGTIME}] Problem decteted, restarting ${NAME}..."
|
||||
stop >/dev/null 2>&1
|
||||
start >/dev/null 2>&1
|
||||
return 0
|
||||
}
|
||||
|
||||
cat_connect() {
|
||||
target="$1"
|
||||
retry=${2:-1}
|
||||
timeout=5
|
||||
[ $retry -lt 1 ] && return 1
|
||||
if which wait4x >/dev/null 2>&1; then # use [wait4x]
|
||||
wait4x http $target || cat_connect $target $((retry - 1))
|
||||
elif which wait-for >/dev/null 2>&1; then # use [wait-for]
|
||||
wait-for -t=10s http --url=$target >/dev/null 2>&1 || cat_connect $target $((retry - 1))
|
||||
else # use [curl]
|
||||
ret_code=$(curl -s --connect-timeout $timeout "$target" -w %{http_code} -o /dev/null | tail -n1)
|
||||
# echo -n "[ $retry $ret_code ] "
|
||||
[ "x$ret_code" = "x200" -o "x$ret_code" = "x204" ] && return 0 || sleep 1 && cat_connect $target $((retry - 1))
|
||||
fi
|
||||
}
|
||||
|
||||
TRPORT=$(uci_get_by_type transparent_proxy local_port 1234)
|
||||
GOOGLE=$(ping -4 -q -c 1 -s 0 -W 1 -w 1 ${WATCHDOG_ENDPOINT} 2>/dev/null | sed '1{s/[^(]*(//;s/).*//;q}')
|
||||
DNSPOD=119.29.29.98 #DNSPOD HTTPDNS (Inside GFW)
|
||||
|
||||
if [ "Z$GOOGLE" = "Z" ]; then
|
||||
iptables -t nat -I OUTPUT -p tcp -d $DNSPOD -j RETURN
|
||||
cat_connect "http://${DNSPOD}/d"
|
||||
if [ "Z$?" = "Z0" ]; then
|
||||
echo "[${LOGTIME}] Problem-DNS decteted, restarting ${NAME}..."
|
||||
[ -x /etc/init.d/dnsmasq-extra ] && /etc/init.d/dnsmasq-extra restart || /etc/init.d/dnsmasq restart
|
||||
stop >/dev/null 2>&1
|
||||
start >/dev/null 2>&1
|
||||
else
|
||||
echo '['$LOGTIME'] Network Problem. Do nothing.'
|
||||
fi
|
||||
iptables -t nat -D OUTPUT -p tcp -d $DNSPOD -j RETURN
|
||||
return 0
|
||||
fi
|
||||
|
||||
iptables -t nat -I OUTPUT -p tcp -d $GOOGLE -j REDIRECT --to-port $TRPORT
|
||||
iptables -t nat -I OUTPUT -p tcp -d $DNSPOD -j RETURN
|
||||
cat_connect "http://${GOOGLE}/generate_204" 3
|
||||
if [ "Z$?" = "Z0" ]; then
|
||||
echo "[${LOGTIME}] ${NAME} No Problem."
|
||||
else
|
||||
# cat_connect "http://wifi.vivo.com.cn/generate_204"
|
||||
# cat_connect "http://www.qualcomm.cn/generate_204"
|
||||
cat_connect "http://${DNSPOD}/d"
|
||||
if [ "Z$?" = "Z0" ]; then
|
||||
echo "[${LOGTIME}] Problem decteted, restarting ${NAME}..."
|
||||
[ -x /etc/init.d/haproxy-tcp ] && /etc/init.d/haproxy-tcp restart
|
||||
stop >/dev/null 2>&1
|
||||
start >/dev/null 2>&1
|
||||
else
|
||||
echo '['$LOGTIME'] Network Problem. Do nothing.'
|
||||
fi
|
||||
fi
|
||||
|
||||
iptables -t nat -D OUTPUT -p tcp -d $GOOGLE -j REDIRECT --to-port $TRPORT
|
||||
iptables -t nat -D OUTPUT -p tcp -d $DNSPOD -j RETURN
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-shadowsocks.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-shadowsocks.json << EEOF
|
||||
{
|
||||
"config": "shadowsocks",
|
||||
"init": "shadowsocks"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
uci get shadowsocks.@general[-1] >/dev/null 2>&1 || \
|
||||
uci add shadowsocks general >/dev/null 2>&1
|
||||
uci get shadowsocks.@transparent_proxy[-1] >/dev/null 2>&1 || \
|
||||
uci add shadowsocks transparent_proxy >/dev/null 2>&1
|
||||
uci get shadowsocks.@http_proxy[-1] >/dev/null 2>&1 || \
|
||||
uci add shadowsocks http_proxy >/dev/null 2>&1
|
||||
uci get shadowsocks.@socks_proxy[-1] >/dev/null 2>&1 || \
|
||||
uci add shadowsocks socks_proxy >/dev/null 2>&1
|
||||
uci get shadowsocks.@port_forward[-1] >/dev/null 2>&1 || \
|
||||
uci add shadowsocks port_forward >/dev/null 2>&1
|
||||
uci get shadowsocks.@access_control[-1] >/dev/null 2>&1 || \
|
||||
uci add shadowsocks access_control >/dev/null 2>&1
|
||||
uci commit shadowsocks
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@shadowsocks[-1]
|
||||
add ucitrack shadowsocks
|
||||
set ucitrack.@shadowsocks[-1].init=shadowsocks
|
||||
commit ucitrack
|
||||
delete firewall.shadowsocks
|
||||
set firewall.shadowsocks=include
|
||||
set firewall.shadowsocks.type=script
|
||||
set firewall.shadowsocks.path=/var/etc/shadowsocks.include
|
||||
set firewall.shadowsocks.reload=1
|
||||
commit firewall
|
||||
EOF
|
||||
sysctl -w net.ipv4.tcp_fastopen=3
|
||||
exit 0
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2014-2017 Jian Chang <aa65535@live.com>
|
||||
# 2017-2020 honwen https://github.com/honwen
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
usage() {
|
||||
cat <<-EOF
|
||||
Usage: ss-rules [options]
|
||||
|
||||
Valid options are:
|
||||
|
||||
-s <server_ips> ip address of shadowsocks remote server
|
||||
-l <local_port> port number of shadowsocks local server
|
||||
-S <server_ips> ip address of shadowsocks remote UDP server
|
||||
-L <local_port> port number of shadowsocks local UDP server
|
||||
-B <ip_list_file> a file whose content is bypassed ip list
|
||||
-b <wan_ips> wan ip of will be bypassed
|
||||
-W <ip_list_file> a file whose content is forwarded ip list
|
||||
-w <wan_ips> wan ip of will be forwarded
|
||||
-I <interface> proxy only for the given interface
|
||||
-d <target> the default target of lan access control
|
||||
-a <lan_hosts> lan ip of access control, need a prefix to
|
||||
define proxy type
|
||||
-e <extra_args> extra arguments for iptables
|
||||
-o apply the rules to the OUTPUT chain
|
||||
-O apply the global rules to the OUTPUT chain
|
||||
-u enable udprelay mode, TPROXY is required
|
||||
-U enable udprelay mode, using different IP
|
||||
and ports for TCP and UDP
|
||||
-f flush the rules
|
||||
-h show this help message and exit
|
||||
EOF
|
||||
exit $1
|
||||
}
|
||||
|
||||
loger() {
|
||||
# 1.alert 2.crit 3.err 4.warn 5.notice 6.info 7.debug
|
||||
logger -st ss-rules[$$] -p$1 $2
|
||||
}
|
||||
|
||||
fw_reinit() {
|
||||
uci -q show firewall | sed -n 's/.*path=//p' | sed -n '/adbyby\|koolproxy\|dnsmasq/p' | tr -d \' | while read init; do
|
||||
sh $init restart >/dev/null 2>&1
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
flush_rules() {
|
||||
iptables-save -c | grep -v "SS_SPEC" | sed '/[^ ]--/d' | uniq | iptables-restore -w -c
|
||||
uci -q show firewall | sed -n 's/.*path=//p' | sed -n '/gargoyle/p' | tr -d \' | while read init; do
|
||||
sh $init restart >/dev/null 2>&1
|
||||
done
|
||||
|
||||
if command -v ip >/dev/null 2>&1; then
|
||||
ip rule del fwmark 1 lookup 100 2>/dev/null
|
||||
ip route del local default dev lo table 100 2>/dev/null
|
||||
fi
|
||||
for setname in $(ipset -n list | grep "ss_spec"); do
|
||||
ipset destroy $setname 2>/dev/null
|
||||
done
|
||||
FWI=$(uci get firewall.shadowsocks.path 2>/dev/null)
|
||||
[ -n "$FWI" ] && echo '# firewall include file' >$FWI
|
||||
return 0
|
||||
}
|
||||
|
||||
ipset_init() {
|
||||
ipset -! restore <<-EOF || return 1
|
||||
create ss_spec_src_ac hash:ip hashsize 64
|
||||
create ss_spec_src_bp hash:ip hashsize 64
|
||||
create ss_spec_src_fw hash:ip hashsize 64
|
||||
create ss_spec_dst_sp hash:net hashsize 64
|
||||
create ss_spec_dst_bp hash:net hashsize 64
|
||||
create ss_spec_dst_fw hash:net hashsize 64
|
||||
$(gen_lan_host_ipset_entry)
|
||||
$(gen_special_purpose_ip | sed -e "s/^/add ss_spec_dst_sp /")
|
||||
$(sed -e "s/^/add ss_spec_dst_bp /" ${WAN_BP_LIST:=/dev/null} 2>/dev/null)
|
||||
$(for ip in $WAN_BP_IP; do echo "add ss_spec_dst_bp $ip"; done)
|
||||
$(sed -e "s/^/add ss_spec_dst_fw /" ${WAN_FW_LIST:=/dev/null} 2>/dev/null)
|
||||
$(for ip in $WAN_FW_IP; do echo "add ss_spec_dst_fw $ip"; done)
|
||||
EOF
|
||||
return 0
|
||||
}
|
||||
|
||||
ipt_nat() {
|
||||
include_ac_rules nat
|
||||
ipt="iptables -w -t nat"
|
||||
$ipt -A SS_SPEC_WAN_FW -p tcp \
|
||||
-j REDIRECT --to-ports $local_port || return 1
|
||||
if [ -n "$OUTPUT" ]; then
|
||||
$ipt -N SS_SPEC_WAN_DG
|
||||
$ipt -A SS_SPEC_WAN_DG -m mark --mark 0xff -j RETURN
|
||||
$ipt -A SS_SPEC_WAN_DG -m set --match-set ss_spec_dst_sp dst -j RETURN
|
||||
$ipt -A SS_SPEC_WAN_DG -p tcp $EXT_ARGS -j $OUTPUT
|
||||
$ipt -I OUTPUT 1 -p tcp -j SS_SPEC_WAN_DG
|
||||
fi
|
||||
return $?
|
||||
}
|
||||
|
||||
ipt_mangle() {
|
||||
[ -n "$TPROXY" ] || return 0
|
||||
if !(lsmod | grep -q TPROXY && command -v ip >/dev/null); then
|
||||
loger 4 "TPROXY or ip not found."
|
||||
return 0
|
||||
fi
|
||||
ip rule add fwmark 1 lookup 100
|
||||
ip route add local default dev lo table 100
|
||||
include_ac_rules mangle
|
||||
iptables -w -t mangle -A SS_SPEC_WAN_FW -p udp \
|
||||
-j TPROXY --on-port $LOCAL_PORT --tproxy-mark 0x01/0x01
|
||||
return $?
|
||||
}
|
||||
|
||||
export_ipt_rules() {
|
||||
[ -n "$FWI" ] || return 0
|
||||
cat <<-CAT >>$FWI
|
||||
iptables-save -c | grep -v "SS_SPEC" | sed '/[^ ]--/d' | uniq | iptables-restore -w -c
|
||||
|
||||
iptables-restore -w -n <<-EOF
|
||||
$(iptables-save | grep -E "SS_SPEC|^\*|^COMMIT" |\
|
||||
sed -e "s/^-A \(OUTPUT\|PREROUTING\)/-I \1 1/")
|
||||
EOF
|
||||
|
||||
uci -q show firewall | sed -n 's/.*path=//p' | sed -n '/gargoyle\|adbyby\|koolproxy\|dnsmasq/p' | tr -d \' | while read init; do
|
||||
sh \$init restart >/dev/null 2>&1
|
||||
done
|
||||
return 0
|
||||
CAT
|
||||
return $?
|
||||
}
|
||||
|
||||
gen_lan_host_ipset_entry() {
|
||||
for host in $LAN_HOSTS; do
|
||||
case "${host:0:1}" in
|
||||
b|B)
|
||||
echo add ss_spec_src_bp ${host:2}
|
||||
;;
|
||||
g|G)
|
||||
echo add ss_spec_src_fw ${host:2}
|
||||
;;
|
||||
n|N)
|
||||
echo add ss_spec_src_ac ${host:2}
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
gen_special_purpose_ip() {
|
||||
cat <<-EOF | grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}"
|
||||
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.31.196.0/24
|
||||
192.52.193.0/24
|
||||
192.88.99.0/24
|
||||
192.168.0.0/16
|
||||
192.175.48.0/24
|
||||
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
|
||||
$server
|
||||
$SERVER
|
||||
EOF
|
||||
}
|
||||
|
||||
include_ac_rules() {
|
||||
ipt_chain=$1
|
||||
local protocol=$([ "$1" = "mangle" ] && echo udp || echo tcp)
|
||||
iptables-restore -w -n <<-EOF
|
||||
*$1
|
||||
:SS_SPEC_LAN_DG - [0:0]
|
||||
:SS_SPEC_LAN_AC - [0:0]
|
||||
:SS_SPEC_WAN_AC - [0:0]
|
||||
:SS_SPEC_WAN_FW - [0:0]
|
||||
-A SS_SPEC_LAN_DG -m set --match-set ss_spec_dst_sp dst -j RETURN
|
||||
-A SS_SPEC_LAN_DG -p $protocol $EXT_ARGS -j SS_SPEC_LAN_AC
|
||||
-A SS_SPEC_LAN_AC -m set --match-set ss_spec_src_bp src -j RETURN
|
||||
-A SS_SPEC_LAN_AC -m set --match-set ss_spec_src_fw src -j SS_SPEC_WAN_FW
|
||||
-A SS_SPEC_LAN_AC -m set --match-set ss_spec_src_ac src -j SS_SPEC_WAN_AC
|
||||
-A SS_SPEC_LAN_AC -j ${LAN_TARGET:=SS_SPEC_WAN_AC}
|
||||
-A SS_SPEC_WAN_AC -m set --match-set ss_spec_dst_fw dst -j SS_SPEC_WAN_FW
|
||||
-A SS_SPEC_WAN_AC -m set --match-set ss_spec_dst_bp dst -j RETURN
|
||||
-A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW
|
||||
$(gen_prerouting_rules $protocol)
|
||||
COMMIT
|
||||
EOF
|
||||
if [ "Z${WAN_BP_LIST}" = "Z/dev/flag_gfwlist" ]; then
|
||||
[ $(ipset list -n | grep -c gfwlist) -lt 1 ] && /etc/init.d/dnsmasq-extra restart
|
||||
idx=$(($(iptables -w -t $ipt_chain -L SS_SPEC_WAN_AC | grep all | sed -n -e '/ss_spec_dst_bp/=') +1))
|
||||
iptables -w -t $ipt_chain -I SS_SPEC_WAN_AC $idx -m set ! --match-set gfwlist dst -j RETURN
|
||||
fi
|
||||
}
|
||||
|
||||
gen_prerouting_rules() {
|
||||
[ -z "$IFNAMES" ] && echo -I PREROUTING 1 -p $1 -j SS_SPEC_LAN_DG
|
||||
for ifname in $IFNAMES; do
|
||||
echo -I PREROUTING 1 -i $ifname -p $1 -j SS_SPEC_LAN_DG
|
||||
done
|
||||
}
|
||||
|
||||
resolveip() {
|
||||
ping -q -c 1 -s 0 -W 1 -w 1 $1 2>/dev/null | sed '1{s/[^(]*(//; s/).*//;q}' | sed 's/[^(]*(//; s/).*//'
|
||||
}
|
||||
|
||||
while getopts ":s:l:S:L:B:b:W:w:I:d:a:e:oOuUfh" arg; do
|
||||
case "$arg" in
|
||||
s)
|
||||
server=$(for it in $(echo -n $OPTARG | tr ' ' '\n' | sort -u); do resolveip $it; done)
|
||||
;;
|
||||
l)
|
||||
local_port=$OPTARG
|
||||
;;
|
||||
S)
|
||||
SERVER=$(for it in $(echo -n $OPTARG | tr ' ' '\n' | sort -u); do resolveip $it; done)
|
||||
;;
|
||||
L)
|
||||
LOCAL_PORT=$OPTARG
|
||||
;;
|
||||
B)
|
||||
WAN_BP_LIST=$OPTARG
|
||||
;;
|
||||
b)
|
||||
WAN_BP_IP=$OPTARG
|
||||
;;
|
||||
W)
|
||||
WAN_FW_LIST=$OPTARG
|
||||
;;
|
||||
w)
|
||||
WAN_FW_IP=$OPTARG
|
||||
;;
|
||||
I)
|
||||
IFNAMES=$OPTARG
|
||||
;;
|
||||
d)
|
||||
LAN_TARGET=$OPTARG
|
||||
;;
|
||||
a)
|
||||
LAN_HOSTS=$OPTARG
|
||||
;;
|
||||
e)
|
||||
EXT_ARGS=$OPTARG
|
||||
;;
|
||||
o)
|
||||
OUTPUT=SS_SPEC_WAN_AC
|
||||
;;
|
||||
O)
|
||||
OUTPUT=SS_SPEC_WAN_FW
|
||||
;;
|
||||
u)
|
||||
TPROXY=1
|
||||
;;
|
||||
U)
|
||||
TPROXY=2
|
||||
;;
|
||||
f)
|
||||
flush_rules
|
||||
exit 0
|
||||
;;
|
||||
h)
|
||||
usage 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -z "$server" -o -z "$local_port" ] && usage 2
|
||||
|
||||
if [ "$TPROXY" = 1 ]; then
|
||||
unset SERVER
|
||||
LOCAL_PORT=$local_port
|
||||
elif [ "$TPROXY" = 2 ]; then
|
||||
: ${SERVER:?"You must assign an ip for the udp relay server."}
|
||||
: ${LOCAL_PORT:?"You must assign a port for the udp relay server."}
|
||||
fi
|
||||
|
||||
flush_rules && ipset_init && ipt_nat && ipt_mangle && fw_reinit && export_ipt_rules
|
||||
RET=$?
|
||||
[ "$RET" = 0 ] || loger 3 "Start failed!"
|
||||
exit $RET
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-shadowsocks": {
|
||||
"description": "Grant UCI access for luci-app-shadowsocks",
|
||||
"read": {
|
||||
"uci": [ "shadowsocks" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "shadowsocks" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"config": "shadowsocks",
|
||||
"init": "shadowsocks"
|
||||
}
|
||||
Reference in new issue
Block a user