添加广播MDNS服务

This commit is contained in:
2024-08-19 09:39:32 +08:00
parent 1f7bc017ca
commit 0a5b0db9a5
192 changed files with 22181 additions and 616 deletions

View File

@@ -0,0 +1,10 @@
configure_file(Doxyfile.in "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
add_custom_target(doc ALL
"${DOXYGEN_EXECUTABLE}" \"${CMAKE_CURRENT_BINARY_DIR}/Doxyfile\"
)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
DESTINATION "${DOC_INSTALL_DIR}"
COMPONENT documentation
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
QMdnsEngine provides an implementation of multicast DNS as per RFC 6762.
Some of QMdnsEngine's features include:
- Supports Windows, macOS, Linux, and most other platforms supported by Qt
- Requires only QtCore and QtNetwork - no other dependencies
- Includes an exhaustive set of unit tests
## Build Requirements
QMdnsEngine requires the following in order to build the library:
- CMake 3.2+
- Qt 5.4+
- C++ compiler with C++11 support
## Build Instructions
QMdnsEngine uses CMake for building the library. The options shown below allow the build to be customized:
- Installation:
- `BIN_INSTALL_DIR` - binary installation directory relative to the install prefix
- `LIB_INSTALL_DIR` - library installation directory relative to the install prefix
- `INCLUDE_INSTALL_DIR` - header installation directory relative to the install prefix
- Customization:
- `BUILD_DOC` - build the documentation for the library with Doxygen
- `BUILD_EXAMPLES` - build example applications that use the library
- `BUILD_TESTS` - build the test suite
## Basic Provider Usage
To provide a service on the local network, begin by creating a [Server](@ref QMdnsEngine::Server), a [Hostname](@ref QMdnsEngine::Hostname), and a [Provider](@ref QMdnsEngine::Provider):
@code
QMdnsEngine::Server server;
QMdnsEngine::Hostname hostname(&server);
QMdnsEngine::Provider provider(&server, &hostname);
@endcode
The server sends and receives raw DNS packets. The hostname finds a unique hostname that is not in use to identify the device. Lastly, the provider manages the records for a service.
The next step is to create the service and update the provider:
@code
QMdnsEngine::Service service;
service.setType("_http._tcp.local.");
service.setName("My Service");
service.setPort(1234);
provider.update(service);
@endcode
That's it! As long as the provider remains in scope, the service will be available on the local network and other devices will be able to find it.
## Basic Browser Usage
To find services on the local network, begin by creating a [Server](@ref QMdnsEngine::Server) and a [Browser](@ref QMdnsEngine::Browser):
@code
QMdnsEngine::Server server;
QMdnsEngine::Cache cache;
QMdnsEngine::Browser browser(&server, "_http._tcp.local.", &cache);
@endcode
The cache is optional but helps save time later when resolving services. The browser is provided with a service type which is used to filter services.
To receive a notification when services are added, connect to the [Browser::serviceAdded()](@ref QMdnsEngine::Browser::serviceAdded) signal:
@code
QObject::connect(&browser, &QMdnsEngine::Browser::serviceAdded,
[](const QMdnsEngine::Service &service) {
qDebug() << service.name() << "discovered!";
}
);
@endcode
To resolve the service, use a [Resolver](@ref QMdnsEngine::Resolver):
@code
QMdnsEngine::Resolver resolver(&server, service.hostname(), &cache);
QObject::connect(&resolver, &QMdnsEngine::Resolver::resolved,
[](const QHostAddress &address) {
qDebug() << "resolved to" << address;
}
);
@endcode
Note that [Resolver::resolved()](@ref QMdnsEngine::Resolver::resolved) may be emitted once for each address provided by the service.

View File

@@ -0,0 +1,34 @@
#titlearea {
margin: 10px 0;
}
#projectalign {
padding-left: 0 !important;
}
.fragment {
padding: 4px !important;
}
@media (min-width: 992px) {
#top, .header, .contents, .footer {
margin: auto !important;
max-width: 900px;
}
#titlearea {
border-bottom: none;
}
#main-nav, #navrow1 {
border-radius: 4px 4px 0 0;
border-top: 1px solid #c4cfe5;
position: relative;
}
#main-nav, #navrow1, .header, .nav-path, .contents {
border-left: 1px solid #c4cfe5;
border-right: 1px solid #c4cfe5;
box-sizing: border-box;
}
.contents {
padding: 14px;
}
hr.footer {
border-top: 1px solid #c4cfe5;
}
}