[+] 结构调整
This commit is contained in:
@@ -5,9 +5,9 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.acgist.taoyao.boot.config.MediaProperties;
|
||||
import com.acgist.taoyao.boot.config.WebrtcProperties;
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.boot.property.MediaProperties;
|
||||
import com.acgist.taoyao.boot.property.WebrtcProperties;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.acgist.taoyao.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.signal.protocol.media.MediaRebootProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.media.MediaShutdownProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.platform.PlatformRebootProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.platform.PlatformShutdownProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.system.SystemRebootProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.system.SystemShutdownProtocol;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
/**
|
||||
* 控制
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Tag(name = "控制", description = "控制管理")
|
||||
@RestController
|
||||
@RequestMapping("/control")
|
||||
public class ControlController {
|
||||
|
||||
@Autowired
|
||||
private MediaRebootProtocol mediaRebootProtocol;
|
||||
@Autowired
|
||||
private MediaShutdownProtocol mediaShutdownProtocol;
|
||||
@Autowired
|
||||
private SystemRebootProtocol systemRebootProtocol;
|
||||
@Autowired
|
||||
private SystemShutdownProtocol systemShutdownProtocol;
|
||||
@Autowired
|
||||
private PlatformRebootProtocol platformRebootProtocol;
|
||||
@Autowired
|
||||
private PlatformShutdownProtocol platformShutdownProtocol;
|
||||
|
||||
@Operation(summary = "重启媒体", description = "重启媒体")
|
||||
@GetMapping("/media/reboot/{mediaId}")
|
||||
public Message mediaReboot(@PathVariable String mediaId) {
|
||||
this.mediaRebootProtocol.execute(mediaId);
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭媒体", description = "关闭媒体")
|
||||
@GetMapping("/media/shutdown/{mediaId}")
|
||||
public Message mediaShutdown(@PathVariable String mediaId) {
|
||||
this.mediaShutdownProtocol.execute(mediaId);
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "重启系统", description = "重启系统")
|
||||
@GetMapping("/system/reboot")
|
||||
public Message systemReboot() {
|
||||
this.systemRebootProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭系统", description = "关闭系统")
|
||||
@GetMapping("/system/shutdown")
|
||||
public Message systemShutdown() {
|
||||
this.systemShutdownProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "重启平台", description = "重启平台")
|
||||
@GetMapping("/platform/reboot")
|
||||
public Message platformReboot() {
|
||||
this.platformRebootProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭平台", description = "关闭平台")
|
||||
@GetMapping("/platform/shutdown")
|
||||
public Message platformShutdown() {
|
||||
this.platformShutdownProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import com.acgist.taoyao.boot.config.SecurityProperties;
|
||||
import com.acgist.taoyao.boot.interceptor.InterceptorAdapter;
|
||||
import com.acgist.taoyao.boot.property.SecurityProperties;
|
||||
import com.acgist.taoyao.signal.service.SecurityService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.acgist.taoyao.interceptor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.acgist.taoyao.boot.config.TaoyaoProperties;
|
||||
import com.acgist.taoyao.boot.interceptor.InterceptorAdapter;
|
||||
import com.acgist.taoyao.boot.property.TaoyaoProperties;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -2,7 +2,9 @@ taoyao:
|
||||
media:
|
||||
media-server-list:
|
||||
- media-id: media-local-a
|
||||
enabled: true
|
||||
enabled: false
|
||||
rewrite-ip: true
|
||||
# host: 192.168.1.110
|
||||
host: 192.168.8.110
|
||||
port: 9443
|
||||
schema: wss
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
taoyao:
|
||||
media:
|
||||
media-server-list:
|
||||
- media-id: media-local-a
|
||||
enabled: true
|
||||
host: 192.168.1.110
|
||||
port: 9443
|
||||
schema: wss
|
||||
username: taoyao
|
||||
password: taoyao
|
||||
security:
|
||||
permit: /v3/api-docs/**,/swagger-ui/**,/swagger-ui.html,/,/error,/index.html,/favicon.ico
|
||||
@@ -20,7 +20,7 @@ server:
|
||||
# context-path: /taoyao
|
||||
spring:
|
||||
profiles:
|
||||
active: local
|
||||
active: dev
|
||||
application:
|
||||
name: taoyao-signal-server
|
||||
servlet:
|
||||
@@ -51,6 +51,7 @@ taoyao:
|
||||
name: 桃夭信令服务
|
||||
version: 1.0.0
|
||||
description: 桃夭WebRTC信令服务
|
||||
ip-mask: 24
|
||||
timeout: 5000
|
||||
id:
|
||||
index: 0
|
||||
@@ -102,14 +103,16 @@ taoyao:
|
||||
media-server-list:
|
||||
- media-id: media-local-a
|
||||
enabled: true
|
||||
host: localhost
|
||||
rewrite-ip: true
|
||||
host: 127.0.0.1
|
||||
port: 9443
|
||||
schema: wss
|
||||
username: taoyao
|
||||
password: taoyao
|
||||
- media-id: media-local-z
|
||||
enabled: true
|
||||
host: localhost
|
||||
rewrite-ip: true
|
||||
host: 127.0.0.1
|
||||
port: 9443
|
||||
schema: wss
|
||||
username: taoyao
|
||||
@@ -126,21 +129,21 @@ taoyao:
|
||||
thread-name-prefix: ${spring.application.name}-signal-
|
||||
keep-alive-time: 60000
|
||||
buffer-size: 2048
|
||||
# WebRTC配置:没有P2P所以不会用到
|
||||
# WebRTC配置
|
||||
webrtc:
|
||||
# STUN服务
|
||||
stun:
|
||||
- host: stun1.l.google.com
|
||||
port: 19302
|
||||
- host: stun2.l.google.com
|
||||
port: 19302
|
||||
# TURN服务:需要自己搭建coturn
|
||||
turn:
|
||||
- host: 192.168.1.110
|
||||
port: 3478
|
||||
- host: 192.168.8.110
|
||||
port: 3478
|
||||
# TURN服务
|
||||
turn:
|
||||
- host: 192.168.1.110
|
||||
port: 3478
|
||||
username: taoyao
|
||||
password: taoyao
|
||||
- host: 192.168.8.111
|
||||
- host: 192.168.8.110
|
||||
port: 3478
|
||||
username: taoyao
|
||||
password: taoyao
|
||||
@@ -158,8 +161,8 @@ taoyao:
|
||||
# 脚本配置
|
||||
script:
|
||||
enabled: true
|
||||
media-reboot: pm2 restart taoyao-media-server
|
||||
media-shutdown: pm2 stop taoyao-media-server
|
||||
media-reboot: pm2 restart taoyao-client-media
|
||||
media-shutdown: pm2 stop taoyao-client-media
|
||||
system-reboot: reboot
|
||||
system-shutdown: shutdown now
|
||||
platform-reboot: systemctl restart taoyao-signal-server
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.acgist.taoyao.boot.service;
|
||||
package com.acgist.taoyao.service;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.acgist.taoyao.annotation.CostedTest;
|
||||
import com.acgist.taoyao.annotation.TaoyaoTest;
|
||||
import com.acgist.taoyao.boot.service.IdService;
|
||||
import com.acgist.taoyao.main.TaoyaoApplication;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.acgist.taoyao.service;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.acgist.taoyao.annotation.TaoyaoTest;
|
||||
import com.acgist.taoyao.boot.service.IpService;
|
||||
import com.acgist.taoyao.main.TaoyaoApplication;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@TaoyaoTest(classes = TaoyaoApplication.class)
|
||||
public class IpServiceTest {
|
||||
|
||||
@Autowired
|
||||
private IpService ipService;
|
||||
|
||||
@Test
|
||||
public void testDomain() throws UnknownHostException {
|
||||
InetAddress byName = InetAddress.getByName("www.acgist.com");
|
||||
System.out.println(byName);
|
||||
System.out.println(byName.getHostAddress());
|
||||
System.out.println(byName.getHostName());
|
||||
System.out.println(byName.isAnyLocalAddress());
|
||||
System.out.println(byName.isLoopbackAddress());
|
||||
System.out.println(byName.isLinkLocalAddress());
|
||||
System.out.println(byName.isMulticastAddress());
|
||||
System.out.println(byName.isSiteLocalAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubnetIp() {
|
||||
assertTrue(this.ipService.subnetIp("192.168.8.1", "192.168.8.100"));
|
||||
assertTrue(this.ipService.subnetIp("192.168.100.1", "192.168.100.100"));
|
||||
assertFalse(this.ipService.subnetIp("192.168.1.1", "192.168.8.100"));
|
||||
assertFalse(this.ipService.subnetIp("192.168.80.1", "192.168.8.100"));
|
||||
assertTrue(this.ipService.subnetIp("fe80::9ff9:2da9:9759:17e9", "fe80::9ff9:2da9:9759:17e9"));
|
||||
assertTrue(this.ipService.subnetIp("fe80::9ff9:2da9:9759:17ee", "fe80::9ff9:2da9:9759:17e9"));
|
||||
assertFalse(this.ipService.subnetIp("fe81::9ff9:2da9:9759:17e9", "fe80::9ff9:2da9:9759:17e9"));
|
||||
assertFalse(this.ipService.subnetIp("fe81::9ff9:2da9:9759:17ee", "fe80::9ff9:2da9:9759:17e9"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRewriteIp() {
|
||||
assertEquals("192.168.1.0", this.ipService.rewriteIp("0.0.0.0", "192.168.1.1"));
|
||||
assertEquals("192.168.1.10", this.ipService.rewriteIp("0.0.0.0", "192.168.1.1", "192.168.8.10"));
|
||||
assertEquals("192.168.1.100", this.ipService.rewriteIp("192.168.8.100", "192.168.1.1"));
|
||||
assertEquals("192.168.10.100", this.ipService.rewriteIp("192.168.8.100", "192.168.10.1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCost() {
|
||||
long a = System.currentTimeMillis();
|
||||
for (int index = 0; index < 100000; index++) {
|
||||
assertTrue(this.ipService.subnetIp("192.168.100.1", "192.168.100.100"));
|
||||
assertFalse(this.ipService.subnetIp("192.168.1.1", "192.168.8.100"));
|
||||
}
|
||||
long z = System.currentTimeMillis();
|
||||
log.info("耗时:{}", z - a);
|
||||
a = System.currentTimeMillis();
|
||||
for (int index = 0; index < 100000; index++) {
|
||||
assertEquals("192.168.1.100", this.ipService.rewriteIp("192.168.8.100", "192.168.1.1"));
|
||||
assertEquals("192.168.10.100", this.ipService.rewriteIp("192.168.8.100", "192.168.10.1"));
|
||||
}
|
||||
z = System.currentTimeMillis();
|
||||
log.info("耗时:{}", z - a);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import java.util.concurrent.Executors;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.acgist.taoyao.boot.property.Constant;
|
||||
import com.acgist.taoyao.boot.config.Constant;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user