mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-09-29 22:52:11 +08:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
40fba0d348 | ||
![]() |
73941d1e0b | ||
![]() |
709c2c6ac7 | ||
![]() |
f96bc11ddb | ||
![]() |
5563ddc0d2 | ||
![]() |
95657bd6df | ||
![]() |
b9e19e75c8 | ||
![]() |
eac623639d | ||
![]() |
fea6e98ca7 | ||
![]() |
649a5b558a | ||
![]() |
b3c8d35fad | ||
![]() |
ab745145d9 | ||
![]() |
a1bdc8528b |
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
@@ -5,10 +5,10 @@ ListenAddr = ":8080"
|
|||||||
[Plugins.RTMP]
|
[Plugins.RTMP]
|
||||||
ListenAddr = ":1935"
|
ListenAddr = ":1935"
|
||||||
[Plugins.GateWay]
|
[Plugins.GateWay]
|
||||||
ListenAddr = ":81"
|
ListenAddr = ":8081"
|
||||||
#[Plugins.Cluster]
|
[Plugins.Cluster]
|
||||||
#Master = "localhost:2019"
|
#Master = "localhost:2019"
|
||||||
#ListenAddr = ":2019"
|
ListenAddr = ":2019"
|
||||||
#
|
#
|
||||||
#[Plugins.Auth]
|
#[Plugins.Auth]
|
||||||
#Key="www.monibuca.com"
|
#Key="www.monibuca.com"
|
||||||
|
@@ -1 +1 @@
|
|||||||
#app,body,html{height:100%}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#184c18;position:relative}#app>div:first-child{position:absolute;top:10px;left:30px;font-size:x-large}.content{padding-top:60px}.feature-title[data-v-54efad41]{color:#eb5e46;font-weight:700;font-size:larger}p[data-v-54efad41]{margin:30px;font-size:20px}img[data-v-54efad41]{margin:20px}.root[data-v-e34eab40]{background:#d3d3d3}.root>img[data-v-e34eab40]{width:300px;margin:30px}.records[data-v-4eee1624]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;padding:0 15px}.records>[data-v-4eee1624]{width:200px}.log-container{overflow-y:auto;max-height:500px}@-webkit-keyframes recording-data-v-f6113870{0%{opacity:.2}50%{opacity:1}to{opacity:.2}}@keyframes recording-data-v-f6113870{0%{opacity:.2}50%{opacity:1}to{opacity:.2}}.recording[data-v-f6113870]{-webkit-animation:recording-data-v-f6113870 1s infinite;animation:recording-data-v-f6113870 1s infinite}.layout[data-v-f6113870]{padding-bottom:30px;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.room[data-v-f6113870]{width:250px;margin:10px;text-align:left}.empty[data-v-f6113870]{color:#eb5e46;width:100%;min-height:500px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.empty[data-v-f6113870],.status[data-v-f6113870]{display:-webkit-box;display:-ms-flexbox;display:flex}.status[data-v-f6113870]{position:fixed;left:5px;bottom:10px}.status>div[data-v-f6113870]{margin:0 5px}
|
#app,body,html{height:100%}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#184c18;position:relative}#app>div:first-child{position:absolute;top:10px;left:30px;font-size:x-large}.content{padding-top:60px}.feature-title[data-v-54efad41]{color:#eb5e46;font-weight:700;font-size:larger}p[data-v-54efad41]{margin:30px;font-size:20px}img[data-v-54efad41]{margin:20px}.root[data-v-e34eab40]{background:#d3d3d3}.root>img[data-v-e34eab40]{width:300px;margin:30px}.records[data-v-7d5ab110]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;padding:0 15px}.records>[data-v-7d5ab110]{width:200px}.log-container{overflow-y:auto;max-height:500px}@-webkit-keyframes recording-data-v-65ac4b48{0%{opacity:.2}50%{opacity:1}to{opacity:.2}}@keyframes recording-data-v-65ac4b48{0%{opacity:.2}50%{opacity:1}to{opacity:.2}}.recording[data-v-65ac4b48]{-webkit-animation:recording-data-v-65ac4b48 1s infinite;animation:recording-data-v-65ac4b48 1s infinite}.layout[data-v-65ac4b48]{padding-bottom:30px;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.room[data-v-65ac4b48]{width:250px;margin:10px;text-align:left}.empty[data-v-65ac4b48]{color:#eb5e46;width:100%;min-height:500px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.empty[data-v-65ac4b48],.status[data-v-65ac4b48]{display:-webkit-box;display:-ms-flexbox;display:flex}.status[data-v-65ac4b48]{position:fixed;left:5px;bottom:10px}.status>div[data-v-65ac4b48]{margin:0 5px}
|
2
dashboard/dist/index.html
vendored
2
dashboard/dist/index.html
vendored
@@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>Monibuca</title><script src=jessibuca/ajax.js></script><script src=jessibuca/renderer.js></script><link href=/css/app.ea4656d8.css rel=preload as=style><link href=/css/chunk-vendors.22ebf426.css rel=preload as=style><link href=/js/app.af5e5ef3.js rel=preload as=script><link href=/js/chunk-vendors.ebc28a73.js rel=preload as=script><link href=/css/chunk-vendors.22ebf426.css rel=stylesheet><link href=/css/app.ea4656d8.css rel=stylesheet></head><body><noscript><strong>We're sorry but dashboard doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ebc28a73.js></script><script src=/js/app.af5e5ef3.js></script></body></html>
|
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>Monibuca</title><script src=jessibuca/ajax.js></script><script src=jessibuca/renderer.js></script><link href=/css/app.ce470878.css rel=preload as=style><link href=/css/chunk-vendors.22ebf426.css rel=preload as=style><link href=/js/app.16c0d7c9.js rel=preload as=script><link href=/js/chunk-vendors.ebc28a73.js rel=preload as=script><link href=/css/chunk-vendors.22ebf426.css rel=stylesheet><link href=/css/app.ce470878.css rel=stylesheet></head><body><noscript><strong>We're sorry but dashboard doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ebc28a73.js></script><script src=/js/app.16c0d7c9.js></script></body></html>
|
22
dashboard/dist/jessibuca/renderer.js
vendored
22
dashboard/dist/jessibuca/renderer.js
vendored
@@ -1,4 +1,6 @@
|
|||||||
|
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||||
function Jessibuca(opt) {
|
function Jessibuca(opt) {
|
||||||
|
this.audioContext = new window.AudioContext()
|
||||||
this.canvasElement = opt.canvas;
|
this.canvasElement = opt.canvas;
|
||||||
this.contextOptions = opt.contextOptions;
|
this.contextOptions = opt.contextOptions;
|
||||||
this.videoBuffer = opt.videoBuffer || 1
|
this.videoBuffer = opt.videoBuffer || 1
|
||||||
@@ -9,7 +11,7 @@ function Jessibuca(opt) {
|
|||||||
this.initBuffers();
|
this.initBuffers();
|
||||||
this.initTextures();
|
this.initTextures();
|
||||||
};
|
};
|
||||||
this.decoderWorker = new Worker(opt.decoder || '264_mp3.js')
|
this.decoderWorker = new Worker(opt.decoder || 'ff.js')
|
||||||
var _this = this
|
var _this = this
|
||||||
function draw(output) {
|
function draw(output) {
|
||||||
_this.drawNextOutputPicture(_this.width, _this.height, null, output)
|
_this.drawNextOutputPicture(_this.width, _this.height, null, output)
|
||||||
@@ -65,9 +67,7 @@ function Jessibuca(opt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
function _unlock(context) {
|
||||||
function _unlock() {
|
|
||||||
var context = Jessibuca.prototype.audioContext = Jessibuca.prototype.audioContext || new window.AudioContext();
|
|
||||||
context.resume();
|
context.resume();
|
||||||
var source = context.createBufferSource();
|
var source = context.createBufferSource();
|
||||||
source.buffer = context.createBuffer(1, 1, 22050);
|
source.buffer = context.createBuffer(1, 1, 22050);
|
||||||
@@ -81,7 +81,7 @@ function _unlock() {
|
|||||||
// document.addEventListener("touchend", _unlock, true);
|
// document.addEventListener("touchend", _unlock, true);
|
||||||
Jessibuca.prototype.audioEnabled = function (flag) {
|
Jessibuca.prototype.audioEnabled = function (flag) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
_unlock()
|
_unlock(this.audioContext)
|
||||||
this.audioEnabled = function (flag) {
|
this.audioEnabled = function (flag) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.audioContext.resume();
|
this.audioContext.resume();
|
||||||
@@ -118,12 +118,15 @@ Jessibuca.prototype.playAudio = function (data) {
|
|||||||
}
|
}
|
||||||
// setTimeout(playNextBuffer, buffer.duration * 1000)
|
// setTimeout(playNextBuffer, buffer.duration * 1000)
|
||||||
}
|
}
|
||||||
var tryPlay = function (buffer) {
|
var decodeAudio = function () {
|
||||||
if (decodeQueue.length) {
|
if (decodeQueue.length) {
|
||||||
context.decodeAudioData(decodeQueue.shift(), tryPlay, console.error);
|
context.decodeAudioData(decodeQueue.shift(), tryPlay, decodeAudio);
|
||||||
} else {
|
} else {
|
||||||
isDecoding = false
|
isDecoding = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
var tryPlay = function (buffer) {
|
||||||
|
decodeAudio()
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
audioBuffers.push(buffer);
|
audioBuffers.push(buffer);
|
||||||
} else {
|
} else {
|
||||||
@@ -134,7 +137,7 @@ Jessibuca.prototype.playAudio = function (data) {
|
|||||||
decodeQueue.push(...data)
|
decodeQueue.push(...data)
|
||||||
if (!isDecoding) {
|
if (!isDecoding) {
|
||||||
isDecoding = true
|
isDecoding = true
|
||||||
context.decodeAudioData(decodeQueue.shift(), tryPlay, console.error);
|
decodeAudio()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.playAudio = playAudio
|
this.playAudio = playAudio
|
||||||
@@ -449,10 +452,11 @@ Jessibuca.prototype.close = function () {
|
|||||||
if (this.audioInterval) {
|
if (this.audioInterval) {
|
||||||
clearInterval(this.audioInterval)
|
clearInterval(this.audioInterval)
|
||||||
}
|
}
|
||||||
|
delete this.playAudio
|
||||||
this.decoderWorker.postMessage({ cmd: "close" })
|
this.decoderWorker.postMessage({ cmd: "close" })
|
||||||
this.contextGL.clear(this.contextGL.COLOR_BUFFER_BIT);
|
this.contextGL.clear(this.contextGL.COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
Jessibuca.prototype.destroy = function(){
|
Jessibuca.prototype.destroy = function () {
|
||||||
this.decoderWorker.terminate()
|
this.decoderWorker.terminate()
|
||||||
}
|
}
|
||||||
Jessibuca.prototype.play = function (url) {
|
Jessibuca.prototype.play = function (url) {
|
||||||
|
2
dashboard/dist/js/app.16c0d7c9.js
vendored
Normal file
2
dashboard/dist/js/app.16c0d7c9.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dashboard/dist/js/app.16c0d7c9.js.map
vendored
Normal file
1
dashboard/dist/js/app.16c0d7c9.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dashboard/dist/js/app.af5e5ef3.js
vendored
2
dashboard/dist/js/app.af5e5ef3.js
vendored
File diff suppressed because one or more lines are too long
1
dashboard/dist/js/app.af5e5ef3.js.map
vendored
1
dashboard/dist/js/app.af5e5ef3.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -27,7 +27,9 @@ func main() {
|
|||||||
|
|
||||||
该配置文件主要是为了定制各个插件的配置,例如监听端口号等,具体还是要看各个插件的设计。
|
该配置文件主要是为了定制各个插件的配置,例如监听端口号等,具体还是要看各个插件的设计。
|
||||||
|
|
||||||
> 如果你编写了自己的插件,就必须在该配置文件中写入对自己插件的配置信息
|
::: tip
|
||||||
|
如果你编写了自己的插件,就必须在该配置文件中写入对自己插件的配置信息
|
||||||
|
:::
|
||||||
|
|
||||||
如果注释掉部分插件的配置,那么该插件就不会启用,典型的配置如下:
|
如果注释掉部分插件的配置,那么该插件就不会启用,典型的配置如下:
|
||||||
```toml
|
```toml
|
||||||
|
43
dashboard/docs/design.md
Normal file
43
dashboard/docs/design.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Monibuca设计思想
|
||||||
|
|
||||||
|
## 背景
|
||||||
|
|
||||||
|
市面上的流媒体服务器不可谓不多,从本人的第一份工作起,就一直接触和研究了形形色色的流媒体服务器,从最早的**FCS**(全称Flash Communication Server),后来改名为**FMS**(全称Flash Media Server),到Red5(java语言开发),到**CrtmpServer**(C++开发),让我对流媒体服务器的基本原理有了深刻的认识。当时本人痴迷C#,于是乎在业余时间对crtmpServer的代码进行移植,用C#仿照着写了一遍取名为[csharprtmp](https://github.com/langhuihui/csharprtmp),并且适当的增强了一些功能,于是对rtmp协议了如指掌。后来Adobe推出了RTMFP协议,是一种p2p协议,十分节省带宽。我就又开始研究一款名为**OpenRTMFP**的开源项目,后来该项目改名为**MonaServer**。我在起基础上进行了扩展,实现了一些例如录制flv,shareObject等原本FMS有的功能。后开发出了HTML5直播技术(现在命名为Jessibuca,尚未开源),采用的传输协议就是WebSocket传输裸的视频流的方式,属于私有协议。而Server当时就使用的MonaServer。但当时遇到一个问题,C++的内存泄漏问题,这个一直没有很好的解决。遂决定放弃使用MonaServer转而使用srs,而srs要用一个很简单的go写的小程序将http-flv转换成WebSocket的Flv来适配我的Jessibuca,感觉最好能直接修改srs来实现这个功能。对srs的源码研究了一小段时间后放弃了,因为C++代码过于难写,容易出现bug。后来转而使用golang写的**gortmp**作为server,同样对其进行了扩展,而且进展十分顺利,golang的开发效率令人惊叹,而且其协程的特性很完美的处理了流媒体服务器的并发的场景。所以使用golang写的流媒体服务器项目很多,github上随便一搜就有很多,比如**livego**、**joy4**等。期间还接触到一位使用Node.js实现的流媒体服务器Node Media Server,我也和作者交流了许多,收益良多。
|
||||||
|
|
||||||
|
### 现有项目的不足
|
||||||
|
虽然流媒体服务器项目很多,但在我使用过程中遇到了几个痛点
|
||||||
|
|
||||||
|
1. 功能太多太重,往往大而全,不够轻量 很多号称轻量的项目最后都会越来越重
|
||||||
|
2. 扩展性弱,由于功能复杂,设计之初没有提供良好的扩展性,有些项目带有脚本支持,如FMS和MonaServer,但执行脚本会牺牲性能,而且脚本和原生代码相比,功能限制很大,只能实现业务逻辑而不是流媒体服务器本身的功能扩展。
|
||||||
|
3. 缺少图形管理界面,FMS是配套有图形管理界面的,当然FMS的问题是商业软件需要付费,源码也是不可见的。
|
||||||
|
|
||||||
|
综上所述,本人在吸收了以上诸多流媒体服务器的设计后,完成了Monibuca这款golang编写的流媒体开发框架的编写
|
||||||
|
|
||||||
|
### 受到vue渐进式思想的影响
|
||||||
|
vue渐进式框架的设计思想非常棒,那么是否可以用来设计流媒体服务器,使得流媒体服务器不只是一个服务器,而是一个开发框架,让开发者可以定制化自己的流媒体服务器呢?答案是肯定的。当然我们需要更多的抽象。
|
||||||
|
|
||||||
|
## 流媒体服务器的核心
|
||||||
|
|
||||||
|
流媒体服务器的核心是**转发**二字。当你去研究一款流媒体服务器的时候,会有海量的代码阻碍你看清其核心逻辑。包括:
|
||||||
|
|
||||||
|
1. 多媒体格式定义、解析,如Flv、MP4、MP3、H264、AAC等等
|
||||||
|
2. 传输协议的解析,如RTMP家族、AMF、HTTP、RTSP、HLS、WebSocket等等
|
||||||
|
3. 各种工具类,用来读取字节的缓冲、大小端转换、加解密算法、等等
|
||||||
|
|
||||||
|
大部分流媒体服务器都是基于rtmp协议之上扩展而来,这是历史原因造成的,所以功能不能很好的分离,耦合度很高。往往牵一发而动全身。其实所谓的流媒体服务器本质上就是把发布者的数据经过服务器转发到订阅者手里播放,起一个中转作用。至于什么协议格式,什么媒体格式都是属于扩展功能。所以最轻量的服务器应该不包含任何协议格式,任何媒体格式,仅仅只是完成中转。再说的直白一点核心代码就是一个for循环。
|
||||||
|
```go
|
||||||
|
for _, v := range r.Subscribers {
|
||||||
|
v.sendVideo(video)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
其他都是围绕这个for循环展开。所有的流媒体服务器代码里面都有这个for循环,写法稍有不同,但本质相同。
|
||||||
|
|
||||||
|
### 核心概念
|
||||||
|
|
||||||
|
|
||||||
|
基于这个循环,我们需要思考两个问题:
|
||||||
|
1. 如何高效的循环(性能问题)
|
||||||
|
2. 如何对接不同的协议(扩展性)
|
||||||
|
|
||||||
|
第一个问题,golang的性能算是很好的,那么重点就在于减少内存的分配上,池化是一个不错的选择,所以尽量池化,在Monibuca中对`[]byte`类型,采用了[github.com/funny/slab](https://github.com/funny/slab)包来管理。其他结构体就用系统自带的pool包来池化对象。对于协程的使用,在多次迭代后,已经使用了最少的协程来支持并发性。
|
||||||
|
|
@@ -1,4 +1,6 @@
|
|||||||
|
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||||
function Jessibuca(opt) {
|
function Jessibuca(opt) {
|
||||||
|
this.audioContext = new window.AudioContext()
|
||||||
this.canvasElement = opt.canvas;
|
this.canvasElement = opt.canvas;
|
||||||
this.contextOptions = opt.contextOptions;
|
this.contextOptions = opt.contextOptions;
|
||||||
this.videoBuffer = opt.videoBuffer || 1
|
this.videoBuffer = opt.videoBuffer || 1
|
||||||
@@ -9,7 +11,7 @@ function Jessibuca(opt) {
|
|||||||
this.initBuffers();
|
this.initBuffers();
|
||||||
this.initTextures();
|
this.initTextures();
|
||||||
};
|
};
|
||||||
this.decoderWorker = new Worker(opt.decoder || '264_mp3.js')
|
this.decoderWorker = new Worker(opt.decoder || 'ff.js')
|
||||||
var _this = this
|
var _this = this
|
||||||
function draw(output) {
|
function draw(output) {
|
||||||
_this.drawNextOutputPicture(_this.width, _this.height, null, output)
|
_this.drawNextOutputPicture(_this.width, _this.height, null, output)
|
||||||
@@ -65,9 +67,7 @@ function Jessibuca(opt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
function _unlock(context) {
|
||||||
function _unlock() {
|
|
||||||
var context = Jessibuca.prototype.audioContext = Jessibuca.prototype.audioContext || new window.AudioContext();
|
|
||||||
context.resume();
|
context.resume();
|
||||||
var source = context.createBufferSource();
|
var source = context.createBufferSource();
|
||||||
source.buffer = context.createBuffer(1, 1, 22050);
|
source.buffer = context.createBuffer(1, 1, 22050);
|
||||||
@@ -81,7 +81,7 @@ function _unlock() {
|
|||||||
// document.addEventListener("touchend", _unlock, true);
|
// document.addEventListener("touchend", _unlock, true);
|
||||||
Jessibuca.prototype.audioEnabled = function (flag) {
|
Jessibuca.prototype.audioEnabled = function (flag) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
_unlock()
|
_unlock(this.audioContext)
|
||||||
this.audioEnabled = function (flag) {
|
this.audioEnabled = function (flag) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.audioContext.resume();
|
this.audioContext.resume();
|
||||||
@@ -118,12 +118,15 @@ Jessibuca.prototype.playAudio = function (data) {
|
|||||||
}
|
}
|
||||||
// setTimeout(playNextBuffer, buffer.duration * 1000)
|
// setTimeout(playNextBuffer, buffer.duration * 1000)
|
||||||
}
|
}
|
||||||
var tryPlay = function (buffer) {
|
var decodeAudio = function () {
|
||||||
if (decodeQueue.length) {
|
if (decodeQueue.length) {
|
||||||
context.decodeAudioData(decodeQueue.shift(), tryPlay, console.error);
|
context.decodeAudioData(decodeQueue.shift(), tryPlay, decodeAudio);
|
||||||
} else {
|
} else {
|
||||||
isDecoding = false
|
isDecoding = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
var tryPlay = function (buffer) {
|
||||||
|
decodeAudio()
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
audioBuffers.push(buffer);
|
audioBuffers.push(buffer);
|
||||||
} else {
|
} else {
|
||||||
@@ -134,7 +137,7 @@ Jessibuca.prototype.playAudio = function (data) {
|
|||||||
decodeQueue.push(...data)
|
decodeQueue.push(...data)
|
||||||
if (!isDecoding) {
|
if (!isDecoding) {
|
||||||
isDecoding = true
|
isDecoding = true
|
||||||
context.decodeAudioData(decodeQueue.shift(), tryPlay, console.error);
|
decodeAudio()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.playAudio = playAudio
|
this.playAudio = playAudio
|
||||||
@@ -449,10 +452,11 @@ Jessibuca.prototype.close = function () {
|
|||||||
if (this.audioInterval) {
|
if (this.audioInterval) {
|
||||||
clearInterval(this.audioInterval)
|
clearInterval(this.audioInterval)
|
||||||
}
|
}
|
||||||
|
delete this.playAudio
|
||||||
this.decoderWorker.postMessage({ cmd: "close" })
|
this.decoderWorker.postMessage({ cmd: "close" })
|
||||||
this.contextGL.clear(this.contextGL.COLOR_BUFFER_BIT);
|
this.contextGL.clear(this.contextGL.COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
Jessibuca.prototype.destroy = function(){
|
Jessibuca.prototype.destroy = function () {
|
||||||
this.decoderWorker.terminate()
|
this.decoderWorker.terminate()
|
||||||
}
|
}
|
||||||
Jessibuca.prototype.play = function (url) {
|
Jessibuca.prototype.play = function (url) {
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="mountNode"></div>
|
<div>
|
||||||
|
自动更新
|
||||||
|
<i-switch v-model="autoUpdate"></i-switch>
|
||||||
|
<div id="mountNode"></div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -7,24 +11,22 @@ import { mapState } from "vuex";
|
|||||||
import G6 from "@antv/g6";
|
import G6 from "@antv/g6";
|
||||||
var graph = null;
|
var graph = null;
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
autoUpdate: true
|
||||||
|
};
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
data(state) {
|
data(state) {
|
||||||
let summary = state.summary;
|
let d = this.addServer(state.summary);
|
||||||
// 点集
|
d.label = "🏠" + d.label;
|
||||||
let nodes = [];
|
return d;
|
||||||
// 边集
|
|
||||||
let edges = [];
|
|
||||||
this.addServer(summary, nodes, edges);
|
|
||||||
return {
|
|
||||||
nodes,
|
|
||||||
edges
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addServer(node, nodes, edges) {
|
addServer(node) {
|
||||||
let result = {
|
let result = {
|
||||||
id: node.Address,
|
id: node.Address,
|
||||||
label: node.Address,
|
label: node.Address,
|
||||||
@@ -33,38 +35,35 @@ export default {
|
|||||||
shape: "modelRect",
|
shape: "modelRect",
|
||||||
logoIcon: {
|
logoIcon: {
|
||||||
show: false
|
show: false
|
||||||
}
|
},
|
||||||
|
children: []
|
||||||
};
|
};
|
||||||
nodes.push(result);
|
|
||||||
if (node.Rooms) {
|
if (node.Rooms) {
|
||||||
for (let i = 0; i < node.Rooms.length; i++) {
|
for (let i = 0; i < node.Rooms.length; i++) {
|
||||||
let room = node.Rooms[i];
|
let room = node.Rooms[i];
|
||||||
let roomId = result.id + room.StreamPath;
|
let roomId = room.StreamPath;
|
||||||
nodes.push({
|
let roomData = {
|
||||||
id: roomId,
|
id: roomId,
|
||||||
label: room.StreamPath,
|
label: room.StreamPath,
|
||||||
shape: "rect"
|
shape: "rect",
|
||||||
});
|
children: []
|
||||||
edges.push({ source: result.id, target: roomId });
|
};
|
||||||
|
result.children.push(roomData);
|
||||||
if (room.SubscriberInfo) {
|
if (room.SubscriberInfo) {
|
||||||
for (let j = 0; j < room.SubscriberInfo.length; j++) {
|
for (let j = 0; j < room.SubscriberInfo.length; j++) {
|
||||||
let subId = roomId + room.SubscriberInfo[j].ID;
|
let subId = roomId + room.SubscriberInfo[j].ID;
|
||||||
nodes.push({
|
roomData.children.push({
|
||||||
id: subId,
|
id: subId,
|
||||||
label: room.SubscriberInfo[j].ID
|
label: room.SubscriberInfo[j].ID
|
||||||
});
|
});
|
||||||
edges.push({ source: roomId, target: subId });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.Children && node.Children.length > 0) {
|
if (node.Children) {
|
||||||
for (let i = 0; i < node.Children.length; i++) {
|
for (let childId in node.Children) {
|
||||||
let child = this.addServer(node.Children[i], nodes, edges);
|
result.children.push(this.addServer(node.Children[childId]));
|
||||||
edges.push({
|
|
||||||
source: result.id,
|
|
||||||
target: child.id
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -72,23 +71,33 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
data(v) {
|
data(v) {
|
||||||
if (graph) {
|
if (graph && this.autoUpdate) {
|
||||||
graph.read(v); // 加载数据
|
//graph.updateChild(v, "");
|
||||||
|
graph.changeData(v); // 加载数据
|
||||||
|
graph.fitView();
|
||||||
|
//graph.read(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
graph = new G6.Graph({
|
graph = new G6.TreeGraph({
|
||||||
renderer: "svg",
|
linkCenter: true,
|
||||||
|
// renderer: "svg",
|
||||||
container: "mountNode", // 指定挂载容器
|
container: "mountNode", // 指定挂载容器
|
||||||
width: 800, // 图的宽度
|
width: 800, // 图的宽度
|
||||||
height: 500, // 图的高度
|
height: 500, // 图的高度
|
||||||
layout: {
|
modes: {
|
||||||
type: "radial"
|
default: ["drag-canvas", "zoom-canvas", "click-select", "drag-node"]
|
||||||
},
|
},
|
||||||
defaultNode: {}
|
animate: false,
|
||||||
|
layout: {
|
||||||
|
// type: "indeted",
|
||||||
|
direction: "H"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
//graph.addChild(this.data, "");
|
||||||
graph.read(this.data); // 加载数据
|
graph.read(this.data); // 加载数据
|
||||||
|
graph.fitView();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
>
|
>
|
||||||
<canvas id="canvas" width="488" height="275" style="background: black" />
|
<canvas id="canvas" width="488" height="275" style="background: black" />
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
|
<!-- 音频缓冲:-->
|
||||||
|
<!-- <InputNumber v-model="audioBuffer" size="small"></InputNumber>-->
|
||||||
<Button v-if="audioEnabled" @click="turnOff" icon="md-volume-off" />
|
<Button v-if="audioEnabled" @click="turnOff" icon="md-volume-off" />
|
||||||
<Button v-else @click="turnOn" icon="md-volume-up"></Button>
|
<Button v-else @click="turnOn" icon="md-volume-up"></Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -22,18 +24,23 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
audioEnabled: false,
|
audioEnabled: false,
|
||||||
|
// audioBuffer: 12,
|
||||||
url: ""
|
url: ""
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
audioEnabled(value) {
|
audioEnabled(value) {
|
||||||
h5lc.audioEnabled(value);
|
h5lc.audioEnabled(value);
|
||||||
}
|
},
|
||||||
|
// audioBuffer(v) {
|
||||||
|
// h5lc.audioBuffer = v;
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
h5lc = new window.Jessibuca({
|
h5lc = new window.Jessibuca({
|
||||||
canvas: document.getElementById("canvas"),
|
canvas: document.getElementById("canvas"),
|
||||||
decoder: "jessibuca/ff.js"
|
decoder: "jessibuca/ff.js",
|
||||||
|
audioBuffer: this.audioBuffer
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
|
@@ -33,7 +33,7 @@ export default {
|
|||||||
x => {
|
x => {
|
||||||
if (x == "success") {
|
if (x == "success") {
|
||||||
this.onVisible(true);
|
this.onVisible(true);
|
||||||
this.$Message.success("删除成功");
|
this.$Message.success("开始发布");
|
||||||
} else {
|
} else {
|
||||||
this.$Message.error(x);
|
this.$Message.error(x);
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ export default {
|
|||||||
{ streamPath: item.Path.replace(".flv", "") },
|
{ streamPath: item.Path.replace(".flv", "") },
|
||||||
x => {
|
x => {
|
||||||
if (x == "success") {
|
if (x == "success") {
|
||||||
this.$Message.success("开始发布");
|
this.$Message.success("删除成功");
|
||||||
} else {
|
} else {
|
||||||
this.$Message.error(x);
|
this.$Message.error(x);
|
||||||
}
|
}
|
||||||
|
@@ -118,6 +118,7 @@ export default {
|
|||||||
currentTab: "",
|
currentTab: "",
|
||||||
currentStream: [],
|
currentStream: [],
|
||||||
typeMap: {
|
typeMap: {
|
||||||
|
Receiver: "📡",
|
||||||
FlvFile: "🎥",
|
FlvFile: "🎥",
|
||||||
TS: "🎬",
|
TS: "🎬",
|
||||||
HLS: "🍎",
|
HLS: "🍎",
|
||||||
|
409
main.go
409
main.go
@@ -1,17 +1,410 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
. "github.com/langhuihui/monibuca/monica"
|
"fmt"
|
||||||
_ "github.com/langhuihui/monibuca/plugins"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"mime"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"os/user"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
|
"github.com/langhuihui/monibuca/monica/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
type InstanceDesc struct {
|
||||||
log.SetOutput(os.Stdout)
|
Name string
|
||||||
configPath := flag.String("c", "config.toml", "configFile")
|
Path string
|
||||||
flag.Parse()
|
Plugins []string
|
||||||
Run(*configPath)
|
Config string
|
||||||
select {}
|
}
|
||||||
|
|
||||||
|
var instances = make(map[string]*InstanceDesc)
|
||||||
|
var instancesDir string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// log.SetOutput(os.Stdout)
|
||||||
|
// configPath := flag.String("c", "config.toml", "configFile")
|
||||||
|
// flag.Parse()
|
||||||
|
// Run(*configPath)
|
||||||
|
// select {}
|
||||||
|
println("start monibuca instance manager version:", Version)
|
||||||
|
if MayBeError(readInstances()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
addr := flag.String("port", "8000", "http server port")
|
||||||
|
flag.Parse()
|
||||||
|
http.HandleFunc("/instance/listDir", listDir)
|
||||||
|
http.HandleFunc("/instance/import", importInstance)
|
||||||
|
http.HandleFunc("/instance/updateConfig", updateConfig)
|
||||||
|
http.HandleFunc("/instance/list", listInstance)
|
||||||
|
http.HandleFunc("/instance/create", initInstance)
|
||||||
|
http.HandleFunc("/instance/restart", restartInstance)
|
||||||
|
http.HandleFunc("/instance/shutdown", shutdownInstance)
|
||||||
|
http.HandleFunc("/", website)
|
||||||
|
fmt.Printf("start listen at %s", *addr)
|
||||||
|
if err := http.ListenAndServe(":"+*addr, nil); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func listDir(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if input := r.URL.Query().Get("input"); input != "" {
|
||||||
|
if dir, err := os.Open(filepath.Dir(input)); err == nil {
|
||||||
|
var dirs []string
|
||||||
|
if infos, err := dir.Readdir(0); err == nil {
|
||||||
|
for _, info := range infos {
|
||||||
|
if info.IsDir() {
|
||||||
|
dirs = append(dirs, info.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if bytes, err := json.Marshal(dirs); err == nil {
|
||||||
|
w.Write(bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func importInstance(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var e error
|
||||||
|
defer func() {
|
||||||
|
result := "success"
|
||||||
|
if e != nil {
|
||||||
|
result = e.Error()
|
||||||
|
}
|
||||||
|
w.Write([]byte(result))
|
||||||
|
}()
|
||||||
|
name := r.URL.Query().Get("name")
|
||||||
|
if importPath := r.URL.Query().Get("path"); importPath != "" {
|
||||||
|
if strings.HasSuffix(importPath, "/") {
|
||||||
|
importPath = importPath[:len(importPath)-1]
|
||||||
|
}
|
||||||
|
f, err := os.Open(importPath)
|
||||||
|
if e = err; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
children, err := f.Readdir(0)
|
||||||
|
if e = err; err == nil {
|
||||||
|
var hasMain, hasConfig, hasMod, hasRestart bool
|
||||||
|
for _, child := range children {
|
||||||
|
switch child.Name() {
|
||||||
|
case "main.go":
|
||||||
|
hasMain = true
|
||||||
|
case "config.toml":
|
||||||
|
hasConfig = true
|
||||||
|
case "go.mod":
|
||||||
|
hasMod = true
|
||||||
|
case "restart.sh":
|
||||||
|
hasRestart = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if hasMain && hasConfig && hasMod && hasRestart {
|
||||||
|
if name == "" {
|
||||||
|
_, name = path.Split(importPath)
|
||||||
|
}
|
||||||
|
config, err := ioutil.ReadFile(path.Join(importPath, "config.toml"))
|
||||||
|
if e = err; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
mainGo, err := ioutil.ReadFile(path.Join(importPath, "main.go"))
|
||||||
|
if e = err; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reg, err := regexp.Compile("_ \"(.+)\"")
|
||||||
|
if e = err; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
instances[name] = &InstanceDesc{
|
||||||
|
Name: name,
|
||||||
|
Path: importPath,
|
||||||
|
Plugins: nil,
|
||||||
|
Config: string(config),
|
||||||
|
}
|
||||||
|
for _, m := range reg.FindAllStringSubmatch(string(mainGo), -1) {
|
||||||
|
instances[name].Plugins = append(instances[name].Plugins, m[1])
|
||||||
|
}
|
||||||
|
var file *os.File
|
||||||
|
file, e = os.OpenFile(path.Join(instancesDir, name+".toml"), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tomlEncoder := toml.NewEncoder(file)
|
||||||
|
e = tomlEncoder.Encode(instances[name])
|
||||||
|
} else {
|
||||||
|
e = errors.New("路径中缺少文件")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
w.Write([]byte("参数错误"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func readInstances() error {
|
||||||
|
if homeDir, err := Home(); err == nil {
|
||||||
|
instancesDir = path.Join(homeDir, ".monibuca")
|
||||||
|
if err = os.MkdirAll(instancesDir, os.FileMode(0666)); err == nil {
|
||||||
|
if f, err := os.Open(instancesDir); err != nil {
|
||||||
|
return err
|
||||||
|
} else if cs, err := f.Readdir(0); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
for _, configFile := range cs {
|
||||||
|
des := new(InstanceDesc)
|
||||||
|
if _, err = toml.DecodeFile(path.Join(instancesDir, configFile.Name()), des); err == nil {
|
||||||
|
instances[des.Name] = des
|
||||||
|
} else {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func website(w http.ResponseWriter, r *http.Request) {
|
||||||
|
filePath := r.URL.Path
|
||||||
|
if filePath == "/" {
|
||||||
|
filePath = "/index.html"
|
||||||
|
}
|
||||||
|
if mime := mime.TypeByExtension(path.Ext(filePath)); mime != "" {
|
||||||
|
w.Header().Set("Content-Type", mime)
|
||||||
|
}
|
||||||
|
_, currentFilePath, _, _ := runtime.Caller(0)
|
||||||
|
if f, err := ioutil.ReadFile(path.Join(path.Dir(currentFilePath), "pm/dist", filePath)); err == nil {
|
||||||
|
if _, err = w.Write(f); err != nil {
|
||||||
|
w.WriteHeader(505)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
w.Header().Set("Location", "/")
|
||||||
|
w.WriteHeader(302)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func listInstance(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if bytes, err := json.Marshal(instances); err == nil {
|
||||||
|
_, err = w.Write(bytes)
|
||||||
|
} else {
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func initInstance(w http.ResponseWriter, r *http.Request) {
|
||||||
|
instanceDesc := new(InstanceDesc)
|
||||||
|
sse := util.NewSSE(w, r.Context())
|
||||||
|
err := json.Unmarshal([]byte(r.URL.Query().Get("info")), instanceDesc)
|
||||||
|
clearDir := r.URL.Query().Get("clear") != ""
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
sse.WriteEvent("exception", []byte(err.Error()))
|
||||||
|
} else {
|
||||||
|
sse.Write([]byte("success"))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sse.WriteEvent("step", []byte("1:参数解析成功!"))
|
||||||
|
err = instanceDesc.createDir(sse, clearDir)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sse.WriteEvent("step", []byte("6:实例创建成功!"))
|
||||||
|
var file *os.File
|
||||||
|
file, err = os.OpenFile(path.Join(instancesDir, instanceDesc.Name+".toml"), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tomlEncoder := toml.NewEncoder(file)
|
||||||
|
err = tomlEncoder.Encode(&instanceDesc)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
instances[instanceDesc.Name] = instanceDesc
|
||||||
|
}
|
||||||
|
func shutdownInstance(w http.ResponseWriter, r *http.Request) {
|
||||||
|
instanceName := r.URL.Query().Get("instance")
|
||||||
|
if instance, ok := instances[instanceName]; ok {
|
||||||
|
if err := instance.command("kill", "-9", "`cat pid`").Run(); err == nil {
|
||||||
|
w.Write([]byte("success"))
|
||||||
|
} else {
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
w.Write([]byte("no such instance"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func restartInstance(w http.ResponseWriter, r *http.Request) {
|
||||||
|
sse := util.NewSSE(w, r.Context())
|
||||||
|
instanceName := r.URL.Query().Get("instance")
|
||||||
|
needUpdate := r.URL.Query().Get("update") != ""
|
||||||
|
needBuild := r.URL.Query().Get("build") != ""
|
||||||
|
if instance, ok := instances[instanceName]; ok {
|
||||||
|
if needUpdate {
|
||||||
|
if err := sse.WriteExec(instance.command("go", "get", "-u")); err != nil {
|
||||||
|
sse.WriteEvent("failed", []byte(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if needBuild {
|
||||||
|
if err := sse.WriteExec(instance.command("go", "build")); err != nil {
|
||||||
|
sse.WriteEvent("failed", []byte(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := sse.WriteExec(instance.command("sh", "restart.sh")); err != nil {
|
||||||
|
sse.WriteEvent("failed", []byte(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sse.Write([]byte("success"))
|
||||||
|
} else {
|
||||||
|
sse.WriteEvent("failed", []byte("no such instance"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *InstanceDesc) command(name string, args ...string) (cmd *exec.Cmd) {
|
||||||
|
cmd = exec.Command(name, args...)
|
||||||
|
cmd.Dir = p.Path
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (p *InstanceDesc) createDir(sse *util.SSE, clearDir bool) (err error) {
|
||||||
|
if clearDir {
|
||||||
|
os.RemoveAll(p.Path)
|
||||||
|
}
|
||||||
|
err = os.MkdirAll(p.Path, 0666)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sse.WriteEvent("step", []byte("2:目录创建成功!"))
|
||||||
|
err = ioutil.WriteFile(path.Join(p.Path, "config.toml"), []byte(p.Config), 0666)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var build bytes.Buffer
|
||||||
|
build.WriteString(`package main
|
||||||
|
import(
|
||||||
|
"github.com/langhuihui/monibuca/monica"`)
|
||||||
|
for _, plugin := range p.Plugins {
|
||||||
|
build.WriteString("\n_ \"")
|
||||||
|
build.WriteString(plugin)
|
||||||
|
build.WriteString("\"")
|
||||||
|
}
|
||||||
|
build.WriteString("\n)\n")
|
||||||
|
build.WriteString(`
|
||||||
|
func main(){
|
||||||
|
monica.Run("config.toml")
|
||||||
|
select{}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
err = ioutil.WriteFile(path.Join(p.Path, "main.go"), build.Bytes(), 0666)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sse.WriteEvent("step", []byte("3:文件创建成功!"))
|
||||||
|
err = sse.WriteExec(p.command("go", "mod", "init", p.Name))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sse.WriteEvent("step", []byte("4:go mod 初始化完成!"))
|
||||||
|
err = sse.WriteExec(p.command("go", "build"))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sse.WriteEvent("step", []byte("5:go build 成功!"))
|
||||||
|
build.Reset()
|
||||||
|
build.WriteString("kill -9 `cat pid`\n ./")
|
||||||
|
binFile := strings.TrimSuffix(p.Path, "/")
|
||||||
|
_, binFile = path.Split(binFile)
|
||||||
|
build.WriteString(binFile)
|
||||||
|
build.WriteString(" & echo $! > pid\n")
|
||||||
|
err = ioutil.WriteFile(path.Join(p.Path, "restart.sh"), build.Bytes(), 0777)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return sse.WriteExec(p.command("sh", "restart.sh"))
|
||||||
|
}
|
||||||
|
func updateConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
instanceName := r.URL.Query().Get("instance")
|
||||||
|
if instance, ok := instances[instanceName]; ok {
|
||||||
|
f, err := os.OpenFile(path.Join(instance.Path, "config.toml"), os.O_WRONLY|os.O_TRUNC, 0666)
|
||||||
|
if err != nil {
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = io.Copy(f, r.Body)
|
||||||
|
if err != nil {
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Write([]byte("success"))
|
||||||
|
} else {
|
||||||
|
w.Write([]byte("no such instance"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func Home() (string, error) {
|
||||||
|
user, err := user.Current()
|
||||||
|
if nil == err {
|
||||||
|
return user.HomeDir, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// cross compile support
|
||||||
|
|
||||||
|
if "windows" == runtime.GOOS {
|
||||||
|
return homeWindows()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unix-like system, so just assume Unix
|
||||||
|
return homeUnix()
|
||||||
|
}
|
||||||
|
|
||||||
|
func homeUnix() (string, error) {
|
||||||
|
// First prefer the HOME environmental variable
|
||||||
|
if home := os.Getenv("HOME"); home != "" {
|
||||||
|
return home, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If that fails, try the shell
|
||||||
|
var stdout bytes.Buffer
|
||||||
|
cmd := exec.Command("sh", "-c", "eval echo ~$USER")
|
||||||
|
cmd.Stdout = &stdout
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.TrimSpace(stdout.String())
|
||||||
|
if result == "" {
|
||||||
|
return "", errors.New("blank output when reading home directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func homeWindows() (string, error) {
|
||||||
|
drive := os.Getenv("HOMEDRIVE")
|
||||||
|
path := os.Getenv("HOMEPATH")
|
||||||
|
home := drive + path
|
||||||
|
if drive == "" || path == "" {
|
||||||
|
home = os.Getenv("USERPROFILE")
|
||||||
|
}
|
||||||
|
if home == "" {
|
||||||
|
return "", errors.New("HOMEDRIVE, HOMEPATH, and USERPROFILE are blank")
|
||||||
|
}
|
||||||
|
|
||||||
|
return home, nil
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package pool
|
package avformat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/langhuihui/monibuca/monica/pool"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,13 +34,25 @@ type AVPacket struct {
|
|||||||
func (av *AVPacket) IsKeyFrame() bool {
|
func (av *AVPacket) IsKeyFrame() bool {
|
||||||
return av.VideoFrameType == 1 || av.VideoFrameType == 4
|
return av.VideoFrameType == 1 || av.VideoFrameType == 4
|
||||||
}
|
}
|
||||||
|
func (av *AVPacket) ADTS2ASC() (tagPacket *AVPacket) {
|
||||||
|
tagPacket = NewAVPacket(FLV_TAG_TYPE_AUDIO)
|
||||||
|
tagPacket.Payload = ADTSToAudioSpecificConfig(av.Payload)
|
||||||
|
tagPacket.IsAACSequence = true
|
||||||
|
ADTSLength := 7 + ((1 - int(av.Payload[1]&1)) << 1)
|
||||||
|
if len(av.Payload) > ADTSLength {
|
||||||
|
av.Payload[0] = 0xAF
|
||||||
|
av.Payload[1] = 0x01 //raw AAC
|
||||||
|
copy(av.Payload[2:], av.Payload[ADTSLength:])
|
||||||
|
av.Payload = av.Payload[:(len(av.Payload) - ADTSLength + 2)]
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
func (av *AVPacket) Recycle() {
|
func (av *AVPacket) Recycle() {
|
||||||
if av.RefCount == 0 {
|
if av.RefCount == 0 {
|
||||||
return
|
return
|
||||||
} else if av.RefCount == 1 {
|
} else if av.RefCount == 1 {
|
||||||
av.RefCount = 0
|
av.RefCount = 0
|
||||||
RecycleSlice(av.Payload)
|
pool.RecycleSlice(av.Payload)
|
||||||
AVPacketPool.Put(av)
|
AVPacketPool.Put(av)
|
||||||
} else {
|
} else {
|
||||||
av.RefCount--
|
av.RefCount--
|
@@ -70,7 +70,7 @@ var (
|
|||||||
|
|
||||||
var FLVHeader = []byte{0x46, 0x4c, 0x56, 0x01, 0x05, 0, 0, 0, 9, 0, 0, 0, 0}
|
var FLVHeader = []byte{0x46, 0x4c, 0x56, 0x01, 0x05, 0, 0, 0, 9, 0, 0, 0, 0}
|
||||||
|
|
||||||
func WriteFLVTag(w io.Writer, tag *pool.SendPacket) (err error) {
|
func WriteFLVTag(w io.Writer, tag *SendPacket) (err error) {
|
||||||
head := pool.GetSlice(11)
|
head := pool.GetSlice(11)
|
||||||
defer pool.RecycleSlice(head)
|
defer pool.RecycleSlice(head)
|
||||||
tail := pool.GetSlice(4)
|
tail := pool.GetSlice(4)
|
||||||
@@ -93,13 +93,13 @@ func WriteFLVTag(w io.Writer, tag *pool.SendPacket) (err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func ReadFLVTag(r io.Reader) (tag *pool.AVPacket, err error) {
|
func ReadFLVTag(r io.Reader) (tag *AVPacket, err error) {
|
||||||
head := pool.GetSlice(11)
|
head := pool.GetSlice(11)
|
||||||
defer pool.RecycleSlice(head)
|
defer pool.RecycleSlice(head)
|
||||||
if _, err = io.ReadFull(r, head); err != nil {
|
if _, err = io.ReadFull(r, head); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tag = pool.NewAVPacket(head[0])
|
tag = NewAVPacket(head[0])
|
||||||
dataSize := util.BigEndian.Uint24(head[1:])
|
dataSize := util.BigEndian.Uint24(head[1:])
|
||||||
tag.Timestamp = util.BigEndian.Uint24(head[4:])
|
tag.Timestamp = util.BigEndian.Uint24(head[4:])
|
||||||
body := pool.GetSlice(int(dataSize))
|
body := pool.GetSlice(int(dataSize))
|
||||||
|
@@ -8,8 +8,8 @@ func (h AuthHook) AddHook(hook func(string) error) {
|
|||||||
AuthHooks = append(h, hook)
|
AuthHooks = append(h, hook)
|
||||||
}
|
}
|
||||||
func (h AuthHook) Trigger(sign string) error {
|
func (h AuthHook) Trigger(sign string) error {
|
||||||
for _, h := range h {
|
for _, f := range h {
|
||||||
if err := h(sign); err != nil {
|
if err := f(sign); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,8 +24,8 @@ func (h OnPublishHook) AddHook(hook func(r *Room)) {
|
|||||||
OnPublishHooks = append(h, hook)
|
OnPublishHooks = append(h, hook)
|
||||||
}
|
}
|
||||||
func (h OnPublishHook) Trigger(r *Room) {
|
func (h OnPublishHook) Trigger(r *Room) {
|
||||||
for _, h := range h {
|
for _, f := range h {
|
||||||
h(r)
|
f(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ func (h OnSubscribeHook) AddHook(hook func(s *OutputStream)) {
|
|||||||
OnSubscribeHooks = append(h, hook)
|
OnSubscribeHooks = append(h, hook)
|
||||||
}
|
}
|
||||||
func (h OnSubscribeHook) Trigger(s *OutputStream) {
|
func (h OnSubscribeHook) Trigger(s *OutputStream) {
|
||||||
for _, h := range h {
|
for _, f := range h {
|
||||||
h(s)
|
f(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +50,8 @@ func (h OnDropHook) AddHook(hook func(s *OutputStream)) {
|
|||||||
OnDropHooks = append(h, hook)
|
OnDropHooks = append(h, hook)
|
||||||
}
|
}
|
||||||
func (h OnDropHook) Trigger(s *OutputStream) {
|
func (h OnDropHook) Trigger(s *OutputStream) {
|
||||||
for _, h := range h {
|
for _, f := range h {
|
||||||
h(s)
|
f(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ func (h OnSummaryHook) AddHook(hook func(bool)) {
|
|||||||
OnSummaryHooks = append(h, hook)
|
OnSummaryHooks = append(h, hook)
|
||||||
}
|
}
|
||||||
func (h OnSummaryHook) Trigger(v bool) {
|
func (h OnSummaryHook) Trigger(v bool) {
|
||||||
for _, h := range h {
|
for _, f := range h {
|
||||||
h(v)
|
f(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,15 +2,24 @@ package monica
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ConfigRaw []byte
|
var ConfigRaw []byte
|
||||||
|
var Version = "0.2.8"
|
||||||
|
var EngineInfo = &struct {
|
||||||
|
Version string
|
||||||
|
StartTime time.Time
|
||||||
|
}{Version, time.Now()}
|
||||||
|
|
||||||
func Run(configFile string) (err error) {
|
func Run(configFile string) (err error) {
|
||||||
|
log.Printf("start monibuca version:%s", Version)
|
||||||
if ConfigRaw, err = ioutil.ReadFile(configFile); err != nil {
|
if ConfigRaw, err = ioutil.ReadFile(configFile); err != nil {
|
||||||
|
log.Printf("read config file error: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go Summary.StartSummary()
|
go Summary.StartSummary()
|
||||||
@@ -29,6 +38,8 @@ func Run(configFile string) (err error) {
|
|||||||
go config.Run()
|
go config.Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.Printf("decode config file error: %v", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -2,11 +2,11 @@ package monica
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/langhuihui/monibuca/monica/avformat"
|
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -22,8 +22,8 @@ func (c *Collection) Get(name string) (result *Room) {
|
|||||||
item, loaded := AllRoom.LoadOrStore(name, &Room{
|
item, loaded := AllRoom.LoadOrStore(name, &Room{
|
||||||
Subscribers: make(map[string]*OutputStream),
|
Subscribers: make(map[string]*OutputStream),
|
||||||
Control: make(chan interface{}),
|
Control: make(chan interface{}),
|
||||||
VideoChan: make(chan *pool.AVPacket, 1),
|
VideoChan: make(chan *avformat.AVPacket, 1),
|
||||||
AudioChan: make(chan *pool.AVPacket, 1),
|
AudioChan: make(chan *avformat.AVPacket, 1),
|
||||||
})
|
})
|
||||||
result = item.(*Room)
|
result = item.(*Room)
|
||||||
if !loaded {
|
if !loaded {
|
||||||
@@ -41,11 +41,11 @@ type Room struct {
|
|||||||
Control chan interface{}
|
Control chan interface{}
|
||||||
Cancel context.CancelFunc
|
Cancel context.CancelFunc
|
||||||
Subscribers map[string]*OutputStream // 订阅者
|
Subscribers map[string]*OutputStream // 订阅者
|
||||||
VideoTag *pool.AVPacket // 每个视频包都是这样的结构,区别在于Payload的大小.FMS在发送AVC sequence header,需要加上 VideoTags,这个tag 1个字节(8bits)的数据
|
VideoTag *avformat.AVPacket // 每个视频包都是这样的结构,区别在于Payload的大小.FMS在发送AVC sequence header,需要加上 VideoTags,这个tag 1个字节(8bits)的数据
|
||||||
AudioTag *pool.AVPacket // 每个音频包都是这样的结构,区别在于Payload的大小.FMS在发送AAC sequence header,需要加上 AudioTags,这个tag 1个字节(8bits)的数据
|
AudioTag *avformat.AVPacket // 每个音频包都是这样的结构,区别在于Payload的大小.FMS在发送AAC sequence header,需要加上 AudioTags,这个tag 1个字节(8bits)的数据
|
||||||
FirstScreen []*pool.AVPacket
|
FirstScreen []*avformat.AVPacket
|
||||||
AudioChan chan *pool.AVPacket
|
AudioChan chan *avformat.AVPacket
|
||||||
VideoChan chan *pool.AVPacket
|
VideoChan chan *avformat.AVPacket
|
||||||
UseTimestamp bool //是否采用数据包中的时间戳
|
UseTimestamp bool //是否采用数据包中的时间戳
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ func (r *Room) Subscribe(s *OutputStream) {
|
|||||||
if r.Err() == nil {
|
if r.Err() == nil {
|
||||||
s.SubscribeTime = time.Now()
|
s.SubscribeTime = time.Now()
|
||||||
log.Printf("subscribe :%s %s,to room %s", s.Type, s.ID, r.StreamPath)
|
log.Printf("subscribe :%s %s,to room %s", s.Type, s.ID, r.StreamPath)
|
||||||
s.packetQueue = make(chan *pool.SendPacket, 1024)
|
s.packetQueue = make(chan *avformat.SendPacket, 1024)
|
||||||
s.Context, s.Cancel = context.WithCancel(r)
|
s.Context, s.Cancel = context.WithCancel(r)
|
||||||
s.Control <- &SubscribeCmd{s}
|
s.Control <- &SubscribeCmd{s}
|
||||||
}
|
}
|
||||||
@@ -153,12 +153,21 @@ func (r *Room) Run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (r *Room) PushAudio(audio *pool.AVPacket) {
|
func (r *Room) PushAudio(audio *avformat.AVPacket) {
|
||||||
|
if len(audio.Payload) < 4 {
|
||||||
|
return
|
||||||
|
}
|
||||||
if audio.Payload[0] == 0xFF && (audio.Payload[1]&0xF0) == 0xF0 {
|
if audio.Payload[0] == 0xFF && (audio.Payload[1]&0xF0) == 0xF0 {
|
||||||
audio.IsADTS = true
|
//audio.IsADTS = true
|
||||||
r.AudioTag = audio
|
r.AudioInfo.SoundFormat = 10
|
||||||
|
r.AudioInfo.SoundRate = avformat.SamplingFrequencies[(audio.Payload[2]&0x3c)>>2]
|
||||||
|
r.AudioInfo.SoundType = ((audio.Payload[2] & 0x1) << 2) | ((audio.Payload[3] & 0xc0) >> 6)
|
||||||
|
r.AudioTag = audio.ADTS2ASC()
|
||||||
} else if r.AudioTag == nil {
|
} else if r.AudioTag == nil {
|
||||||
audio.IsAACSequence = true
|
audio.IsAACSequence = true
|
||||||
|
if len(audio.Payload) < 5 {
|
||||||
|
return
|
||||||
|
}
|
||||||
r.AudioTag = audio
|
r.AudioTag = audio
|
||||||
tmp := audio.Payload[0] // 第一个字节保存着音频的相关信息
|
tmp := audio.Payload[0] // 第一个字节保存着音频的相关信息
|
||||||
if r.AudioInfo.SoundFormat = tmp >> 4; r.AudioInfo.SoundFormat == 10 { //真的是AAC的话,后面有一个字节的详细信息
|
if r.AudioInfo.SoundFormat = tmp >> 4; r.AudioInfo.SoundFormat == 10 { //真的是AAC的话,后面有一个字节的详细信息
|
||||||
@@ -191,7 +200,7 @@ func (r *Room) PushAudio(audio *pool.AVPacket) {
|
|||||||
r.AudioInfo.PacketCount++
|
r.AudioInfo.PacketCount++
|
||||||
r.AudioChan <- audio
|
r.AudioChan <- audio
|
||||||
}
|
}
|
||||||
func (r *Room) setH264Info(video *pool.AVPacket) {
|
func (r *Room) setH264Info(video *avformat.AVPacket) {
|
||||||
r.VideoTag = video
|
r.VideoTag = video
|
||||||
info := avformat.AVCDecoderConfigurationRecord{}
|
info := avformat.AVCDecoderConfigurationRecord{}
|
||||||
//0:codec,1:IsAVCSequence,2~4:compositionTime
|
//0:codec,1:IsAVCSequence,2~4:compositionTime
|
||||||
@@ -199,7 +208,10 @@ func (r *Room) setH264Info(video *pool.AVPacket) {
|
|||||||
r.VideoInfo.SPSInfo, err = avformat.ParseSPS(info.SequenceParameterSetNALUnit)
|
r.VideoInfo.SPSInfo, err = avformat.ParseSPS(info.SequenceParameterSetNALUnit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (r *Room) PushVideo(video *pool.AVPacket) {
|
func (r *Room) PushVideo(video *avformat.AVPacket) {
|
||||||
|
if len(video.Payload) < 3 {
|
||||||
|
return
|
||||||
|
}
|
||||||
video.VideoFrameType = video.Payload[0] >> 4 // 帧类型 4Bit, H264一般为1或者2
|
video.VideoFrameType = video.Payload[0] >> 4 // 帧类型 4Bit, H264一般为1或者2
|
||||||
r.VideoInfo.CodecID = video.Payload[0] & 0x0f // 编码类型ID 4Bit, JPEG, H263, AVC...
|
r.VideoInfo.CodecID = video.Payload[0] & 0x0f // 编码类型ID 4Bit, JPEG, H263, AVC...
|
||||||
video.IsAVCSequence = video.VideoFrameType == 1 && video.Payload[1] == 0
|
video.IsAVCSequence = video.VideoFrameType == 1 && video.Payload[1] == 0
|
||||||
|
@@ -3,12 +3,12 @@ package monica
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Subscriber interface {
|
type Subscriber interface {
|
||||||
Send(*pool.SendPacket) error
|
Send(*avformat.SendPacket) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubscriberInfo struct {
|
type SubscriberInfo struct {
|
||||||
@@ -23,14 +23,14 @@ type OutputStream struct {
|
|||||||
context.Context
|
context.Context
|
||||||
*Room
|
*Room
|
||||||
SubscriberInfo
|
SubscriberInfo
|
||||||
SendHandler func(*pool.SendPacket) error
|
SendHandler func(*avformat.SendPacket) error
|
||||||
Cancel context.CancelFunc
|
Cancel context.CancelFunc
|
||||||
Sign string
|
Sign string
|
||||||
VTSent bool
|
VTSent bool
|
||||||
ATSent bool
|
ATSent bool
|
||||||
VSentTime uint32
|
VSentTime uint32
|
||||||
ASentTime uint32
|
ASentTime uint32
|
||||||
packetQueue chan *pool.SendPacket
|
packetQueue chan *avformat.SendPacket
|
||||||
dropCount int
|
dropCount int
|
||||||
OffsetTime uint32
|
OffsetTime uint32
|
||||||
firstScreenIndex int
|
firstScreenIndex int
|
||||||
@@ -61,7 +61,7 @@ func (s *OutputStream) Play(streamPath string) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s *OutputStream) sendPacket(packet *pool.AVPacket, timestamp uint32) {
|
func (s *OutputStream) sendPacket(packet *avformat.AVPacket, timestamp uint32) {
|
||||||
if !packet.IsAVCSequence && timestamp == 0 {
|
if !packet.IsAVCSequence && timestamp == 0 {
|
||||||
timestamp = 1 //防止为0
|
timestamp = 1 //防止为0
|
||||||
}
|
}
|
||||||
@@ -82,11 +82,11 @@ func (s *OutputStream) sendPacket(packet *pool.AVPacket, timestamp uint32) {
|
|||||||
s.TotalDrop++
|
s.TotalDrop++
|
||||||
packet.Recycle()
|
packet.Recycle()
|
||||||
} else if !s.IsClosed() {
|
} else if !s.IsClosed() {
|
||||||
s.packetQueue <- pool.NewSendPacket(packet, timestamp)
|
s.packetQueue <- avformat.NewSendPacket(packet, timestamp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OutputStream) sendVideo(video *pool.AVPacket) error {
|
func (s *OutputStream) sendVideo(video *avformat.AVPacket) error {
|
||||||
isKF := video.IsKeyFrame()
|
isKF := video.IsKeyFrame()
|
||||||
if s.VTSent {
|
if s.VTSent {
|
||||||
if s.FirstScreen == nil || s.firstScreenIndex == -1 {
|
if s.FirstScreen == nil || s.firstScreenIndex == -1 {
|
||||||
@@ -119,7 +119,7 @@ func (s *OutputStream) sendVideo(video *pool.AVPacket) error {
|
|||||||
s.VSentTime = video.Timestamp
|
s.VSentTime = video.Timestamp
|
||||||
return s.sendVideo(video)
|
return s.sendVideo(video)
|
||||||
}
|
}
|
||||||
func (s *OutputStream) sendAudio(audio *pool.AVPacket) error {
|
func (s *OutputStream) sendAudio(audio *avformat.AVPacket) error {
|
||||||
if s.ATSent {
|
if s.ATSent {
|
||||||
if s.FirstScreen != nil && s.firstScreenIndex == -1 {
|
if s.FirstScreen != nil && s.firstScreenIndex == -1 {
|
||||||
audio.Recycle()
|
audio.Recycle()
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package monica
|
package monica
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/cpu"
|
"github.com/shirou/gopsutil/cpu"
|
||||||
@@ -57,11 +58,13 @@ func (s *ServerSummary) StartSummary() {
|
|||||||
case v := <-s.control:
|
case v := <-s.control:
|
||||||
if v {
|
if v {
|
||||||
if s.ref++; s.ref == 1 {
|
if s.ref++; s.ref == 1 {
|
||||||
|
log.Println("start report summary")
|
||||||
OnSummaryHooks.Trigger(true)
|
OnSummaryHooks.Trigger(true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if s.ref--; s.ref == 0 {
|
if s.ref--; s.ref == 0 {
|
||||||
s.lastNetWork = nil
|
s.lastNetWork = nil
|
||||||
|
log.Println("stop report summary")
|
||||||
OnSummaryHooks.Trigger(false)
|
OnSummaryHooks.Trigger(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
73
monica/util/SSE.go
Normal file
73
monica/util/SSE.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
sseEent = []byte("event: ")
|
||||||
|
sseBegin = []byte("data: ")
|
||||||
|
sseEnd = []byte("\n\n")
|
||||||
|
)
|
||||||
|
|
||||||
|
type SSE struct {
|
||||||
|
http.ResponseWriter
|
||||||
|
context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sse *SSE) Write(data []byte) (n int, err error) {
|
||||||
|
if err = sse.Err(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = sse.ResponseWriter.Write(sseBegin)
|
||||||
|
n, err = sse.ResponseWriter.Write(data)
|
||||||
|
_, err = sse.ResponseWriter.Write(sseEnd)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sse.ResponseWriter.(http.Flusher).Flush()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sse *SSE) WriteEvent(event string, data []byte) (err error) {
|
||||||
|
if err = sse.Err(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = sse.ResponseWriter.Write(sseEent)
|
||||||
|
_, err = sse.ResponseWriter.Write([]byte(event))
|
||||||
|
_, err = sse.ResponseWriter.Write([]byte("\n"))
|
||||||
|
_, err = sse.Write(data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSSE(w http.ResponseWriter, ctx context.Context) *SSE {
|
||||||
|
header := w.Header()
|
||||||
|
header.Set("Content-Type", "text/event-stream")
|
||||||
|
header.Set("Cache-Control", "no-cache")
|
||||||
|
header.Set("Connection", "keep-alive")
|
||||||
|
header.Set("X-Accel-Buffering", "no")
|
||||||
|
header.Set("Access-Control-Allow-Origin", "*")
|
||||||
|
return &SSE{
|
||||||
|
w,
|
||||||
|
ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sse *SSE) WriteJSON(data interface{}) (err error) {
|
||||||
|
var jsonData []byte
|
||||||
|
if jsonData, err = json.Marshal(data); err == nil {
|
||||||
|
if _, err = sse.Write(jsonData); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (sse *SSE) WriteExec(cmd *exec.Cmd) error {
|
||||||
|
cmd.Stderr = sse
|
||||||
|
cmd.Stdout = sse
|
||||||
|
return cmd.Run()
|
||||||
|
}
|
@@ -3,7 +3,6 @@ package HDL
|
|||||||
import (
|
import (
|
||||||
. "github.com/langhuihui/monibuca/monica"
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
"github.com/langhuihui/monibuca/monica/avformat"
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -42,7 +41,7 @@ func HDLHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Write(avformat.FLVHeader)
|
w.Write(avformat.FLVHeader)
|
||||||
p := OutputStream{
|
p := OutputStream{
|
||||||
Sign: sign,
|
Sign: sign,
|
||||||
SendHandler: func(packet *pool.SendPacket) error {
|
SendHandler: func(packet *avformat.SendPacket) error {
|
||||||
return avformat.WriteFLVTag(w, packet)
|
return avformat.WriteFLVTag(w, packet)
|
||||||
},
|
},
|
||||||
SubscriberInfo: SubscriberInfo{
|
SubscriberInfo: SubscriberInfo{
|
||||||
|
@@ -5,7 +5,6 @@ import (
|
|||||||
. "github.com/langhuihui/monibuca/monica"
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
"github.com/langhuihui/monibuca/monica/avformat"
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
"github.com/langhuihui/monibuca/monica/avformat/mpegts"
|
"github.com/langhuihui/monibuca/monica/avformat/mpegts"
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
|
||||||
"github.com/langhuihui/monibuca/monica/util"
|
"github.com/langhuihui/monibuca/monica/util"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
@@ -36,6 +35,7 @@ func (ts *TS) run() {
|
|||||||
spsHead := []byte{0xE1, 0, 0}
|
spsHead := []byte{0xE1, 0, 0}
|
||||||
ppsHead := []byte{0x01, 0, 0}
|
ppsHead := []byte{0x01, 0, 0}
|
||||||
nalLength := []byte{0, 0, 0, 0}
|
nalLength := []byte{0, 0, 0, 0}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ts.Done():
|
case <-ts.Done():
|
||||||
@@ -46,12 +46,21 @@ func (ts *TS) run() {
|
|||||||
ts.TotalPesCount++
|
ts.TotalPesCount++
|
||||||
switch tsPesPkt.PesPkt.Header.StreamID & 0xF0 {
|
switch tsPesPkt.PesPkt.Header.StreamID & 0xF0 {
|
||||||
case mpegts.STREAM_ID_AUDIO:
|
case mpegts.STREAM_ID_AUDIO:
|
||||||
av := pool.NewAVPacket(avformat.FLV_TAG_TYPE_AUDIO)
|
data := tsPesPkt.PesPkt.Payload
|
||||||
av.Payload = tsPesPkt.PesPkt.Payload
|
for remainLen := len(data); remainLen > 0; {
|
||||||
ts.PushAudio(av)
|
// AACFrameLength(13)
|
||||||
|
// xx xxxxxxxx xxx
|
||||||
|
frameLen := (int(data[3]&3) << 11) | (int(data[4]) << 3) | (int(data[5]) >> 5)
|
||||||
|
av := avformat.NewAVPacket(avformat.FLV_TAG_TYPE_AUDIO)
|
||||||
|
av.Payload = data[:frameLen]
|
||||||
|
ts.PushAudio(av)
|
||||||
|
data = data[frameLen:remainLen]
|
||||||
|
remainLen = remainLen - frameLen
|
||||||
|
}
|
||||||
|
|
||||||
case mpegts.STREAM_ID_VIDEO:
|
case mpegts.STREAM_ID_VIDEO:
|
||||||
var err error
|
var err error
|
||||||
av := pool.NewAVPacket(avformat.FLV_TAG_TYPE_VIDEO)
|
av := avformat.NewAVPacket(avformat.FLV_TAG_TYPE_VIDEO)
|
||||||
ts.PTS = tsPesPkt.PesPkt.Header.Pts
|
ts.PTS = tsPesPkt.PesPkt.Header.Pts
|
||||||
ts.DTS = tsPesPkt.PesPkt.Header.Dts
|
ts.DTS = tsPesPkt.PesPkt.Header.Dts
|
||||||
lastDts := ts.lastDts
|
lastDts := ts.lastDts
|
||||||
@@ -95,7 +104,7 @@ func (ts *TS) run() {
|
|||||||
av.VideoFrameType = 1
|
av.VideoFrameType = 1
|
||||||
av.Payload = r.Bytes()
|
av.Payload = r.Bytes()
|
||||||
ts.PushVideo(av)
|
ts.PushVideo(av)
|
||||||
av = pool.NewAVPacket(avformat.FLV_TAG_TYPE_VIDEO)
|
av = avformat.NewAVPacket(avformat.FLV_TAG_TYPE_VIDEO)
|
||||||
av.Timestamp = uint32(dts / 90)
|
av.Timestamp = uint32(dts / 90)
|
||||||
r = bytes.NewBuffer([]byte{})
|
r = bytes.NewBuffer([]byte{})
|
||||||
continue
|
continue
|
||||||
|
@@ -61,9 +61,10 @@ func (p *HLS) run(info *M3u8Info) {
|
|||||||
log.Printf("hls %s exit:%v", p.StreamPath, err)
|
log.Printf("hls %s exit:%v", p.StreamPath, err)
|
||||||
p.Cancel()
|
p.Cancel()
|
||||||
}()
|
}()
|
||||||
|
errcount := 0
|
||||||
for ; err == nil && p.Err() == nil; resp, err = client.Do(info.Req) {
|
for ; err == nil && p.Err() == nil; resp, err = client.Do(info.Req) {
|
||||||
if playlist, err := readM3U8(resp); err == nil {
|
if playlist, err := readM3U8(resp); err == nil {
|
||||||
|
errcount = 0
|
||||||
info.LastM3u8 = playlist.String()
|
info.LastM3u8 = playlist.String()
|
||||||
//if !playlist.Live {
|
//if !playlist.Live {
|
||||||
// log.Println(p.LastM3u8)
|
// log.Println(p.LastM3u8)
|
||||||
@@ -129,7 +130,11 @@ func (p *HLS) run(info *M3u8Info) {
|
|||||||
time.Sleep(time.Second * time.Duration(playlist.Target) * 2)
|
time.Sleep(time.Second * time.Duration(playlist.Target) * 2)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("%s readM3u8:%v", p.StreamPath, err)
|
log.Printf("%s readM3u8:%v", p.StreamPath, err)
|
||||||
return
|
errcount++
|
||||||
|
if errcount > 10 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,28 +1,27 @@
|
|||||||
package QoS
|
package QoS
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
. "github.com/langhuihui/monibuca/monica"
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
selectMap = map[string][]string{
|
// selectMap = map[string][]string{
|
||||||
"low": {"low", "medium", "high"},
|
// "low": {"low", "medium", "high"},
|
||||||
"medium": {"medium", "low", "high"},
|
// "medium": {"medium", "low", "high"},
|
||||||
"high": {"high", "medium", "low"},
|
// "high": {"high", "medium", "low"},
|
||||||
}
|
// }
|
||||||
)
|
// )
|
||||||
|
|
||||||
func getQualityName(name string, qualityLevel string) string {
|
// func getQualityName(name string, qualityLevel string) string {
|
||||||
if qualityLevel == "" {
|
// for _, l := range selectMap[qualityLevel] {
|
||||||
return name
|
// if _, ok := AllRoom.Load(name + "/" + l); ok {
|
||||||
}
|
// return name + "/" + l
|
||||||
for _, l := range selectMap[qualityLevel] {
|
// }
|
||||||
if _, ok := AllRoom.Load(name + "/" + l); ok {
|
// }
|
||||||
return name + "/" + l
|
// return name + "/" + qualityLevel
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
return name + "/" + qualityLevel
|
|
||||||
}
|
|
||||||
|
|
||||||
var config = struct {
|
var config = struct {
|
||||||
Suffix []string
|
Suffix []string
|
||||||
@@ -39,8 +38,23 @@ func init() {
|
|||||||
func run() {
|
func run() {
|
||||||
OnDropHooks.AddHook(func(s *OutputStream) {
|
OnDropHooks.AddHook(func(s *OutputStream) {
|
||||||
if s.TotalDrop > s.TotalPacket>>2 {
|
if s.TotalDrop > s.TotalPacket>>2 {
|
||||||
//TODO
|
var newStreamPath = ""
|
||||||
//s.Control<-&ChangeRoomCmd{s,AllRoom.Get()}
|
for i, suf := range config.Suffix {
|
||||||
|
if strings.HasSuffix(s.StreamPath, suf) {
|
||||||
|
if i < len(config.Suffix)-1 {
|
||||||
|
newStreamPath = s.StreamPath + "/" + config.Suffix[i+1]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newStreamPath = s.StreamPath + "/" + suf
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if newStreamPath != "" {
|
||||||
|
if _, ok := AllRoom.Load(newStreamPath); ok {
|
||||||
|
s.Control <- &ChangeRoomCmd{s, AllRoom.Get(newStreamPath)}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package cluster
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
@@ -46,52 +47,52 @@ func run() {
|
|||||||
if MayBeError(err) {
|
if MayBeError(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
masterConn, err = net.DialTCP("tcp", nil, addr)
|
go readMaster(addr)
|
||||||
if MayBeError(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go readMaster()
|
|
||||||
}
|
}
|
||||||
if config.ListenAddr != "" {
|
if config.ListenAddr != "" {
|
||||||
|
Summary.Children = make(map[string]*ServerSummary)
|
||||||
OnSummaryHooks.AddHook(onSummary)
|
OnSummaryHooks.AddHook(onSummary)
|
||||||
log.Printf("server bare start at %s", config.ListenAddr)
|
log.Printf("server bare start at %s", config.ListenAddr)
|
||||||
log.Fatal(ListenBare(config.ListenAddr))
|
log.Fatal(ListenBare(config.ListenAddr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func readMaster() {
|
|
||||||
|
func readMaster(addr *net.TCPAddr) {
|
||||||
var err error
|
var err error
|
||||||
defer func() {
|
var cmd byte
|
||||||
for {
|
|
||||||
time.Sleep(time.Second*5 + time.Duration(rand.Int63n(5))*time.Second)
|
|
||||||
addr, _ := net.ResolveTCPAddr("tcp", config.Master)
|
|
||||||
if masterConn, err = net.DialTCP("tcp", nil, addr); err == nil {
|
|
||||||
go readMaster()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
brw := bufio.NewReadWriter(bufio.NewReader(masterConn), bufio.NewWriter(masterConn))
|
|
||||||
//首次报告
|
|
||||||
if b, err := json.Marshal(Summary); err == nil {
|
|
||||||
_, err = masterConn.Write(b)
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
cmd, err := brw.ReadByte()
|
if masterConn, err = net.DialTCP("tcp", nil, addr); !MayBeError(err) {
|
||||||
if err != nil {
|
reader := bufio.NewReader(masterConn)
|
||||||
return
|
log.Printf("connect to master %s reporting", config.Master)
|
||||||
}
|
for report(); err == nil; {
|
||||||
switch cmd {
|
if cmd, err = reader.ReadByte(); !MayBeError(err) {
|
||||||
case MSG_SUMMARY: //收到主服务器指令,进行采集和上报
|
switch cmd {
|
||||||
if cmd, err = brw.ReadByte(); err != nil {
|
case MSG_SUMMARY: //收到主服务器指令,进行采集和上报
|
||||||
return
|
log.Println("receive summary request from master")
|
||||||
}
|
if cmd, err = reader.ReadByte(); !MayBeError(err) {
|
||||||
if cmd == 1 {
|
if cmd == 1 {
|
||||||
Summary.Add()
|
Summary.Add()
|
||||||
go onReport()
|
go onReport()
|
||||||
} else {
|
} else {
|
||||||
Summary.Done()
|
Summary.Done()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
t := 5 + rand.Int63n(5)
|
||||||
|
log.Printf("reconnect to master %s after %d seconds", config.Master, t)
|
||||||
|
time.Sleep(time.Duration(t) * time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func report() {
|
||||||
|
if b, err := json.Marshal(Summary); err == nil {
|
||||||
|
data := make([]byte, len(b)+2)
|
||||||
|
data[0] = MSG_SUMMARY
|
||||||
|
copy(data[1:], b)
|
||||||
|
data[len(data)-1] = 0
|
||||||
|
_, err = masterConn.Write(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,28 +100,24 @@ func readMaster() {
|
|||||||
func onReport() {
|
func onReport() {
|
||||||
for range time.NewTicker(time.Second).C {
|
for range time.NewTicker(time.Second).C {
|
||||||
if Summary.Running() {
|
if Summary.Running() {
|
||||||
if b, err := json.Marshal(Summary); err == nil {
|
report()
|
||||||
data := make([]byte, len(b)+2)
|
|
||||||
data[0] = MSG_SUMMARY
|
|
||||||
copy(data[1:], b)
|
|
||||||
data[len(data)-1] = 0
|
|
||||||
_, err = masterConn.Write(data)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func orderReport(conn io.Writer, start bool) {
|
||||||
|
b := []byte{MSG_SUMMARY, 0}
|
||||||
|
if start {
|
||||||
|
b[1] = 1
|
||||||
|
}
|
||||||
|
conn.Write(b)
|
||||||
|
}
|
||||||
|
|
||||||
//通知从服务器需要上报或者关闭上报
|
//通知从服务器需要上报或者关闭上报
|
||||||
func onSummary(start bool) {
|
func onSummary(start bool) {
|
||||||
slaves.Range(func(k, v interface{}) bool {
|
slaves.Range(func(k, v interface{}) bool {
|
||||||
conn := v.(*net.TCPConn)
|
orderReport(v.(*net.TCPConn), start)
|
||||||
b := []byte{MSG_SUMMARY, 0}
|
|
||||||
if start {
|
|
||||||
b[1] = 1
|
|
||||||
}
|
|
||||||
conn.Write(b)
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -3,12 +3,14 @@ package cluster
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
"strings"
|
||||||
|
|
||||||
. "github.com/langhuihui/monibuca/monica"
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
"github.com/langhuihui/monibuca/monica/avformat"
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
"github.com/langhuihui/monibuca/monica/pool"
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Receiver struct {
|
type Receiver struct {
|
||||||
@@ -24,14 +26,15 @@ func (p *Receiver) Auth(authSub *OutputStream) {
|
|||||||
p.Flush()
|
p.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Receiver) readAVPacket(avType byte) (av *pool.AVPacket, err error) {
|
func (p *Receiver) readAVPacket(avType byte) (av *avformat.AVPacket, err error) {
|
||||||
buf := pool.GetSlice(4)
|
buf := pool.GetSlice(4)
|
||||||
|
defer pool.RecycleSlice(buf)
|
||||||
_, err = io.ReadFull(p, buf)
|
_, err = io.ReadFull(p, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
av = pool.NewAVPacket(avType)
|
av = avformat.NewAVPacket(avType)
|
||||||
av.Timestamp = binary.BigEndian.Uint32(buf)
|
av.Timestamp = binary.BigEndian.Uint32(buf)
|
||||||
_, err = io.ReadFull(p, buf)
|
_, err = io.ReadFull(p, buf)
|
||||||
if MayBeError(err) {
|
if MayBeError(err) {
|
||||||
@@ -39,10 +42,7 @@ func (p *Receiver) readAVPacket(avType byte) (av *pool.AVPacket, err error) {
|
|||||||
}
|
}
|
||||||
av.Payload = pool.GetSlice(int(binary.BigEndian.Uint32(buf)))
|
av.Payload = pool.GetSlice(int(binary.BigEndian.Uint32(buf)))
|
||||||
_, err = io.ReadFull(p, av.Payload)
|
_, err = io.ReadFull(p, av.Payload)
|
||||||
if MayBeError(err) {
|
MayBeError(err)
|
||||||
return
|
|
||||||
}
|
|
||||||
pool.RecycleSlice(buf)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ func PullUpStream(streamPath string) {
|
|||||||
}
|
}
|
||||||
brw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
|
brw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
|
||||||
p := &Receiver{
|
p := &Receiver{
|
||||||
Reader: conn,
|
Reader: brw.Reader,
|
||||||
Writer: brw.Writer,
|
Writer: brw.Writer,
|
||||||
}
|
}
|
||||||
if p.Publish(streamPath, p) {
|
if p.Publish(streamPath, p) {
|
||||||
@@ -72,11 +72,7 @@ func PullUpStream(streamPath string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer p.Cancel()
|
defer p.Cancel()
|
||||||
for {
|
for cmd, err := brw.ReadByte(); !MayBeError(err); cmd, err = brw.ReadByte() {
|
||||||
cmd, err := brw.ReadByte()
|
|
||||||
if MayBeError(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case MSG_AUDIO:
|
case MSG_AUDIO:
|
||||||
if audio, err := p.readAVPacket(avformat.FLV_TAG_TYPE_AUDIO); err == nil {
|
if audio, err := p.readAVPacket(avformat.FLV_TAG_TYPE_AUDIO); err == nil {
|
||||||
@@ -103,6 +99,8 @@ func PullUpStream(streamPath string) {
|
|||||||
v.Cancel()
|
v.Cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
log.Printf("unknown cmd:%v", cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -53,7 +55,7 @@ func process(conn net.Conn) {
|
|||||||
reader := bufio.NewReader(conn)
|
reader := bufio.NewReader(conn)
|
||||||
connAddr := conn.RemoteAddr().String()
|
connAddr := conn.RemoteAddr().String()
|
||||||
stream := OutputStream{
|
stream := OutputStream{
|
||||||
SendHandler: func(p *pool.SendPacket) error {
|
SendHandler: func(p *avformat.SendPacket) error {
|
||||||
head := pool.GetSlice(9)
|
head := pool.GetSlice(9)
|
||||||
head[0] = p.Packet.Type - 7
|
head[0] = p.Packet.Type - 7
|
||||||
binary.BigEndian.PutUint32(head[1:5], p.Timestamp)
|
binary.BigEndian.PutUint32(head[1:5], p.Timestamp)
|
||||||
@@ -80,29 +82,32 @@ func process(conn net.Conn) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
bytes = bytes[0 : len(bytes)-1]
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case MSG_SUBSCRIBE:
|
case MSG_SUBSCRIBE:
|
||||||
if stream.Room != nil {
|
if stream.Room != nil {
|
||||||
fmt.Printf("bare stream already exist from %s", conn.RemoteAddr())
|
fmt.Printf("bare stream already exist from %s", conn.RemoteAddr())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
streamName := string(bytes[0 : len(bytes)-1])
|
go stream.Play(string(bytes))
|
||||||
go stream.Play(streamName)
|
|
||||||
case MSG_AUTH:
|
case MSG_AUTH:
|
||||||
sign := strings.Split(string(bytes[0:len(bytes)-1]), ",")
|
sign := strings.Split(string(bytes), ",")
|
||||||
head := []byte{MSG_AUTH, 2}
|
head := []byte{MSG_AUTH, 2}
|
||||||
if len(sign) > 1 && AuthHooks.Trigger(sign[1]) == nil {
|
if len(sign) > 1 && AuthHooks.Trigger(sign[1]) == nil {
|
||||||
head[1] = 1
|
head[1] = 1
|
||||||
}
|
}
|
||||||
conn.Write(head)
|
conn.Write(head)
|
||||||
conn.Write(bytes)
|
conn.Write(bytes[0 : len(bytes)+1])
|
||||||
case MSG_SUMMARY: //收到从服务器发来报告,加入摘要中
|
case MSG_SUMMARY: //收到从服务器发来报告,加入摘要中
|
||||||
var summary *ServerSummary
|
summary := &ServerSummary{}
|
||||||
if err = json.Unmarshal(bytes, summary); err == nil {
|
if err = json.Unmarshal(bytes, summary); err == nil {
|
||||||
summary.Address = connAddr
|
summary.Address = connAddr
|
||||||
Summary.Report(summary)
|
Summary.Report(summary)
|
||||||
if _, ok := slaves.Load(connAddr); !ok {
|
if _, ok := slaves.Load(connAddr); !ok {
|
||||||
slaves.Store(connAddr, conn)
|
slaves.Store(connAddr, conn)
|
||||||
|
if Summary.Running() {
|
||||||
|
orderReport(io.Writer(conn), true)
|
||||||
|
}
|
||||||
defer slaves.Delete(connAddr)
|
defer slaves.Delete(connAddr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,74 +1,25 @@
|
|||||||
package gateway
|
package gateway
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "github.com/langhuihui/monibuca/monica"
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
|
. "github.com/langhuihui/monibuca/monica/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
config = new(ListenerConfig)
|
config = new(ListenerConfig)
|
||||||
sseBegin = []byte("data: ")
|
startTime = time.Now()
|
||||||
sseEnd = []byte("\n\n")
|
|
||||||
dashboardPath string
|
dashboardPath string
|
||||||
)
|
)
|
||||||
|
|
||||||
type SSE struct {
|
|
||||||
http.ResponseWriter
|
|
||||||
context.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sse *SSE) Write(data []byte) (n int, err error) {
|
|
||||||
if err = sse.Err(); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, err = sse.ResponseWriter.Write(sseBegin)
|
|
||||||
n, err = sse.ResponseWriter.Write(data)
|
|
||||||
_, err = sse.ResponseWriter.Write(sseEnd)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sse.ResponseWriter.(http.Flusher).Flush()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func NewSSE(w http.ResponseWriter, ctx context.Context) *SSE {
|
|
||||||
header := w.Header()
|
|
||||||
header.Set("Content-Type", "text/event-stream")
|
|
||||||
header.Set("Cache-Control", "no-cache")
|
|
||||||
header.Set("Connection", "keep-alive")
|
|
||||||
header.Set("X-Accel-Buffering", "no")
|
|
||||||
header.Set("Access-Control-Allow-Origin", "*")
|
|
||||||
return &SSE{
|
|
||||||
w,
|
|
||||||
ctx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sse *SSE) WriteJSON(data interface{}) (err error) {
|
|
||||||
var jsonData []byte
|
|
||||||
if jsonData, err = json.Marshal(data); err == nil {
|
|
||||||
if _, err = sse.Write(jsonData); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (sse *SSE) WriteExec(cmd *exec.Cmd) error {
|
|
||||||
cmd.Stderr = sse
|
|
||||||
cmd.Stdout = sse
|
|
||||||
return cmd.Run()
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
_, currentFilePath, _, _ := runtime.Caller(0)
|
_, currentFilePath, _, _ := runtime.Caller(0)
|
||||||
dashboardPath = path.Join(path.Dir(currentFilePath), "../../dashboard/dist")
|
dashboardPath = path.Join(path.Dir(currentFilePath), "../../dashboard/dist")
|
||||||
@@ -81,6 +32,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
func run() {
|
func run() {
|
||||||
|
http.HandleFunc("/api/sysInfo", sysInfo)
|
||||||
http.HandleFunc("/api/stop", stopPublish)
|
http.HandleFunc("/api/stop", stopPublish)
|
||||||
http.HandleFunc("/api/summary", summary)
|
http.HandleFunc("/api/summary", summary)
|
||||||
http.HandleFunc("/api/logs", watchLogs)
|
http.HandleFunc("/api/logs", watchLogs)
|
||||||
@@ -146,3 +98,10 @@ func summary(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func sysInfo(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
bytes, err := json.Marshal(EngineInfo)
|
||||||
|
if err == nil {
|
||||||
|
_, err = w.Write(bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -2,12 +2,13 @@ package jessica
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gobwas/ws"
|
"github.com/gobwas/ws"
|
||||||
. "github.com/langhuihui/monibuca/monica"
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
"github.com/langhuihui/monibuca/monica/avformat"
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
"github.com/langhuihui/monibuca/monica/pool"
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func WsHandler(w http.ResponseWriter, r *http.Request) {
|
func WsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -31,7 +32,7 @@ func WsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
if isFlv {
|
if isFlv {
|
||||||
baseStream.Type = "JessicaFlv"
|
baseStream.Type = "JessicaFlv"
|
||||||
baseStream.SendHandler = func(packet *pool.SendPacket) error {
|
baseStream.SendHandler = func(packet *avformat.SendPacket) error {
|
||||||
return avformat.WriteFLVTag(conn, packet)
|
return avformat.WriteFLVTag(conn, packet)
|
||||||
}
|
}
|
||||||
if err := ws.WriteHeader(conn, ws.Header{
|
if err := ws.WriteHeader(conn, ws.Header{
|
||||||
@@ -46,7 +47,7 @@ func WsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
baseStream.Type = "Jessica"
|
baseStream.Type = "Jessica"
|
||||||
baseStream.SendHandler = func(packet *pool.SendPacket) error {
|
baseStream.SendHandler = func(packet *avformat.SendPacket) error {
|
||||||
err := ws.WriteHeader(conn, ws.Header{
|
err := ws.WriteHeader(conn, ws.Header{
|
||||||
Fin: true,
|
Fin: true,
|
||||||
OpCode: ws.OpBinary,
|
OpCode: ws.OpBinary,
|
||||||
|
78
plugins/logrotate/index.go
Normal file
78
plugins/logrotate/index.go
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package logrotate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var config = new(LogRotate)
|
||||||
|
|
||||||
|
type LogRotate struct {
|
||||||
|
Path string
|
||||||
|
Size int64
|
||||||
|
Days int
|
||||||
|
file *os.File
|
||||||
|
currentSize int64
|
||||||
|
createTime time.Time
|
||||||
|
hours float64
|
||||||
|
splitFunc func() bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
InstallPlugin(&PluginConfig{
|
||||||
|
Name: "LogRotate",
|
||||||
|
Type: PLUGIN_HOOK,
|
||||||
|
Config: config,
|
||||||
|
Run: run,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func run() {
|
||||||
|
if config.Size > 0 {
|
||||||
|
config.splitFunc = config.splitBySize
|
||||||
|
} else {
|
||||||
|
if config.Days == 0 {
|
||||||
|
config.Days = 1
|
||||||
|
}
|
||||||
|
config.hours = float64(config.Days) * 24
|
||||||
|
config.splitFunc = config.splitByTime
|
||||||
|
}
|
||||||
|
config.createTime = time.Now()
|
||||||
|
err := os.MkdirAll(config.Path, 0666)
|
||||||
|
config.file, err = os.OpenFile(path.Join(config.Path, fmt.Sprintf("%s.log", config.createTime.Format("2006-01-02T15:04:05"))), os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0666)
|
||||||
|
if err == nil {
|
||||||
|
stat, _ := config.file.Stat()
|
||||||
|
config.currentSize = stat.Size()
|
||||||
|
AddWriter(config)
|
||||||
|
} else {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (l *LogRotate) splitBySize() bool {
|
||||||
|
return l.currentSize >= l.Size
|
||||||
|
}
|
||||||
|
func (l *LogRotate) splitByTime() bool {
|
||||||
|
return time.Since(l.createTime).Hours() > l.hours
|
||||||
|
}
|
||||||
|
func (l *LogRotate) Write(data []byte) (n int, err error) {
|
||||||
|
n, err = l.file.Write(data)
|
||||||
|
l.currentSize += int64(n)
|
||||||
|
if err == nil {
|
||||||
|
if l.splitFunc() {
|
||||||
|
l.createTime = time.Now()
|
||||||
|
if file, err := os.OpenFile(path.Join(l.Path, fmt.Sprintf("%s.log", l.createTime.Format("2006-01-02T15:04:05"))), os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0666); err == nil {
|
||||||
|
l.file = file
|
||||||
|
l.currentSize = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//func (l *LogRotate) FindLog(grep string) string{
|
||||||
|
// cmd:=exec.Command("grep",fmt.Sprintf("\"%s\"",grep),l.Path)
|
||||||
|
// err:=cmd.Run()
|
||||||
|
//}
|
@@ -3,7 +3,6 @@ package record
|
|||||||
import (
|
import (
|
||||||
. "github.com/langhuihui/monibuca/monica"
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
"github.com/langhuihui/monibuca/monica/avformat"
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
|
||||||
"github.com/langhuihui/monibuca/monica/util"
|
"github.com/langhuihui/monibuca/monica/util"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@@ -17,7 +16,7 @@ func getDuration(file *os.File) uint32 {
|
|||||||
if tagSize, err = util.ReadByteToUint32(file, true); err == nil {
|
if tagSize, err = util.ReadByteToUint32(file, true); err == nil {
|
||||||
_, err = file.Seek(-int64(tagSize)-4, io.SeekEnd)
|
_, err = file.Seek(-int64(tagSize)-4, io.SeekEnd)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
var tag *pool.AVPacket
|
var tag *avformat.AVPacket
|
||||||
tag, err = avformat.ReadFLVTag(file)
|
tag, err = avformat.ReadFLVTag(file)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return tag.Timestamp
|
return tag.Timestamp
|
||||||
@@ -40,7 +39,7 @@ func SaveFlv(streamPath string, append bool) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p := OutputStream{SendHandler: func(packet *pool.SendPacket) error {
|
p := OutputStream{SendHandler: func(packet *avformat.SendPacket) error {
|
||||||
return avformat.WriteFLVTag(file, packet)
|
return avformat.WriteFLVTag(file, packet)
|
||||||
}}
|
}}
|
||||||
p.ID = filePath
|
p.ID = filePath
|
||||||
|
@@ -3,6 +3,7 @@ package rtmp
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
"github.com/langhuihui/monibuca/monica/pool"
|
||||||
"github.com/langhuihui/monibuca/monica/util"
|
"github.com/langhuihui/monibuca/monica/util"
|
||||||
"io"
|
"io"
|
||||||
@@ -312,21 +313,21 @@ func (conn *NetConnection) SendMessage(message string, args interface{}) error {
|
|||||||
return conn.writeMessage(RTMP_MSG_AMF0_COMMAND, m)
|
return conn.writeMessage(RTMP_MSG_AMF0_COMMAND, m)
|
||||||
case SEND_UNPUBLISH_RESPONSE_MESSAGE:
|
case SEND_UNPUBLISH_RESPONSE_MESSAGE:
|
||||||
case SEND_FULL_AUDIO_MESSAGE:
|
case SEND_FULL_AUDIO_MESSAGE:
|
||||||
audio, ok := args.(*pool.SendPacket)
|
audio, ok := args.(*avformat.SendPacket)
|
||||||
if !ok {
|
if !ok {
|
||||||
errors.New(message + ", The parameter is AVPacket")
|
errors.New(message + ", The parameter is AVPacket")
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn.sendAVMessage(audio, true, true)
|
return conn.sendAVMessage(audio, true, true)
|
||||||
case SEND_AUDIO_MESSAGE:
|
case SEND_AUDIO_MESSAGE:
|
||||||
audio, ok := args.(*pool.SendPacket)
|
audio, ok := args.(*avformat.SendPacket)
|
||||||
if !ok {
|
if !ok {
|
||||||
errors.New(message + ", The parameter is AVPacket")
|
errors.New(message + ", The parameter is AVPacket")
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn.sendAVMessage(audio, true, false)
|
return conn.sendAVMessage(audio, true, false)
|
||||||
case SEND_FULL_VDIEO_MESSAGE:
|
case SEND_FULL_VDIEO_MESSAGE:
|
||||||
video, ok := args.(*pool.SendPacket)
|
video, ok := args.(*avformat.SendPacket)
|
||||||
if !ok {
|
if !ok {
|
||||||
errors.New(message + ", The parameter is AVPacket")
|
errors.New(message + ", The parameter is AVPacket")
|
||||||
}
|
}
|
||||||
@@ -334,7 +335,7 @@ func (conn *NetConnection) SendMessage(message string, args interface{}) error {
|
|||||||
return conn.sendAVMessage(video, false, true)
|
return conn.sendAVMessage(video, false, true)
|
||||||
case SEND_VIDEO_MESSAGE:
|
case SEND_VIDEO_MESSAGE:
|
||||||
{
|
{
|
||||||
video, ok := args.(*pool.SendPacket)
|
video, ok := args.(*avformat.SendPacket)
|
||||||
if !ok {
|
if !ok {
|
||||||
errors.New(message + ", The parameter is AVPacket")
|
errors.New(message + ", The parameter is AVPacket")
|
||||||
}
|
}
|
||||||
@@ -349,7 +350,7 @@ func (conn *NetConnection) SendMessage(message string, args interface{}) error {
|
|||||||
// 当发送音视频数据的时候,当块类型为12的时候,Chunk Message Header有一个字段TimeStamp,指明一个时间
|
// 当发送音视频数据的时候,当块类型为12的时候,Chunk Message Header有一个字段TimeStamp,指明一个时间
|
||||||
// 当块类型为4,8的时候,Chunk Message Header有一个字段TimeStamp Delta,记录与上一个Chunk的时间差值
|
// 当块类型为4,8的时候,Chunk Message Header有一个字段TimeStamp Delta,记录与上一个Chunk的时间差值
|
||||||
// 当块类型为0的时候,Chunk Message Header没有时间字段,与上一个Chunk时间值相同
|
// 当块类型为0的时候,Chunk Message Header没有时间字段,与上一个Chunk时间值相同
|
||||||
func (conn *NetConnection) sendAVMessage(av *pool.SendPacket, isAudio bool, isFirst bool) error {
|
func (conn *NetConnection) sendAVMessage(av *avformat.SendPacket, isAudio bool, isFirst bool) error {
|
||||||
if conn.writeSeqNum > conn.bandwidth {
|
if conn.writeSeqNum > conn.bandwidth {
|
||||||
conn.totalWrite += conn.writeSeqNum
|
conn.totalWrite += conn.writeSeqNum
|
||||||
conn.writeSeqNum = 0
|
conn.writeSeqNum = 0
|
||||||
|
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
. "github.com/langhuihui/monibuca/monica"
|
. "github.com/langhuihui/monibuca/monica"
|
||||||
"github.com/langhuihui/monibuca/monica/avformat"
|
"github.com/langhuihui/monibuca/monica/avformat"
|
||||||
"github.com/langhuihui/monibuca/monica/pool"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -103,7 +102,7 @@ func processRtmp(conn net.Conn) {
|
|||||||
streamPath := nc.appName + "/" + strings.Split(pm.PublishingName, "?")[0]
|
streamPath := nc.appName + "/" + strings.Split(pm.PublishingName, "?")[0]
|
||||||
pub := new(RTMP)
|
pub := new(RTMP)
|
||||||
if pub.Publish(streamPath, pub) {
|
if pub.Publish(streamPath, pub) {
|
||||||
pub.FirstScreen = make([]*pool.AVPacket, 0)
|
pub.FirstScreen = make([]*avformat.AVPacket, 0)
|
||||||
room = pub.Room
|
room = pub.Room
|
||||||
err = nc.SendMessage(SEND_STREAM_BEGIN_MESSAGE, nil)
|
err = nc.SendMessage(SEND_STREAM_BEGIN_MESSAGE, nil)
|
||||||
err = nc.SendMessage(SEND_PUBLISH_START_MESSAGE, newPublishResponseMessageData(nc.streamID, NetStream_Publish_Start, Level_Status))
|
err = nc.SendMessage(SEND_PUBLISH_START_MESSAGE, newPublishResponseMessageData(nc.streamID, NetStream_Publish_Start, Level_Status))
|
||||||
@@ -114,15 +113,15 @@ func processRtmp(conn net.Conn) {
|
|||||||
pm := msg.MsgData.(*PlayMessage)
|
pm := msg.MsgData.(*PlayMessage)
|
||||||
streamPath := nc.appName + "/" + strings.Split(pm.StreamName, "?")[0]
|
streamPath := nc.appName + "/" + strings.Split(pm.StreamName, "?")[0]
|
||||||
nc.writeChunkSize = 512
|
nc.writeChunkSize = 512
|
||||||
stream := &OutputStream{SendHandler: func(packet *pool.SendPacket) (err error) {
|
stream := &OutputStream{SendHandler: func(packet *avformat.SendPacket) (err error) {
|
||||||
switch true {
|
switch true {
|
||||||
case packet.Packet.IsADTS:
|
case packet.Packet.IsADTS:
|
||||||
tagPacket := pool.NewAVPacket(RTMP_MSG_AUDIO)
|
tagPacket := avformat.NewAVPacket(RTMP_MSG_AUDIO)
|
||||||
tagPacket.Payload = avformat.ADTSToAudioSpecificConfig(packet.Packet.Payload)
|
tagPacket.Payload = avformat.ADTSToAudioSpecificConfig(packet.Packet.Payload)
|
||||||
err = nc.SendMessage(SEND_FULL_AUDIO_MESSAGE, tagPacket)
|
err = nc.SendMessage(SEND_FULL_AUDIO_MESSAGE, tagPacket)
|
||||||
ADTSLength := 7 + (int(packet.Packet.Payload[1]&1) << 1)
|
ADTSLength := 7 + (int(packet.Packet.Payload[1]&1) << 1)
|
||||||
if len(packet.Packet.Payload) > ADTSLength {
|
if len(packet.Packet.Payload) > ADTSLength {
|
||||||
contentPacket := pool.NewAVPacket(RTMP_MSG_AUDIO)
|
contentPacket := avformat.NewAVPacket(RTMP_MSG_AUDIO)
|
||||||
contentPacket.Timestamp = packet.Timestamp
|
contentPacket.Timestamp = packet.Timestamp
|
||||||
contentPacket.Payload = make([]byte, len(packet.Packet.Payload)-ADTSLength+2)
|
contentPacket.Payload = make([]byte, len(packet.Packet.Payload)-ADTSLength+2)
|
||||||
contentPacket.Payload[0] = 0xAF
|
contentPacket.Payload[0] = 0xAF
|
||||||
@@ -162,7 +161,7 @@ func processRtmp(conn net.Conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case RTMP_MSG_AUDIO:
|
case RTMP_MSG_AUDIO:
|
||||||
pkt := pool.NewAVPacket(RTMP_MSG_AUDIO)
|
pkt := avformat.NewAVPacket(RTMP_MSG_AUDIO)
|
||||||
if msg.Timestamp == 0xffffff {
|
if msg.Timestamp == 0xffffff {
|
||||||
totalDuration += msg.ExtendTimestamp
|
totalDuration += msg.ExtendTimestamp
|
||||||
} else {
|
} else {
|
||||||
@@ -172,7 +171,7 @@ func processRtmp(conn net.Conn) {
|
|||||||
pkt.Payload = msg.Body
|
pkt.Payload = msg.Body
|
||||||
room.PushAudio(pkt)
|
room.PushAudio(pkt)
|
||||||
case RTMP_MSG_VIDEO:
|
case RTMP_MSG_VIDEO:
|
||||||
pkt := pool.NewAVPacket(RTMP_MSG_VIDEO)
|
pkt := avformat.NewAVPacket(RTMP_MSG_VIDEO)
|
||||||
if msg.Timestamp == 0xffffff {
|
if msg.Timestamp == 0xffffff {
|
||||||
totalDuration += msg.ExtendTimestamp
|
totalDuration += msg.ExtendTimestamp
|
||||||
} else {
|
} else {
|
||||||
|
21
pm/.gitignore
vendored
Normal file
21
pm/.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# Log files
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
24
pm/README.md
Normal file
24
pm/README.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# pm
|
||||||
|
|
||||||
|
## Project setup
|
||||||
|
```
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compiles and hot-reloads for development
|
||||||
|
```
|
||||||
|
npm run serve
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compiles and minifies for production
|
||||||
|
```
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lints and fixes files
|
||||||
|
```
|
||||||
|
npm run lint
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customize configuration
|
||||||
|
See [Configuration Reference](https://cli.vuejs.org/config/).
|
5
pm/babel.config.js
Normal file
5
pm/babel.config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
presets: [
|
||||||
|
'@vue/cli-plugin-babel/preset'
|
||||||
|
]
|
||||||
|
}
|
535
pm/dist/ajax.js
vendored
Normal file
535
pm/dist/ajax.js
vendored
Normal file
@@ -0,0 +1,535 @@
|
|||||||
|
// a simple ajax
|
||||||
|
!(function () {
|
||||||
|
|
||||||
|
var jsonType = 'application/json';
|
||||||
|
var htmlType = 'text/html';
|
||||||
|
var xmlTypeRE = /^(?:text|application)\/xml/i;
|
||||||
|
var blankRE = /^\s*$/; // \s
|
||||||
|
|
||||||
|
/*
|
||||||
|
* default setting
|
||||||
|
* */
|
||||||
|
var _settings = {
|
||||||
|
|
||||||
|
type: "GET",
|
||||||
|
|
||||||
|
beforeSend: noop,
|
||||||
|
|
||||||
|
success: noop,
|
||||||
|
|
||||||
|
error: noop,
|
||||||
|
|
||||||
|
complete: noop,
|
||||||
|
|
||||||
|
context: null,
|
||||||
|
|
||||||
|
xhr: function () {
|
||||||
|
return new window.XMLHttpRequest();
|
||||||
|
},
|
||||||
|
|
||||||
|
accepts: {
|
||||||
|
json: jsonType,
|
||||||
|
xml: 'application/xml, text/xml',
|
||||||
|
html: htmlType,
|
||||||
|
text: 'text/plain'
|
||||||
|
},
|
||||||
|
|
||||||
|
crossDomain: false,
|
||||||
|
|
||||||
|
timeout: 0,
|
||||||
|
|
||||||
|
username: null,
|
||||||
|
|
||||||
|
password: null,
|
||||||
|
|
||||||
|
processData: true,
|
||||||
|
|
||||||
|
promise: noop
|
||||||
|
};
|
||||||
|
|
||||||
|
function noop() {
|
||||||
|
}
|
||||||
|
|
||||||
|
var ajax = function (options) {
|
||||||
|
|
||||||
|
//
|
||||||
|
var settings = extend({}, options || {});
|
||||||
|
|
||||||
|
//
|
||||||
|
for (var key in _settings) {
|
||||||
|
if (settings[key] === undefined) {
|
||||||
|
settings[key] = _settings[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
try {
|
||||||
|
var q = {};
|
||||||
|
var promise = new Promise(function (resolve, reject) {
|
||||||
|
q.resolve = resolve;
|
||||||
|
q.reject = reject;
|
||||||
|
});
|
||||||
|
|
||||||
|
promise.resolve = q.resolve;
|
||||||
|
promise.reject = q.reject;
|
||||||
|
|
||||||
|
settings.promise = promise;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
//
|
||||||
|
settings.promise = {
|
||||||
|
resolve: noop,
|
||||||
|
reject: noop
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!settings.crossDomain) {
|
||||||
|
settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) && RegExp.$2 !== window.location.href;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataType = settings.dataType;
|
||||||
|
// jsonp
|
||||||
|
if (dataType === 'jsonp') {
|
||||||
|
//
|
||||||
|
var hasPlaceholder = /=\?/.test(settings.url);
|
||||||
|
if (!hasPlaceholder) {
|
||||||
|
var jsonpCallback = (settings.jsonp || 'callback') + '=?';
|
||||||
|
|
||||||
|
settings.url = appendQuery(settings.url, jsonpCallback)
|
||||||
|
}
|
||||||
|
return JSONP(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// url
|
||||||
|
if (!settings.url) {
|
||||||
|
settings.url = window.location.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
serializeData(settings);
|
||||||
|
|
||||||
|
var mime = settings.accepts[dataType]; // mime
|
||||||
|
var baseHeader = {}; // header
|
||||||
|
var protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol; // protocol
|
||||||
|
var xhr = _settings.xhr();
|
||||||
|
var abortTimeout;
|
||||||
|
|
||||||
|
// X-Requested-With header
|
||||||
|
// For cross-domain requests, seeing as conditions for a preflight are
|
||||||
|
// akin to a jigsaw puzzle, we simply never set it to be sure.
|
||||||
|
// (it can always be set on a per-request basis or even using ajaxSetup)
|
||||||
|
// For same-domain requests, won't change header if already provided.
|
||||||
|
if (!settings.crossDomain && !baseHeader['X-Requested-With']) {
|
||||||
|
baseHeader['X-Requested-With'] = 'XMLHttpRequest';
|
||||||
|
}
|
||||||
|
|
||||||
|
// mime
|
||||||
|
if (mime) {
|
||||||
|
//
|
||||||
|
baseHeader['Accept'] = mime;
|
||||||
|
|
||||||
|
if (mime.indexOf(',') > -1) {
|
||||||
|
mime = mime.split(',', 2)[0]
|
||||||
|
}
|
||||||
|
//
|
||||||
|
xhr.overrideMimeType && xhr.overrideMimeType(mime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// contentType
|
||||||
|
if (settings.contentType || (settings.data && settings.type.toUpperCase() !== 'GET')) {
|
||||||
|
baseHeader['Content-Type'] = (settings.contentType || 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
// headers
|
||||||
|
settings.headers = extend(baseHeader, settings.headers || {});
|
||||||
|
|
||||||
|
// on ready state change
|
||||||
|
xhr.onreadystatechange = function () {
|
||||||
|
// readystate
|
||||||
|
if (xhr.readyState === 4) {
|
||||||
|
clearTimeout(abortTimeout);
|
||||||
|
var result;
|
||||||
|
var error = false;
|
||||||
|
//
|
||||||
|
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
|
||||||
|
dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'));
|
||||||
|
result = xhr.responseText;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// xml
|
||||||
|
if (dataType === 'xml') {
|
||||||
|
result = xhr.responseXML;
|
||||||
|
}
|
||||||
|
// json
|
||||||
|
else if (dataType === 'json') {
|
||||||
|
result = blankRE.test(result) ? null : JSON.parse(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
ajaxError(error, 'parseerror', xhr, settings);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ajaxSuccess(result, xhr, settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ajaxError(null, 'error', xhr, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// async
|
||||||
|
var async = 'async' in settings ? settings.async : true;
|
||||||
|
|
||||||
|
// open
|
||||||
|
xhr.open(settings.type, settings.url, async, settings.username, settings.password);
|
||||||
|
|
||||||
|
// xhrFields
|
||||||
|
if (settings.xhrFields) {
|
||||||
|
for (var name in settings.xhrFields) {
|
||||||
|
xhr[name] = settings.xhrFields[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override mime type if needed
|
||||||
|
if (settings.mimeType && xhr.overrideMimeType) {
|
||||||
|
xhr.overrideMimeType(settings.mimeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set request header
|
||||||
|
for (var name in settings.headers) {
|
||||||
|
// Support: IE<9
|
||||||
|
// IE's ActiveXObject throws a 'Type Mismatch' exception when setting
|
||||||
|
// request header to a null-value.
|
||||||
|
//
|
||||||
|
// To keep consistent with other XHR implementations, cast the value
|
||||||
|
// to string and ignore `undefined`.
|
||||||
|
if (settings.headers[name] !== undefined) {
|
||||||
|
xhr.setRequestHeader(name, settings.headers[name] + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// before send
|
||||||
|
if (ajaxBeforeSend(xhr, settings) === false) {
|
||||||
|
xhr.abort();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// timeout
|
||||||
|
if (settings.timeout > 0) {
|
||||||
|
abortTimeout = window.setTimeout(function () {
|
||||||
|
xhr.onreadystatechange = noop;
|
||||||
|
xhr.abort();
|
||||||
|
ajaxError(null, 'timeout', xhr, settings);
|
||||||
|
}, settings.timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send
|
||||||
|
xhr.send(settings.data ? settings.data : null);
|
||||||
|
|
||||||
|
return settings.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method get
|
||||||
|
* */
|
||||||
|
ajax.get = function (url, data, success, dataType) {
|
||||||
|
if (isFunction(data)) {
|
||||||
|
dataType = dataType || success;
|
||||||
|
success = data;
|
||||||
|
data = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ajax({
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
success: success,
|
||||||
|
dataType: dataType
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method post
|
||||||
|
*
|
||||||
|
* dataType:
|
||||||
|
* */
|
||||||
|
ajax.post = function (url, data, success, dataType) {
|
||||||
|
if (isFunction(data)) {
|
||||||
|
dataType = dataType || success;
|
||||||
|
success = data;
|
||||||
|
data = undefined;
|
||||||
|
}
|
||||||
|
return ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
success: success,
|
||||||
|
dataType: dataType
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method getJSON
|
||||||
|
* */
|
||||||
|
ajax.getJSON = function (url, data, success) {
|
||||||
|
|
||||||
|
if (isFunction(data)) {
|
||||||
|
success = data;
|
||||||
|
data = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ajax({
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
success: success,
|
||||||
|
dataType: 'json'
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method ajaxSetup
|
||||||
|
* */
|
||||||
|
ajax.ajaxSetup = function (target, settings) {
|
||||||
|
return settings ? extend(extend(target, _settings), settings) : extend(_settings, target);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* utils
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
|
||||||
|
|
||||||
|
// triggers and extra global event ajaxBeforeSend that's like ajaxSend but cancelable
|
||||||
|
function ajaxBeforeSend(xhr, settings) {
|
||||||
|
var context = settings.context;
|
||||||
|
//
|
||||||
|
if (settings.beforeSend.call(context, xhr, settings) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ajax success
|
||||||
|
function ajaxSuccess(data, xhr, settings) {
|
||||||
|
var context = settings.context;
|
||||||
|
var status = 'success';
|
||||||
|
settings.success.call(context, data, status, xhr);
|
||||||
|
settings.promise.resolve(data, status, xhr);
|
||||||
|
ajaxComplete(status, xhr, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// status: "success", "notmodified", "error", "timeout", "abort", "parsererror"
|
||||||
|
function ajaxComplete(status, xhr, settings) {
|
||||||
|
var context = settings.context;
|
||||||
|
settings.complete.call(context, xhr, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
// type: "timeout", "error", "abort", "parsererror"
|
||||||
|
function ajaxError(error, type, xhr, settings) {
|
||||||
|
var context = settings.context;
|
||||||
|
settings.error.call(context, xhr, type, error);
|
||||||
|
settings.promise.reject(xhr, type, error);
|
||||||
|
ajaxComplete(type, xhr, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// jsonp
|
||||||
|
/*
|
||||||
|
* tks: https://www.cnblogs.com/rubylouvre/archive/2011/02/13/1953087.html
|
||||||
|
* */
|
||||||
|
function JSONP(options) {
|
||||||
|
//
|
||||||
|
var callbackName = options.jsonpCallback || 'jsonp' + (new Date().getTime());
|
||||||
|
|
||||||
|
var script = window.document.createElement('script');
|
||||||
|
|
||||||
|
var abort = function () {
|
||||||
|
// 设置 window.xxx = noop
|
||||||
|
if (callbackName in window) {
|
||||||
|
window[callbackName] = noop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var xhr = {abort: abort};
|
||||||
|
var abortTimeout;
|
||||||
|
|
||||||
|
var head = window.document.getElementsByTagName('head')[0] || window.document.documentElement;
|
||||||
|
|
||||||
|
// ie8+
|
||||||
|
script.onerror = function (error) {
|
||||||
|
_error(error);
|
||||||
|
};
|
||||||
|
|
||||||
|
function _error(error) {
|
||||||
|
window.clearTimeout(abortTimeout);
|
||||||
|
xhr.abort();
|
||||||
|
ajaxError(error.type, xhr, error.type, options);
|
||||||
|
_removeScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
window[callbackName] = function (data) {
|
||||||
|
window.clearTimeout(abortTimeout);
|
||||||
|
ajaxSuccess(data, xhr, options);
|
||||||
|
_removeScript();
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
serializeData(options);
|
||||||
|
|
||||||
|
script.src = options.url.replace(/=\?/, '=' + callbackName);
|
||||||
|
//
|
||||||
|
script.src = appendQuery(script.src, '_=' + (new Date()).getTime());
|
||||||
|
//
|
||||||
|
script.async = true;
|
||||||
|
|
||||||
|
// script charset
|
||||||
|
if (options.scriptCharset) {
|
||||||
|
script.charset = options.scriptCharset;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
head.insertBefore(script, head.firstChild);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (options.timeout > 0) {
|
||||||
|
abortTimeout = window.setTimeout(function () {
|
||||||
|
xhr.abort();
|
||||||
|
ajaxError('timeout', xhr, 'timeout', options);
|
||||||
|
_removeScript();
|
||||||
|
}, options.timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove script
|
||||||
|
function _removeScript() {
|
||||||
|
if (script.clearAttributes) {
|
||||||
|
script.clearAttributes();
|
||||||
|
} else {
|
||||||
|
script.onload = script.onreadystatechange = script.onerror = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (script.parentNode) {
|
||||||
|
script.parentNode.removeChild(script);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
script = null;
|
||||||
|
|
||||||
|
delete window[callbackName];
|
||||||
|
}
|
||||||
|
|
||||||
|
return options.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mime to data type
|
||||||
|
function mimeToDataType(mime) {
|
||||||
|
return mime && (mime === htmlType ? 'html' : mime === jsonType ? 'json' : xmlTypeRE.test(mime) && 'xml') || 'text'
|
||||||
|
}
|
||||||
|
|
||||||
|
// append query
|
||||||
|
function appendQuery(url, query) {
|
||||||
|
return (url + '&' + query).replace(/[&?]{1,2}/, '?');
|
||||||
|
}
|
||||||
|
|
||||||
|
// serialize data
|
||||||
|
function serializeData(options) {
|
||||||
|
// formData
|
||||||
|
if (isObject(options) && !isFormData(options.data) && options.processData) {
|
||||||
|
options.data = param(options.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.data && (!options.type || options.type.toUpperCase() === 'GET')) {
|
||||||
|
options.url = appendQuery(options.url, options.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// serialize
|
||||||
|
function serialize(params, obj, traditional, scope) {
|
||||||
|
var _isArray = isArray(obj);
|
||||||
|
|
||||||
|
for (var key in obj) {
|
||||||
|
var value = obj[key];
|
||||||
|
|
||||||
|
if (scope) {
|
||||||
|
key = traditional ? scope : scope + '[' + (_isArray ? '' : key) + ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle data in serializeArray format
|
||||||
|
if (!scope && _isArray) {
|
||||||
|
params.add(value.name, value.value);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (traditional ? _isArray(value) : isObject(value)) {
|
||||||
|
serialize(params, value, traditional, key);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
params.add(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// param
|
||||||
|
function param(obj, traditional) {
|
||||||
|
var params = [];
|
||||||
|
//
|
||||||
|
params.add = function (k, v) {
|
||||||
|
this.push(encodeURIComponent(k) + '=' + encodeURIComponent(v));
|
||||||
|
};
|
||||||
|
serialize(params, obj, traditional);
|
||||||
|
return params.join('&').replace('%20', '+');
|
||||||
|
}
|
||||||
|
|
||||||
|
// extend
|
||||||
|
function extend(target) {
|
||||||
|
var slice = Array.prototype.slice;
|
||||||
|
var args = slice.call(arguments, 1);
|
||||||
|
//
|
||||||
|
for (var i = 0, length = args.length; i < length; i++) {
|
||||||
|
var source = args[i] || {};
|
||||||
|
for (var key in source) {
|
||||||
|
if (source.hasOwnProperty(key) && source[key] !== undefined) {
|
||||||
|
target[key] = source[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is object
|
||||||
|
function isObject(obj) {
|
||||||
|
var type = typeof obj;
|
||||||
|
return type === 'function' || type === 'object' && !!obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is formData
|
||||||
|
function isFormData(obj) {
|
||||||
|
return obj instanceof FormData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is array
|
||||||
|
function isArray(value) {
|
||||||
|
return Object.prototype.toString.call(value) === "[object Array]";
|
||||||
|
}
|
||||||
|
|
||||||
|
// is function
|
||||||
|
function isFunction(value) {
|
||||||
|
return typeof value === "function";
|
||||||
|
}
|
||||||
|
|
||||||
|
// browser
|
||||||
|
window.ajax = ajax;
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
pm/dist/css/app.200d2f8f.css
vendored
Normal file
1
pm/dist/css/app.200d2f8f.css
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.content{background:#fff}pre{white-space:pre-wrap;word-wrap:break-word}.ivu-tabs .ivu-tabs-tabpane{padding:20px}
|
1
pm/dist/css/chunk-vendors.22ebf426.css
vendored
Normal file
1
pm/dist/css/chunk-vendors.22ebf426.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
pm/dist/favicon.ico
vendored
Normal file
BIN
pm/dist/favicon.ico
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
pm/dist/fonts/ionicons.143146fa.woff2
vendored
Normal file
BIN
pm/dist/fonts/ionicons.143146fa.woff2
vendored
Normal file
Binary file not shown.
BIN
pm/dist/fonts/ionicons.99ac3308.woff
vendored
Normal file
BIN
pm/dist/fonts/ionicons.99ac3308.woff
vendored
Normal file
Binary file not shown.
BIN
pm/dist/fonts/ionicons.d535a25a.ttf
vendored
Normal file
BIN
pm/dist/fonts/ionicons.d535a25a.ttf
vendored
Normal file
Binary file not shown.
870
pm/dist/img/ionicons.a2c4a261.svg
vendored
Normal file
870
pm/dist/img/ionicons.a2c4a261.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 542 KiB |
1
pm/dist/index.html
vendored
Normal file
1
pm/dist/index.html
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>Monibuca Instance Manager</title><script src=ajax.js></script><link href=/css/app.200d2f8f.css rel=preload as=style><link href=/css/chunk-vendors.22ebf426.css rel=preload as=style><link href=/js/app.13e2de5f.js rel=preload as=script><link href=/js/chunk-vendors.2e3b192a.js rel=preload as=script><link href=/css/chunk-vendors.22ebf426.css rel=stylesheet><link href=/css/app.200d2f8f.css rel=stylesheet></head><body><noscript><strong>We're sorry but pm doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.2e3b192a.js></script><script src=/js/app.13e2de5f.js></script></body></html>
|
2
pm/dist/js/app.13e2de5f.js
vendored
Normal file
2
pm/dist/js/app.13e2de5f.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
pm/dist/js/app.13e2de5f.js.map
vendored
Normal file
1
pm/dist/js/app.13e2de5f.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
51
pm/dist/js/chunk-vendors.2e3b192a.js
vendored
Normal file
51
pm/dist/js/chunk-vendors.2e3b192a.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
pm/dist/js/chunk-vendors.2e3b192a.js.map
vendored
Normal file
1
pm/dist/js/chunk-vendors.2e3b192a.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
11593
pm/package-lock.json
generated
Normal file
11593
pm/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
50
pm/package.json
Normal file
50
pm/package.json
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"name": "pm",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"serve": "vue-cli-service serve",
|
||||||
|
"build": "vue-cli-service build",
|
||||||
|
"lint": "vue-cli-service lint"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@iarna/toml": "^2.2.3",
|
||||||
|
"core-js": "^3.4.4",
|
||||||
|
"view-design": "^4.0.0",
|
||||||
|
"vue": "^2.6.10",
|
||||||
|
"vue-router": "^3.1.3",
|
||||||
|
"vuex": "^3.1.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@vue/cli-plugin-babel": "^4.1.0",
|
||||||
|
"@vue/cli-plugin-eslint": "^4.1.0",
|
||||||
|
"@vue/cli-plugin-router": "^4.1.0",
|
||||||
|
"@vue/cli-plugin-vuex": "^4.1.0",
|
||||||
|
"@vue/cli-service": "^4.1.0",
|
||||||
|
"babel-eslint": "^10.0.3",
|
||||||
|
"eslint": "^5.16.0",
|
||||||
|
"eslint-plugin-vue": "^5.0.0",
|
||||||
|
"less": "^3.0.4",
|
||||||
|
"less-loader": "^5.0.0",
|
||||||
|
"vue-cli-plugin-iview": "^2.0.0",
|
||||||
|
"vue-template-compiler": "^2.6.10"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"root": true,
|
||||||
|
"env": {
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"plugin:vue/essential",
|
||||||
|
"eslint:recommended"
|
||||||
|
],
|
||||||
|
"rules": {"no-console": "off"},
|
||||||
|
"parserOptions": {
|
||||||
|
"parser": "babel-eslint"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"browserslist": [
|
||||||
|
"> 1%",
|
||||||
|
"last 2 versions"
|
||||||
|
]
|
||||||
|
}
|
535
pm/public/ajax.js
Normal file
535
pm/public/ajax.js
Normal file
@@ -0,0 +1,535 @@
|
|||||||
|
// a simple ajax
|
||||||
|
!(function () {
|
||||||
|
|
||||||
|
var jsonType = 'application/json';
|
||||||
|
var htmlType = 'text/html';
|
||||||
|
var xmlTypeRE = /^(?:text|application)\/xml/i;
|
||||||
|
var blankRE = /^\s*$/; // \s
|
||||||
|
|
||||||
|
/*
|
||||||
|
* default setting
|
||||||
|
* */
|
||||||
|
var _settings = {
|
||||||
|
|
||||||
|
type: "GET",
|
||||||
|
|
||||||
|
beforeSend: noop,
|
||||||
|
|
||||||
|
success: noop,
|
||||||
|
|
||||||
|
error: noop,
|
||||||
|
|
||||||
|
complete: noop,
|
||||||
|
|
||||||
|
context: null,
|
||||||
|
|
||||||
|
xhr: function () {
|
||||||
|
return new window.XMLHttpRequest();
|
||||||
|
},
|
||||||
|
|
||||||
|
accepts: {
|
||||||
|
json: jsonType,
|
||||||
|
xml: 'application/xml, text/xml',
|
||||||
|
html: htmlType,
|
||||||
|
text: 'text/plain'
|
||||||
|
},
|
||||||
|
|
||||||
|
crossDomain: false,
|
||||||
|
|
||||||
|
timeout: 0,
|
||||||
|
|
||||||
|
username: null,
|
||||||
|
|
||||||
|
password: null,
|
||||||
|
|
||||||
|
processData: true,
|
||||||
|
|
||||||
|
promise: noop
|
||||||
|
};
|
||||||
|
|
||||||
|
function noop() {
|
||||||
|
}
|
||||||
|
|
||||||
|
var ajax = function (options) {
|
||||||
|
|
||||||
|
//
|
||||||
|
var settings = extend({}, options || {});
|
||||||
|
|
||||||
|
//
|
||||||
|
for (var key in _settings) {
|
||||||
|
if (settings[key] === undefined) {
|
||||||
|
settings[key] = _settings[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
try {
|
||||||
|
var q = {};
|
||||||
|
var promise = new Promise(function (resolve, reject) {
|
||||||
|
q.resolve = resolve;
|
||||||
|
q.reject = reject;
|
||||||
|
});
|
||||||
|
|
||||||
|
promise.resolve = q.resolve;
|
||||||
|
promise.reject = q.reject;
|
||||||
|
|
||||||
|
settings.promise = promise;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
//
|
||||||
|
settings.promise = {
|
||||||
|
resolve: noop,
|
||||||
|
reject: noop
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!settings.crossDomain) {
|
||||||
|
settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) && RegExp.$2 !== window.location.href;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataType = settings.dataType;
|
||||||
|
// jsonp
|
||||||
|
if (dataType === 'jsonp') {
|
||||||
|
//
|
||||||
|
var hasPlaceholder = /=\?/.test(settings.url);
|
||||||
|
if (!hasPlaceholder) {
|
||||||
|
var jsonpCallback = (settings.jsonp || 'callback') + '=?';
|
||||||
|
|
||||||
|
settings.url = appendQuery(settings.url, jsonpCallback)
|
||||||
|
}
|
||||||
|
return JSONP(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// url
|
||||||
|
if (!settings.url) {
|
||||||
|
settings.url = window.location.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
serializeData(settings);
|
||||||
|
|
||||||
|
var mime = settings.accepts[dataType]; // mime
|
||||||
|
var baseHeader = {}; // header
|
||||||
|
var protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol; // protocol
|
||||||
|
var xhr = _settings.xhr();
|
||||||
|
var abortTimeout;
|
||||||
|
|
||||||
|
// X-Requested-With header
|
||||||
|
// For cross-domain requests, seeing as conditions for a preflight are
|
||||||
|
// akin to a jigsaw puzzle, we simply never set it to be sure.
|
||||||
|
// (it can always be set on a per-request basis or even using ajaxSetup)
|
||||||
|
// For same-domain requests, won't change header if already provided.
|
||||||
|
if (!settings.crossDomain && !baseHeader['X-Requested-With']) {
|
||||||
|
baseHeader['X-Requested-With'] = 'XMLHttpRequest';
|
||||||
|
}
|
||||||
|
|
||||||
|
// mime
|
||||||
|
if (mime) {
|
||||||
|
//
|
||||||
|
baseHeader['Accept'] = mime;
|
||||||
|
|
||||||
|
if (mime.indexOf(',') > -1) {
|
||||||
|
mime = mime.split(',', 2)[0]
|
||||||
|
}
|
||||||
|
//
|
||||||
|
xhr.overrideMimeType && xhr.overrideMimeType(mime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// contentType
|
||||||
|
if (settings.contentType || (settings.data && settings.type.toUpperCase() !== 'GET')) {
|
||||||
|
baseHeader['Content-Type'] = (settings.contentType || 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
// headers
|
||||||
|
settings.headers = extend(baseHeader, settings.headers || {});
|
||||||
|
|
||||||
|
// on ready state change
|
||||||
|
xhr.onreadystatechange = function () {
|
||||||
|
// readystate
|
||||||
|
if (xhr.readyState === 4) {
|
||||||
|
clearTimeout(abortTimeout);
|
||||||
|
var result;
|
||||||
|
var error = false;
|
||||||
|
//
|
||||||
|
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
|
||||||
|
dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'));
|
||||||
|
result = xhr.responseText;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// xml
|
||||||
|
if (dataType === 'xml') {
|
||||||
|
result = xhr.responseXML;
|
||||||
|
}
|
||||||
|
// json
|
||||||
|
else if (dataType === 'json') {
|
||||||
|
result = blankRE.test(result) ? null : JSON.parse(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
ajaxError(error, 'parseerror', xhr, settings);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ajaxSuccess(result, xhr, settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ajaxError(null, 'error', xhr, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// async
|
||||||
|
var async = 'async' in settings ? settings.async : true;
|
||||||
|
|
||||||
|
// open
|
||||||
|
xhr.open(settings.type, settings.url, async, settings.username, settings.password);
|
||||||
|
|
||||||
|
// xhrFields
|
||||||
|
if (settings.xhrFields) {
|
||||||
|
for (var name in settings.xhrFields) {
|
||||||
|
xhr[name] = settings.xhrFields[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override mime type if needed
|
||||||
|
if (settings.mimeType && xhr.overrideMimeType) {
|
||||||
|
xhr.overrideMimeType(settings.mimeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set request header
|
||||||
|
for (var name in settings.headers) {
|
||||||
|
// Support: IE<9
|
||||||
|
// IE's ActiveXObject throws a 'Type Mismatch' exception when setting
|
||||||
|
// request header to a null-value.
|
||||||
|
//
|
||||||
|
// To keep consistent with other XHR implementations, cast the value
|
||||||
|
// to string and ignore `undefined`.
|
||||||
|
if (settings.headers[name] !== undefined) {
|
||||||
|
xhr.setRequestHeader(name, settings.headers[name] + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// before send
|
||||||
|
if (ajaxBeforeSend(xhr, settings) === false) {
|
||||||
|
xhr.abort();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// timeout
|
||||||
|
if (settings.timeout > 0) {
|
||||||
|
abortTimeout = window.setTimeout(function () {
|
||||||
|
xhr.onreadystatechange = noop;
|
||||||
|
xhr.abort();
|
||||||
|
ajaxError(null, 'timeout', xhr, settings);
|
||||||
|
}, settings.timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send
|
||||||
|
xhr.send(settings.data ? settings.data : null);
|
||||||
|
|
||||||
|
return settings.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method get
|
||||||
|
* */
|
||||||
|
ajax.get = function (url, data, success, dataType) {
|
||||||
|
if (isFunction(data)) {
|
||||||
|
dataType = dataType || success;
|
||||||
|
success = data;
|
||||||
|
data = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ajax({
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
success: success,
|
||||||
|
dataType: dataType
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method post
|
||||||
|
*
|
||||||
|
* dataType:
|
||||||
|
* */
|
||||||
|
ajax.post = function (url, data, success, dataType) {
|
||||||
|
if (isFunction(data)) {
|
||||||
|
dataType = dataType || success;
|
||||||
|
success = data;
|
||||||
|
data = undefined;
|
||||||
|
}
|
||||||
|
return ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
success: success,
|
||||||
|
dataType: dataType
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method getJSON
|
||||||
|
* */
|
||||||
|
ajax.getJSON = function (url, data, success) {
|
||||||
|
|
||||||
|
if (isFunction(data)) {
|
||||||
|
success = data;
|
||||||
|
data = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ajax({
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
success: success,
|
||||||
|
dataType: 'json'
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method ajaxSetup
|
||||||
|
* */
|
||||||
|
ajax.ajaxSetup = function (target, settings) {
|
||||||
|
return settings ? extend(extend(target, _settings), settings) : extend(_settings, target);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* utils
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
|
||||||
|
|
||||||
|
// triggers and extra global event ajaxBeforeSend that's like ajaxSend but cancelable
|
||||||
|
function ajaxBeforeSend(xhr, settings) {
|
||||||
|
var context = settings.context;
|
||||||
|
//
|
||||||
|
if (settings.beforeSend.call(context, xhr, settings) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ajax success
|
||||||
|
function ajaxSuccess(data, xhr, settings) {
|
||||||
|
var context = settings.context;
|
||||||
|
var status = 'success';
|
||||||
|
settings.success.call(context, data, status, xhr);
|
||||||
|
settings.promise.resolve(data, status, xhr);
|
||||||
|
ajaxComplete(status, xhr, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// status: "success", "notmodified", "error", "timeout", "abort", "parsererror"
|
||||||
|
function ajaxComplete(status, xhr, settings) {
|
||||||
|
var context = settings.context;
|
||||||
|
settings.complete.call(context, xhr, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
// type: "timeout", "error", "abort", "parsererror"
|
||||||
|
function ajaxError(error, type, xhr, settings) {
|
||||||
|
var context = settings.context;
|
||||||
|
settings.error.call(context, xhr, type, error);
|
||||||
|
settings.promise.reject(xhr, type, error);
|
||||||
|
ajaxComplete(type, xhr, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// jsonp
|
||||||
|
/*
|
||||||
|
* tks: https://www.cnblogs.com/rubylouvre/archive/2011/02/13/1953087.html
|
||||||
|
* */
|
||||||
|
function JSONP(options) {
|
||||||
|
//
|
||||||
|
var callbackName = options.jsonpCallback || 'jsonp' + (new Date().getTime());
|
||||||
|
|
||||||
|
var script = window.document.createElement('script');
|
||||||
|
|
||||||
|
var abort = function () {
|
||||||
|
// 设置 window.xxx = noop
|
||||||
|
if (callbackName in window) {
|
||||||
|
window[callbackName] = noop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var xhr = {abort: abort};
|
||||||
|
var abortTimeout;
|
||||||
|
|
||||||
|
var head = window.document.getElementsByTagName('head')[0] || window.document.documentElement;
|
||||||
|
|
||||||
|
// ie8+
|
||||||
|
script.onerror = function (error) {
|
||||||
|
_error(error);
|
||||||
|
};
|
||||||
|
|
||||||
|
function _error(error) {
|
||||||
|
window.clearTimeout(abortTimeout);
|
||||||
|
xhr.abort();
|
||||||
|
ajaxError(error.type, xhr, error.type, options);
|
||||||
|
_removeScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
window[callbackName] = function (data) {
|
||||||
|
window.clearTimeout(abortTimeout);
|
||||||
|
ajaxSuccess(data, xhr, options);
|
||||||
|
_removeScript();
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
serializeData(options);
|
||||||
|
|
||||||
|
script.src = options.url.replace(/=\?/, '=' + callbackName);
|
||||||
|
//
|
||||||
|
script.src = appendQuery(script.src, '_=' + (new Date()).getTime());
|
||||||
|
//
|
||||||
|
script.async = true;
|
||||||
|
|
||||||
|
// script charset
|
||||||
|
if (options.scriptCharset) {
|
||||||
|
script.charset = options.scriptCharset;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
head.insertBefore(script, head.firstChild);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (options.timeout > 0) {
|
||||||
|
abortTimeout = window.setTimeout(function () {
|
||||||
|
xhr.abort();
|
||||||
|
ajaxError('timeout', xhr, 'timeout', options);
|
||||||
|
_removeScript();
|
||||||
|
}, options.timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove script
|
||||||
|
function _removeScript() {
|
||||||
|
if (script.clearAttributes) {
|
||||||
|
script.clearAttributes();
|
||||||
|
} else {
|
||||||
|
script.onload = script.onreadystatechange = script.onerror = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (script.parentNode) {
|
||||||
|
script.parentNode.removeChild(script);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
script = null;
|
||||||
|
|
||||||
|
delete window[callbackName];
|
||||||
|
}
|
||||||
|
|
||||||
|
return options.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mime to data type
|
||||||
|
function mimeToDataType(mime) {
|
||||||
|
return mime && (mime === htmlType ? 'html' : mime === jsonType ? 'json' : xmlTypeRE.test(mime) && 'xml') || 'text'
|
||||||
|
}
|
||||||
|
|
||||||
|
// append query
|
||||||
|
function appendQuery(url, query) {
|
||||||
|
return (url + '&' + query).replace(/[&?]{1,2}/, '?');
|
||||||
|
}
|
||||||
|
|
||||||
|
// serialize data
|
||||||
|
function serializeData(options) {
|
||||||
|
// formData
|
||||||
|
if (isObject(options) && !isFormData(options.data) && options.processData) {
|
||||||
|
options.data = param(options.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.data && (!options.type || options.type.toUpperCase() === 'GET')) {
|
||||||
|
options.url = appendQuery(options.url, options.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// serialize
|
||||||
|
function serialize(params, obj, traditional, scope) {
|
||||||
|
var _isArray = isArray(obj);
|
||||||
|
|
||||||
|
for (var key in obj) {
|
||||||
|
var value = obj[key];
|
||||||
|
|
||||||
|
if (scope) {
|
||||||
|
key = traditional ? scope : scope + '[' + (_isArray ? '' : key) + ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle data in serializeArray format
|
||||||
|
if (!scope && _isArray) {
|
||||||
|
params.add(value.name, value.value);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (traditional ? _isArray(value) : isObject(value)) {
|
||||||
|
serialize(params, value, traditional, key);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
params.add(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// param
|
||||||
|
function param(obj, traditional) {
|
||||||
|
var params = [];
|
||||||
|
//
|
||||||
|
params.add = function (k, v) {
|
||||||
|
this.push(encodeURIComponent(k) + '=' + encodeURIComponent(v));
|
||||||
|
};
|
||||||
|
serialize(params, obj, traditional);
|
||||||
|
return params.join('&').replace('%20', '+');
|
||||||
|
}
|
||||||
|
|
||||||
|
// extend
|
||||||
|
function extend(target) {
|
||||||
|
var slice = Array.prototype.slice;
|
||||||
|
var args = slice.call(arguments, 1);
|
||||||
|
//
|
||||||
|
for (var i = 0, length = args.length; i < length; i++) {
|
||||||
|
var source = args[i] || {};
|
||||||
|
for (var key in source) {
|
||||||
|
if (source.hasOwnProperty(key) && source[key] !== undefined) {
|
||||||
|
target[key] = source[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is object
|
||||||
|
function isObject(obj) {
|
||||||
|
var type = typeof obj;
|
||||||
|
return type === 'function' || type === 'object' && !!obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is formData
|
||||||
|
function isFormData(obj) {
|
||||||
|
return obj instanceof FormData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is array
|
||||||
|
function isArray(value) {
|
||||||
|
return Object.prototype.toString.call(value) === "[object Array]";
|
||||||
|
}
|
||||||
|
|
||||||
|
// is function
|
||||||
|
function isFunction(value) {
|
||||||
|
return typeof value === "function";
|
||||||
|
}
|
||||||
|
|
||||||
|
// browser
|
||||||
|
window.ajax = ajax;
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
pm/public/favicon.ico
Normal file
BIN
pm/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
18
pm/public/index.html
Normal file
18
pm/public/index.html
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||||
|
<title>Monibuca Instance Manager</title>
|
||||||
|
<script src="ajax.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
<strong>We're sorry but pm doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||||
|
</noscript>
|
||||||
|
<div id="app"></div>
|
||||||
|
<!-- built files will be auto injected -->
|
||||||
|
</body>
|
||||||
|
</html>
|
17
pm/src/App.vue
Normal file
17
pm/src/App.vue
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<div id="app">
|
||||||
|
<router-view/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'app',
|
||||||
|
components: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
BIN
pm/src/assets/logo.png
Normal file
BIN
pm/src/assets/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
65
pm/src/components/CreateInstance.vue
Normal file
65
pm/src/components/CreateInstance.vue
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<template>
|
||||||
|
<Modal v-bind="$attrs" v-on="$listeners" :title="info && info.Path">
|
||||||
|
<Steps :current="currentStep" size="small" :status="status">
|
||||||
|
<Step title="解析请求"></Step>
|
||||||
|
<Step title="创建目录"></Step>
|
||||||
|
<Step title="写入文件"></Step>
|
||||||
|
<Step title="执行go mod init"></Step>
|
||||||
|
<Step title="执行go build"></Step>
|
||||||
|
<Step title="启动实例"></Step>
|
||||||
|
<Step title="完成"></Step>
|
||||||
|
</Steps>
|
||||||
|
<div>
|
||||||
|
<pre>{{log}}</pre>
|
||||||
|
</div>
|
||||||
|
<div slot="footer">
|
||||||
|
<Checkbox v-model="clearDir">安装前清空目录</Checkbox>
|
||||||
|
<Button type="primary" @click="start" :loading="status=='process'">开始</Button>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let eventSource = null;
|
||||||
|
export default {
|
||||||
|
name: "CreateInstance",
|
||||||
|
props: {
|
||||||
|
info: Object
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
start() {
|
||||||
|
this.status = "process";
|
||||||
|
eventSource = new EventSource(
|
||||||
|
"/instance/create?info=" +
|
||||||
|
JSON.stringify(this.info) +
|
||||||
|
(this.clearDir ? "&clear=true" : "")
|
||||||
|
);
|
||||||
|
eventSource.onopen = () => (this.log = "");
|
||||||
|
eventSource.onmessage = evt => {
|
||||||
|
this.log += evt.data + "\n";
|
||||||
|
if (evt.data == "success") {
|
||||||
|
this.status = "finish";
|
||||||
|
eventSource.close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
eventSource.addEventListener("exception", evt => {
|
||||||
|
this.log += evt.data + "\n";
|
||||||
|
this.status = "error";
|
||||||
|
eventSource.close();
|
||||||
|
});
|
||||||
|
eventSource.addEventListener("step", evt => {
|
||||||
|
let [step, msg] = evt.data.split(":");
|
||||||
|
this.currentStep = step | 0;
|
||||||
|
this.log += msg + "\n";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return { clearDir: true, currentStep: 0, log: "", status: "wait" };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
47
pm/src/components/ImportInstance.vue
Normal file
47
pm/src/components/ImportInstance.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PathSelector v-model="instancePath" placeholder="输入实例所在的路径"></PathSelector>
|
||||||
|
<i-input style="width: 300px;margin:40px auto" v-model="instanceName" :placeholder="defaultInstanceName" search enter-button="Import" @on-search="doImport">
|
||||||
|
<span slot="prepend">实例名称</span>
|
||||||
|
</i-input>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import PathSelector from "./PathSelector"
|
||||||
|
export default {
|
||||||
|
name: "ImportInstance",
|
||||||
|
components:{
|
||||||
|
PathSelector
|
||||||
|
},
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
instancePath:"",
|
||||||
|
instanceName:""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
defaultInstanceName(){
|
||||||
|
let path = this.instancePath.replace(/\\/g,"/")
|
||||||
|
let s = path.split("/")
|
||||||
|
if(path.endsWith("/")) s.pop()
|
||||||
|
return s.pop()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
doImport(){
|
||||||
|
window.ajax.get("/instance/import?path="+this.instancePath+"&name="+this.instanceName).then(x=>{
|
||||||
|
if(x=="success"){
|
||||||
|
this.$Message.success("导入成功!")
|
||||||
|
}else{
|
||||||
|
this.$Message.error(x)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
156
pm/src/components/InstanceList.vue
Normal file
156
pm/src/components/InstanceList.vue
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<List border>
|
||||||
|
<ListItem v-for="item in instances" :key="item.Name">
|
||||||
|
<ListItemMeta :title="item.Name" :description="item.Path"></ListItemMeta>
|
||||||
|
<template v-if="item.Info.StartTime">
|
||||||
|
引擎版本:{{item.Info.Version}} <br>启动时间:
|
||||||
|
<StartTime :value="item.Info.StartTime"></StartTime>
|
||||||
|
</template>
|
||||||
|
<template v-else>{{item.Info}}</template>
|
||||||
|
<template slot="action">
|
||||||
|
<li @click="changeConfig(item)">
|
||||||
|
<Icon type="ios-settings"/>
|
||||||
|
修改配置
|
||||||
|
</li>
|
||||||
|
<li v-if="hasGateway(item)" @click="openGateway(item)">
|
||||||
|
<Icon type="md-browsers"/>
|
||||||
|
管理界面
|
||||||
|
</li>
|
||||||
|
<li @click="currentItem=item,showRestart=true">
|
||||||
|
<Icon type="ios-refresh"/>
|
||||||
|
重启
|
||||||
|
</li>
|
||||||
|
<li @click="shutdown(item)">
|
||||||
|
<Icon type="ios-power"/>
|
||||||
|
关闭
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
</ListItem>
|
||||||
|
</List>
|
||||||
|
<Modal v-model="showRestart" title="重启选项" @on-ok="restart">
|
||||||
|
<Checkbox v-model="update">go get -u</Checkbox>
|
||||||
|
<Checkbox v-model="build">go build</Checkbox>
|
||||||
|
</Modal>
|
||||||
|
<Modal v-model="showConfig" title="修改实例配置" @on-ok="submitConfigChange">
|
||||||
|
<i-input type="textarea" v-model="currentConfig" :rows="20"></i-input>
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import toml from "@iarna/toml"
|
||||||
|
import StartTime from "./StartTime"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "InstanceList",
|
||||||
|
components: {StartTime},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
instances: [],
|
||||||
|
showRestart: false,
|
||||||
|
update: false,
|
||||||
|
build: false,
|
||||||
|
showConfig: false,
|
||||||
|
currentItem: null,
|
||||||
|
currentConfig: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
window.ajax.getJSON("/instance/list").then(x => {
|
||||||
|
for (let name in x) {
|
||||||
|
let instance = x[name]
|
||||||
|
instance.Config = toml.parse(instance.Config)
|
||||||
|
if (this.hasGateway(instance)) {
|
||||||
|
window.ajax.getJSON(this.gateWayHref(instance) + "/api/sysInfo").then(x => {
|
||||||
|
instance.Info = x
|
||||||
|
}).catch(() => {
|
||||||
|
instance.Info = "无法访问实例"
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
instance.Info = "实例未配置网关插件"
|
||||||
|
}
|
||||||
|
this.instances.push(instance)
|
||||||
|
}
|
||||||
|
// this.instances = x;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
changeConfig(item) {
|
||||||
|
this.showConfig = true
|
||||||
|
this.currentItem = item
|
||||||
|
this.currentConfig = toml.stringify(item.Config)
|
||||||
|
},
|
||||||
|
submitConfigChange() {
|
||||||
|
try {
|
||||||
|
this.currentItem.Config = toml.parse(this.currentConfig)
|
||||||
|
window.ajax.post("/instance/updateConfig?instance=" + this.currentItem.Name, this.currentConfig).then(x => {
|
||||||
|
if (x == "success") {
|
||||||
|
this.$Message.success("更新成功!")
|
||||||
|
} else {
|
||||||
|
this.$Message.error(x)
|
||||||
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
this.$Message.error(e)
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
this.$Message.error(e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
openGateway(item) {
|
||||||
|
window.open(this.gateWayHref(item), '_blank')
|
||||||
|
},
|
||||||
|
hasGateway(item) {
|
||||||
|
return item.Config.Plugins.hasOwnProperty("GateWay")
|
||||||
|
},
|
||||||
|
gateWayHref(item) {
|
||||||
|
return "http://" + location.hostname + ":" + item.Config.Plugins.GateWay.ListenAddr.split(":").pop()
|
||||||
|
},
|
||||||
|
restart() {
|
||||||
|
let item = this.currentItem
|
||||||
|
const msg = this.$Message.loading({
|
||||||
|
content: 'restart ' + item.Name + '...',
|
||||||
|
duration: 0
|
||||||
|
});
|
||||||
|
let arg = item.Name
|
||||||
|
if (this.update) {
|
||||||
|
arg += "&update=true"
|
||||||
|
}
|
||||||
|
if (this.build) {
|
||||||
|
arg += "&build=true"
|
||||||
|
}
|
||||||
|
const es = new EventSource("/instance/restart?instance=" + arg)
|
||||||
|
es.onmessage = evt => {
|
||||||
|
if (evt.data == "success") {
|
||||||
|
this.$Message.success("重启成功!")
|
||||||
|
msg()
|
||||||
|
} else {
|
||||||
|
this.$Message.info(evt.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
es.addEventListener("failed", evt => {
|
||||||
|
this.$Message.error(evt.data)
|
||||||
|
msg()
|
||||||
|
})
|
||||||
|
es.onerror = e => {
|
||||||
|
if (e && e.toString()) this.$Message.error(e);
|
||||||
|
msg()
|
||||||
|
es.close()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
shutdown(item) {
|
||||||
|
window.ajax.get("/instance/shutdown?instance=" + item.Name).then(x => {
|
||||||
|
if (x == "success") {
|
||||||
|
this.$Message.success("已关闭实例")
|
||||||
|
} else {
|
||||||
|
this.$Message.error(x)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
66
pm/src/components/PathSelector.vue
Normal file
66
pm/src/components/PathSelector.vue
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<i-input ref="input" v-bind="$attrs" v-on="$listeners" clearable @on-change="onInput">
|
||||||
|
<Button slot="prepend" icon="md-arrow-round-up" @click="goUp"></Button>
|
||||||
|
</i-input>
|
||||||
|
<CellGroup @on-click="onSelectCand">
|
||||||
|
<Cell v-for="item in candidate" :key="item" :title="item" :name="item"></Cell>
|
||||||
|
</CellGroup>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "PathSelector",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
candidate: [],
|
||||||
|
lastInput: "",
|
||||||
|
searching: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
dir(){
|
||||||
|
let paths = this.$refs.input.value.split("/");
|
||||||
|
paths.pop();
|
||||||
|
return paths.join("/");
|
||||||
|
},
|
||||||
|
goUp() {
|
||||||
|
this.lastInput = this.$attrs.value = this.dir()
|
||||||
|
this.$refs.input.$emit('input', this.$attrs.value)
|
||||||
|
this.search(this.lastInput)
|
||||||
|
},
|
||||||
|
onSelectCand(name) {
|
||||||
|
this.lastInput = this.$attrs.value = this.dir()+"/"+name+"/"
|
||||||
|
this.$refs.input.$emit('input', this.$attrs.value)
|
||||||
|
this.search(this.lastInput)
|
||||||
|
},
|
||||||
|
onInput(evt) {
|
||||||
|
this.lastInput = evt.target.value
|
||||||
|
this.search(this.lastInput)
|
||||||
|
},
|
||||||
|
search(v) {
|
||||||
|
if(this.searching)return
|
||||||
|
window.ajax.getJSON("/instance/listDir?input=" + v).then(x => {
|
||||||
|
this.candidate = x
|
||||||
|
if (this.lastInput != v) {
|
||||||
|
this.search(this.lastInput)
|
||||||
|
}else{
|
||||||
|
this.searching = false
|
||||||
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
this.$Message.error(e)
|
||||||
|
if (this.lastInput != v) {
|
||||||
|
this.search(this.lastInput)
|
||||||
|
}else{
|
||||||
|
this.searching = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
18
pm/src/components/StartTime.vue
Normal file
18
pm/src/components/StartTime.vue
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<Poptip trigger="hover" :content="'⌚️'+ new Date(value).toLocaleString()">
|
||||||
|
<Time :time="new Date(value)"></Time>
|
||||||
|
</Poptip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "StartTime",
|
||||||
|
props:{
|
||||||
|
value:String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
13
pm/src/main.js
Normal file
13
pm/src/main.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from './router'
|
||||||
|
import store from './store'
|
||||||
|
import './plugins/iview.js'
|
||||||
|
|
||||||
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
new Vue({
|
||||||
|
router,
|
||||||
|
store,
|
||||||
|
render: h => h(App)
|
||||||
|
}).$mount('#app')
|
6
pm/src/plugins/iview.js
Normal file
6
pm/src/plugins/iview.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import ViewUI from 'view-design'
|
||||||
|
|
||||||
|
Vue.use(ViewUI)
|
||||||
|
|
||||||
|
import 'view-design/dist/styles/iview.css'
|
20
pm/src/router/index.js
Normal file
20
pm/src/router/index.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import VueRouter from 'vue-router'
|
||||||
|
import Instances from "../views/Instances"
|
||||||
|
Vue.use(VueRouter)
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
name: 'instances',
|
||||||
|
component: Instances
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const router = new VueRouter({
|
||||||
|
mode: 'history',
|
||||||
|
base: process.env.BASE_URL,
|
||||||
|
routes
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
45
pm/src/store/index.js
Normal file
45
pm/src/store/index.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import Vuex from 'vuex'
|
||||||
|
Vue.use(Vuex)
|
||||||
|
|
||||||
|
export default new Vuex.Store({
|
||||||
|
state: {
|
||||||
|
defaultPlugins:{
|
||||||
|
GateWay:[
|
||||||
|
"gateway",'ListenAddr = ":8081"',"网关插件,提供各种API服务,包括信息采集和控制等,控制台页面展示(静态资源服务器)"
|
||||||
|
],
|
||||||
|
LogRotate:[
|
||||||
|
"logrotate",`Path = "log"
|
||||||
|
Size = 0
|
||||||
|
Days = 1`,"日志分割插件,Size 代表按照字节数分割,0代表采用时间分割"
|
||||||
|
],
|
||||||
|
Jessica:[
|
||||||
|
"jessica",'ListenAddr = ":8080"',"WebSocket协议订阅,采用私有协议,搭配Jessibuca播放器实现低延时播放"
|
||||||
|
],
|
||||||
|
Cluster:[
|
||||||
|
"cluster",'Master = "localhost:2019"\nListenAddr = ":2019"',"集群插件,可以实现级联转发功能,Master代表上游服务器,ListenAdder代表源服务器监听端口,可只配置一项"
|
||||||
|
],
|
||||||
|
RTMP:[
|
||||||
|
"rtmp",'ListenAddr = ":1935"',"rtmp协议实现,基本发布和订阅功能"
|
||||||
|
],
|
||||||
|
RecordFlv:[
|
||||||
|
"record",'Path="./resource"',"录制视频流到flv文件"
|
||||||
|
],
|
||||||
|
HDL:[
|
||||||
|
"HDL",'ListenAddr = ":2020"',"Http-flv格式实现,可以对接CDN厂商进行回源拉流"
|
||||||
|
],
|
||||||
|
Auth:[
|
||||||
|
"auth",'Key = "www.monibuca.com"',"一个鉴权验证模块"
|
||||||
|
],
|
||||||
|
Qos:[
|
||||||
|
"QoS",'Suffix = ["high","medium","low"]',"质量控制插件,可以动态改变订阅的不同的质量的流"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
},
|
||||||
|
modules: {
|
||||||
|
}
|
||||||
|
})
|
195
pm/src/views/Instances.vue
Normal file
195
pm/src/views/Instances.vue
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
<template>
|
||||||
|
<Layout class="layout">
|
||||||
|
<Header style=" background:unset;text-align: center;">Monibuca 实例管理器</Header>
|
||||||
|
<Content class="content">
|
||||||
|
<Tabs value="name1">
|
||||||
|
<TabPane label="实例" name="name1">
|
||||||
|
<InstanceList></InstanceList>
|
||||||
|
</TabPane>
|
||||||
|
<TabPane label="创建" name="name2">
|
||||||
|
<Steps :current="createStep">
|
||||||
|
<Step title="选择目录" content="选择创建实例的目录"></Step>
|
||||||
|
<Step title="选插件" content="选择要启用的插件"></Step>
|
||||||
|
<Step title="完成" content="完成实例创建"></Step>
|
||||||
|
</Steps>
|
||||||
|
<div style="margin:50px;width:auto">
|
||||||
|
<PathSelector v-model="createPath" v-if="createStep==0"></PathSelector>
|
||||||
|
<div style="display: flex;flex-wrap: wrap" v-else-if="createStep==1">
|
||||||
|
<Card v-for="(item,name) in plugins" :key="name" style="width:200px;margin:5px">
|
||||||
|
<Poptip :content="item.Description" slot="extra" width="200" word-wrap>
|
||||||
|
<Icon size="18" type="ios-help-circle-outline" style="cursor:pointer"/>
|
||||||
|
</Poptip>
|
||||||
|
<Poptip :content="item.Path" trigger="hover" word-wrap slot="title">
|
||||||
|
<Checkbox v-model="item.enabled" style="color: #eb5e46">{{name}}</Checkbox>
|
||||||
|
</Poptip>
|
||||||
|
<i-input type="textarea" v-model="item.Config" placeholder="请输入toml格式"></i-input>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<h3>实例名称:</h3>
|
||||||
|
<i-input
|
||||||
|
v-model="instanceName"
|
||||||
|
:placeholder="createPath.split('/').pop()"
|
||||||
|
></i-input>
|
||||||
|
<h4>安装路径:</h4>
|
||||||
|
<div>
|
||||||
|
<pre>{{createPath}}</pre>
|
||||||
|
</div>
|
||||||
|
<h4>启用的插件:</h4>
|
||||||
|
<div>
|
||||||
|
<pre>{{pluginStr}}</pre>
|
||||||
|
</div>
|
||||||
|
<h4>配置文件:</h4>
|
||||||
|
<div>
|
||||||
|
<pre>{{configStr}}</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ButtonGroup style="display:table;margin:50px auto;">
|
||||||
|
<Button
|
||||||
|
size="large"
|
||||||
|
type="primary"
|
||||||
|
@click="createStep--"
|
||||||
|
v-if="createStep!=0"
|
||||||
|
>
|
||||||
|
<Icon type="ios-arrow-back"></Icon>
|
||||||
|
上一步
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="large"
|
||||||
|
type="success"
|
||||||
|
@click="showAddPlugin=true"
|
||||||
|
v-if="createStep==1"
|
||||||
|
>
|
||||||
|
+
|
||||||
|
添加插件
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="large"
|
||||||
|
type="primary"
|
||||||
|
@click="createStep++"
|
||||||
|
v-if="createStep!=2"
|
||||||
|
>
|
||||||
|
下一步
|
||||||
|
<Icon type="ios-arrow-forward"></Icon>
|
||||||
|
</Button>
|
||||||
|
<Button size="large" type="success" @click="createInstance" v-else>开始创建</Button>
|
||||||
|
</ButtonGroup>
|
||||||
|
</div>
|
||||||
|
</TabPane>
|
||||||
|
<TabPane label="导入" name="name3">
|
||||||
|
<ImportInstance></ImportInstance>
|
||||||
|
</TabPane>
|
||||||
|
</Tabs>
|
||||||
|
</Content>
|
||||||
|
<Modal v-model="showAddPlugin" title="添加Plugin" @on-ok="addPlugin">
|
||||||
|
<Form :model="formPlugin" label-position="top">
|
||||||
|
<FormItem label="插件名称">
|
||||||
|
<i-input v-model="formPlugin.Name" placeholder="插件名称必须和插件注册时的名称一致"></i-input>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="插件包地址">
|
||||||
|
<i-input v-model="formPlugin.Path"></i-input>
|
||||||
|
</FormItem>
|
||||||
|
<Alert show-icon type="warning">
|
||||||
|
如果该插件是私有仓库,请到服务器上输入:echo "machine {{privateHost}} login 用户名 password 密码" >> ~/.netrc
|
||||||
|
并且添加环境变量GOPRIVATE={{privateHost}}
|
||||||
|
</Alert>
|
||||||
|
<FormItem label="插件配置信息">
|
||||||
|
<i-input type="textarea" v-model="formPlugin.Config" placeholder="请输入toml格式"></i-input>
|
||||||
|
</FormItem>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
<CreateInstance v-model="showCreate" :info="createInfo"></CreateInstance>
|
||||||
|
</Layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import CreateInstance from "../components/CreateInstance";
|
||||||
|
import InstanceList from "../components/InstanceList";
|
||||||
|
import ImportInstance from "../components/ImportInstance";
|
||||||
|
import PathSelector from "../components/PathSelector"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
CreateInstance, InstanceList, ImportInstance, PathSelector
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
let plugins = {}
|
||||||
|
for (let name in this.$store.state.defaultPlugins) {
|
||||||
|
plugins[name] = {
|
||||||
|
Name: name,
|
||||||
|
enabled: ["GateWay", "LogRotate", "Jessica"].includes(name),
|
||||||
|
Path: "github.com/langhuihui/monibuca/plugins/" + this.$store.state.defaultPlugins[name][0],
|
||||||
|
Config: this.$store.state.defaultPlugins[name][1],
|
||||||
|
Description: this.$store.state.defaultPlugins[name][2],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
instanceName: "",
|
||||||
|
createStep: 0,
|
||||||
|
showCreate: false,
|
||||||
|
createInfo: null,
|
||||||
|
createPath: "/opt/monibuca",
|
||||||
|
plugins,
|
||||||
|
showAddPlugin: false,
|
||||||
|
formPlugin: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
pluginStr() {
|
||||||
|
return Object.values(this.plugins).filter(x => x.enabled)
|
||||||
|
.map(x => x.Path)
|
||||||
|
.join("\n");
|
||||||
|
},
|
||||||
|
configStr() {
|
||||||
|
return Object.values(this.plugins).filter(x => x.enabled)
|
||||||
|
.map(
|
||||||
|
x => `[Plugins.${x.Name}]
|
||||||
|
${x.Config || ""}`
|
||||||
|
)
|
||||||
|
.join("\n");
|
||||||
|
},
|
||||||
|
privateHost() {
|
||||||
|
return (
|
||||||
|
(this.formPlugin.Path && this.formPlugin.Path.split("/")[0]) ||
|
||||||
|
"仓库域名"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
goUp() {
|
||||||
|
let paths = this.createPath.split("/");
|
||||||
|
paths.pop();
|
||||||
|
this.createPath = paths.join("/");
|
||||||
|
},
|
||||||
|
createInstance() {
|
||||||
|
this.showCreate = true;
|
||||||
|
this.createInfo = {
|
||||||
|
Name: this.instanceName || this.createPath.split("/").pop(),
|
||||||
|
Path: this.createPath,
|
||||||
|
Plugins: Object.values(this.plugins).filter(x => x.enabled).map(x => x.Path),
|
||||||
|
Config: this.configStr
|
||||||
|
};
|
||||||
|
},
|
||||||
|
addPlugin() {
|
||||||
|
this.plugins[this.formPlugin.Name] = this.formPlugin;
|
||||||
|
this.formPlugin = {};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.content {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ivu-tabs .ivu-tabs-tabpane {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
18
slave.toml
Normal file
18
slave.toml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# [Plugins.HDL]
|
||||||
|
# ListenAddr = ":2020"
|
||||||
|
[Plugins.Jessica]
|
||||||
|
ListenAddr = ":8082"
|
||||||
|
[Plugins.RTMP]
|
||||||
|
ListenAddr = ":1936"
|
||||||
|
[Plugins.GateWay]
|
||||||
|
ListenAddr = ":8083"
|
||||||
|
[Plugins.Cluster]
|
||||||
|
Master = "localhost:2019"
|
||||||
|
#ListenAddr = ":2019"
|
||||||
|
#
|
||||||
|
#[Plugins.Auth]
|
||||||
|
#Key="www.monibuca.com"
|
||||||
|
# [Plugins.RecordFlv]
|
||||||
|
# Path="./resource"
|
||||||
|
# [Plugins.QoS]
|
||||||
|
# Suffix = ["high","medium","low"]
|
Reference in New Issue
Block a user