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