Initial Commit
This commit is contained in:
commit
c9ea17a601
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/seashell
|
||||
/seashell.hcl
|
661
LICENSE
Normal file
661
LICENSE
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 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 Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are 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.
|
||||
|
||||
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.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
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 Affero 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. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
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 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 work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero 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 your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
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 AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
64
README.md
Normal file
64
README.md
Normal file
@ -0,0 +1,64 @@
|
||||
<p align="center">
|
||||
<img src="assets/seashell-text.svg" width="250">
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
Seashell is a custom SSH server that implements virtual hosts with username-based routing, allowing users to securely access shells inside VMs, containers, or even on serial ports. It also features its own authentication and permissions system, independent of system users.
|
||||
|
||||
## Features
|
||||
|
||||
### Fail2Ban
|
||||
|
||||
Seashell has a built-in rate limiter for failed logins. If a user exceeds the configured amount of failed login attempts within the specified time interval, they will be blocked from making any further login attempts until the time interval passes.
|
||||
|
||||
### Permissions
|
||||
|
||||
Seashell comes with a granular permissions system that allows you to allow or deny access to specific resources for specific users or groups of users. This allows you to safely provide shell access to users without also giving them access to any unintended resources.
|
||||
|
||||
## Integrations
|
||||
|
||||
### Docker
|
||||
|
||||
Seashell can integrate with Docker to provide remote shell access into a container. For example, with a route configured to match `docker\\.(.+)`, you can use the following `ssh` command to get a shell inside the `example` container:
|
||||
|
||||
```bash
|
||||
ssh user:docker.example@ssh.example.com
|
||||
```
|
||||
### Nomad
|
||||
|
||||
Seashell can integrate with a Nomad cluster to provide remote shell access into a Nomad allocation. For example, with a route configured to match `nomad\\.(.+)`, you can use the following `ssh` command to get a shell in the first allocation in the `example` job:
|
||||
|
||||
```bash
|
||||
ssh user:nomad.example@ssh.example.com
|
||||
```
|
||||
|
||||
If your job has several tasks, you can specify the task you want like so:
|
||||
|
||||
```bash
|
||||
ssh user:nomad.example.mytask@ssh.example.com
|
||||
```
|
||||
|
||||
### Serial
|
||||
|
||||
Seashell can provide remote access to a physical serial port. For example, with a route configured to match `serial\\.(.+)`, you can use the following `ssh` command to get a access to `/dev/ttyS0`:
|
||||
|
||||
```bash
|
||||
ssh user:serial.ttyS0@ssh.example.com
|
||||
```
|
||||
|
||||
If the baud rate and mode are unknown beforehand, you can specify them in the ssh command, like so:
|
||||
|
||||
```bash
|
||||
ssh user:serial.ttyS0.115200.8n1@ssh.example.com
|
||||
```
|
||||
|
||||
### Proxy
|
||||
|
||||
Seashell can proxy another SSH server. In this case, your client will authenticate to seashell and then seashell will authenticate to the target server, so you should provide seashell with a private key to use for authentication and encryption. If you don't provide this, seashell will ask the authenticating user for the target server's password.
|
||||
|
||||
The proxy backend takes no extra arguments, so the `ssh` command only requires your username and the routing path:
|
||||
|
||||
```bash
|
||||
ssh user:myproxy@ssh.example.com
|
||||
```
|
205
assets/seashell-text.svg
Normal file
205
assets/seashell-text.svg
Normal file
@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="217.73248mm"
|
||||
height="221.66422mm"
|
||||
viewBox="0 0 217.73248 221.66422"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xml:space="preserve"
|
||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||
sodipodi:docname="seashell (copy).svg"
|
||||
inkscape:export-filename="seashell2.png"
|
||||
inkscape:export-xdpi="34.997074"
|
||||
inkscape:export-ydpi="34.997074"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:zoom="0.39533211"
|
||||
inkscape:cx="355.39739"
|
||||
inkscape:cy="308.60129"
|
||||
inkscape:window-width="1046"
|
||||
inkscape:window-height="1182"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="layer1"
|
||||
showguides="false" /><defs
|
||||
id="defs1"><rect
|
||||
x="3.8041592"
|
||||
y="-175.16917"
|
||||
width="832.0437"
|
||||
height="198.64627"
|
||||
id="rect2" /><rect
|
||||
x="156.25291"
|
||||
y="-586.58679"
|
||||
width="518.7984"
|
||||
height="230.71892"
|
||||
id="rect1" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect9"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect7"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect5"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1-5"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1-5-7"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1-5-7-6"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1-5-7-9"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(3.8662446,-60.738641)"><path
|
||||
style="fill:#1a78ff;fill-opacity:1;stroke:none;stroke-width:2.54857;stroke-linecap:round"
|
||||
id="path224475"
|
||||
sodipodi:type="arc"
|
||||
sodipodi:cx="-193.54536"
|
||||
sodipodi:cy="-122.65689"
|
||||
sodipodi:rx="130.53343"
|
||||
sodipodi:ry="148.55132"
|
||||
sodipodi:start="0"
|
||||
sodipodi:end="2.0943951"
|
||||
sodipodi:arc-type="slice"
|
||||
d="m -63.011932,-122.65689 a 130.53343,148.55132 0 0 1 -65.266718,128.6492119 130.53343,148.55132 0 0 1 -130.53343,2e-7 l 65.26672,-128.6492121 z"
|
||||
transform="matrix(-0.79958147,-0.60055764,0.40564612,-0.91403021,0,0)" /><g
|
||||
id="use9"
|
||||
transform="matrix(-1,0,0,1,191.9013,102.25719)"><path
|
||||
id="path224469"
|
||||
style="fill:#005bdd;fill-opacity:1"
|
||||
d="m 96.311034,-41.197039 c 3.935916,0.26961 5.140226,0.31642 11.724866,1.61385 7.8667,1.55004 10.95654,2.62194 13.49116,4.6793 1.46501,1.18915 1.92157,2.29198 1.92857,4.65657 0.006,2.32701 -0.43788,4.26491 -2.27015,9.90688 -2.54293,7.83024 -32.912339,124.273829 -31.620798,125.072489 1.152527,0.71231 10.348262,-27.479179 29.087618,-89.175959 2.20997,-7.2760404 5.028,-16.50339036 6.26267,-20.5052204 1.23466,-4.00181 2.70627,-9.0024396 3.27008,-11.1124996 2.02731,-7.58694 3.1902,-10.35519 5.05861,-12.04319 0.94492,-0.85369 1.14634,-0.92139 2.74712,-0.92139 2.10603,0 4.17823,0.65828 7.39903,2.34921 2.76575,1.45203 9.81897,5.75802 13.15424,8.03103 2.31613,1.57847 5.16674,4.34966 5.86631,5.7025 1.11903,2.16398 0.69564,4.9243696 -1.40819,9.1849696 -21.97826,36.3180704 -44.6351,72.5472504 -64.744356,109.8542894 0.80924,0.80924 45.974986,-67.858849 64.849266,-97.7552894 4.12568,-6.93446 6.71658,-9.15899996 10.12393,-8.69196996 3.0573,0.41904 7.1249,3.67800996 10.86342,8.70436996 2.98671,4.0155904 5.7121,10.7125904 5.7335,14.0880404 0.0101,1.59365 -0.11639,2.11898 -0.89246,3.69539 -0.96239,1.95489 -2.34003,3.43956 -9.94358,10.71924 -17.86656,17.10557 -62.22544,61.06184 -69.28776,68.658859 -4.08781,4.3973 -4.84696,5.32863 -4.57078,5.60482 0.87505,0.87505 36.75847,-31.706649 68.69917,-61.042269 8.88251,-8.15805 11.5354,-10.31447 14.2875,-11.61479 4.05558,-1.91619 7.25733,-0.42156 8.32766,3.88762 0.94029,3.78558 1.598,12.49906 1.20302,15.93649 -0.51992,4.52477 -1.90956,7.7653 -4.27054,9.9596 -0.82752,0.7691 -4.80665,3.30892 -34.62889,22.10149 C 128.62,108.0744 117.48113,115.08666 95.768434,128.73782 c -4.193465,2.63651 -6.323301,3.87745 -8.073922,4.64829 l 5.17e-4,0.61805 c -0.262471,-0.0881 -0.53185,-0.20809 -0.79375,-0.30902 -0.261901,0.10093 -0.53128,0.22088 -0.79375,0.30902 l 5.17e-4,-0.61805 C 84.357424,132.61527 82.227592,131.37433 78.03412,128.73782 56.321419,115.08666 45.182551,108.0744 17.051279,90.347391 c -29.822241,-18.79257 -33.801376,-21.33239 -34.628894,-22.10149 -2.360978,-2.1943 -3.750621,-5.43483 -4.270541,-9.9596 -0.394979,-3.43743 0.263255,-12.15091 1.203544,-15.93649 1.070329,-4.30918 4.271564,-5.80381 8.32714,-3.88762 2.7520966,1.30032 5.4049886,3.45674 14.2875006,11.61479 31.9406984,29.33562 67.8246334,61.917319 68.6996824,61.042269 0.27618,-0.27619 -0.483481,-1.20752 -4.571297,-5.60482 -7.062313,-7.597019 -51.421198,-51.553289 -69.2877614,-68.658859 -7.6035426,-7.27968 -8.9806736,-8.76435 -9.9430626,-10.71924 -0.776069,-1.57641 -0.903098,-2.10174 -0.892968,-3.69539 0.0214,-3.37545 2.7473,-10.07245 5.7340166,-14.0880404 3.738516,-5.02636 7.80559598,-8.28532996 10.862904,-8.70436996 3.407346,-0.46703 5.998244,1.75750996 10.1239294,8.69196996 C 31.569753,38.236941 76.735504,106.90503 77.544744,106.09579 57.435482,68.788751 34.778643,32.559571 12.800375,-3.7584994 c -2.103827,-4.2606 -2.527221,-7.0209896 -1.408182,-9.1849696 0.699569,-1.35284 3.550687,-4.12403 5.866825,-5.7025 3.335267,-2.27301 10.387972,-6.579 13.153719,-8.03103 3.220797,-1.69093 5.293004,-2.34921 7.399032,-2.34921 1.600778,0 1.8022,0.0677 2.747119,0.92139 1.868408,1.688 3.031298,4.45625 5.058606,12.04319 0.563819,2.11006 2.035426,7.1106896 3.270084,11.1124996 1.234669,4.00183004 4.053216,13.22918 6.263184,20.5052204 18.739363,61.69678 27.934585,89.888269 29.087113,89.175959 1.291541,-0.79866 -29.077881,-117.242249 -31.620808,-125.072489 -1.832269,-5.64197 -2.276029,-7.57987 -2.269629,-9.90688 0.007,-2.36459 0.463039,-3.46742 1.928047,-4.65657 2.534628,-2.05736 5.624464,-3.12926 13.491166,-4.6793 6.584634,-1.29743 7.789297,-1.34424 11.725383,-1.61385 6.258336,-0.42867 12.560665,-0.42869 18.819,0 z"
|
||||
sodipodi:nodetypes="asscscsscssssscccsssssssssssssscccccssssssssssscsscccsssssssccscssaa" /></g><g
|
||||
id="g1"
|
||||
transform="matrix(0.91593948,0,0,0.91593948,8.8263539,12.482984)" /><path
|
||||
style="font-size:160px;font-family:Poppins;-inkscape-font-specification:Poppins;text-align:center;letter-spacing:0px;text-anchor:middle;white-space:pre;fill:#005bdd;stroke-width:1.62319;stroke-linecap:round"
|
||||
d="m 13.062661,282.29897 c 7.843239,0 12.050539,-5.09031 12.050539,-10.23257 0,-13.40103 -19.5301831,-7.58353 -19.5301831,-16.93309 0,-3.89564 3.064576,-5.92138 6.9602251,-5.8175 4.415067,0.052 6.700514,2.80487 7.012166,5.24615 h 5.194198 c -0.571361,-5.50585 -5.090313,-9.29762 -11.998597,-9.29762 -7.1679921,0 -11.99859614,4.05147 -11.99859614,10.0248 0,13.45298 19.58212514,7.21994 19.58212514,16.98503 0,3.42817 -2.700983,6.02527 -7.271877,6.02527 -5.0383711,0 -7.1679931,-3.01263 -7.4796441,-6.02527 H 0.54464486 c 0.103884,5.97333 5.24613904,10.0248 12.51801614,10.0248 z m 31.113241,-25.29574 c 4.882546,0 9.037904,3.06458 8.985963,8.62237 H 35.18994 c 0.51942,-5.55779 4.363126,-8.62237 8.985962,-8.62237 z m 13.297147,16.15395 h -5.090314 c -1.03884,3.06458 -3.739823,5.24615 -7.999065,5.24615 -4.830604,0 -8.882078,-3.16847 -9.245672,-8.93402 h 22.750586 c 0.103885,-0.9869 0.155827,-1.81798 0.155827,-2.85681 0,-7.7913 -5.401966,-13.6088 -13.660741,-13.6088 -8.310716,0 -14.076276,5.66167 -14.076276,14.64763 0,9.0379 5.973328,14.75152 14.076276,14.75152 7.064109,0 11.635003,-4.05147 13.089379,-9.24567 z m 5.038414,-5.55779 c 0,8.83014 5.869443,14.80346 13.452974,14.80346 5.246134,0 8.934021,-2.70098 10.648105,-5.76555 v 5.29808 H 91.3912 v -28.4642 h -4.778658 v 5.19419 c -1.662147,-2.96069 -5.29808,-5.66167 -10.596168,-5.66167 -7.635468,0 -13.504911,5.71362 -13.504911,14.59569 z m 24.101079,0.0519 c 0,6.70051 -4.467011,10.59617 -9.661208,10.59617 -5.194197,0 -9.609271,-3.94759 -9.609271,-10.64811 0,-6.70051 4.415074,-10.49227 9.609271,-10.49227 5.194197,0 9.661208,3.94758 9.661208,10.54421 z m 22.854498,14.75152 c 6.28498,0 10.3884,-3.53205 10.3884,-8.20682 -0.20777,-10.18063 -16.72532,-6.49276 -16.72532,-13.24522 0,-2.28544 2.07768,-3.94759 5.55779,-3.94759 3.79177,0 5.97333,2.07769 6.18109,4.93449 h 4.72673 c -0.31165,-5.55779 -4.46701,-8.93401 -10.75199,-8.93401 -6.33692,0 -10.440343,3.58399 -10.440343,7.94711 0,10.59617 16.829203,6.90829 16.829203,13.24522 0,2.33738 -2.07768,4.20729 -5.8175,4.20729 -3.99953,0 -6.44081,-2.07768 -6.70052,-4.8306 h -4.882542 c 0.311648,5.1942 4.986432,8.83013 11.635002,8.83013 z m 17.03694,-38.90454 v 38.43707 h 4.72672 v -15.73842 c 0,-6.12915 3.32429,-9.14179 8.15489,-9.14179 4.77866,0 7.94712,2.96069 7.94712,8.77819 v 16.10202 h 4.67478 v -16.77726 c 0,-8.1549 -5.03837,-12.20637 -11.3753,-12.20637 -3.99952,0 -7.53158,1.6102 -9.40149,4.62284 v -14.07628 z m 45.34532,13.50491 c 4.88254,0 9.0379,3.06459 8.98595,8.62238 h -17.97192 c 0.51942,-5.55779 4.36313,-8.62238 8.98597,-8.62238 z m 13.29714,16.15396 h -5.09032 c -1.03883,3.06458 -3.73981,5.24614 -7.99906,5.24614 -4.8306,0 -8.88207,-3.16846 -9.24567,-8.93402 h 22.75059 c 0.10388,-0.98689 0.15582,-1.81797 0.15582,-2.85681 0,-7.79129 -5.40197,-13.60879 -13.66074,-13.60879 -8.31072,0 -14.07627,5.66167 -14.07627,14.64763 0,9.0379 5.97332,14.75152 14.07627,14.75152 7.06411,0 11.635,-4.05147 13.08938,-9.24567 z m 6.80445,-29.65887 v 38.43707 h 4.72672 v -38.43707 z m 12.77774,0 v 38.43707 h 4.72672 v -38.43707 z"
|
||||
id="text1"
|
||||
aria-label="Seashell" /></g></svg>
|
After Width: | Height: | Size: 14 KiB |
196
assets/seashell.svg
Normal file
196
assets/seashell.svg
Normal file
@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="217.73248mm"
|
||||
height="175.52271mm"
|
||||
viewBox="0 0 217.73248 175.52271"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xml:space="preserve"
|
||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||
sodipodi:docname="seashell.svg"
|
||||
inkscape:export-filename="seashell2.png"
|
||||
inkscape:export-xdpi="34.997074"
|
||||
inkscape:export-ydpi="34.997074"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:zoom="0.39533211"
|
||||
inkscape:cx="254.21664"
|
||||
inkscape:cy="308.60129"
|
||||
inkscape:window-width="1186"
|
||||
inkscape:window-height="706"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1"
|
||||
showguides="false" /><defs
|
||||
id="defs1"><rect
|
||||
x="156.25292"
|
||||
y="-586.58679"
|
||||
width="518.7984"
|
||||
height="230.71892"
|
||||
id="rect1" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect9"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect7"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect5"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1-5"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1-5-7"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1-5-7-6"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /><inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect1-5-7-9"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,0,1,0,0.70525833,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1 @ F,0,0,1,0,6.8791667,0,1"
|
||||
radius="26"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" /></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(3.8662446,-60.738641)"><path
|
||||
style="fill:#1a78ff;fill-opacity:1;stroke:none;stroke-width:2.54857;stroke-linecap:round"
|
||||
id="path224475"
|
||||
sodipodi:type="arc"
|
||||
sodipodi:cx="-193.54536"
|
||||
sodipodi:cy="-122.65689"
|
||||
sodipodi:rx="130.53343"
|
||||
sodipodi:ry="148.55132"
|
||||
sodipodi:start="0"
|
||||
sodipodi:end="2.0943951"
|
||||
sodipodi:arc-type="slice"
|
||||
d="m -63.011932,-122.65689 a 130.53343,148.55132 0 0 1 -65.266718,128.6492119 130.53343,148.55132 0 0 1 -130.53343,2e-7 l 65.26672,-128.6492121 z"
|
||||
transform="matrix(-0.79958147,-0.60055764,0.40564612,-0.91403021,0,0)" /><g
|
||||
id="use9"
|
||||
transform="matrix(-1,0,0,1,191.9013,102.25719)"><path
|
||||
id="path224469"
|
||||
style="fill:#005bdd;fill-opacity:1"
|
||||
d="m 96.311034,-41.197039 c 3.935916,0.26961 5.140226,0.31642 11.724866,1.61385 7.8667,1.55004 10.95654,2.62194 13.49116,4.6793 1.46501,1.18915 1.92157,2.29198 1.92857,4.65657 0.006,2.32701 -0.43788,4.26491 -2.27015,9.90688 -2.54293,7.83024 -32.912339,124.273829 -31.620798,125.072489 1.152527,0.71231 10.348262,-27.479179 29.087618,-89.175959 2.20997,-7.2760404 5.028,-16.50339036 6.26267,-20.5052204 1.23466,-4.00181 2.70627,-9.0024396 3.27008,-11.1124996 2.02731,-7.58694 3.1902,-10.35519 5.05861,-12.04319 0.94492,-0.85369 1.14634,-0.92139 2.74712,-0.92139 2.10603,0 4.17823,0.65828 7.39903,2.34921 2.76575,1.45203 9.81897,5.75802 13.15424,8.03103 2.31613,1.57847 5.16674,4.34966 5.86631,5.7025 1.11903,2.16398 0.69564,4.9243696 -1.40819,9.1849696 -21.97826,36.3180704 -44.6351,72.5472504 -64.744356,109.8542894 0.80924,0.80924 45.974986,-67.858849 64.849266,-97.7552894 4.12568,-6.93446 6.71658,-9.15899996 10.12393,-8.69196996 3.0573,0.41904 7.1249,3.67800996 10.86342,8.70436996 2.98671,4.0155904 5.7121,10.7125904 5.7335,14.0880404 0.0101,1.59365 -0.11639,2.11898 -0.89246,3.69539 -0.96239,1.95489 -2.34003,3.43956 -9.94358,10.71924 -17.86656,17.10557 -62.22544,61.06184 -69.28776,68.658859 -4.08781,4.3973 -4.84696,5.32863 -4.57078,5.60482 0.87505,0.87505 36.75847,-31.706649 68.69917,-61.042269 8.88251,-8.15805 11.5354,-10.31447 14.2875,-11.61479 4.05558,-1.91619 7.25733,-0.42156 8.32766,3.88762 0.94029,3.78558 1.598,12.49906 1.20302,15.93649 -0.51992,4.52477 -1.90956,7.7653 -4.27054,9.9596 -0.82752,0.7691 -4.80665,3.30892 -34.62889,22.10149 C 128.62,108.0744 117.48113,115.08666 95.768434,128.73782 c -4.193465,2.63651 -6.323301,3.87745 -8.073922,4.64829 l 5.17e-4,0.61805 c -0.262471,-0.0881 -0.53185,-0.20809 -0.79375,-0.30902 -0.261901,0.10093 -0.53128,0.22088 -0.79375,0.30902 l 5.17e-4,-0.61805 C 84.357424,132.61527 82.227592,131.37433 78.03412,128.73782 56.321419,115.08666 45.182551,108.0744 17.051279,90.347391 c -29.822241,-18.79257 -33.801376,-21.33239 -34.628894,-22.10149 -2.360978,-2.1943 -3.750621,-5.43483 -4.270541,-9.9596 -0.394979,-3.43743 0.263255,-12.15091 1.203544,-15.93649 1.070329,-4.30918 4.271564,-5.80381 8.32714,-3.88762 2.7520966,1.30032 5.4049886,3.45674 14.2875006,11.61479 31.9406984,29.33562 67.8246334,61.917319 68.6996824,61.042269 0.27618,-0.27619 -0.483481,-1.20752 -4.571297,-5.60482 -7.062313,-7.597019 -51.421198,-51.553289 -69.2877614,-68.658859 -7.6035426,-7.27968 -8.9806736,-8.76435 -9.9430626,-10.71924 -0.776069,-1.57641 -0.903098,-2.10174 -0.892968,-3.69539 0.0214,-3.37545 2.7473,-10.07245 5.7340166,-14.0880404 3.738516,-5.02636 7.80559598,-8.28532996 10.862904,-8.70436996 3.407346,-0.46703 5.998244,1.75750996 10.1239294,8.69196996 C 31.569753,38.236941 76.735504,106.90503 77.544744,106.09579 57.435482,68.788751 34.778643,32.559571 12.800375,-3.7584994 c -2.103827,-4.2606 -2.527221,-7.0209896 -1.408182,-9.1849696 0.699569,-1.35284 3.550687,-4.12403 5.866825,-5.7025 3.335267,-2.27301 10.387972,-6.579 13.153719,-8.03103 3.220797,-1.69093 5.293004,-2.34921 7.399032,-2.34921 1.600778,0 1.8022,0.0677 2.747119,0.92139 1.868408,1.688 3.031298,4.45625 5.058606,12.04319 0.563819,2.11006 2.035426,7.1106896 3.270084,11.1124996 1.234669,4.00183004 4.053216,13.22918 6.263184,20.5052204 18.739363,61.69678 27.934585,89.888269 29.087113,89.175959 1.291541,-0.79866 -29.077881,-117.242249 -31.620808,-125.072489 -1.832269,-5.64197 -2.276029,-7.57987 -2.269629,-9.90688 0.007,-2.36459 0.463039,-3.46742 1.928047,-4.65657 2.534628,-2.05736 5.624464,-3.12926 13.491166,-4.6793 6.584634,-1.29743 7.789297,-1.34424 11.725383,-1.61385 6.258336,-0.42867 12.560665,-0.42869 18.819,0 z"
|
||||
sodipodi:nodetypes="asscscsscssssscccsssssssssssssscccccssssssssssscsscccsssssssccscssaa" /></g><g
|
||||
id="g1"
|
||||
transform="matrix(0.91593948,0,0,0.91593948,8.8263539,12.482984)" /></g></svg>
|
After Width: | Height: | Size: 10 KiB |
107
auth.go
Normal file
107
auth.go
Normal file
@ -0,0 +1,107 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/alexedwards/argon2id"
|
||||
"github.com/gliderlabs/ssh"
|
||||
"go.elara.ws/seashell/internal/config"
|
||||
"go.elara.ws/seashell/internal/fail2ban"
|
||||
"go.elara.ws/seashell/internal/sshctx"
|
||||
)
|
||||
|
||||
// passwordHandler returns a handler that checks password authentication attempts against
|
||||
// fail2ban and the configured argon2id password hash.
|
||||
func passwordHandler(f2b *fail2ban.Fail2Ban, cfg config.Config) ssh.PasswordHandler {
|
||||
return func(ctx ssh.Context, password string) (ok bool) {
|
||||
if !f2b.LoginAllowed(ctx.RemoteAddr()) {
|
||||
log.Warn(
|
||||
"Login attempt blocked by fail2ban policy",
|
||||
slog.String("username", ctx.User()),
|
||||
slog.String("addr", ctx.RemoteAddr().String()),
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
user, ok := getUser(ctx, cfg)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
ok, err := argon2id.ComparePasswordAndHash(password, user.Password)
|
||||
return err == nil && ok
|
||||
}
|
||||
}
|
||||
|
||||
// pubkeyHandler returns a handler that checks public key authentication attempts against
|
||||
// fail2ban and the configures authorized public keys.
|
||||
func pubkeyHandler(f2b *fail2ban.Fail2Ban, cfg config.Config) ssh.PublicKeyHandler {
|
||||
return func(ctx ssh.Context, key ssh.PublicKey) (ok bool) {
|
||||
if !f2b.LoginAllowed(ctx.RemoteAddr()) {
|
||||
log.Warn(
|
||||
"Login attempt blocked by fail2ban policy",
|
||||
slog.String("username", ctx.User()),
|
||||
slog.String("addr", ctx.RemoteAddr().String()),
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
user, ok := getUser(ctx, cfg)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, pubkeyStr := range user.Pubkeys {
|
||||
pubkey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(pubkeyStr))
|
||||
if err != nil {
|
||||
log.Warn("Invalid pubkey", slog.String("user", user.Name), slog.Int("index", i))
|
||||
continue
|
||||
}
|
||||
|
||||
if ssh.KeysEqual(key, pubkey) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// failedConnHandler returns a handler that reports failed login attempts
|
||||
// to the rate limiter.
|
||||
func failedConnHandler(f2b *fail2ban.Fail2Ban) ssh.ConnectionFailedCallback {
|
||||
return func(conn net.Conn, err error) {
|
||||
if strings.Contains(err.Error(), "permission denied") {
|
||||
log.Warn("Failed login attempt", slog.Any("addr", conn.RemoteAddr()))
|
||||
f2b.AddFailedLogin(conn.RemoteAddr())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getUser uses information from the request to retrieve the seashell user
|
||||
// that is attempting to authenticate.
|
||||
func getUser(ctx ssh.Context, cfg config.Config) (config.User, bool) {
|
||||
user, ok := sshctx.GetUser(ctx)
|
||||
if ok {
|
||||
return user, true
|
||||
} else {
|
||||
username, arg, ok := strings.Cut(ctx.User(), ":")
|
||||
if !ok {
|
||||
username, arg, ok = strings.Cut(ctx.User(), "~")
|
||||
if !ok {
|
||||
return config.User{}, false
|
||||
}
|
||||
}
|
||||
sshctx.SetArg(ctx, arg)
|
||||
|
||||
for _, user := range cfg.Auth.Users {
|
||||
if user.Name == username {
|
||||
sshctx.SetUser(ctx, user)
|
||||
return user, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return config.User{}, false
|
||||
}
|
67
go.mod
Normal file
67
go.mod
Normal file
@ -0,0 +1,67 @@
|
||||
module go.elara.ws/seashell
|
||||
|
||||
go 1.22.4
|
||||
|
||||
require (
|
||||
github.com/alexedwards/argon2id v1.0.0
|
||||
github.com/docker/docker v27.0.3+incompatible
|
||||
github.com/gliderlabs/ssh v0.3.7
|
||||
github.com/hashicorp/hcl/v2 v2.21.0
|
||||
github.com/hashicorp/nomad/api v0.0.0-20240709194557-d3041a0e86ed
|
||||
github.com/melbahja/goph v1.4.0
|
||||
github.com/moby/moby v27.0.3+incompatible
|
||||
github.com/zclconf/go-cty v1.13.0
|
||||
go.bug.st/serial v1.6.2
|
||||
go.elara.ws/loggers v0.0.0-20240720233522-c61add53e1a3
|
||||
golang.org/x/crypto v0.17.0
|
||||
lure.sh/fakeroot v0.0.0-20231024205152-b2da39c1be0c
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.4.14 // indirect
|
||||
github.com/agext/levenshtein v1.2.1 // indirect
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
||||
github.com/containerd/log v0.1.0 // indirect
|
||||
github.com/creack/goselect v0.1.2 // indirect
|
||||
github.com/distribution/reference v0.6.0 // indirect
|
||||
github.com/docker/go-connections v0.5.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/hashicorp/cronexpr v1.1.2 // indirect
|
||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/kr/fs v0.1.0 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||
github.com/moby/term v0.5.0 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pkg/sftp v1.13.5 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
|
||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/term v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
||||
gotest.tools/v3 v3.5.1 // indirect
|
||||
)
|
233
go.sum
Normal file
233
go.sum
Normal file
@ -0,0 +1,233 @@
|
||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
|
||||
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/alexedwards/argon2id v1.0.0 h1:wJzDx66hqWX7siL/SRUmgz3F8YMrd/nfX/xHHcQQP0w=
|
||||
github.com/alexedwards/argon2id v1.0.0/go.mod h1:tYKkqIjzXvZdzPvADMWOEZ+l6+BD6CtBXMj5fnJppiw=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
|
||||
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
|
||||
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
|
||||
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
|
||||
github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0=
|
||||
github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||
github.com/docker/docker v27.0.3+incompatible h1:aBGI9TeQ4MPlhquTQKq9XbK79rKFVwXNUAYz9aXyEBE=
|
||||
github.com/docker/docker v27.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
||||
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE=
|
||||
github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
|
||||
github.com/hashicorp/cronexpr v1.1.2 h1:wG/ZYIKT+RT3QkOdgYc+xsKWVRgnxJ1OJtjjy84fJ9A=
|
||||
github.com/hashicorp/cronexpr v1.1.2/go.mod h1:P4wA0KBl9C5q2hABiMO7cp6jcIg96CDh1Efb3g1PWA4=
|
||||
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
|
||||
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
|
||||
github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14=
|
||||
github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
|
||||
github.com/hashicorp/nomad/api v0.0.0-20240709194557-d3041a0e86ed h1:c7JOcxQBYqgoHLNiz4Nr0DQTv7e9noL5lS5l72CnGDQ=
|
||||
github.com/hashicorp/nomad/api v0.0.0-20240709194557-d3041a0e86ed/go.mod h1:svtxn6QnrQ69P23VvIWMR34tg3vmwLz4UdUzm1dSCgE=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/melbahja/goph v1.4.0 h1:z0PgDbBFe66lRYl3v5dGb9aFgPy0kotuQ37QOwSQFqs=
|
||||
github.com/melbahja/goph v1.4.0/go.mod h1:uG+VfK2Dlhk+O32zFrRlc3kYKTlV6+BtvPWd/kK7U68=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
|
||||
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||
github.com/moby/moby v27.0.3+incompatible h1:lnUi7z7EFl1VkcahJOdvkI5QDEHJyib4CHbQK3MCQsw=
|
||||
github.com/moby/moby v27.0.3+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc=
|
||||
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
|
||||
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
|
||||
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
|
||||
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
|
||||
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/sftp v1.13.5 h1:a3RLUqkyjYRtBTZJZ1VRrKbN3zhuPLlUc3sphVz81go=
|
||||
github.com/pkg/sftp v1.13.5/go.mod h1:wHDZ0IZX6JcBYRK1TH9bcVq8G7TLpVHYIGJRFnmPfxg=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/shoenig/test v1.7.1 h1:UJcjSAI3aUKx52kfcfhblgyhZceouhvvs3OYdWgn+PY=
|
||||
github.com/shoenig/test v1.7.1/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0=
|
||||
github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
|
||||
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
|
||||
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
|
||||
go.bug.st/serial v1.6.2 h1:kn9LRX3sdm+WxWKufMlIRndwGfPWsH1/9lCWXQCasq8=
|
||||
go.bug.st/serial v1.6.2/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
|
||||
go.elara.ws/loggers v0.0.0-20240720233522-c61add53e1a3 h1:z69Dh0KTwZF6JPbMhwwzN2ifiMPLGQtD8NjriFUv0k0=
|
||||
go.elara.ws/loggers v0.0.0-20240720233522-c61add53e1a3/go.mod h1:sRtfSVC2elu+igeuceKY8b0cIb4NcWo9OUa5+WyLcxk=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg=
|
||||
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
|
||||
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0/go.mod h1:s75jGIWA9OfCMzF0xr+ZgfrB5FEbbV7UuYo32ahUiFI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk=
|
||||
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
|
||||
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
|
||||
go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE=
|
||||
go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg=
|
||||
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
|
||||
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
|
||||
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
|
||||
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 h1:0+ozOGcrp+Y8Aq8TLNN2Aliibms5LEzsq99ZZmAGYm0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094/go.mod h1:fJ/e3If/Q67Mj99hin0hMhiNyCRmt6BQ2aWIJshUSJw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
||||
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
|
||||
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
|
||||
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
|
||||
lure.sh/fakeroot v0.0.0-20231024205152-b2da39c1be0c h1:3pJqlD1zNMAfgSIkbSix/lXvL8EzXLQyOH4Dy79/oKI=
|
||||
lure.sh/fakeroot v0.0.0-20231024205152-b2da39c1be0c/go.mod h1:/v0u0AZ+wbzUWhV02KzciOf1KFNh7/7rbkz5Z0b5gDA=
|
105
internal/backends/backends.go
Normal file
105
internal/backends/backends.go
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package backends
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
"go.elara.ws/seashell/internal/config"
|
||||
"go.elara.ws/seashell/internal/router"
|
||||
)
|
||||
|
||||
// Backend represents a seashell backend
|
||||
type Backend func(config.Route) router.Handler
|
||||
|
||||
// backends contains all the available backends
|
||||
var backends = map[string]Backend{
|
||||
"proxy": Proxy,
|
||||
"nomad": Nomad,
|
||||
"docker": Docker,
|
||||
"serial": Serial,
|
||||
}
|
||||
|
||||
// Get returns a backend given its name
|
||||
func Get(name string) Backend {
|
||||
return backends[name]
|
||||
}
|
||||
|
||||
// ctyTupleToStrings converts a cty tuple type to a slice of strings
|
||||
func ctyTupleToStrings(t *cty.Value) []string {
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
i := 0
|
||||
out := make([]string, t.LengthInt())
|
||||
iter := t.ElementIterator()
|
||||
for iter.Next() {
|
||||
_, val := iter.Element()
|
||||
if val.Type() == cty.String {
|
||||
out[i] = val.AsString()
|
||||
} else {
|
||||
out[i] = val.GoString()
|
||||
}
|
||||
i++
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// ctyObjToStringMap convertys a cty object type to a map from strings to strings
|
||||
func ctyObjToStringMap(o *cty.Value) map[string]string {
|
||||
if o == nil {
|
||||
return map[string]string{}
|
||||
}
|
||||
|
||||
out := make(map[string]string, o.LengthInt())
|
||||
iter := o.ElementIterator()
|
||||
for iter.Next() {
|
||||
key, val := iter.Element()
|
||||
if key.Type() != cty.String || val.Type() != cty.String {
|
||||
continue
|
||||
}
|
||||
out[key.AsString()] = val.AsString()
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// sshGetenv gets an environment variable from the SSH session
|
||||
func sshGetenv(env []string, key string) string {
|
||||
for _, kv := range env {
|
||||
before, after, ok := strings.Cut(kv, "=")
|
||||
if ok && before == key {
|
||||
return after
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// valueOr returns the value that v points to
|
||||
// or a default value if v is nil.
|
||||
func valueOr[T any](v *T, or T) T {
|
||||
if v == nil {
|
||||
return or
|
||||
}
|
||||
return *v
|
||||
}
|
131
internal/backends/docker.go
Normal file
131
internal/backends/docker.go
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package backends
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
"github.com/zclconf/go-cty/cty/gocty"
|
||||
"go.elara.ws/seashell/internal/config"
|
||||
"go.elara.ws/seashell/internal/router"
|
||||
"go.elara.ws/seashell/internal/sshctx"
|
||||
)
|
||||
|
||||
// dockerSettings represents settings for the docker backend.
|
||||
type dockerSettings struct {
|
||||
Command *cty.Value `cty:"command"`
|
||||
Privileged *bool `cty:"privileged"`
|
||||
User *string `cty:"user"`
|
||||
}
|
||||
|
||||
// Docker is the docker backend. It returns a handler that connects
|
||||
// to a Docker container and executes commands via an SSH session.
|
||||
func Docker(route config.Route) router.Handler {
|
||||
return func(sess ssh.Session, arg string) error {
|
||||
user, _ := sshctx.GetUser(sess.Context())
|
||||
if !route.Permissions.IsAllowed(user, arg) {
|
||||
return router.ErrUnauthorized
|
||||
}
|
||||
|
||||
var opts dockerSettings
|
||||
err := gocty.FromCtyValue(route.Settings, &opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pty, resizeCh, ok := sess.Pty()
|
||||
if !ok {
|
||||
return errors.New("this route only accepts pty sessions (try adding the -t flag)")
|
||||
}
|
||||
|
||||
c, err := client.NewClientWithOpts(
|
||||
client.WithHostFromEnv(),
|
||||
client.WithVersionFromEnv(),
|
||||
client.WithTLSClientConfigFromEnv(),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opts.User == nil {
|
||||
envUser := sshGetenv(sess.Environ(), "DOCKER_USER")
|
||||
opts.User = &envUser
|
||||
}
|
||||
|
||||
cmd := sess.Command()
|
||||
if len(cmd) == 0 {
|
||||
cmd = ctyTupleToStrings(opts.Command)
|
||||
if len(cmd) == 0 {
|
||||
cmd = []string{"/bin/sh"}
|
||||
}
|
||||
}
|
||||
|
||||
idr, err := c.ContainerExecCreate(sess.Context(), arg, container.ExecOptions{
|
||||
User: *opts.User,
|
||||
Privileged: opts.Privileged != nil && *opts.Privileged,
|
||||
Tty: true,
|
||||
AttachStdin: true,
|
||||
AttachStderr: true,
|
||||
AttachStdout: true,
|
||||
Env: append(sess.Environ(), "TERM="+pty.Term),
|
||||
Cmd: cmd,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go dockerHandleResize(resizeCh, sess.Context(), c, idr.ID)
|
||||
|
||||
hr, err := c.ContainerExecAttach(sess.Context(), idr.ID, container.ExecAttachOptions{Tty: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer hr.Close()
|
||||
|
||||
err = c.ContainerExecStart(sess.Context(), idr.ID, container.ExecStartOptions{Tty: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go io.Copy(hr.Conn, sess)
|
||||
io.Copy(sess, hr.Reader)
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// dockerHandleResize resizes the Docker pseudo-tty whenever it receives
|
||||
// a client resize event over SSH.
|
||||
func dockerHandleResize(resizeCh <-chan ssh.Window, ctx context.Context, c *client.Client, execID string) {
|
||||
for newSize := range resizeCh {
|
||||
c.ContainerExecResize(ctx, execID, container.ResizeOptions{
|
||||
Height: uint(newSize.Height),
|
||||
Width: uint(newSize.Width),
|
||||
})
|
||||
}
|
||||
}
|
226
internal/backends/nomad.go
Normal file
226
internal/backends/nomad.go
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package backends
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/hashicorp/nomad/api"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
"github.com/zclconf/go-cty/cty/gocty"
|
||||
"go.elara.ws/seashell/internal/config"
|
||||
"go.elara.ws/seashell/internal/router"
|
||||
"go.elara.ws/seashell/internal/sshctx"
|
||||
)
|
||||
|
||||
// nomadSettings represents settings for the nomad backend.
|
||||
type nomadSettings struct {
|
||||
Server string `cty:"server"`
|
||||
Delimiter *string `cty:"delimeter"`
|
||||
Region *string `cty:"region"`
|
||||
Namespace *string `cty:"namespace"`
|
||||
AuthToken *string `cty:"auth_token"`
|
||||
Command *cty.Value `cty:"command"`
|
||||
}
|
||||
|
||||
// Nomad is the nomad backend. It returns a handler that connects
|
||||
// to a Nomad task and executes commands via an SSH session.
|
||||
func Nomad(route config.Route) router.Handler {
|
||||
return func(sess ssh.Session, arg string) error {
|
||||
user, _ := sshctx.GetUser(sess.Context())
|
||||
|
||||
var opts nomadSettings
|
||||
err := gocty.FromCtyValue(route.Settings, &opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, resizeCh, ok := sess.Pty()
|
||||
if !ok {
|
||||
return errors.New("this route only accepts pty sessions (try adding the -t flag)")
|
||||
}
|
||||
|
||||
c, err := api.NewClient(&api.Config{
|
||||
Address: opts.Server,
|
||||
Region: valueOr(opts.Region, ""),
|
||||
Namespace: valueOr(opts.Namespace, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
delimeter := valueOr(opts.Delimiter, ".")
|
||||
args := strings.Split(arg, delimeter)
|
||||
|
||||
allocList, _, err := c.Jobs().Allocations(args[0], false, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(allocList) == 0 {
|
||||
return fmt.Errorf("job %q has no allocations", args[0])
|
||||
}
|
||||
|
||||
cmd := sess.Command()
|
||||
if len(cmd) == 0 {
|
||||
cmd = ctyTupleToStrings(opts.Command)
|
||||
if len(cmd) == 0 {
|
||||
cmd = []string{"/bin/sh"}
|
||||
}
|
||||
}
|
||||
|
||||
switch len(args) {
|
||||
case 1:
|
||||
alloc, _, err := c.Allocations().Info(allocList[0].ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task := alloc.Job.TaskGroups[0].Tasks[0]
|
||||
|
||||
if !route.Permissions.IsAllowed(
|
||||
user,
|
||||
"job:"+args[0],
|
||||
"task:"+task.Name,
|
||||
"group:"+valueOr(alloc.Job.TaskGroups[0].Name, "unknown"),
|
||||
) {
|
||||
return router.ErrUnauthorized
|
||||
}
|
||||
|
||||
sizeCh := make(chan api.TerminalSize)
|
||||
go nomadHandleResize(resizeCh, sizeCh)
|
||||
_, err = c.Allocations().Exec(sess.Context(), alloc, task.Name, true, cmd, sess, sess, sess.Stderr(), sizeCh, nil)
|
||||
return err
|
||||
case 2:
|
||||
alloc, _, err := c.Allocations().Info(allocList[0].ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
group := alloc.Job.TaskGroups[0]
|
||||
for _, task := range group.Tasks {
|
||||
if task.Name != args[1] {
|
||||
continue
|
||||
}
|
||||
|
||||
if !route.Permissions.IsAllowed(
|
||||
user,
|
||||
"job:"+args[0],
|
||||
"task:"+task.Name,
|
||||
"group:"+valueOr(group.Name, "unknown"),
|
||||
) {
|
||||
return router.ErrUnauthorized
|
||||
}
|
||||
|
||||
sizeCh := make(chan api.TerminalSize)
|
||||
go nomadHandleResize(resizeCh, sizeCh)
|
||||
_, err = c.Allocations().Exec(sess.Context(), alloc, task.Name, true, cmd, sess, sess, sess.Stderr(), sizeCh, nil)
|
||||
return err
|
||||
}
|
||||
return errors.New("task not found")
|
||||
case 3:
|
||||
alloc, _, err := c.Allocations().Info(allocList[0].ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
group := alloc.Job.LookupTaskGroup(args[1])
|
||||
if group == nil {
|
||||
return errors.New("task group not found")
|
||||
}
|
||||
|
||||
var taskName = args[2]
|
||||
if taskName == "" {
|
||||
taskName = group.Tasks[0].Name
|
||||
}
|
||||
|
||||
if !route.Permissions.IsAllowed(
|
||||
user,
|
||||
"job:"+args[0],
|
||||
"task:"+taskName,
|
||||
"group:"+valueOr(group.Name, "unknown"),
|
||||
) {
|
||||
return router.ErrUnauthorized
|
||||
}
|
||||
|
||||
sizeCh := make(chan api.TerminalSize)
|
||||
go nomadHandleResize(resizeCh, sizeCh)
|
||||
_, err = c.Allocations().Exec(sess.Context(), alloc, taskName, true, cmd, sess, sess, sess.Stderr(), sizeCh, nil)
|
||||
return err
|
||||
case 4:
|
||||
allocID := args[1]
|
||||
if index, err := strconv.Atoi(args[1]); err == nil && index < len(allocList) {
|
||||
allocID = allocList[index].ID
|
||||
}
|
||||
|
||||
alloc, _, err := c.Allocations().Info(allocID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var group *api.TaskGroup
|
||||
if args[2] == "" {
|
||||
group = alloc.Job.TaskGroups[0]
|
||||
} else {
|
||||
group = alloc.Job.LookupTaskGroup(args[2])
|
||||
if group == nil {
|
||||
return errors.New("task group not found")
|
||||
}
|
||||
}
|
||||
|
||||
var taskName = args[3]
|
||||
if taskName == "" {
|
||||
taskName = group.Tasks[0].Name
|
||||
}
|
||||
|
||||
if !route.Permissions.IsAllowed(
|
||||
user,
|
||||
"job:"+args[0],
|
||||
"task:"+taskName,
|
||||
"group:"+valueOr(group.Name, "unknown"),
|
||||
) {
|
||||
return router.ErrUnauthorized
|
||||
}
|
||||
|
||||
sizeCh := make(chan api.TerminalSize)
|
||||
go nomadHandleResize(resizeCh, sizeCh)
|
||||
_, err = c.Allocations().Exec(sess.Context(), alloc, taskName, true, cmd, sess, sess, sess.Stderr(), sizeCh, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// nomadHandleResize resizes the Nomad pseudo-tty whenever it receives
|
||||
// a client resize event over SSH.
|
||||
func nomadHandleResize(resizeCh <-chan ssh.Window, sizeCh chan<- api.TerminalSize) {
|
||||
defer close(sizeCh)
|
||||
for newSize := range resizeCh {
|
||||
sizeCh <- api.TerminalSize{
|
||||
Height: newSize.Height,
|
||||
Width: newSize.Width,
|
||||
}
|
||||
}
|
||||
}
|
223
internal/backends/proxy.go
Normal file
223
internal/backends/proxy.go
Normal file
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package backends
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/melbahja/goph"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
"github.com/zclconf/go-cty/cty/gocty"
|
||||
"go.elara.ws/seashell/internal/config"
|
||||
"go.elara.ws/seashell/internal/router"
|
||||
"go.elara.ws/seashell/internal/sshctx"
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
// proxySettings represents settings for the proxy backend.
|
||||
type proxySettings struct {
|
||||
Server string `cty:"server"`
|
||||
User *string `cty:"user"`
|
||||
PrivkeyPath *string `cty:"privkey"`
|
||||
UserMap *cty.Value `cty:"userMap"`
|
||||
}
|
||||
|
||||
// Proxy is the proxy backend. It returns a handler that establishes a proxy
|
||||
// session to a remote server based on the provided configuration.
|
||||
func Proxy(route config.Route) router.Handler {
|
||||
return func(sess ssh.Session, arg string) error {
|
||||
user, _ := sshctx.GetUser(sess.Context())
|
||||
if !route.Permissions.IsAllowed(user, "*") {
|
||||
return router.ErrUnauthorized
|
||||
}
|
||||
|
||||
var opts proxySettings
|
||||
err := gocty.FromCtyValue(route.Settings, &opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pty, resizeCh, ok := sess.Pty()
|
||||
if !ok {
|
||||
return errors.New("this route only accepts pty sessions (try adding the -t flag)")
|
||||
}
|
||||
|
||||
if opts.User == nil {
|
||||
userMap := ctyObjToStringMap(opts.UserMap)
|
||||
user, _ := sshctx.GetUser(sess.Context())
|
||||
|
||||
if muser, ok := userMap[user.Name]; ok {
|
||||
opts.User = &muser
|
||||
} else {
|
||||
opts.User = &user.Name
|
||||
}
|
||||
}
|
||||
|
||||
auth := goph.Auth{
|
||||
gossh.PasswordCallback(requestPassword(opts, sess)),
|
||||
}
|
||||
|
||||
if opts.PrivkeyPath != nil {
|
||||
data, err := os.ReadFile(*opts.PrivkeyPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pk, err := gossh.ParsePrivateKey(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
auth = append(goph.Auth{gossh.PublicKeys(pk)}, auth...)
|
||||
}
|
||||
|
||||
c, err := goph.New(*opts.User, opts.Server, auth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
knownHostHandler, err := goph.DefaultKnownHosts()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.Config.Callback = func(host string, remote net.Addr, key gossh.PublicKey) error {
|
||||
println("hi")
|
||||
err = goph.AddKnownHost(host, remote, key, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return knownHostHandler(host, remote, key)
|
||||
}
|
||||
|
||||
baseCmd := sess.Command()
|
||||
|
||||
var userCmd string
|
||||
if len(baseCmd) > 0 {
|
||||
userCmd = baseCmd[0]
|
||||
}
|
||||
|
||||
var userArgs []string
|
||||
if len(baseCmd) > 1 {
|
||||
userArgs = baseCmd[1:]
|
||||
}
|
||||
|
||||
cmd, err := c.Command(userCmd, userArgs...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = cmd.RequestPty(pty.Term, pty.Window.Height, pty.Window.Width, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
go sshHandleResize(resizeCh, cmd)
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stdin.Close()
|
||||
|
||||
go io.Copy(sess, stdout)
|
||||
go io.Copy(stdin, sess)
|
||||
|
||||
if len(baseCmd) == 0 {
|
||||
err = cmd.Shell()
|
||||
} else {
|
||||
err = cmd.Start()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return cmd.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
// requestPassword asks the client for the remote server's password
|
||||
func requestPassword(opts proxySettings, sess ssh.Session) func() (secret string, err error) {
|
||||
return func() (secret string, err error) {
|
||||
_, err = fmt.Fprintf(sess.Stderr(), "Password for %s@%s: ", *opts.User, opts.Server)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
pwd, err := readPassword(sess)
|
||||
sess.Write([]byte{'\n'})
|
||||
return strings.TrimSpace(pwd), err
|
||||
}
|
||||
}
|
||||
|
||||
// nomadHandleResize resizes the remote SSH pseudo-tty whenever it
|
||||
// receives a client resize event over SSH.
|
||||
func sshHandleResize(resizeCh <-chan ssh.Window, cmd *goph.Cmd) {
|
||||
for newSize := range resizeCh {
|
||||
cmd.WindowChange(newSize.Height, newSize.Width)
|
||||
}
|
||||
}
|
||||
|
||||
// readPassword reads a password from the SSH session, sending an asterisk
|
||||
// for each character typed.
|
||||
//
|
||||
// It handles interrupts (Ctrl+C), EOF (Ctrl+D), and backspace.
|
||||
// It returns what it read once it receives a carriage return or a newline.
|
||||
func readPassword(sess ssh.Session) (string, error) {
|
||||
var out []byte
|
||||
|
||||
for {
|
||||
buf := make([]byte, 1)
|
||||
_, err := sess.Read(buf)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
switch buf[0] {
|
||||
case '\r', '\n':
|
||||
return string(out), nil
|
||||
case '\x7F':
|
||||
if len(out) != 0 {
|
||||
out = out[:len(out)-1]
|
||||
// Delete the last asterisk character
|
||||
sess.Write([]byte("\x08 \x08"))
|
||||
}
|
||||
continue
|
||||
case '\x03', '\x04':
|
||||
sess.Close()
|
||||
return "", errors.New("password entry canceled")
|
||||
default:
|
||||
// Give users some feedback that their password is being received
|
||||
sess.Write([]byte{'*'})
|
||||
}
|
||||
|
||||
out = append(out, buf[0])
|
||||
}
|
||||
}
|
192
internal/backends/serial.go
Normal file
192
internal/backends/serial.go
Normal file
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package backends
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/zclconf/go-cty/cty/gocty"
|
||||
"go.bug.st/serial"
|
||||
"go.elara.ws/seashell/internal/config"
|
||||
"go.elara.ws/seashell/internal/router"
|
||||
"go.elara.ws/seashell/internal/sshctx"
|
||||
)
|
||||
|
||||
// serialSettings represents settings for the serial backend.
|
||||
type serialSettings struct {
|
||||
Directory *string `cty:"directory"`
|
||||
File *string `cty:"file"`
|
||||
Delimiter *string `cty:"delimeter"`
|
||||
BaudRate *int `cty:"baud_rate"`
|
||||
Configuration *string `cty:"config"`
|
||||
}
|
||||
|
||||
// Serial is the serial backend. It returns a handler that
|
||||
// exposes a serial port on an SSH connection.
|
||||
func Serial(route config.Route) router.Handler {
|
||||
return func(sess ssh.Session, arg string) error {
|
||||
user, _ := sshctx.GetUser(sess.Context())
|
||||
|
||||
var opts serialSettings
|
||||
err := gocty.FromCtyValue(route.Settings, &opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opts.Directory == nil && opts.File == nil {
|
||||
return errors.New("either directory or file must be set in the server config")
|
||||
}
|
||||
|
||||
// Since we can't specify the size of a physical serial port,
|
||||
// we can discard the window size channel and the pty info.
|
||||
_, _, ok := sess.Pty()
|
||||
if !ok {
|
||||
return errors.New("this route only accepts pty sessions")
|
||||
}
|
||||
|
||||
delimeter := valueOr(opts.Delimiter, ".")
|
||||
args := strings.Split(arg, delimeter)
|
||||
|
||||
if len(args) == 0 {
|
||||
return errors.New("at least one argument required")
|
||||
}
|
||||
|
||||
var file, baudRate, config string
|
||||
if opts.File != nil {
|
||||
file = *opts.File
|
||||
switch len(args) {
|
||||
case 1:
|
||||
baudRate = args[0]
|
||||
default:
|
||||
baudRate, config = args[0], args[1]
|
||||
}
|
||||
} else if opts.Directory != nil {
|
||||
switch len(args) {
|
||||
case 1:
|
||||
file = filepath.Join(*opts.Directory, args[0])
|
||||
case 2:
|
||||
file, baudRate = filepath.Join(*opts.Directory, args[0]), args[1]
|
||||
default:
|
||||
file, baudRate, config = filepath.Join(*opts.Directory, args[0]), args[1], args[2]
|
||||
}
|
||||
}
|
||||
|
||||
if !route.Permissions.IsAllowed(user, filepath.Base(file)) {
|
||||
return router.ErrUnauthorized
|
||||
}
|
||||
|
||||
mode, err := getSerialMode(opts, baudRate, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
port, err := serial.Open(file, mode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer port.Close()
|
||||
|
||||
go io.Copy(sess, port)
|
||||
io.Copy(port, sess)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// getSerialMode tries to get the serial mode configuration from the
|
||||
// config or from the argument provided by the client.
|
||||
func getSerialMode(opts serialSettings, baudRate, config string) (out *serial.Mode, err error) {
|
||||
if config == "" {
|
||||
if opts.Configuration == nil {
|
||||
return nil, errors.New("no serial configuration provided")
|
||||
}
|
||||
|
||||
out, err = parseSerialMode(*opts.Configuration)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
out, err = parseSerialMode(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if baudRate == "" {
|
||||
if opts.BaudRate == nil {
|
||||
return nil, errors.New("no baud rate provided")
|
||||
}
|
||||
|
||||
out.BaudRate = *opts.BaudRate
|
||||
} else {
|
||||
out.BaudRate, err = strconv.Atoi(baudRate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// parseSerialMode parses a serial mode string (e.x. 8n1)
|
||||
func parseSerialMode(cfg string) (out *serial.Mode, err error) {
|
||||
cfg = strings.ToLower(cfg)
|
||||
|
||||
out = &serial.Mode{}
|
||||
out.DataBits, err = strconv.Atoi(cfg[:1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch parity := cfg[1]; parity {
|
||||
case 'n':
|
||||
out.Parity = serial.NoParity
|
||||
case 'e':
|
||||
out.Parity = serial.EvenParity
|
||||
case 'o':
|
||||
out.Parity = serial.OddParity
|
||||
case 'm':
|
||||
out.Parity = serial.MarkParity
|
||||
case 's':
|
||||
out.Parity = serial.SpaceParity
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown parity mode: %c", parity)
|
||||
}
|
||||
|
||||
switch stop := cfg[2:]; stop {
|
||||
case "1":
|
||||
out.StopBits = serial.OneStopBit
|
||||
case "1.5":
|
||||
out.StopBits = serial.OnePointFiveStopBits
|
||||
case "2":
|
||||
out.StopBits = serial.TwoStopBits
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported stop bit amount: %s", stop)
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
79
internal/config/config.go
Normal file
79
internal/config/config.go
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/hcl/v2/hclsimple"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
// Config represents the main config structure.
|
||||
type Config struct {
|
||||
Settings *Settings `hcl:"settings,block"`
|
||||
Routes []Route `hcl:"route,block"`
|
||||
Auth Auth `hcl:"auth,block"`
|
||||
}
|
||||
|
||||
// Settings represents settings for the SSH server.
|
||||
type Settings struct {
|
||||
SSHDir string `hcl:"ssh_dir,optional"`
|
||||
ListenAddr string `hcl:"listen_addr,optional"`
|
||||
Debug bool `hcl:"debug,optional"`
|
||||
}
|
||||
|
||||
// Route represents a virtual host configuration.
|
||||
type Route struct {
|
||||
Name string `hcl:"name,label"`
|
||||
Backend string `hcl:"backend"`
|
||||
Match string `hcl:"match"`
|
||||
Settings cty.Value `hcl:"settings"`
|
||||
Permissions PermissionsMap `hcl:"permissions,optional"`
|
||||
}
|
||||
|
||||
// Auth contains the authentication settings.
|
||||
type Auth struct {
|
||||
Fail2Ban *Fail2Ban `hcl:"fail2ban,block"`
|
||||
Users []User `hcl:"user,block"`
|
||||
}
|
||||
|
||||
// Fail2Ban contains the fail2ban rate limiter settings.
|
||||
type Fail2Ban struct {
|
||||
Limit string `hcl:"limit"`
|
||||
Attempts int `hcl:"attempts"`
|
||||
}
|
||||
|
||||
// User contains the configuration for a virtual user.
|
||||
type User struct {
|
||||
Name string `hcl:"name,label"`
|
||||
Password string `hcl:"password,optional"`
|
||||
Groups []string `hcl:"groups,optional"`
|
||||
Pubkeys []string `hcl:"pubkeys,optional"`
|
||||
}
|
||||
|
||||
// Load loads the configuration from the specified path.
|
||||
func Load(path string) (cfg Config, err error) {
|
||||
err = hclsimple.DecodeFile(path, nil, &cfg)
|
||||
if cfg.Settings == nil {
|
||||
cfg.Settings = &Settings{}
|
||||
}
|
||||
return cfg, err
|
||||
}
|
91
internal/config/permissions.go
Normal file
91
internal/config/permissions.go
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PermissionsMap defines the config structure for permissions.
|
||||
type PermissionsMap map[string]map[string][]string
|
||||
|
||||
// IsAllowed checks if the user has permissions for all the specified items.
|
||||
//
|
||||
// The default policy is deny, and denials take priority, so if one item
|
||||
// in items is set to deny, IsAllowed will always return false, even if
|
||||
// other items are explicitly allowed.
|
||||
func (pm PermissionsMap) IsAllowed(u User, items ...string) bool {
|
||||
if pm == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
allowed := false
|
||||
denied := false
|
||||
|
||||
groups := append(u.Groups, "all")
|
||||
for _, group := range groups {
|
||||
perms, ok := pm[group]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if denyList, found := perms["deny"]; found {
|
||||
for _, denyItem := range denyList {
|
||||
if matchPattern(denyItem, item) {
|
||||
denied = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if denied {
|
||||
break
|
||||
}
|
||||
|
||||
if allowList, found := perms["allow"]; found {
|
||||
for _, allowItem := range allowList {
|
||||
if matchPattern(allowItem, item) {
|
||||
allowed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if denied || !allowed {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// matchPattern checks if an item matches a given pattern.
|
||||
func matchPattern(pattern, item string) bool {
|
||||
if pattern == "*" {
|
||||
return true
|
||||
}
|
||||
if before, after, ok := strings.Cut(pattern, "*"); ok {
|
||||
return strings.HasPrefix(item, before) && strings.HasSuffix(item, after)
|
||||
}
|
||||
return pattern == item
|
||||
}
|
99
internal/fail2ban/fail2ban.go
Normal file
99
internal/fail2ban/fail2ban.go
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package fail2ban
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Fail2Ban represents a fail2ban-like rate limiter
|
||||
type Fail2Ban struct {
|
||||
limit time.Duration
|
||||
amount int
|
||||
mtx sync.Mutex
|
||||
attempts map[string]int
|
||||
}
|
||||
|
||||
// New creates a new [Fail2Ban] instance.
|
||||
func New(limit time.Duration, attempts int) *Fail2Ban {
|
||||
f := &Fail2Ban{
|
||||
limit: limit,
|
||||
amount: attempts,
|
||||
attempts: map[string]int{},
|
||||
}
|
||||
go f.clear()
|
||||
return f
|
||||
}
|
||||
|
||||
// AddFailedLogin adds a failed login attempt from the given address.
|
||||
func (f *Fail2Ban) AddFailedLogin(addr net.Addr) {
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
|
||||
f.mtx.Lock()
|
||||
defer f.mtx.Unlock()
|
||||
f.attempts[getAddrString(addr)]++
|
||||
}
|
||||
|
||||
// LoginAllowed checks if login is allowed from the given address.
|
||||
func (f *Fail2Ban) LoginAllowed(addr net.Addr) bool {
|
||||
if f == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
f.mtx.Lock()
|
||||
defer f.mtx.Unlock()
|
||||
return f.attempts[getAddrString(addr)] < f.amount
|
||||
}
|
||||
|
||||
// clear resets the login attempts at regular intervals.
|
||||
func (f *Fail2Ban) clear() {
|
||||
for range time.Tick(f.limit) {
|
||||
f.mtx.Lock()
|
||||
clear(f.attempts)
|
||||
f.attempts = map[string]int{}
|
||||
f.mtx.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
// getAddrString gets an IP address string from a [net.Addr].
|
||||
func getAddrString(addr net.Addr) string {
|
||||
switch addr := addr.(type) {
|
||||
case *net.TCPAddr:
|
||||
return addr.IP.String()
|
||||
case *net.IPAddr:
|
||||
return addr.IP.String()
|
||||
case *net.UDPAddr:
|
||||
return addr.IP.String()
|
||||
default:
|
||||
addrstr := addr.String()
|
||||
idx := strings.LastIndex(addrstr, ":")
|
||||
if idx == -1 {
|
||||
return addrstr
|
||||
}
|
||||
return addrstr[:idx]
|
||||
}
|
||||
}
|
74
internal/router/logging.go
Normal file
74
internal/router/logging.go
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package router
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"go.elara.ws/seashell/internal/sshctx"
|
||||
)
|
||||
|
||||
// Logging returns a middleware that logs incoming session details,
|
||||
// and closed connections, as well as any error that may have caused
|
||||
// the connection to close.
|
||||
func Logging(log *slog.Logger) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return func(sess ssh.Session, arg string) error {
|
||||
user, _ := sshctx.GetUser(sess.Context())
|
||||
route := sess.Context().Value(routeKey{}).(route)
|
||||
|
||||
log.Info(
|
||||
"Incoming user session",
|
||||
slog.String("user", user.Name),
|
||||
slog.String("route", route.name),
|
||||
slog.String("arg", arg),
|
||||
slog.String("addr", sess.RemoteAddr().String()),
|
||||
)
|
||||
|
||||
start := time.Now()
|
||||
err := next(sess, arg)
|
||||
duration := time.Since(start)
|
||||
|
||||
if err != nil {
|
||||
log.Error(
|
||||
"Connection closed",
|
||||
slog.String("user", user.Name),
|
||||
slog.String("route", route.name),
|
||||
slog.Duration("duration", duration),
|
||||
slog.String("addr", sess.RemoteAddr().String()),
|
||||
slog.Any("error", err),
|
||||
)
|
||||
} else {
|
||||
log.Info(
|
||||
"Connection closed",
|
||||
slog.String("user", user.Name),
|
||||
slog.String("route", route.name),
|
||||
slog.Duration("duration", duration),
|
||||
)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
122
internal/router/router.go
Normal file
122
internal/router/router.go
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package router
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"go.elara.ws/seashell/internal/sshctx"
|
||||
)
|
||||
|
||||
// ErrUnauthorized represents an unauthorized access error.
|
||||
var ErrUnauthorized = errors.New("you are not authorized to access this resource")
|
||||
|
||||
// Handler defines a function type to handle SSH sessions.
|
||||
type Handler func(sess ssh.Session, arg string) error
|
||||
|
||||
// Middleware defines a function type for middleware.
|
||||
type Middleware func(next Handler) Handler
|
||||
|
||||
// Router manages routing and middleware for SSH sessions.
|
||||
type Router struct {
|
||||
routes map[string]route
|
||||
middlewares []Middleware
|
||||
}
|
||||
|
||||
// route represents a single route configuration.
|
||||
type route struct {
|
||||
name string
|
||||
handler Handler
|
||||
regex *regexp.Regexp
|
||||
}
|
||||
|
||||
// New creates and returns a new [Router] instance.
|
||||
func New() *Router {
|
||||
return &Router{routes: map[string]route{}}
|
||||
}
|
||||
|
||||
// Use adds a middleware to the router.
|
||||
func (r *Router) Use(m Middleware) {
|
||||
r.middlewares = append(r.middlewares, m)
|
||||
}
|
||||
|
||||
// Handle registers a new route with the given name and pattern.
|
||||
func (r *Router) Handle(name, pattern string, h Handler) error {
|
||||
re, err := regexp.Compile(pattern)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.routes[pattern] = route{
|
||||
name: name,
|
||||
handler: h,
|
||||
regex: re,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// routeKey is a context key for storing route information.
|
||||
type routeKey struct{}
|
||||
|
||||
// Handler handles an SSH session, routing it to the appropriate handler.
|
||||
func (r *Router) Handler(sess ssh.Session) {
|
||||
arg, _ := sshctx.GetArg(sess.Context())
|
||||
|
||||
for _, ro := range r.routes {
|
||||
matches := ro.regex.FindStringSubmatch(arg)
|
||||
if matches == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
sess.Context().SetValue(routeKey{}, ro)
|
||||
|
||||
var cleanArg string
|
||||
if idx := ro.regex.SubexpIndex("arg"); idx != -1 {
|
||||
cleanArg = matches[idx]
|
||||
} else if len(matches) >= 2 {
|
||||
cleanArg = matches[1]
|
||||
} else {
|
||||
cleanArg = arg
|
||||
}
|
||||
|
||||
handler := ro.handler
|
||||
for _, middleware := range r.middlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
err := handler(sess, cleanArg)
|
||||
if err != nil {
|
||||
writeError(sess, err.Error())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
writeError(sess, "no matching route found for %q", arg)
|
||||
}
|
||||
|
||||
// writeError writes a formatted error message to the SSH session.
|
||||
func writeError(sess ssh.Session, format string, v ...any) {
|
||||
fmt.Fprintf(sess.Stderr(), "\x1b[31;1m[ERROR]\x1b[0m "+format+"\r\n", v...)
|
||||
}
|
47
internal/sshctx/sshctx.go
Normal file
47
internal/sshctx/sshctx.go
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package sshctx
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"go.elara.ws/seashell/internal/config"
|
||||
)
|
||||
|
||||
type (
|
||||
argCtxKey struct{}
|
||||
userCtxKey struct{}
|
||||
)
|
||||
|
||||
func SetArg(ctx ssh.Context, arg string) { ctx.SetValue(argCtxKey{}, arg) }
|
||||
func SetUser(ctx ssh.Context, user config.User) { ctx.SetValue(userCtxKey{}, user) }
|
||||
|
||||
func GetArg(ctx context.Context) (string, bool) {
|
||||
arg, ok := ctx.Value(argCtxKey{}).(string)
|
||||
return arg, ok
|
||||
}
|
||||
|
||||
func GetUser(ctx context.Context) (config.User, bool) {
|
||||
user, ok := ctx.Value(userCtxKey{}).(config.User)
|
||||
return user, ok
|
||||
}
|
114
keys.go
Normal file
114
keys.go
Normal file
@ -0,0 +1,114 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"crypto/rand"
|
||||
"encoding/pem"
|
||||
"io/fs"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
// ensureHostKeys attempts to add any host ssh keys to the server.
|
||||
// If no keys are found, it generates and saves a new ed25519 keypair.
|
||||
func ensureHostKeys(sshdir string, srv *ssh.Server) error {
|
||||
err := addHostKeys(sshdir, srv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(srv.HostSigners) == 0 {
|
||||
log.Warn("No valid host keys found. Generating new ed25519 keys...")
|
||||
err = generateAndSaveKeys(sshdir, srv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// generateAndSaveKeys generates a new ed25519 keypair and saves it
|
||||
// in the ssh directory.
|
||||
func generateAndSaveKeys(sshdir string, srv *ssh.Server) error {
|
||||
if err := os.MkdirAll(sshdir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, privkey, err := ed25519.GenerateKey(rand.Reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sshkey, err := gossh.NewSignerFromSigner(privkey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
srv.AddHostKey(sshkey)
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
user, err := user.Current()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
privpem, err := gossh.MarshalPrivateKey(privkey, user.Username+"@"+hostname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
privdata := pem.EncodeToMemory(privpem)
|
||||
pubdata := gossh.MarshalAuthorizedKey(sshkey.PublicKey())
|
||||
|
||||
err = os.WriteFile(filepath.Join(sshdir, "id_ed25519"), privdata, 0o600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(filepath.Join(sshdir, "id_ed25519.pub"), pubdata, 0o644)
|
||||
}
|
||||
|
||||
// addHostKeys recursively walks the ssh directory looking for valid keypairs
|
||||
// and adds them to the server.
|
||||
func addHostKeys(sshdir string, srv *ssh.Server) error {
|
||||
if err := os.MkdirAll(sshdir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return filepath.WalkDir(sshdir, func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if d.IsDir() || filepath.Ext(path) == ".pub" || !strings.HasPrefix(d.Name(), "id_") {
|
||||
return nil
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
key, err := gossh.ParsePrivateKey(data)
|
||||
if err != nil {
|
||||
log.Warn(
|
||||
"Invalid private key",
|
||||
slog.String("path", path),
|
||||
slog.Any("error", err),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
srv.AddHostKey(key)
|
||||
return nil
|
||||
})
|
||||
}
|
131
main.go
Normal file
131
main.go
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Seashell - SSH server with virtual hosts and username-based routing
|
||||
*
|
||||
* Copyright (C) 2024 Elara6331 <elara@elara.ws>
|
||||
*
|
||||
* This file is part of Seashell.
|
||||
*
|
||||
* Seashell is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Seashell 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Seashell. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/alexedwards/argon2id"
|
||||
"github.com/gliderlabs/ssh"
|
||||
"go.elara.ws/loggers"
|
||||
"go.elara.ws/seashell/internal/backends"
|
||||
"go.elara.ws/seashell/internal/config"
|
||||
"go.elara.ws/seashell/internal/fail2ban"
|
||||
"go.elara.ws/seashell/internal/router"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var (
|
||||
handler = loggers.NewPretty(os.Stderr, loggers.Options{})
|
||||
log = slog.New(handler)
|
||||
)
|
||||
|
||||
func main() {
|
||||
genHash := flag.Bool("gen-hash", false, "Generate an argon2id hash")
|
||||
flag.Parse()
|
||||
|
||||
if *genHash {
|
||||
fmt.Print("Password: ")
|
||||
data, err := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
log.Error("Error reading password from terminal", slog.Any("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
hash, err := argon2id.CreateHash(string(data), argon2id.DefaultParams)
|
||||
if err != nil {
|
||||
log.Error("Error calculating argon2id hash", slog.Any("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("\n%s\n", hash)
|
||||
return
|
||||
}
|
||||
|
||||
cfg, err := config.Load("seashell.hcl")
|
||||
if err != nil {
|
||||
log.Error("Error loading config file", slog.Any("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if cfg.Settings.Debug {
|
||||
handler.ShowCaller = true
|
||||
handler.Level = slog.LevelDebug
|
||||
}
|
||||
|
||||
r := router.New()
|
||||
r.Use(router.Logging(log))
|
||||
|
||||
for _, route := range cfg.Routes {
|
||||
backend := backends.Get(route.Backend)
|
||||
if backend == nil {
|
||||
log.Warn("Invalid backend", slog.String("id", route.Backend))
|
||||
continue
|
||||
}
|
||||
r.Handle(route.Name, route.Match, backend(route))
|
||||
}
|
||||
|
||||
if cfg.Settings.ListenAddr == "" {
|
||||
cfg.Settings.ListenAddr = ":2222"
|
||||
}
|
||||
|
||||
var f2b *fail2ban.Fail2Ban
|
||||
if cfg.Auth.Fail2Ban != nil {
|
||||
limit, err := time.ParseDuration(cfg.Auth.Fail2Ban.Limit)
|
||||
if err != nil {
|
||||
log.Error("Error parsing fail2ban limit", slog.Any("error", err))
|
||||
}
|
||||
f2b = fail2ban.New(limit, cfg.Auth.Fail2Ban.Attempts)
|
||||
}
|
||||
|
||||
srv := &ssh.Server{
|
||||
Addr: cfg.Settings.ListenAddr,
|
||||
Handler: r.Handler,
|
||||
PublicKeyHandler: pubkeyHandler(f2b, cfg),
|
||||
PasswordHandler: passwordHandler(f2b, cfg),
|
||||
ConnectionFailedCallback: failedConnHandler(f2b),
|
||||
}
|
||||
|
||||
if cfg.Settings.SSHDir == "" {
|
||||
homedir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log.Error("Error getting home directory", slog.Any("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
cfg.Settings.SSHDir = filepath.Join(homedir, ".ssh")
|
||||
}
|
||||
|
||||
err = ensureHostKeys(cfg.Settings.SSHDir, srv)
|
||||
if err != nil {
|
||||
log.Error("Error adding host keys", slog.Any("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
log.Info("Starting seashell server", slog.String("addr", srv.Addr))
|
||||
|
||||
if err := srv.ListenAndServe(); err != nil {
|
||||
log.Error("Error while running server", slog.Any("error", err))
|
||||
}
|
||||
}
|
58
seashell.ex.hcl
Normal file
58
seashell.ex.hcl
Normal file
@ -0,0 +1,58 @@
|
||||
settings {
|
||||
listen_addr = ":2222"
|
||||
debug = true
|
||||
}
|
||||
|
||||
route "nomad" {
|
||||
backend = "nomad"
|
||||
match = "nomad\\.(.+)"
|
||||
settings = {
|
||||
server = "http://nomad:4646"
|
||||
}
|
||||
permissions = {
|
||||
admins = {
|
||||
allow = ["*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
route "srv" {
|
||||
backend = "proxy"
|
||||
match = "srv"
|
||||
settings = {
|
||||
server = "1.2.3.4"
|
||||
privkey = "/home/elara/.ssh/id_ed25519"
|
||||
}
|
||||
}
|
||||
|
||||
route "docker" {
|
||||
backend = "docker"
|
||||
match = "docker\\.(.+)"
|
||||
settings = {
|
||||
command = ["/bin/bash"]
|
||||
}
|
||||
}
|
||||
|
||||
route "serial" {
|
||||
backend = "serial"
|
||||
match = "serial\\.(.+)"
|
||||
settings = {
|
||||
directory = "/dev"
|
||||
}
|
||||
}
|
||||
|
||||
auth {
|
||||
fail2ban {
|
||||
limit = "5m"
|
||||
attempts = 5
|
||||
}
|
||||
|
||||
user "admin" {
|
||||
password = "$argon2id$v=19$m=65536,t=1,p=16$lFu9zVL125Ypnv+NK+6FgA$uEtZ7IRx7O3/xG9ViOkRBqJ3no9xMZT9VcoyY9cZqEU" # 1234
|
||||
groups = ["admins"]
|
||||
pubkeys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEEAxoKZPa16LYOXVAkjShGmxdDWeu/jW6BbhI76eUwX",
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGqaLNW3/uRoXi9GD1PQMVguLkv4SvO3pNDMZCnChcbR",
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user