mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-20 00:06:53 +08:00
不安全的随机数,剩余一个缺陷
This commit is contained in:
@@ -3,6 +3,7 @@ package com.xboe.module.idconfig;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -50,8 +51,10 @@ public class IdGeneratorAutoConfig {
|
||||
dataCenterId=ipm.getDcNum();
|
||||
}else {
|
||||
log.warn("无IP【"+ip+"】的配置的workNum和DataCenterNum,系统自动生成随机数");
|
||||
workServerId=RandomUtils.nextInt(0,31);
|
||||
dataCenterId=RandomUtils.nextInt(0,31);
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||
workServerId = random.nextInt(31);
|
||||
dataCenterId = random.nextInt(31);
|
||||
|
||||
ipm=new IPMapping();
|
||||
ipm.setId(md5);
|
||||
ipm.setIp(ip);
|
||||
|
||||
Reference in New Issue
Block a user