Commit 17f4fe254ae3d1c56ffbad8770b9d0578204731e
1 parent
642d93c0
增加对配置文件的校验
Showing
1 changed file
with
63 additions
and
0 deletions
src/main/java/com/genersoft/iot/vmp/conf/ApplicationCheckRunner.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.conf; | ||
| 2 | + | ||
| 3 | +import org.slf4j.Logger; | ||
| 4 | +import org.slf4j.LoggerFactory; | ||
| 5 | +import org.springframework.beans.factory.annotation.Value; | ||
| 6 | +import org.springframework.boot.CommandLineRunner; | ||
| 7 | +import org.springframework.core.annotation.Order; | ||
| 8 | +import org.springframework.stereotype.Component; | ||
| 9 | + | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 对配置文件进行校验 | ||
| 13 | + */ | ||
| 14 | +@Component | ||
| 15 | +@Order(value=2) | ||
| 16 | +public class ApplicationCheckRunner implements CommandLineRunner { | ||
| 17 | + | ||
| 18 | + private Logger logger = LoggerFactory.getLogger("ApplicationCheckRunner"); | ||
| 19 | + | ||
| 20 | + @Value("${sip.ip}") | ||
| 21 | + private String sipIp; | ||
| 22 | + | ||
| 23 | + @Value("${media.ip}") | ||
| 24 | + private String mediaIp; | ||
| 25 | + | ||
| 26 | + @Value("${media.wanIp}") | ||
| 27 | + private String mediaWanIp; | ||
| 28 | + | ||
| 29 | + @Value("${media.hookIp}") | ||
| 30 | + private String mediaHookIp; | ||
| 31 | + | ||
| 32 | + @Value("${media.port}") | ||
| 33 | + private int mediaPort; | ||
| 34 | + | ||
| 35 | + @Value("${media.secret}") | ||
| 36 | + private String mediaSecret; | ||
| 37 | + | ||
| 38 | + @Value("${media.streamNoneReaderDelayMS}") | ||
| 39 | + private String streamNoneReaderDelayMS; | ||
| 40 | + | ||
| 41 | + @Value("${sip.ip}") | ||
| 42 | + private String sipIP; | ||
| 43 | + | ||
| 44 | + @Value("${server.port}") | ||
| 45 | + private String serverPort; | ||
| 46 | + | ||
| 47 | + @Value("${media.autoConfig}") | ||
| 48 | + private boolean autoConfig; | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public void run(String... args) throws Exception { | ||
| 53 | + if (sipIP.equals("localhost") || sipIP.equals("127.0.0.1")) { | ||
| 54 | + logger.error("sip.ip不能使用 {} ,请使用类似192.168.1.44这样的来自网卡的IP!!!", sipIP ); | ||
| 55 | + System.exit(1); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + if (mediaIp.equals("localhost") || mediaIp.equals("127.0.0.1")) { | ||
| 59 | + logger.warn("mediaIp.ip使用 {} ,将无法收到网络内其他设备的推流!!!", mediaIp ); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | +} |