This commit is contained in:
crusader 2018-04-28 01:29:54 +09:00
parent 31a36dc2df
commit d8ffaa8d84
16 changed files with 102 additions and 88 deletions

View File

@ -3,10 +3,10 @@ import { Store, select } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import {
DiscoveryStartInfo,
DiscoveryZone,
DiscoverZone,
Zone,
DiscoveryPort,
DiscoveryService
DiscoverPort,
DiscoverService
} from '../../model';
import * as CIDR from 'ip-cidr';
import * as DiscoveredStore from '../../store/setting';
@ -65,23 +65,35 @@ export class SettingComponent implements OnInit, AfterContentInit {
includeServices = [];
serviceItems = [
{ name: 'SSH' },
{ name: 'PostgreSQL' },
{ name: 'ACTIVEDIRECTORY' },
{ name: 'CASSANDRA' },
{ name: 'DHCP' },
{ name: 'DNS' },
{ name: 'WMI'},
{ name: 'SMB' },
{ name: 'ActiveDirectory' },
{ name: 'Cassandra' },
{ name: 'FTP' },
{ name: 'HTTP' },
{ name: 'IMAP' },
{ name: 'LDAP' },
{ name: 'MongoDB' },
{ name: 'MySQL' },
{ name: 'NBSS' },
{ name: 'MONGODB' },
{ name: 'MSSQL' },
{ name: 'MYSQL' },
{ name: 'NETBIOS' },
{ name: 'ORACLE' },
{ name: 'POP' },
{ name: 'POSTGRESQL' },
{ name: 'REDIS' },
{ name: 'RMI' },
{ name: 'SMB' },
{ name: 'SMTP' },
{ name: 'SNMP' },
{ name: 'SSH' },
{ name: 'TELNET' },
{ name: 'WMI' },
{ name: 'UNKNOWN' },
{ name: 'SSH' },
{ name: 'WMI' },
{ name: 'SNMP' },
];
treeNodes = [];
selectedNodes = [];
zones: Map<string, Zone> = null;
@ -256,41 +268,41 @@ export class SettingComponent implements OnInit, AfterContentInit {
console.log(this.startPort);
console.log(this.endPort);
let discoveryPort: DiscoveryPort = null;
let discoveryService: DiscoveryService = null;
let discoverPort: DiscoverPort = null;
let discoverService: DiscoverService = null;
if (this.serviceChecked.length > 0) {
const services = new Array();
for (const service of this.includeServices) {
services.push(service.name);
}
discoveryService = {
discoverService = {
includeServices: services,
};
}
if (this.portChecked.length > 0) {
discoveryPort = {
discoverPort = {
firstScanRange: this.startPort,
lastScanRange: this.endPort,
includeTCP: this.tcpChecked,
includeUDP: this.udpChecked,
excludePorts: null,
discoveryService: discoveryService
discoverService: discoverService
};
}
const discoveryZone: DiscoveryZone = {
discoveryHost: {
const discoverZone: DiscoverZone = {
discoverHost: {
firstScanRange: this.startIP,
lastScanRange: this.endIP,
discoveryPort: discoveryPort,
discoverPort: discoverPort,
},
};
console.log(discoveryZone);
console.log(discoverZone);
// console.log('start discovery - ' + this.probe.probeKey);
this.discoverstore.dispatch(new DiscoverStore.DiscoverZone(
{ probeID: this.probe.probeKey, discoveryZone: discoveryZone }));
{ probeID: this.probe.probeKey, discoverZone: discoverZone }));
this.started = true;
}

View File

@ -0,0 +1,10 @@
import { DiscoverPort } from './DiscoverPort';
export interface DiscoverHost {
firstScanRange?: string;
lastScanRange?: string;
excludeHosts?: string[];
includeHosts?: string[];
discoverPort?: DiscoverPort;
}

View File

@ -1,11 +1,11 @@
import { DiscoveryService } from './DiscoveryService';
import { DiscoverService } from './DiscoverService';
export interface DiscoveryPort {
export interface DiscoverPort {
firstScanRange: number;
lastScanRange: number;
excludePorts: number[];
includeTCP: boolean;
includeUDP: boolean;
discoveryService?: DiscoveryService;
discoverService?: DiscoverService;
}

View File

@ -0,0 +1,3 @@
export interface DiscoverService {
includeServices: string[];
}

View File

@ -0,0 +1,7 @@
import { DiscoverHost } from './DiscoverHost';
export interface DiscoverZone {
excludePatterns?: string[];
discoverHost?: DiscoverHost;
}

View File

@ -1,10 +0,0 @@
import { DiscoveryPort } from './DiscoveryPort';
export interface DiscoveryHost {
firstScanRange?: string;
lastScanRange?: string;
excludeHosts?: string[];
includeHosts?: string[];
discoveryPort?: DiscoveryPort;
}

View File

@ -1,3 +0,0 @@
export interface DiscoveryService {
includeServices: string[];
}

View File

@ -1,7 +0,0 @@
import { DiscoveryHost } from './DiscoveryHost';
export interface DiscoveryZone {
excludePatterns?: string[];
discoveryHost?: DiscoveryHost;
}

View File

@ -3,7 +3,8 @@ import { Port } from './Port';
export interface Host {
id?: number;
ip: string;
ip4?: string;
ip6?: string;
mac: number;
os: string;
discoveredDate?: Date;

View File

@ -3,7 +3,8 @@ import { Host } from './Host';
export interface Zone {
id?: number;
network?: string;
ip?: string;
ip4?: string;
ip6?: string;
iface?: string;
mac?: string;
discoveredDate?: Date;

View File

@ -1,7 +1,7 @@
export * from './DiscoveryHost';
export * from './DiscoveryPort';
export * from './DiscoveryService';
export * from './DiscoveryZone';
export * from './DiscoverHost';
export * from './DiscoverPort';
export * from './DiscoverService';
export * from './DiscoverZone';
export * from './DiscoveryStartInfo';
export * from './Host';
export * from './Port';

View File

@ -3,10 +3,10 @@ import { Observable } from 'rxjs/Observable';
import { RPCService } from '@loafer/ng-rpc/service';
import {
DiscoveryStartInfo,
DiscoveryZone,
DiscoveryHost,
DiscoveryPort,
DiscoveryService as M_DiscoveryService,
DiscoverZone as MDDiscoverZone,
DiscoverHost as MDDiscoverHost,
DiscoverPort as MDDiscoverPort,
DiscoverService as MDDiscoverService,
Zone,
Host,
Port,
@ -27,16 +27,16 @@ export class DiscoveryService {
return this.rpcService.call('DiscoveryService.startDiscovery', dsInfo);
}
public discoverZone(probeID: string, discoveryZone: DiscoveryZone): void {
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoveryZone);
public discoverZone(probeID: string, discoverZone: MDDiscoverZone): void {
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone);
}
public discoverHost(probeID: string, zone: Zone, discoveryHost: DiscoveryHost): void {
this.rpcService.send('DiscoveryService.discoverHost', probeID, zone, discoveryHost);
public discoverHost(probeID: string, zone: Zone, discoverHost: MDDiscoverHost): void {
this.rpcService.send('DiscoveryService.discoverHost', probeID, zone, discoverHost);
}
public discoverPort(probeID: string, host: Host, discoveryPort: DiscoveryPort): void {
this.rpcService.send('DiscoveryService.discoverPort', probeID, host, discoveryPort);
public discoverPort(probeID: string, host: Host, discoverPort: MDDiscoverPort): void {
this.rpcService.send('DiscoveryService.discoverPort', probeID, host, discoverPort);
}
public discoverService(probeID: string, port: Port, discoveryService: M_DiscoveryService): void {
this.rpcService.send('DiscoveryService.discoverService', probeID, port, discoveryService);
public discoverService(probeID: string, port: Port, discoverService: MDDiscoverService): void {
this.rpcService.send('DiscoveryService.discoverService', probeID, port, discoverService);
}
}

View File

@ -3,10 +3,10 @@ import { Observable } from 'rxjs/Observable';
import { RPCService } from '@loafer/ng-rpc/service';
import {
DiscoveryStartInfo,
DiscoveryZone,
DiscoveryHost,
DiscoveryPort,
DiscoveryService as M_DiscoveryService,
DiscoverZone as MDDiscoverZone,
DiscoverHost as MDDiscoverHost,
DiscoverPort as MDDiscoverPort,
DiscoverService as MDDiscoverService,
Zone,
Host,
Port,

View File

@ -5,10 +5,10 @@ import {
Host,
Port,
Service,
DiscoveryZone,
DiscoveryHost,
DiscoveryPort,
DiscoveryService as MDiscoveryService,
DiscoverZone as MDDiscoverZone,
DiscoverHost as MDDiscoverHost,
DiscoverPort as MDDiscoverPort,
DiscoverService as MDiscoverService,
} from '../../model';
export enum ActionType {
@ -28,24 +28,24 @@ import {
export class DiscoverZone implements Action {
readonly type = ActionType.DiscoverZone;
constructor(public payload: {probeID: string, discoveryZone: DiscoveryZone}) {}
constructor(public payload: {probeID: string, discoverZone: MDDiscoverZone}) {}
}
export class DiscoverHost implements Action {
readonly type = ActionType.DiscoverHost;
constructor(public payload: {probeID: string, zone: Zone, discoveryHost: DiscoveryHost}) {}
constructor(public payload: {probeID: string, zone: Zone, discoverHost: MDDiscoverHost}) {}
}
export class DiscoverPort implements Action {
readonly type = ActionType.DiscoverPort;
constructor(public payload: {probeID: string, host: Host, discoveryPort: DiscoveryPort}) {}
constructor(public payload: {probeID: string, host: Host, discoverPort: MDDiscoverPort}) {}
}
export class DiscoverService implements Action {
readonly type = ActionType.DiscoverService;
constructor(public payload: {probeID: string, port: Port, discoveryService: MDiscoveryService}) {}
constructor(public payload: {probeID: string, port: Port, discoverService: MDiscoverService}) {}
}
export class DiscoveryStart implements Action {

View File

@ -37,7 +37,7 @@ export class Effects {
.ofType(ActionType.DiscoverZone)
.map((action: DiscoverZone) => action.payload)
.do(payload => {
this.discoveryService.discoverZone(payload.probeID, payload.discoveryZone);
this.discoveryService.discoverZone(payload.probeID, payload.discoverZone);
});
@Effect({ dispatch: false })
@ -45,7 +45,7 @@ export class Effects {
.ofType(ActionType.DiscoverHost)
.map((action: DiscoverHost) => action.payload)
.do(payload => {
this.discoveryService.discoverHost(payload.probeID, payload.zone, payload.discoveryHost);
this.discoveryService.discoverHost(payload.probeID, payload.zone, payload.discoverHost);
});
@Effect({ dispatch: false })
@ -53,7 +53,7 @@ export class Effects {
.ofType(ActionType.DiscoverPort)
.map((action: DiscoverPort) => action.payload)
.do(payload => {
this.discoveryService.discoverPort(payload.probeID, payload.host, payload.discoveryPort);
this.discoveryService.discoverPort(payload.probeID, payload.host, payload.discoverPort);
});
@Effect({ dispatch: false })
@ -61,6 +61,6 @@ export class Effects {
.ofType(ActionType.DiscoverService)
.map((action: DiscoverService) => action.payload)
.do(payload => {
this.discoveryService.discoverService(payload.probeID, payload.port, payload.discoveryService);
this.discoveryService.discoverService(payload.probeID, payload.port, payload.discoverService);
});
}

View File

@ -70,10 +70,10 @@ export function reducer(state = initialState, action: Actions): State {
}
if (null === zone.hosts || undefined === zone.hosts) {
zone.hosts = new Map();
zone.hosts.set(host.ip, host);
zone.hosts.set(host.ip4, host);
} else {
if (zone.hosts.has(host.ip) === false) {
zone.hosts.set(host.ip, host);
if (zone.hosts.has(host.ip4) === false) {
zone.hosts.set(host.ip4, host);
}
}
@ -118,7 +118,7 @@ export function reducer(state = initialState, action: Actions): State {
zone.hosts = new Map();
}
let host: Host = null;
host = zone.hosts.get(port.host.ip);
host = zone.hosts.get(port.host.ip4);
if (host === undefined || host === null) {
host = port.host;
@ -133,7 +133,7 @@ export function reducer(state = initialState, action: Actions): State {
}
}
zone.hosts.set(host.ip, host);
zone.hosts.set(host.ip4, host);
zones.set(zone.network, zone);
const newZones: Map<string, Zone> = new Map();
@ -174,10 +174,10 @@ export function reducer(state = initialState, action: Actions): State {
// console.error(`Discovery.DiscoveredPort: Host[${service.port.host.ip}] is not exist`);
// }
let host: Host = null;
host = zone.hosts.get(service.port.host.ip);
host = zone.hosts.get(service.port.host.ip4);
if (host === undefined || host === null) {
zone.hosts.set(service.port.host.ip, service.port.host);
zone.hosts.set(service.port.host.ip4, service.port.host);
host = service.port.host;
}
@ -199,7 +199,7 @@ export function reducer(state = initialState, action: Actions): State {
port.services.set(service.serviceName, service);
host.ports.set(service.port.portNumber, port);
zone.hosts.set(host.ip, host);
zone.hosts.set(host.ip4, host);
zones.set(zone.network, zone);
const newZones: Map<string, Zone> = new Map();