| ard-vtdu/pom.xml | ●●●●● patch | view | raw | blame | history | |
| ard-vtdu/src/main/java/com/ard/vtdu/client/MediamtxAuthInterceptor.java | ●●●●● patch | view | raw | blame | history | |
| ard-work/pom.xml | ●●●●● patch | view | raw | blame | history | |
| ard-work/src/main/java/com/ard/work/component/forest/TokenInterceptor.java | ●●●●● patch | view | raw | blame | history | |
| ard-work/src/main/java/com/ard/work/component/netty/TyTcpClientManager.java | ●●●●● patch | view | raw | blame | history | |
| pom.xml | ●●●●● patch | view | raw | blame | history |
ard-vtdu/pom.xml
@@ -26,7 +26,6 @@ <dependency> <groupId>com.dtflys.forest</groupId> <artifactId>forest-spring-boot-starter</artifactId> <version>1.5.33</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> ard-vtdu/src/main/java/com/ard/vtdu/client/MediamtxAuthInterceptor.java
New file @@ -0,0 +1,54 @@ package com.ard.vtdu.client; import com.ard.vtdu.config.MediamtxConfig; import com.dtflys.forest.http.ForestRequest; import com.dtflys.forest.interceptor.ForestInterceptor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.Base64; /** * 这个拦截器暂时先不使用,需要时在启用 * 用于mediaMtx流媒体接口安全请求 * * @author lsy * @date 2025/10/16 */ @Component @Slf4j public class MediamtxAuthInterceptor implements ForestInterceptor { /** * 该方法在请求发送之前被调用, 若返回false则不会继续发送请求 * * @Param request Forest请求对象 */ @Override public boolean beforeExecute(ForestRequest req) { try { String username = "admin"; String password = "mypass"; //对应mediamtx.yml //- user: argon2:$argon2id$v=19$m=4096,t=3,p=1$c2FsdEl0V2l0aFNhbHQ$Mi4H+feNHQk/E0sm46PEz3dnHPTzZMNWV5LVdDD/4SI // pass: argon2:$argon2id$v=19$m=4096,t=3,p=1$c2FsdEl0V2l0aFNhbHQ$5VEdlOBG/er50vvc4GZO4uA3juhk/uvUzYOzTMv6RiQ // 拼接用户名和密码 String authString = username + ":" + password; // Base64 编码 String encodedAuth = Base64.getEncoder().encodeToString(authString.getBytes()); // 最终的 Authorization 头 String authorizationHeader = "Basic " + encodedAuth; log.debug("Authorization header: " + authorizationHeader); req.addHeader("Authorization", authorizationHeader); } catch (Exception e) { log.error("TokenInterceptor 处理异常:{}", e.getMessage()); return false; } return true; } } ard-work/pom.xml
@@ -29,7 +29,6 @@ <dependency> <groupId>com.dtflys.forest</groupId> <artifactId>forest-spring-boot-starter</artifactId> <version>1.8.0</version> </dependency> <!-- netty依赖 springboot2.x自动导入版本 --> ard-work/src/main/java/com/ard/work/component/forest/TokenInterceptor.java
@@ -4,7 +4,6 @@ import com.ard.work.service.IArdServerInfoService; import com.dtflys.forest.http.ForestRequest; import com.dtflys.forest.interceptor.ForestInterceptor; import com.dtflys.forest.interceptor.Interceptor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.annotation.Resource; ard-work/src/main/java/com/ard/work/component/netty/TyTcpClientManager.java
@@ -63,7 +63,9 @@ return bootstrap; } /** 新增或重连服务器 */ /** * 新增或重连服务器 */ public void connectServer(ArdServerInfo serverInfo) { String serverId = serverInfo.getId(); String host = serverInfo.getHost(); @@ -97,7 +99,9 @@ channels.put(serverId, session); } /** 断开服务器连接 */ /** * 断开服务器连接 */ public void disconnectServer(String serverId) { TcpClientSession session = channels.remove(serverId); if (session != null && session.getChannelFuture() != null) { @@ -188,5 +192,4 @@ session.getServerId(), session.getHost(), session.getPort(), timestamp); }); } } pom.xml
@@ -34,6 +34,7 @@ <okhttp.version>4.8.1</okhttp.version> <mqtt.version>5.5.5</mqtt.version> <minio.version>8.3.7</minio.version> <forest.version>1.8.0</forest.version> <spring-boot-admin.version>2.5.1</spring-boot-admin.version> </properties> @@ -240,6 +241,13 @@ <version>${minio.version}</version> </dependency> <!-- Forest --> <dependency> <groupId>com.dtflys.forest</groupId> <artifactId>forest-spring-boot-starter</artifactId> <version>${forest.version}</version> </dependency> <!-- SpringBootAdmin管控台 --> <dependency> <groupId>de.codecentric</groupId>