network properties changed
This commit is contained in:
parent
bfa42491e7
commit
3b36c6ade2
|
@ -85,7 +85,7 @@ public class InfraHostGenerator {
|
|||
|
||||
Target target = new Target();
|
||||
Connection connection = new Connection();
|
||||
connection.setIp(StringConvertor.intToIp(infraHost.getIp()));
|
||||
connection.setIp(infraHost.getIpv4());
|
||||
|
||||
HashMap<String, String> optionMap = this.objectMapper.readValue(authCrawler.getAuthJson(), new TypeReference<Map<String, String>>(){});
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public class InfraServiceGenerator {
|
|||
|
||||
Target target = new Target();
|
||||
Connection connection = new Connection();
|
||||
connection.setIp(StringConvertor.intToIp(infraService.getHost().getIp()));
|
||||
connection.setIp(infraService.getHost().getIpv4());
|
||||
connection.setPort(infraService.getPort());
|
||||
connection.setPortType(PortType.valueOf(infraService.getPortType()));
|
||||
connection.setSsl(infraService.isTlsType());
|
||||
|
@ -102,7 +102,7 @@ public class InfraServiceGenerator {
|
|||
Map<String, Object> auth = new HashMap<>();
|
||||
|
||||
if(sensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||
auth.put("url", "jdbc:mysql://"+ StringConvertor.intToIp(infraService.getHost().getIp())+":"+String.valueOf(infraService.getPort()));
|
||||
auth.put("url", "jdbc:mysql://"+ infraService.getHost().getIpv4() +":" + infraService.getPort());
|
||||
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
} else if (sensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
|
|
|
@ -9,6 +9,6 @@ import org.springframework.stereotype.Repository;
|
|||
*/
|
||||
@Repository
|
||||
public interface InfraHostDAO extends JpaRepository<InfraHost, Long> {
|
||||
InfraHost findByIp(long ip);
|
||||
InfraHost findByIp(String ip);
|
||||
|
||||
}
|
|
@ -24,7 +24,7 @@ public class CentralInfraHostService implements InfraHostService {
|
|||
return this.infraHostDAO.findOne(id);
|
||||
}
|
||||
|
||||
public InfraHost readByIp(long ip) throws OverflowException {
|
||||
public InfraHost readByIp(String ip) throws OverflowException {
|
||||
return this.infraHostDAO.findByIp(ip);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,8 +188,8 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
|||
String addrStr = netMap.get("address");
|
||||
String[] addrArr = addrStr.split("\\|");
|
||||
|
||||
infraHost.setIp(StringConvertor.ipToLong(addrArr[1]));
|
||||
infraHost.setMac(StringConvertor.macStrToLong(netMap.get("macAddress")));
|
||||
infraHost.setIpv4(addrArr[0]);
|
||||
infraHost.setMac(netMap.get("macAddress"));
|
||||
infraHost.setOs(infraOS);
|
||||
infraHost.setInfraType(infraType);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.loafle.overflow.central.module.target.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.utils.StringConvertor;
|
||||
import com.loafle.overflow.central.module.infra.service.*;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.core.type.PortType;
|
||||
|
@ -37,8 +36,8 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
|||
@Autowired
|
||||
private CentralInfraHostService infraHostService;
|
||||
|
||||
@Autowired
|
||||
private CentralInfraService infraService;
|
||||
// @Autowired
|
||||
// private CentralInfraService infraService;
|
||||
|
||||
@Autowired
|
||||
private CentralInfraOSPortService infraOSPortService;
|
||||
|
@ -169,12 +168,12 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
|||
private InfraHost createAndReadHost(Host host, Probe probe) throws OverflowException {
|
||||
|
||||
|
||||
InfraHost infraHost = this.infraHostService.readByIp(StringConvertor.ipToLong(host.getIp()));
|
||||
InfraHost infraHost = this.infraHostService.readByIp(host.getIpv4());
|
||||
if(infraHost != null) {
|
||||
|
||||
if(host.isTarget() && infraHost.getTarget() == null) {
|
||||
Target target = new Target();
|
||||
target.setDisplayName(String.valueOf(host.getIp()) + "-Host");
|
||||
target.setDisplayName(host.getIpv4() + "-Host");
|
||||
|
||||
this.targetService.regist(target);
|
||||
infraHost.setTarget(target);
|
||||
|
@ -195,7 +194,7 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
|||
InfraMachine infraMachine = new InfraMachine();
|
||||
infraMachine.setProbe(probe);
|
||||
infraMachine.setInfraType(typeMachine);
|
||||
infraMachine.setMeta(host.getIp()+"-MACHINE");
|
||||
infraMachine.setMeta(host.getIpv4()+"-MACHINE");
|
||||
this.infraMachineService.regist(infraMachine);
|
||||
|
||||
InfraOS infraOS = new InfraOS();
|
||||
|
@ -203,13 +202,12 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
|||
infraOS.setVendor(MetaInfraVendor.CreateInfraVendorByOS(host.getOs()));
|
||||
infraOS.setInfraType(typeOS);
|
||||
infraOS.setProbe(probe);
|
||||
infraOS.setMeta(host.getIp()+"-OS");
|
||||
infraOS.setMeta(host.getIpv4()+"-OS");
|
||||
this.infraOSService.regist(infraOS);
|
||||
|
||||
InfraHost newInfraHost = new InfraHost();
|
||||
newInfraHost.setIp(StringConvertor.ipToLong(host.getIp()));
|
||||
// newInfraHost.setMac(StringConvertor.ipToLong(host.getMac()));
|
||||
newInfraHost.setMac(StringConvertor.macStrToLong(host.getMac()));
|
||||
newInfraHost.setIpv4(host.getIpv4());
|
||||
newInfraHost.setMac(host.getMac());
|
||||
newInfraHost.setOs(infraOS);
|
||||
newInfraHost.setInfraType(typeHost);
|
||||
newInfraHost.setProbe(probe);
|
||||
|
@ -217,7 +215,7 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
|||
|
||||
if(host.isTarget()) {
|
||||
Target target = new Target();
|
||||
target.setDisplayName(host.getIp() + "-Host");
|
||||
target.setDisplayName(host.getIpv4() + "-Host");
|
||||
|
||||
this.targetService.regist(target);
|
||||
newInfraHost.setTarget(target);
|
||||
|
|
|
@ -972,8 +972,8 @@ INSERT INTO public.infra_machine (meta,id) VALUES (
|
|||
INSERT INTO public.infra_os (meta,id,machine_id,vendor_id) VALUES (
|
||||
'',2,1,24);
|
||||
|
||||
INSERT INTO public.infra_host (ip,mac,id,os_id) VALUES (
|
||||
3232235980,8796753988883,3,2);
|
||||
INSERT INTO public.infra_host (ip_v4,ip_v6,mac,id,os_id) VALUES (
|
||||
'192.168.1.111','fe80::b83c:44a8:5d71:5bc0%3','30-9C-23-15-A3-09',3,2);
|
||||
|
||||
-- INSERT INTO public.infra_service (port,port_type,tls_type,id,host_id,vendor_id) VALUES (
|
||||
-- 80,'TCP',false,4,3,45);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.infra.InfraHost;
|
||||
|
@ -16,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 7. 27.
|
||||
*/
|
||||
|
@ -36,9 +34,8 @@ public class InfraHostServiceTest {
|
|||
|
||||
InfraHost infraHost = new InfraHost();
|
||||
|
||||
infraHost.setMac(8796753988883L);
|
||||
infraHost.setIp(3232235980L);
|
||||
|
||||
infraHost.setMac("30-9C-23-15-A3-09");
|
||||
infraHost.setIpv4("192.168.1.1");
|
||||
InfraOS infraOS = new InfraOS();
|
||||
infraOS.setId(2);
|
||||
|
||||
|
@ -70,14 +67,13 @@ public class InfraHostServiceTest {
|
|||
|
||||
InfraHost infraHost;
|
||||
try {
|
||||
infraHost = this.infraHostService.readByIp(3232235980L);
|
||||
infraHost = this.infraHostService.readByIp("192.168.1.1");
|
||||
Assert.assertNotEquals(infraHost, null);
|
||||
} catch (OverflowException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user