network properties changed

This commit is contained in:
insanity 2018-04-26 17:11:31 +09:00
parent bfa42491e7
commit 3b36c6ade2
8 changed files with 28 additions and 34 deletions

View File

@ -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>>(){});

View File

@ -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()) {

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,12 +15,11 @@ 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.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfigTest.class})
@ContextConfiguration(classes = { AppConfigTest.class })
public class InfraHostServiceTest {
@Autowired
@ -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);
@ -59,7 +56,7 @@ public class InfraHostServiceTest {
InfraHost infraHost = this.infraHostService.read(1);
String json = objectMapper.writeValueAsString(infraHost);
String json = objectMapper.writeValueAsString(infraHost);
System.out.println(json);
@ -69,14 +66,13 @@ public class InfraHostServiceTest {
public void readByIp() {
InfraHost infraHost;
try {
infraHost = this.infraHostService.readByIp(3232235980L);
try {
infraHost = this.infraHostService.readByIp("192.168.1.1");
Assert.assertNotEquals(infraHost, null);
} catch (OverflowException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (OverflowException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}