Initial commit

Generic SRV records checker for happyDomain.

For each SRV record attached to an svcs.UnknownSRV service, the checker
resolves every target and probes reachability:

  - DNS resolution (A/AAAA), CNAME detection (RFC 2782 violation),
    null-target detection (RFC 2782 "service explicitly unavailable")
  - TCP connect to target:port for _tcp SRVs
  - UDP probe for _udp SRVs, using ICMP port-unreachable detection

The checker also publishes TLS endpoints (host, port, SNI) for every
SRV target hitting a well-known direct-TLS port (443, 465, 636, 853,
993, 995, 5061, 5223, …) via the EndpointDiscoverer SDK interface, so
a downstream TLS checker can pick them up.

The HTML report groups records as cards and surfaces the most common
failure scenarios (DNS failure, CNAME target, TCP unreachable,
null-target) at the top with remediation guidance.
This commit is contained in:
nemunaire 2026-04-19 10:28:39 +07:00
commit 90f1b4943f
27 changed files with 2809 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
checker-srv
*.so

17
Dockerfile Normal file
View file

@ -0,0 +1,17 @@
FROM golang:1.25-alpine AS builder
ARG CHECKER_VERSION=custom-build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -tags standalone -ldflags "-X main.Version=${CHECKER_VERSION}" -o /checker-srv .
FROM scratch
COPY --from=builder /checker-srv /checker-srv
USER 65534:65534
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/checker-srv", "-healthcheck"]
ENTRYPOINT ["/checker-srv"]

682
LICENSE Normal file
View file

@ -0,0 +1,682 @@
happyDomain Licensing
SOFTWARE LICENSING
You may be licensed to use source code to create compiled versions not produced
by the happyDNS team in one of two ways:
1. Under the AGPL v3, subject to the exceptions outlined in this policy;
2. Under a commercial license available from the happyDNS team by contacting
contact@happydns.org.
happyDNS and happyDomain TRADEMARK GUIDELINES
Your use of the mark happyDNS and happyDomain is subject to the happyDNS team's
prior written approval and our organizations Trademark Standards of Use at
http://www.happydomain.org/trademark-standards-of-use/. For trademark approval
or any questions you have about using these trademarks, please email
contact@happydns.org
------------------------------------------------------------------------------------------------------------------------------
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/>.

28
Makefile Normal file
View file

@ -0,0 +1,28 @@
CHECKER_NAME := checker-srv
CHECKER_IMAGE := happydomain/$(CHECKER_NAME)
CHECKER_VERSION ?= custom-build
CHECKER_SOURCES := main.go $(wildcard checker/*.go)
GO_LDFLAGS := -X main.Version=$(CHECKER_VERSION)
.PHONY: all plugin docker test clean
all: $(CHECKER_NAME)
$(CHECKER_NAME): $(CHECKER_SOURCES)
go build -tags standalone -ldflags "$(GO_LDFLAGS)" -o $@ .
plugin: $(CHECKER_NAME).so
$(CHECKER_NAME).so: $(CHECKER_SOURCES) $(wildcard plugin/*.go)
go build -buildmode=plugin -ldflags "$(GO_LDFLAGS)" -o $@ ./plugin/
docker:
docker build --build-arg CHECKER_VERSION=$(CHECKER_VERSION) -t $(CHECKER_IMAGE) .
test:
go test -tags standalone ./...
clean:
rm -f $(CHECKER_NAME) $(CHECKER_NAME).so

174
README.md Normal file
View file

@ -0,0 +1,174 @@
# checker-srv
Generic SRV records checker for [happyDomain](https://www.happydomain.org/).
For every SRV record attached to a service, verifies:
- DNS resolution of each target (A/AAAA)
- RFC 2782 compliance: target is not `"."` (null), target is not a CNAME
- TCP reachability on `target:port` (for `_tcp` SRVs)
- UDP reachability on `target:port` (for `_udp` SRVs), via ICMP port-unreachable detection
TLS/certificate testing is intentionally out of scope, it belongs to a dedicated TLS checker.
The HTML report surfaces the most common failure scenarios at the top with actionable remediation guidance (DNS failure, CNAME-as-target, TCP unreachable, explicit null-target).
## Usage
### Standalone HTTP server
```bash
# Build and run
make
./checker-srv -listen :8080
```
The server exposes:
- `GET /health`, health check
- `GET /definition`, checker definition (options, rules, availability)
- `POST /collect`, collect SRV observations (happyDomain external checker protocol)
- `POST /evaluate`, evaluate observations against the rules
- `POST /report`, render the HTML report
### Docker
```bash
make docker
docker run -p 8080:8080 happydomain/checker-srv
```
### happyDomain plugin
```bash
make plugin
# produces checker-srv.so, loadable by happyDomain as a Go plugin
```
The plugin exposes a `NewCheckerPlugin` symbol returning the checker
definition and observation provider, which happyDomain registers in its
global registries at load time.
### Versioning
The binary, plugin, and Docker image embed a version string overridable
at build time:
```bash
make CHECKER_VERSION=1.2.3
make plugin CHECKER_VERSION=1.2.3
make docker CHECKER_VERSION=1.2.3
```
### happyDomain remote endpoint
Set the `endpoint` admin option for the SRV checker to the URL of the running checker-srv server (e.g., `http://checker-srv:8080`). happyDomain will delegate observation collection to this endpoint.
## Protocol
### POST /collect
Request:
```json
{
"key": "srv_records",
"target": {"userId": "...", "domainId": "...", "serviceId": "..."},
"options": {
"service": {"_svctype": "svcs.UnknownSRV", "Service": {"srv": [ /* dns.SRV records */ ]}},
"subdomain": "_sip._tcp",
"domain": "example.com",
"tcpTimeout": 3000,
"udpTimeout": 2000
}
}
```
Response:
```json
{
"data": {
"serviceDomain": "_sip._tcp.example.com",
"records": [
{
"service": "sip",
"proto": "tcp",
"owner": "_sip._tcp.example.com",
"target": "sip1.example.com",
"port": 5061,
"priority": 10,
"weight": 20,
"addresses": ["203.0.113.5"],
"probes": [
{
"address": "203.0.113.5:5061",
"proto": "tcp",
"connected": true,
"latencyMs": 12.4
}
]
}
]
}
}
```
## Discovered TLS endpoints
As a by-product of every `/collect`, this checker publishes
`DiscoveryEntry` records of type `tls.endpoint.v1` (see
[`checker-tls/contract`](https://git.happydns.org/checker-tls/tree/master/contract))
so that the TLS checker can probe the targets without re-parsing SRV data:
- **Direct TLS** entries (empty `STARTTLS`) for service names that imply
implicit TLS on connect: `_https`, `_ldaps`, `_sips`, `_imaps`, `_pop3s`,
`_smtps`, `_submissions`, `_xmpps-client`, `_xmpps-server`, `_ftps`,
`_nntps`, `_ircs`, `_telnets`, `_ipps`, `_mqtts`, `_coaps`, `_stuns`,
`_turns`.
- **STARTTLS** entries for service names that upgrade mid-stream:
`_smtp` (opportunistic), `_submission` (required), `_imap` (required),
`_pop3` (required), `_xmpp-client` (required), `_xmpp-server`
(opportunistic), `_ldap`, `_nntp`, `_ftp`, `_sieve`, `_postgresql`.
Null targets (`.`) and unknown service names are skipped. SNI is set to
the SRV target hostname.
## Rules
| Name | Description |
|---|---|
| `srv_records_present` | At least one SRV record is published. |
| `srv_null_target` | Detects `"."` targets (RFC 2782, service intentionally unavailable). |
| `srv_target_not_cname` | Warns when an SRV target is a CNAME (RFC 2782 violation). |
| `srv_targets_resolve` | Every target resolves to at least one A/AAAA. |
| `srv_tcp_reachable` | Every `_tcp` SRV `target:port` accepts a TCP connection. |
| `srv_udp_reachable` | UDP targets do not return ICMP port-unreachable. |
| `srv_redundancy` | At least two distinct targets exist (no single point of failure). |
## License & licensing roadmap
This project is currently licensed under the **GNU Affero General Public
License v3.0** (see `LICENSE`), because it still imports
`happydns.ServiceMessage` from the happyDomain server module
(`git.happydns.org/happyDomain/model`), which is itself distributed under
AGPL-3.0 and a commercial license.
The core checker types (`CheckerOptions`, `CheckerDefinition`,
`ObservationProvider`, `CheckRule`, …) have already been migrated to
[`checker-sdk-go`](https://git.happydns.org/checker-sdk-go); only the
service-message types remain on the AGPL side.
**Planned relicensing:** as soon as the remaining `ServiceMessage`
dependency has been removed (moved into a dedicated permissively licensed
module), this project will be relicensed under the **MIT License**, in
line with the rest of the happyDomain checker ecosystem (see
`checker-dummy` for the target shape).
**Contributors notice:** by submitting a contribution to this repository,
you accept that your contribution will be relicensed from AGPL-3.0 to MIT
at the time of the relicensing described above. If you do not agree with
this, please do not submit contributions until the relicensing has taken
place.
The third-party Apache-2.0 attributions for `checker-sdk-go` are recorded
in `NOTICE` and must accompany any binary or source redistribution of this
project.

228
checker/collect.go Normal file
View file

@ -0,0 +1,228 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"encoding/json"
"fmt"
"net"
"strconv"
"strings"
"time"
sdk "git.happydns.org/checker-sdk-go/checker"
happydns "git.happydns.org/happyDomain/model"
)
// We decode SRV records by hand (instead of importing miekg/dns) so the
// checker stays light and its build surface minimal.
type unknownSRVPayload struct {
Records []struct {
Hdr struct {
Name string `json:"Name"`
} `json:"Hdr"`
Priority uint16 `json:"Priority"`
Weight uint16 `json:"Weight"`
Port uint16 `json:"Port"`
Target string `json:"Target"`
} `json:"srv"`
}
func (p *srvProvider) Collect(ctx context.Context, opts sdk.CheckerOptions) (any, error) {
svcMsg, ok := sdk.GetOption[happydns.ServiceMessage](opts, "service")
if !ok {
return p.collectFallback(ctx, opts)
}
if svcMsg.Type != "svcs.UnknownSRV" {
return nil, fmt.Errorf("service type is %q, expected svcs.UnknownSRV", svcMsg.Type)
}
var payload unknownSRVPayload
if err := json.Unmarshal(svcMsg.Service, &payload); err != nil {
return nil, fmt.Errorf("failed to decode UnknownSRV: %w", err)
}
if len(payload.Records) == 0 {
return nil, fmt.Errorf("service contains no SRV records")
}
subdomain, _ := sdk.GetOption[string](opts, "subdomain")
domain, _ := sdk.GetOption[string](opts, "domain")
serviceDomain := strings.TrimSuffix(subdomain, ".")
if domain != "" {
if serviceDomain != "" {
serviceDomain += "." + strings.TrimSuffix(domain, ".")
} else {
serviceDomain = strings.TrimSuffix(domain, ".")
}
}
tcpTimeout := durationOpt(opts, "tcpTimeout", 3000)
udpTimeout := durationOpt(opts, "udpTimeout", 2000)
data := &SRVData{
ServiceDomain: serviceDomain,
Records: make([]SRVRecord, 0, len(payload.Records)),
}
for _, r := range payload.Records {
owner := strings.TrimSuffix(r.Hdr.Name, ".")
svc, proto := parseOwner(owner, serviceDomain)
rec := SRVRecord{
Service: svc,
Proto: proto,
Owner: owner,
Target: strings.TrimSuffix(r.Target, "."),
Port: r.Port,
Priority: r.Priority,
Weight: r.Weight,
}
resolveAndProbe(ctx, &rec, tcpTimeout, udpTimeout)
data.Records = append(data.Records, rec)
}
return data, nil
}
// Owners that don't match _svc._proto have no proto we can trust, so we
// skip probing rather than silently defaulting to TCP and reporting a misleading status.
func resolveAndProbe(ctx context.Context, rec *SRVRecord, tcpTimeout, udpTimeout time.Duration) {
// RFC 2782: "." target means "service decidedly not available".
if rec.Target == "" || rec.Target == "." {
rec.IsNullTarget = true
return
}
// CNAME detection (RFC 2782 §"Usage rules": target MUST be a name that
// resolves to A/AAAA records directly, not a CNAME).
if cname, err := net.DefaultResolver.LookupCNAME(ctx, rec.Target); err == nil {
canon := strings.TrimSuffix(cname, ".")
if canon != "" && !strings.EqualFold(canon, rec.Target) {
rec.IsCNAME = true
rec.CNAMEChain = []string{rec.Target, canon}
}
}
ips, err := net.DefaultResolver.LookupIPAddr(ctx, rec.Target)
if err != nil {
rec.ResolveError = err.Error()
return
}
for _, ip := range ips {
rec.Addresses = append(rec.Addresses, ip.IP.String())
}
for _, addr := range rec.Addresses {
hostport := net.JoinHostPort(addr, strconv.Itoa(int(rec.Port)))
switch rec.Proto {
case protoTCP:
rec.Probes = append(rec.Probes, probeTCP(ctx, hostport, tcpTimeout))
case protoUDP:
rec.Probes = append(rec.Probes, probeUDP(ctx, hostport, udpTimeout))
}
}
}
func parseOwner(owner, serviceDomain string) (svc, proto string) {
// Returns ("", "") when the owner does not match: callers must treat
// that as "unknown" and skip proto-specific probing rather than guessing.
s := strings.TrimSuffix(owner, "."+serviceDomain)
parts := strings.Split(s, ".")
if len(parts) >= 2 && strings.HasPrefix(parts[0], "_") && strings.HasPrefix(parts[1], "_") {
return strings.TrimPrefix(parts[0], "_"), strings.TrimPrefix(parts[1], "_")
}
return "", ""
}
func durationOpt(opts sdk.CheckerOptions, key string, defMs int) time.Duration {
ms := defMs
if v, ok := opts[key]; ok {
switch n := v.(type) {
case float64:
ms = int(n)
case int:
ms = n
}
}
if ms < 100 {
ms = 100
}
if ms > 60000 {
ms = 60000
}
return time.Duration(ms) * time.Millisecond
}
func probeTCP(ctx context.Context, hostport string, timeout time.Duration) ProbeResult {
pr := ProbeResult{Address: hostport, Proto: protoTCP}
start := time.Now()
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
conn, err := (&net.Dialer{}).DialContext(ctx, protoTCP, hostport)
pr.LatencyMs = float64(time.Since(start).Microseconds()) / 1000.0
if err != nil {
pr.Error = err.Error()
return pr
}
_ = conn.Close()
pr.Connected = true
return pr
}
func probeUDP(ctx context.Context, hostport string, timeout time.Duration) ProbeResult {
pr := ProbeResult{Address: hostport, Proto: protoUDP}
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
conn, err := (&net.Dialer{}).DialContext(ctx, protoUDP, hostport)
if err != nil {
pr.Error = err.Error()
return pr
}
defer conn.Close()
// Send a single zero byte. If the host has nothing listening and returns
// ICMP port-unreachable, a subsequent Read will fail with "connection
// refused". Silent drops (firewalled) remain indistinguishable from a
// working service, report as "reachable (no response)".
_ = conn.SetDeadline(time.Now().Add(timeout))
if _, err := conn.Write([]byte{0}); err != nil {
pr.Error = err.Error()
return pr
}
buf := make([]byte, 1)
_, err = conn.Read(buf)
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Timeout() {
// No ICMP unreachable came back: host probably accepts UDP,
// or packets are silently dropped. Treat as "reachable".
pr.Connected = true
pr.Error = "no UDP response (host may still be reachable)"
return pr
}
pr.Error = err.Error()
return pr
}
pr.Connected = true
return pr
}

35
checker/collect_plugin.go Normal file
View file

@ -0,0 +1,35 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
//go:build !standalone
package checker
import (
"context"
"fmt"
sdk "git.happydns.org/checker-sdk-go/checker"
)
func (p *srvProvider) collectFallback(ctx context.Context, opts sdk.CheckerOptions) (any, error) {
return nil, fmt.Errorf("service not provided")
}

View file

@ -0,0 +1,85 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
//go:build standalone
package checker
import (
"context"
"fmt"
"net"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
// collectFallback queries DNS for SRV records directly when no upstream
// service payload is available (standalone CLI/HTTP mode).
func (p *srvProvider) collectFallback(ctx context.Context, opts sdk.CheckerOptions) (any, error) {
subdomain, _ := sdk.GetOption[string](opts, "subdomain")
domain, _ := sdk.GetOption[string](opts, "domain")
serviceDomain := strings.TrimSuffix(subdomain, ".")
if domain != "" {
if serviceDomain != "" {
serviceDomain += "." + strings.TrimSuffix(domain, ".")
} else {
serviceDomain = strings.TrimSuffix(domain, ".")
}
}
if serviceDomain == "" {
return nil, fmt.Errorf("missing 'domain' option")
}
// Empty service/proto tells the resolver to query the literal name as-is,
// preserving _svc._proto labels already encoded in serviceDomain.
_, srvs, err := net.DefaultResolver.LookupSRV(ctx, "", "", serviceDomain)
if err != nil {
return nil, fmt.Errorf("SRV lookup for %s: %w", serviceDomain, err)
}
if len(srvs) == 0 {
return nil, fmt.Errorf("no SRV records at %s", serviceDomain)
}
tcpTimeout := durationOpt(opts, "tcpTimeout", 3000)
udpTimeout := durationOpt(opts, "udpTimeout", 2000)
svc, proto := parseOwner(serviceDomain, serviceDomain)
data := &SRVData{
ServiceDomain: serviceDomain,
Records: make([]SRVRecord, 0, len(srvs)),
}
for _, s := range srvs {
rec := SRVRecord{
Service: svc,
Proto: proto,
Owner: serviceDomain,
Target: strings.TrimSuffix(s.Target, "."),
Port: s.Port,
Priority: s.Priority,
Weight: s.Weight,
}
resolveAndProbe(ctx, &rec, tcpTimeout, udpTimeout)
data.Records = append(data.Records, rec)
}
return data, nil
}

88
checker/definition.go Normal file
View file

@ -0,0 +1,88 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"time"
sdk "git.happydns.org/checker-sdk-go/checker"
)
var Version = "built-in"
func (p *srvProvider) Definition() *sdk.CheckerDefinition {
return &sdk.CheckerDefinition{
ID: "srv",
Name: "SRV Records Tester",
Version: Version,
Availability: sdk.CheckerAvailability{
ApplyToService: true,
LimitToServices: []string{"svcs.UnknownSRV"},
},
HasHTMLReport: true,
ObservationKeys: []sdk.ObservationKey{ObservationKeySRV},
Options: sdk.CheckerOptionsDocumentation{
UserOpts: []sdk.CheckerOptionDocumentation{
{
Id: "tcpTimeout",
Type: "number",
Label: "TCP connect timeout (ms)",
Default: float64(3000),
Description: "Max time to wait for a TCP handshake on each target.",
},
{
Id: "udpTimeout",
Type: "number",
Label: "UDP probe timeout (ms)",
Default: float64(2000),
Description: "Max time to wait for a UDP response or ICMP unreachable.",
},
},
ServiceOpts: []sdk.CheckerOptionDocumentation{
{
Id: "service",
Label: "Service",
AutoFill: sdk.AutoFillService,
Hide: true,
},
{
Id: "subdomain",
Label: "Subdomain",
AutoFill: sdk.AutoFillSubdomain,
Hide: true,
},
{
Id: "domain",
Label: "Domain",
AutoFill: sdk.AutoFillDomainName,
Hide: true,
},
},
},
Rules: Rules(),
Interval: &sdk.CheckIntervalSpec{
Min: 5 * time.Minute,
Max: 7 * 24 * time.Hour,
Default: 6 * time.Hour,
},
}
}

124
checker/discover.go Normal file
View file

@ -0,0 +1,124 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"fmt"
sdk "git.happydns.org/checker-sdk-go/checker"
tlsct "git.happydns.org/checker-tls/contract"
)
// Matching on the service name is more authoritative than matching on the
// port: port 636 could carry anything, but _ldaps._tcp unambiguously
// designates LDAP over TLS, even on a non-standard port.
var directTLSServices = map[string]bool{
"https": true,
"ftps": true, // FTPS implicit
"smtps": true, // SMTP over TLS (legacy port 465 semantics)
"submissions": true, // RFC 8314: SMTP submission over TLS
"imaps": true,
"pop3s": true,
"nntps": true,
"ircs": true,
"telnets": true,
"ldaps": true,
"sips": true,
"ipps": true, // IPP over TLS (printing)
"xmpps-client": true, // XMPP client over direct TLS
"xmpps-server": true, // XMPP server-to-server over direct TLS
"mqtts": true,
"coaps": true,
"stuns": true,
"turns": true,
}
type starttlsSpec struct {
// When two SRV services share the same wire upgrade (submission/smtp both do
// ESMTP STARTTLS), Proto is the canonical one agreed with checker-tls/contract.
Proto string
// Required is false for opportunistic STARTTLS (e.g. SMTP on port 25, s2s XMPP).
// The consumer uses this to pick severity when the server does not advertise STARTTLS.
Required bool
}
// Proto values follow the tls.endpoint.v1 contract's vocabulary; the SDK
// itself has no opinion on these values, they belong to checker-tls.
var starttlsServices = map[string]starttlsSpec{
"submission": {"smtp", true}, // RFC 8314: STARTTLS required
"smtp": {"smtp", false}, // port 25: opportunistic
"imap": {"imap", true},
"pop3": {"pop3", true},
"xmpp-client": {"xmpp-client", true}, // RFC 7590
"xmpp-server": {"xmpp-server", false}, // s2s: opportunistic
"ldap": {"ldap", false},
"nntp": {"nntp", false},
"ftp": {"ftp", false},
"sieve": {"sieve", true},
"postgresql": {"postgres", false},
}
// DiscoverEntries publishes tls.endpoint.v1 entries for known TLS/STARTTLS services.
// Unknown service names produce no entries: we lean on the SRV naming
// convention rather than guessing from the port, since a port alone
// conveys no protocol semantics.
func (p *srvProvider) DiscoverEntries(data any) ([]sdk.DiscoveryEntry, error) {
d, ok := data.(*SRVData)
if !ok {
return nil, fmt.Errorf("unexpected data type %T", data)
}
var out []sdk.DiscoveryEntry
for _, r := range d.Records {
if r.IsNullTarget || r.Target == "" {
continue
}
if directTLSServices[r.Service] {
e, err := tlsct.NewEntry(tlsct.TLSEndpoint{
Host: r.Target,
Port: r.Port,
SNI: r.Target,
})
if err != nil {
return nil, fmt.Errorf("build tls entry for %s:%d: %w", r.Target, r.Port, err)
}
out = append(out, e)
continue
}
if spec, ok := starttlsServices[r.Service]; ok {
e, err := tlsct.NewEntry(tlsct.TLSEndpoint{
Host: r.Target,
Port: r.Port,
SNI: r.Target,
STARTTLS: spec.Proto,
RequireSTARTTLS: spec.Required,
})
if err != nil {
return nil, fmt.Errorf("build starttls entry for %s:%d: %w", r.Target, r.Port, err)
}
out = append(out, e)
}
}
return out, nil
}

70
checker/interactive.go Normal file
View file

@ -0,0 +1,70 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
//go:build standalone
package checker
import (
"errors"
"net/http"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
func (p *srvProvider) RenderForm() []sdk.CheckerOptionField {
return []sdk.CheckerOptionField{
{
Id: "name",
Type: "string",
Label: "SRV record name to check",
Placeholder: "_sip._tcp.example.com",
Required: true,
Description: "Fully-qualified SRV owner name (e.g. _service._proto.domain).",
},
}
}
func (p *srvProvider) ParseForm(r *http.Request) (sdk.CheckerOptions, error) {
name := strings.TrimSpace(r.FormValue("name"))
if name == "" {
return nil, errors.New("name is required")
}
name = strings.TrimSuffix(name, ".")
// Split into subdomain + domain so collect's serviceDomain
// (subdomain + "." + domain) reconstructs the full SRV owner.
parts := strings.SplitN(name, ".", 2)
sub := parts[0]
parent := ""
if len(parts) == 2 {
parent = parts[1]
} else {
parent = name
sub = ""
}
return sdk.CheckerOptions{
"domain": parent,
"subdomain": sub,
}, nil
}

36
checker/provider.go Normal file
View file

@ -0,0 +1,36 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
sdk "git.happydns.org/checker-sdk-go/checker"
)
func Provider() sdk.ObservationProvider {
return &srvProvider{}
}
type srvProvider struct{}
func (p *srvProvider) Key() sdk.ObservationKey {
return ObservationKeySRV
}

312
checker/report.go Normal file
View file

@ -0,0 +1,312 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"encoding/json"
"fmt"
"html/template"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
type reportData struct {
ServiceDomain string
Records []reportRecord
Alerts []reportAlert
Totals reportTotals
}
type reportRecord struct {
Owner string
Service string
Proto string
Target string
Port uint16
Priority uint16
Weight uint16
IsNullTarget bool
IsCNAME bool
CNAMEChain string
Addresses []string
ResolveError string
Probes []reportProbe
}
type reportProbe struct {
Address string
Proto string
Connected bool
LatencyMs float64
Error string
StatusClass string
StatusLabel string
}
type reportAlert struct {
Severity string // "crit", "warn", "info"
Title string
Body template.HTML
}
type reportTotals struct {
Records int
OKProbes int
BadProbes int
}
var htmlTpl = template.Must(template.New("srv").Parse(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SRV Records Report</title>
<style>
*,*::before,*::after{box-sizing:border-box}
:root{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-size:14px;line-height:1.5;color:#1f2937;background:#f3f4f6}
body{margin:0;padding:1rem}
code{font-family:ui-monospace,monospace;font-size:.9em}
h1{margin:0 0 .4rem;font-size:1.15rem}
h2{font-size:1rem;margin:0 0 .6rem}
h3{font-size:.9rem;font-weight:600;margin:0 0 .4rem}
.hd,.section{background:#fff;border-radius:10px;padding:1rem 1.25rem;margin-bottom:.75rem;box-shadow:0 1px 3px rgba(0,0,0,.08)}
.section{border-radius:8px;padding:.85rem 1rem;margin-bottom:.6rem}
.badge{display:inline-flex;align-items:center;padding:.2em .65em;border-radius:9999px;font-size:.78rem;font-weight:700}
.ok{background:#d1fae5;color:#065f46}
.warn{background:#fef3c7;color:#92400e}
.crit{background:#fee2e2;color:#991b1b}
.info{background:#dbeafe;color:#1e40af}
.alert{border-left:4px solid #d1d5db;padding:.6rem .85rem;margin-bottom:.55rem;background:#fff;border-radius:6px;box-shadow:0 1px 3px rgba(0,0,0,.05)}
.alert.crit{border-left-color:#dc2626}
.alert.warn{border-left-color:#d97706}
.alert.info{border-left-color:#2563eb}
.alert .title{font-weight:600;margin-bottom:.2rem}
.alert .body{font-size:.88rem;color:#374151}
.alert .body code{background:#f3f4f6;padding:.05rem .3rem;border-radius:3px}
.rec{border:1px solid #e5e7eb;border-radius:8px;padding:.7rem .85rem;margin-bottom:.55rem;background:#fff}
.rec-hd{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin-bottom:.4rem}
.rec-hd .target{font-family:ui-monospace,monospace;font-weight:600}
.rec-hd .meta{color:#6b7280;font-size:.82rem}
table{border-collapse:collapse;width:100%;font-size:.85rem;margin-top:.25rem}
th,td{text-align:left;padding:.3rem .5rem;border-bottom:1px solid #f3f4f6}
th{font-weight:600;color:#6b7280;background:#f9fafb}
.errmsg{color:#b91c1c}
.note{color:#6b7280;font-size:.85rem}
.totals{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.25rem}
.tot{background:#f3f4f6;border-radius:6px;padding:.25rem .6rem;font-size:.8rem}
</style>
</head>
<body>
<div class="hd">
<h1>SRV Records &mdash; {{if .ServiceDomain}}<code>{{.ServiceDomain}}</code>{{else}}service{{end}}</h1>
<div class="totals">
<span class="tot">{{.Totals.Records}} record(s)</span>
<span class="tot">{{.Totals.OKProbes}} reachable probe(s)</span>
{{if .Totals.BadProbes}}<span class="tot" style="background:#fee2e2;color:#991b1b">{{.Totals.BadProbes}} failed probe(s)</span>{{end}}
</div>
</div>
{{if .Alerts}}
<div class="section">
<h2>What needs attention</h2>
{{range .Alerts}}
<div class="alert {{.Severity}}">
<div class="title">{{.Title}}</div>
<div class="body">{{.Body}}</div>
</div>
{{end}}
</div>
{{end}}
<div class="section">
<h2>Records</h2>
{{range .Records}}
<div class="rec">
<div class="rec-hd">
<span class="target">{{if .IsNullTarget}}<em>(null target)</em>{{else}}{{.Target}}{{end}}:{{.Port}}</span>
<span class="meta">prio {{.Priority}} &middot; weight {{.Weight}}</span>
{{if .Service}}<span class="meta">_{{.Service}}._{{.Proto}}</span>{{end}}
{{if .IsNullTarget}}<span class="badge warn">null target</span>{{end}}
{{if .IsCNAME}}<span class="badge warn">target is CNAME</span>{{end}}
{{if .ResolveError}}<span class="badge crit">DNS error</span>{{end}}
</div>
{{if .CNAMEChain}}
<p class="note">CNAME chain: <code>{{.CNAMEChain}}</code> &mdash; RFC 2782 forbids a CNAME as SRV target.</p>
{{end}}
{{if .ResolveError}}
<p class="errmsg">Resolution failed: {{.ResolveError}}</p>
{{end}}
{{if .Addresses}}
<p class="note">Resolves to: {{range .Addresses}}<code>{{.}}</code> {{end}}</p>
{{end}}
{{if .Probes}}
<table>
<tr>
<th>Address</th><th>Proto</th><th>Status</th><th>Latency</th><th>Details</th>
</tr>
{{range .Probes}}
<tr>
<td><code>{{.Address}}</code></td>
<td>{{.Proto}}</td>
<td><span class="badge {{.StatusClass}}">{{.StatusLabel}}</span></td>
<td>{{if .LatencyMs}}{{printf "%.1f ms" .LatencyMs}}{{end}}</td>
<td>{{if .Error}}<span class="errmsg">{{.Error}}</span>{{end}}</td>
</tr>
{{end}}
</table>
{{end}}
</div>
{{end}}
</div>
</body>
</html>`))
func (p *srvProvider) GetHTMLReport(ctx sdk.ReportContext) (string, error) {
var d SRVData
if err := json.Unmarshal(ctx.Data(), &d); err != nil {
return "", fmt.Errorf("failed to unmarshal SRV report: %w", err)
}
rd := reportData{ServiceDomain: d.ServiceDomain}
rd.Totals.Records = len(d.Records)
var resolveFails, cnames, nulls []string
type tcpFailure struct{ owner, address, err string }
var tcpDown []tcpFailure
for _, r := range d.Records {
rec := reportRecord{
Owner: r.Owner,
Service: r.Service,
Proto: r.Proto,
Target: r.Target,
Port: r.Port,
Priority: r.Priority,
Weight: r.Weight,
IsNullTarget: r.IsNullTarget,
IsCNAME: r.IsCNAME,
Addresses: r.Addresses,
ResolveError: r.ResolveError,
}
if len(r.CNAMEChain) > 0 {
rec.CNAMEChain = strings.Join(r.CNAMEChain, " → ")
}
if r.IsNullTarget {
nulls = append(nulls, r.Owner)
}
if r.IsCNAME {
cnames = append(cnames, template.HTMLEscapeString(r.Target))
}
if r.ResolveError != "" {
resolveFails = append(resolveFails, fmt.Sprintf("%s (%s)",
template.HTMLEscapeString(r.Target),
template.HTMLEscapeString(r.ResolveError)))
}
for _, pr := range r.Probes {
rp := reportProbe{
Address: pr.Address,
Proto: pr.Proto,
Connected: pr.Connected,
LatencyMs: pr.LatencyMs,
Error: pr.Error,
}
switch {
case pr.Connected:
rp.StatusClass = "ok"
rp.StatusLabel = "reachable"
rd.Totals.OKProbes++
default:
rp.StatusClass = "crit"
rp.StatusLabel = "unreachable"
rd.Totals.BadProbes++
if pr.Proto == "tcp" {
tcpDown = append(tcpDown, tcpFailure{r.Owner, pr.Address, pr.Error})
}
}
rec.Probes = append(rec.Probes, rp)
}
rd.Records = append(rd.Records, rec)
}
if len(resolveFails) > 0 {
rd.Alerts = append(rd.Alerts, reportAlert{
Severity: "crit",
Title: fmt.Sprintf("DNS resolution failed for %d SRV target(s)", len(resolveFails)),
Body: template.HTML(fmt.Sprintf(
"%s<br>Clients will not be able to reach the service. Fix: either publish A/AAAA records for the target(s), or remove the broken SRV record.",
strings.Join(resolveFails, "<br>"))),
})
}
if len(cnames) > 0 {
rd.Alerts = append(rd.Alerts, reportAlert{
Severity: "warn",
Title: "SRV target is a CNAME (RFC 2782 violation)",
Body: template.HTML(fmt.Sprintf(
"Target(s): %s<br>RFC 2782 requires SRV targets to resolve directly to A/AAAA. "+
"Some clients will refuse to follow the CNAME. Fix: point the SRV record to a hostname with A/AAAA records, "+
"or replace the CNAME with an ALIAS/ANAME at the DNS provider.",
"<code>"+strings.Join(cnames, "</code>, <code>")+"</code>")),
})
}
if len(tcpDown) > 0 {
var items []string
for _, f := range tcpDown {
items = append(items, fmt.Sprintf("<code>%s</code> (%s): %s",
template.HTMLEscapeString(f.address),
template.HTMLEscapeString(f.owner),
template.HTMLEscapeString(f.err)))
}
rd.Alerts = append(rd.Alerts, reportAlert{
Severity: "crit",
Title: fmt.Sprintf("%d target(s) unreachable on their advertised TCP port", len(tcpDown)),
Body: template.HTML(strings.Join(items, "<br>") +
"<br>Check: (1) the server is running and bound to the right port; " +
"(2) firewall/security-group allows inbound TCP to that port; " +
"(3) the SRV record is not pointing at an old IP."),
})
}
if len(nulls) > 0 && len(nulls) == len(d.Records) {
rd.Alerts = append(rd.Alerts, reportAlert{
Severity: "warn",
Title: "All SRV records use the null target (\".\"): service is explicitly disabled",
Body: template.HTML(
"RFC 2782 defines a single SRV record with target <code>\".\"</code> to signal that the service is " +
"intentionally not available. If this is what you want, the configuration is correct. " +
"If you expected clients to reach this service, replace the null target with a real hostname."),
})
}
var buf strings.Builder
if err := htmlTpl.Execute(&buf, rd); err != nil {
return "", fmt.Errorf("failed to render SRV HTML report: %w", err)
}
return buf.String(), nil
}

73
checker/rules.go Normal file
View file

@ -0,0 +1,73 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
sdk "git.happydns.org/checker-sdk-go/checker"
)
// One rule per concern so each failure is individually visible rather than buried in a single rule's Code field.
func Rules() []sdk.CheckRule {
return []sdk.CheckRule{
RulePresent(),
RuleNullTarget(),
RuleTargetNotCNAME(),
RuleTargetsResolve(),
RuleTCPReachable(),
RuleUDPReachable(),
RulePortValid(),
RulePriorityWeightSanity(),
RuleRedundancy(),
}
}
func getData(ctx context.Context, obs sdk.ObservationGetter) (*SRVData, *sdk.CheckState) {
var d SRVData
if err := obs.Get(ctx, ObservationKeySRV, &d); err != nil {
return nil, &sdk.CheckState{
Status: sdk.StatusError,
Message: fmt.Sprintf("Failed to load SRV observation: %v", err),
Code: "srv_obs_error",
}
}
return &d, nil
}
func countProbeResults(d *SRVData, proto string) (total, ok int, failed []string) {
for _, r := range d.Records {
if r.IsNullTarget || r.Proto != proto {
continue
}
for _, pr := range r.Probes {
total++
if pr.Connected {
ok++
} else {
failed = append(failed, fmt.Sprintf("%s: %s", pr.Address, pr.Error))
}
}
}
return
}

59
checker/rules_cname.go Normal file
View file

@ -0,0 +1,59 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
type ruleTargetNotCNAME struct{}
func RuleTargetNotCNAME() sdk.CheckRule { return &ruleTargetNotCNAME{} }
func (ruleTargetNotCNAME) Name() string { return "srv_target_not_cname" }
func (ruleTargetNotCNAME) Description() string {
return "RFC 2782: SRV targets must resolve directly to A/AAAA, not through a CNAME."
}
func (ruleTargetNotCNAME) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
var bad []string
for _, r := range d.Records {
if r.IsNullTarget {
continue
}
if r.IsCNAME {
bad = append(bad, r.Target)
}
}
if len(bad) == 0 {
return []sdk.CheckState{{Status: sdk.StatusOK, Code: "srv_targets_not_cname",
Message: "All SRV targets resolve directly (no CNAME)."}}
}
return []sdk.CheckState{{Status: sdk.StatusWarn, Code: "srv_targets_are_cname",
Message: fmt.Sprintf("RFC 2782 violation, SRV target(s) are CNAMEs: %s", strings.Join(bad, ", "))}}
}

View file

@ -0,0 +1,60 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
type ruleNullTarget struct{}
func RuleNullTarget() sdk.CheckRule { return &ruleNullTarget{} }
func (ruleNullTarget) Name() string { return "srv_null_target" }
func (ruleNullTarget) Description() string {
return "Detects SRV records with target \".\", which signals the service is intentionally not available."
}
func (ruleNullTarget) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
var nulls []string
for _, r := range d.Records {
if r.IsNullTarget {
nulls = append(nulls, r.Owner)
}
}
if len(nulls) == 0 {
return []sdk.CheckState{{Status: sdk.StatusOK, Code: "srv_no_null",
Message: "No null-target SRV records."}}
}
if len(nulls) == len(d.Records) {
return []sdk.CheckState{{Status: sdk.StatusWarn, Code: "srv_all_null",
Message: fmt.Sprintf("All %d SRV records use null target (\".\"): service explicitly disabled.", len(nulls))}}
}
return []sdk.CheckState{{Status: sdk.StatusInfo, Code: "srv_some_null",
Message: fmt.Sprintf("%d record(s) have null target: %s", len(nulls), strings.Join(nulls, ", "))}}
}

67
checker/rules_port.go Normal file
View file

@ -0,0 +1,67 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
// Port 0 is valid on the wire but no client can connect to it; null targets are exempt since their port is irrelevant.
type rulePortValid struct{}
func RulePortValid() sdk.CheckRule { return &rulePortValid{} }
func (rulePortValid) Name() string { return "srv_port_valid" }
func (rulePortValid) Description() string {
return "SRV records advertise a non-zero port that clients can actually connect to."
}
func (rulePortValid) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
var bad []string
var checked int
for _, r := range d.Records {
if r.IsNullTarget {
continue
}
checked++
if r.Port == 0 {
bad = append(bad, fmt.Sprintf("%s (port %d)", r.Owner, r.Port))
}
}
if checked == 0 {
return []sdk.CheckState{{Status: sdk.StatusInfo, Code: "srv_port_na",
Message: "No active SRV targets to check ports on."}}
}
if len(bad) == 0 {
return []sdk.CheckState{{Status: sdk.StatusOK, Code: "srv_port_ok",
Message: fmt.Sprintf("All %d SRV record(s) advertise a non-zero port.", checked)}}
}
return []sdk.CheckState{{Status: sdk.StatusCrit, Code: "srv_port_zero",
Message: fmt.Sprintf("SRV record(s) advertise port 0: %s", strings.Join(bad, ", "))}}
}

49
checker/rules_present.go Normal file
View file

@ -0,0 +1,49 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
sdk "git.happydns.org/checker-sdk-go/checker"
)
type rulePresent struct{}
func RulePresent() sdk.CheckRule { return &rulePresent{} }
func (rulePresent) Name() string { return "srv_records_present" }
func (rulePresent) Description() string {
return "At least one SRV record is published for this service."
}
func (rulePresent) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
if len(d.Records) == 0 {
return []sdk.CheckState{{Status: sdk.StatusCrit, Code: "srv_missing",
Message: "No SRV records published."}}
}
return []sdk.CheckState{{Status: sdk.StatusOK, Code: "srv_present",
Message: fmt.Sprintf("%d SRV record(s) published.", len(d.Records))}}
}

View file

@ -0,0 +1,107 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
// Single-priority with multiple targets is Info (not Warn) because it is legal; all-zero-weight within a group is Warn because it almost always indicates a misconfiguration.
type rulePriorityWeightSanity struct{}
func RulePriorityWeightSanity() sdk.CheckRule { return &rulePriorityWeightSanity{} }
func (rulePriorityWeightSanity) Name() string { return "srv_priority_weight_sanity" }
func (rulePriorityWeightSanity) Description() string {
return "Priority/weight values follow RFC 2782 conventions (failover present, weights meaningful)."
}
func (rulePriorityWeightSanity) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
type groupKey struct{ owner string }
type group struct {
priorities map[uint16]int
zeroWeight map[uint16]int
}
groups := map[groupKey]*group{}
for _, r := range d.Records {
if r.IsNullTarget {
continue
}
k := groupKey{owner: r.Owner}
g := groups[k]
if g == nil {
g = &group{priorities: map[uint16]int{}, zeroWeight: map[uint16]int{}}
groups[k] = g
}
g.priorities[r.Priority]++
if r.Weight == 0 {
g.zeroWeight[r.Priority]++
}
}
if len(groups) == 0 {
return []sdk.CheckState{{Status: sdk.StatusInfo, Code: "srv_prio_weight_na",
Message: "No active SRV records to analyse."}}
}
var noFailover []string
var zeroWeightGroups []string
for k, g := range groups {
if len(g.priorities) < 2 {
total := 0
for _, c := range g.priorities {
total += c
}
if total > 1 {
noFailover = append(noFailover, k.owner)
}
}
for prio, zc := range g.zeroWeight {
if zc > 1 && zc == g.priorities[prio] {
zeroWeightGroups = append(zeroWeightGroups, fmt.Sprintf("%s@prio=%d", k.owner, prio))
}
}
}
var out []sdk.CheckState
if len(zeroWeightGroups) > 0 {
out = append(out, sdk.CheckState{Status: sdk.StatusWarn, Code: "srv_weight_all_zero",
Message: fmt.Sprintf("Priority group(s) with multiple targets all weighted 0: %s", strings.Join(zeroWeightGroups, ", "))})
}
if len(noFailover) > 0 {
out = append(out, sdk.CheckState{Status: sdk.StatusInfo, Code: "srv_single_priority",
Message: fmt.Sprintf("Service(s) with multiple records but a single priority tier (no failover): %s", strings.Join(noFailover, ", "))})
}
if len(out) == 0 {
out = append(out, sdk.CheckState{Status: sdk.StatusOK, Code: "srv_prio_weight_ok",
Message: "Priority and weight values are consistent with RFC 2782 conventions."})
}
return out
}

View file

@ -0,0 +1,84 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
type ruleTCPReachable struct{}
func RuleTCPReachable() sdk.CheckRule { return &ruleTCPReachable{} }
func (ruleTCPReachable) Name() string { return "srv_tcp_reachable" }
func (ruleTCPReachable) Description() string {
return "Every TCP SRV target:port accepts a TCP connection."
}
func (ruleTCPReachable) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
total, ok, failed := countProbeResults(d, protoTCP)
if total == 0 {
return []sdk.CheckState{{Status: sdk.StatusUnknown, Code: "srv_tcp_na",
Message: "No TCP targets to test."}}
}
if ok == total {
return []sdk.CheckState{{Status: sdk.StatusOK, Code: "srv_tcp_ok",
Message: fmt.Sprintf("All %d TCP target(s) reachable.", total)}}
}
if ok == 0 {
return []sdk.CheckState{{Status: sdk.StatusCrit, Code: "srv_tcp_all_down",
Message: fmt.Sprintf("All %d TCP target(s) unreachable: %s", total, strings.Join(failed, "; "))}}
}
return []sdk.CheckState{{Status: sdk.StatusWarn, Code: "srv_tcp_partial",
Message: fmt.Sprintf("%d/%d TCP target(s) unreachable: %s", total-ok, total, strings.Join(failed, "; "))}}
}
type ruleUDPReachable struct{}
func RuleUDPReachable() sdk.CheckRule { return &ruleUDPReachable{} }
func (ruleUDPReachable) Name() string { return "srv_udp_reachable" }
func (ruleUDPReachable) Description() string {
return "UDP SRV targets do not return ICMP port-unreachable."
}
func (ruleUDPReachable) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
total, ok, failed := countProbeResults(d, protoUDP)
if total == 0 {
return []sdk.CheckState{{Status: sdk.StatusUnknown, Code: "srv_udp_na",
Message: "No UDP targets to test."}}
}
if ok == total {
return []sdk.CheckState{{Status: sdk.StatusOK, Code: "srv_udp_ok",
Message: fmt.Sprintf("All %d UDP target(s) reachable.", total)}}
}
return []sdk.CheckState{{Status: sdk.StatusWarn, Code: "srv_udp_issue",
Message: fmt.Sprintf("%d/%d UDP target(s) reported port unreachable: %s", total-ok, total, strings.Join(failed, "; "))}}
}

View file

@ -0,0 +1,60 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
sdk "git.happydns.org/checker-sdk-go/checker"
)
type ruleRedundancy struct{}
func RuleRedundancy() sdk.CheckRule { return &ruleRedundancy{} }
func (ruleRedundancy) Name() string { return "srv_redundancy" }
func (ruleRedundancy) Description() string {
return "At least two distinct SRV targets exist (avoids single point of failure)."
}
func (ruleRedundancy) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
targets := map[string]bool{}
for _, r := range d.Records {
if r.IsNullTarget {
continue
}
targets[r.Target] = true
}
if len(targets) >= 2 {
return []sdk.CheckState{{Status: sdk.StatusOK, Code: "srv_redundant",
Message: fmt.Sprintf("%d distinct targets.", len(targets))}}
}
if len(targets) == 1 {
return []sdk.CheckState{{Status: sdk.StatusInfo, Code: "srv_single_target",
Message: "Single SRV target: no redundancy at DNS level."}}
}
return []sdk.CheckState{{Status: sdk.StatusUnknown, Code: "srv_no_targets_redundancy",
Message: "No usable SRV targets."}}
}

65
checker/rules_resolve.go Normal file
View file

@ -0,0 +1,65 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
package checker
import (
"context"
"fmt"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
type ruleTargetsResolve struct{}
func RuleTargetsResolve() sdk.CheckRule { return &ruleTargetsResolve{} }
func (ruleTargetsResolve) Name() string { return "srv_targets_resolve" }
func (ruleTargetsResolve) Description() string {
return "Every SRV target resolves to at least one A/AAAA address."
}
func (ruleTargetsResolve) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
d, cs := getData(ctx, obs)
if cs != nil {
return []sdk.CheckState{*cs}
}
var failed []string
var checked int
for _, r := range d.Records {
if r.IsNullTarget {
continue
}
checked++
if len(r.Addresses) == 0 {
failed = append(failed, fmt.Sprintf("%s (%s)", r.Target, r.ResolveError))
}
}
if checked == 0 {
return []sdk.CheckState{{Status: sdk.StatusUnknown, Code: "srv_no_targets",
Message: "No resolvable targets to test."}}
}
if len(failed) == 0 {
return []sdk.CheckState{{Status: sdk.StatusOK, Code: "srv_all_resolve",
Message: fmt.Sprintf("All %d target(s) resolve.", checked)}}
}
return []sdk.CheckState{{Status: sdk.StatusCrit, Code: "srv_resolve_fail",
Message: fmt.Sprintf("Target(s) failed DNS resolution: %s", strings.Join(failed, "; "))}}
}

73
checker/types.go Normal file
View file

@ -0,0 +1,73 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
// Package checker implements the generic SRV records checker for happyDomain.
//
// TLS/certificate testing is intentionally out of scope: it is handled by a
// dedicated TLS checker.
package checker
import (
sdk "git.happydns.org/checker-sdk-go/checker"
)
const ObservationKeySRV sdk.ObservationKey = "srv_records"
const (
protoTCP = "tcp"
protoUDP = "udp"
)
type SRVRecord struct {
Service string `json:"service"`
Proto string `json:"proto"`
Owner string `json:"owner"`
Target string `json:"target"`
Port uint16 `json:"port"`
Priority uint16 `json:"priority"`
Weight uint16 `json:"weight"`
IsNullTarget bool `json:"isNullTarget,omitempty"` // target == "." means "no service"
IsCNAME bool `json:"isCNAME,omitempty"` // RFC 2782: MUST NOT be CNAME
CNAMEChain []string `json:"cnameChain,omitempty"`
Addresses []string `json:"addresses,omitempty"`
ResolveError string `json:"resolveError,omitempty"`
Probes []ProbeResult `json:"probes,omitempty"`
}
type ProbeResult struct {
Address string `json:"address"`
Proto string `json:"proto"`
// Connected reports whether the probe should be treated as reachable.
// For TCP this is a true handshake. For UDP, where silent drops are
// indistinguishable from a working service, a timeout also sets
// Connected=true and populates Error with an explanatory note: the
// rule treats "no ICMP unreachable" as best-effort reachable.
Connected bool `json:"connected"`
LatencyMs float64 `json:"latencyMs,omitempty"`
Error string `json:"error,omitempty"`
}
type SRVData struct {
ServiceDomain string `json:"serviceDomain"`
Records []SRVRecord `json:"records"`
}

46
go.mod Normal file
View file

@ -0,0 +1,46 @@
module git.happydns.org/checker-srv
go 1.25.0
require (
git.happydns.org/checker-sdk-go v1.5.0
git.happydns.org/checker-tls v0.6.2
git.happydns.org/happyDomain v0.7.0
)
require (
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.15.0 // indirect
github.com/bytedance/sonic/loader v0.5.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/gin-gonic/gin v1.12.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.30.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.19.2 // indirect
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/miekg/dns v1.1.72 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.59.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.1 // indirect
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
golang.org/x/arch v0.24.0 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/mod v0.33.0 // indirect
golang.org/x/net v0.51.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.35.0 // indirect
golang.org/x/tools v0.42.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
)

104
go.sum Normal file
View file

@ -0,0 +1,104 @@
git.happydns.org/checker-sdk-go v1.5.0 h1:5uD5Cm6xJ+lwnhbJ09iCXGHbYS9zRh+Yh0NeBHkAPBY=
git.happydns.org/checker-sdk-go v1.5.0/go.mod h1:aNAcfYFfbhvH9kJhE0Njp5GX0dQbxdRB0rJ0KvSC5nI=
git.happydns.org/checker-tls v0.6.2 h1:8oKia1XlD+tklyqrwzmUgFH1Kw8VLSLLF9suZ7Qr14E=
git.happydns.org/checker-tls v0.6.2/go.mod h1:9tpnxg0iOwS+7If64DRG1jqYonUAgxOBuxwfF5mVkL4=
git.happydns.org/happyDomain v0.7.0 h1:NV82/NbcSeRm0+IUZqaK3Vu9Ovl5+vv4AigUJZMdwws=
git.happydns.org/happyDomain v0.7.0/go.mod h1:5tgkmqFE65kK359rY49V++49wgZ0gco+Gh9X6tbL+bY=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 h1:9Nu54bhS/H/Kgo2/7xNSUuC5G28VR8ljfrLKU2G4IjU=
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12/go.mod h1:TBzl5BIHNXfS9+C35ZyJaklL7mLDbgUkcgXzSLa8Tk0=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI=
github.com/miekg/dns v1.1.72/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
golang.org/x/arch v0.24.0 h1:qlJ3M9upxvFfwRM51tTg3Yl+8CP9vCC1E7vlFpgv99Y=
golang.org/x/arch v0.24.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
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=

45
main.go Normal file
View file

@ -0,0 +1,45 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
// Command checker-srv is the standalone binary for the SRV checker.
package main
import (
"flag"
"log"
"git.happydns.org/checker-sdk-go/checker/server"
srv "git.happydns.org/checker-srv/checker"
)
var Version = "custom-build"
var listenAddr = flag.String("listen", ":8080", "HTTP listen address")
func main() {
flag.Parse()
srv.Version = Version
httpSrv := server.New(srv.Provider())
if err := httpSrv.ListenAndServe(*listenAddr); err != nil {
log.Fatalf("server error: %v", err)
}
}

36
plugin/plugin.go Normal file
View file

@ -0,0 +1,36 @@
// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
//
// This program is offered under a commercial and under the AGPL license.
// For commercial licensing, contact us at <contact@happydomain.org>.
//
// For AGPL licensing:
// 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/>.
// Command plugin is the happyDomain plugin entrypoint for the SRV checker.
package main
import (
sdk "git.happydns.org/checker-sdk-go/checker"
srv "git.happydns.org/checker-srv/checker"
)
var Version = "custom-build"
func NewCheckerPlugin() (*sdk.CheckerDefinition, sdk.ObservationProvider, error) {
srv.Version = Version
prvd := srv.Provider()
return prvd.(sdk.CheckerDefinitionProvider).Definition(), prvd, nil
}