ing
This commit is contained in:
parent
31a36dc2df
commit
d8ffaa8d84
|
@ -3,10 +3,10 @@ import { Store, select } from '@ngrx/store';
|
||||||
import { RPCClientError } from '@loafer/ng-rpc/protocol';
|
import { RPCClientError } from '@loafer/ng-rpc/protocol';
|
||||||
import {
|
import {
|
||||||
DiscoveryStartInfo,
|
DiscoveryStartInfo,
|
||||||
DiscoveryZone,
|
DiscoverZone,
|
||||||
Zone,
|
Zone,
|
||||||
DiscoveryPort,
|
DiscoverPort,
|
||||||
DiscoveryService
|
DiscoverService
|
||||||
} from '../../model';
|
} from '../../model';
|
||||||
import * as CIDR from 'ip-cidr';
|
import * as CIDR from 'ip-cidr';
|
||||||
import * as DiscoveredStore from '../../store/setting';
|
import * as DiscoveredStore from '../../store/setting';
|
||||||
|
@ -65,23 +65,35 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
||||||
includeServices = [];
|
includeServices = [];
|
||||||
|
|
||||||
serviceItems = [
|
serviceItems = [
|
||||||
{ name: 'SSH' },
|
{ name: 'ACTIVEDIRECTORY' },
|
||||||
{ name: 'PostgreSQL' },
|
{ name: 'CASSANDRA' },
|
||||||
|
{ name: 'DHCP' },
|
||||||
{ name: 'DNS' },
|
{ name: 'DNS' },
|
||||||
{ name: 'WMI'},
|
|
||||||
{ name: 'SMB' },
|
|
||||||
{ name: 'ActiveDirectory' },
|
|
||||||
{ name: 'Cassandra' },
|
|
||||||
{ name: 'FTP' },
|
{ name: 'FTP' },
|
||||||
{ name: 'HTTP' },
|
{ name: 'HTTP' },
|
||||||
{ name: 'IMAP' },
|
{ name: 'IMAP' },
|
||||||
{ name: 'LDAP' },
|
{ name: 'LDAP' },
|
||||||
{ name: 'MongoDB' },
|
{ name: 'MONGODB' },
|
||||||
{ name: 'MySQL' },
|
{ name: 'MSSQL' },
|
||||||
{ name: 'NBSS' },
|
{ 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 = [];
|
treeNodes = [];
|
||||||
selectedNodes = [];
|
selectedNodes = [];
|
||||||
zones: Map<string, Zone> = null;
|
zones: Map<string, Zone> = null;
|
||||||
|
@ -256,41 +268,41 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
||||||
console.log(this.startPort);
|
console.log(this.startPort);
|
||||||
console.log(this.endPort);
|
console.log(this.endPort);
|
||||||
|
|
||||||
let discoveryPort: DiscoveryPort = null;
|
let discoverPort: DiscoverPort = null;
|
||||||
let discoveryService: DiscoveryService = null;
|
let discoverService: DiscoverService = null;
|
||||||
|
|
||||||
if (this.serviceChecked.length > 0) {
|
if (this.serviceChecked.length > 0) {
|
||||||
const services = new Array();
|
const services = new Array();
|
||||||
for (const service of this.includeServices) {
|
for (const service of this.includeServices) {
|
||||||
services.push(service.name);
|
services.push(service.name);
|
||||||
}
|
}
|
||||||
discoveryService = {
|
discoverService = {
|
||||||
includeServices: services,
|
includeServices: services,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (this.portChecked.length > 0) {
|
if (this.portChecked.length > 0) {
|
||||||
discoveryPort = {
|
discoverPort = {
|
||||||
firstScanRange: this.startPort,
|
firstScanRange: this.startPort,
|
||||||
lastScanRange: this.endPort,
|
lastScanRange: this.endPort,
|
||||||
includeTCP: this.tcpChecked,
|
includeTCP: this.tcpChecked,
|
||||||
includeUDP: this.udpChecked,
|
includeUDP: this.udpChecked,
|
||||||
excludePorts: null,
|
excludePorts: null,
|
||||||
discoveryService: discoveryService
|
discoverService: discoverService
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const discoveryZone: DiscoveryZone = {
|
const discoverZone: DiscoverZone = {
|
||||||
discoveryHost: {
|
discoverHost: {
|
||||||
firstScanRange: this.startIP,
|
firstScanRange: this.startIP,
|
||||||
lastScanRange: this.endIP,
|
lastScanRange: this.endIP,
|
||||||
discoveryPort: discoveryPort,
|
discoverPort: discoverPort,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(discoveryZone);
|
console.log(discoverZone);
|
||||||
|
|
||||||
// console.log('start discovery - ' + this.probe.probeKey);
|
// console.log('start discovery - ' + this.probe.probeKey);
|
||||||
this.discoverstore.dispatch(new DiscoverStore.DiscoverZone(
|
this.discoverstore.dispatch(new DiscoverStore.DiscoverZone(
|
||||||
{ probeID: this.probe.probeKey, discoveryZone: discoveryZone }));
|
{ probeID: this.probe.probeKey, discoverZone: discoverZone }));
|
||||||
|
|
||||||
this.started = true;
|
this.started = true;
|
||||||
}
|
}
|
||||||
|
|
10
src/packages/discovery/model/DiscoverHost.ts
Normal file
10
src/packages/discovery/model/DiscoverHost.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { DiscoverPort } from './DiscoverPort';
|
||||||
|
|
||||||
|
export interface DiscoverHost {
|
||||||
|
firstScanRange?: string;
|
||||||
|
lastScanRange?: string;
|
||||||
|
excludeHosts?: string[];
|
||||||
|
includeHosts?: string[];
|
||||||
|
|
||||||
|
discoverPort?: DiscoverPort;
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
import { DiscoveryService } from './DiscoveryService';
|
import { DiscoverService } from './DiscoverService';
|
||||||
|
|
||||||
export interface DiscoveryPort {
|
export interface DiscoverPort {
|
||||||
firstScanRange: number;
|
firstScanRange: number;
|
||||||
lastScanRange: number;
|
lastScanRange: number;
|
||||||
excludePorts: number[];
|
excludePorts: number[];
|
||||||
includeTCP: boolean;
|
includeTCP: boolean;
|
||||||
includeUDP: boolean;
|
includeUDP: boolean;
|
||||||
|
|
||||||
discoveryService?: DiscoveryService;
|
discoverService?: DiscoverService;
|
||||||
}
|
}
|
3
src/packages/discovery/model/DiscoverService.ts
Normal file
3
src/packages/discovery/model/DiscoverService.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export interface DiscoverService {
|
||||||
|
includeServices: string[];
|
||||||
|
}
|
7
src/packages/discovery/model/DiscoverZone.ts
Normal file
7
src/packages/discovery/model/DiscoverZone.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import { DiscoverHost } from './DiscoverHost';
|
||||||
|
|
||||||
|
export interface DiscoverZone {
|
||||||
|
excludePatterns?: string[];
|
||||||
|
|
||||||
|
discoverHost?: DiscoverHost;
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
import { DiscoveryPort } from './DiscoveryPort';
|
|
||||||
|
|
||||||
export interface DiscoveryHost {
|
|
||||||
firstScanRange?: string;
|
|
||||||
lastScanRange?: string;
|
|
||||||
excludeHosts?: string[];
|
|
||||||
includeHosts?: string[];
|
|
||||||
|
|
||||||
discoveryPort?: DiscoveryPort;
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
export interface DiscoveryService {
|
|
||||||
includeServices: string[];
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
import { DiscoveryHost } from './DiscoveryHost';
|
|
||||||
|
|
||||||
export interface DiscoveryZone {
|
|
||||||
excludePatterns?: string[];
|
|
||||||
|
|
||||||
discoveryHost?: DiscoveryHost;
|
|
||||||
}
|
|
|
@ -3,7 +3,8 @@ import { Port } from './Port';
|
||||||
|
|
||||||
export interface Host {
|
export interface Host {
|
||||||
id?: number;
|
id?: number;
|
||||||
ip: string;
|
ip4?: string;
|
||||||
|
ip6?: string;
|
||||||
mac: number;
|
mac: number;
|
||||||
os: string;
|
os: string;
|
||||||
discoveredDate?: Date;
|
discoveredDate?: Date;
|
||||||
|
|
|
@ -3,7 +3,8 @@ import { Host } from './Host';
|
||||||
export interface Zone {
|
export interface Zone {
|
||||||
id?: number;
|
id?: number;
|
||||||
network?: string;
|
network?: string;
|
||||||
ip?: string;
|
ip4?: string;
|
||||||
|
ip6?: string;
|
||||||
iface?: string;
|
iface?: string;
|
||||||
mac?: string;
|
mac?: string;
|
||||||
discoveredDate?: Date;
|
discoveredDate?: Date;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export * from './DiscoveryHost';
|
export * from './DiscoverHost';
|
||||||
export * from './DiscoveryPort';
|
export * from './DiscoverPort';
|
||||||
export * from './DiscoveryService';
|
export * from './DiscoverService';
|
||||||
export * from './DiscoveryZone';
|
export * from './DiscoverZone';
|
||||||
export * from './DiscoveryStartInfo';
|
export * from './DiscoveryStartInfo';
|
||||||
export * from './Host';
|
export * from './Host';
|
||||||
export * from './Port';
|
export * from './Port';
|
||||||
|
|
|
@ -3,10 +3,10 @@ import { Observable } from 'rxjs/Observable';
|
||||||
import { RPCService } from '@loafer/ng-rpc/service';
|
import { RPCService } from '@loafer/ng-rpc/service';
|
||||||
import {
|
import {
|
||||||
DiscoveryStartInfo,
|
DiscoveryStartInfo,
|
||||||
DiscoveryZone,
|
DiscoverZone as MDDiscoverZone,
|
||||||
DiscoveryHost,
|
DiscoverHost as MDDiscoverHost,
|
||||||
DiscoveryPort,
|
DiscoverPort as MDDiscoverPort,
|
||||||
DiscoveryService as M_DiscoveryService,
|
DiscoverService as MDDiscoverService,
|
||||||
Zone,
|
Zone,
|
||||||
Host,
|
Host,
|
||||||
Port,
|
Port,
|
||||||
|
@ -27,16 +27,16 @@ export class DiscoveryService {
|
||||||
return this.rpcService.call('DiscoveryService.startDiscovery', dsInfo);
|
return this.rpcService.call('DiscoveryService.startDiscovery', dsInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public discoverZone(probeID: string, discoveryZone: DiscoveryZone): void {
|
public discoverZone(probeID: string, discoverZone: MDDiscoverZone): void {
|
||||||
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoveryZone);
|
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone);
|
||||||
}
|
}
|
||||||
public discoverHost(probeID: string, zone: Zone, discoveryHost: DiscoveryHost): void {
|
public discoverHost(probeID: string, zone: Zone, discoverHost: MDDiscoverHost): void {
|
||||||
this.rpcService.send('DiscoveryService.discoverHost', probeID, zone, discoveryHost);
|
this.rpcService.send('DiscoveryService.discoverHost', probeID, zone, discoverHost);
|
||||||
}
|
}
|
||||||
public discoverPort(probeID: string, host: Host, discoveryPort: DiscoveryPort): void {
|
public discoverPort(probeID: string, host: Host, discoverPort: MDDiscoverPort): void {
|
||||||
this.rpcService.send('DiscoveryService.discoverPort', probeID, host, discoveryPort);
|
this.rpcService.send('DiscoveryService.discoverPort', probeID, host, discoverPort);
|
||||||
}
|
}
|
||||||
public discoverService(probeID: string, port: Port, discoveryService: M_DiscoveryService): void {
|
public discoverService(probeID: string, port: Port, discoverService: MDDiscoverService): void {
|
||||||
this.rpcService.send('DiscoveryService.discoverService', probeID, port, discoveryService);
|
this.rpcService.send('DiscoveryService.discoverService', probeID, port, discoverService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ import { Observable } from 'rxjs/Observable';
|
||||||
import { RPCService } from '@loafer/ng-rpc/service';
|
import { RPCService } from '@loafer/ng-rpc/service';
|
||||||
import {
|
import {
|
||||||
DiscoveryStartInfo,
|
DiscoveryStartInfo,
|
||||||
DiscoveryZone,
|
DiscoverZone as MDDiscoverZone,
|
||||||
DiscoveryHost,
|
DiscoverHost as MDDiscoverHost,
|
||||||
DiscoveryPort,
|
DiscoverPort as MDDiscoverPort,
|
||||||
DiscoveryService as M_DiscoveryService,
|
DiscoverService as MDDiscoverService,
|
||||||
Zone,
|
Zone,
|
||||||
Host,
|
Host,
|
||||||
Port,
|
Port,
|
||||||
|
|
|
@ -5,10 +5,10 @@ import {
|
||||||
Host,
|
Host,
|
||||||
Port,
|
Port,
|
||||||
Service,
|
Service,
|
||||||
DiscoveryZone,
|
DiscoverZone as MDDiscoverZone,
|
||||||
DiscoveryHost,
|
DiscoverHost as MDDiscoverHost,
|
||||||
DiscoveryPort,
|
DiscoverPort as MDDiscoverPort,
|
||||||
DiscoveryService as MDiscoveryService,
|
DiscoverService as MDiscoverService,
|
||||||
} from '../../model';
|
} from '../../model';
|
||||||
|
|
||||||
export enum ActionType {
|
export enum ActionType {
|
||||||
|
@ -28,24 +28,24 @@ import {
|
||||||
export class DiscoverZone implements Action {
|
export class DiscoverZone implements Action {
|
||||||
readonly type = ActionType.DiscoverZone;
|
readonly type = ActionType.DiscoverZone;
|
||||||
|
|
||||||
constructor(public payload: {probeID: string, discoveryZone: DiscoveryZone}) {}
|
constructor(public payload: {probeID: string, discoverZone: MDDiscoverZone}) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DiscoverHost implements Action {
|
export class DiscoverHost implements Action {
|
||||||
readonly type = ActionType.DiscoverHost;
|
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 {
|
export class DiscoverPort implements Action {
|
||||||
readonly type = ActionType.DiscoverPort;
|
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 {
|
export class DiscoverService implements Action {
|
||||||
readonly type = ActionType.DiscoverService;
|
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 {
|
export class DiscoveryStart implements Action {
|
||||||
|
|
|
@ -37,7 +37,7 @@ export class Effects {
|
||||||
.ofType(ActionType.DiscoverZone)
|
.ofType(ActionType.DiscoverZone)
|
||||||
.map((action: DiscoverZone) => action.payload)
|
.map((action: DiscoverZone) => action.payload)
|
||||||
.do(payload => {
|
.do(payload => {
|
||||||
this.discoveryService.discoverZone(payload.probeID, payload.discoveryZone);
|
this.discoveryService.discoverZone(payload.probeID, payload.discoverZone);
|
||||||
});
|
});
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
@Effect({ dispatch: false })
|
||||||
|
@ -45,7 +45,7 @@ export class Effects {
|
||||||
.ofType(ActionType.DiscoverHost)
|
.ofType(ActionType.DiscoverHost)
|
||||||
.map((action: DiscoverHost) => action.payload)
|
.map((action: DiscoverHost) => action.payload)
|
||||||
.do(payload => {
|
.do(payload => {
|
||||||
this.discoveryService.discoverHost(payload.probeID, payload.zone, payload.discoveryHost);
|
this.discoveryService.discoverHost(payload.probeID, payload.zone, payload.discoverHost);
|
||||||
});
|
});
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
@Effect({ dispatch: false })
|
||||||
|
@ -53,7 +53,7 @@ export class Effects {
|
||||||
.ofType(ActionType.DiscoverPort)
|
.ofType(ActionType.DiscoverPort)
|
||||||
.map((action: DiscoverPort) => action.payload)
|
.map((action: DiscoverPort) => action.payload)
|
||||||
.do(payload => {
|
.do(payload => {
|
||||||
this.discoveryService.discoverPort(payload.probeID, payload.host, payload.discoveryPort);
|
this.discoveryService.discoverPort(payload.probeID, payload.host, payload.discoverPort);
|
||||||
});
|
});
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
@Effect({ dispatch: false })
|
||||||
|
@ -61,6 +61,6 @@ export class Effects {
|
||||||
.ofType(ActionType.DiscoverService)
|
.ofType(ActionType.DiscoverService)
|
||||||
.map((action: DiscoverService) => action.payload)
|
.map((action: DiscoverService) => action.payload)
|
||||||
.do(payload => {
|
.do(payload => {
|
||||||
this.discoveryService.discoverService(payload.probeID, payload.port, payload.discoveryService);
|
this.discoveryService.discoverService(payload.probeID, payload.port, payload.discoverService);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,10 @@ export function reducer(state = initialState, action: Actions): State {
|
||||||
}
|
}
|
||||||
if (null === zone.hosts || undefined === zone.hosts) {
|
if (null === zone.hosts || undefined === zone.hosts) {
|
||||||
zone.hosts = new Map();
|
zone.hosts = new Map();
|
||||||
zone.hosts.set(host.ip, host);
|
zone.hosts.set(host.ip4, host);
|
||||||
} else {
|
} else {
|
||||||
if (zone.hosts.has(host.ip) === false) {
|
if (zone.hosts.has(host.ip4) === false) {
|
||||||
zone.hosts.set(host.ip, host);
|
zone.hosts.set(host.ip4, host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ export function reducer(state = initialState, action: Actions): State {
|
||||||
zone.hosts = new Map();
|
zone.hosts = new Map();
|
||||||
}
|
}
|
||||||
let host: Host = null;
|
let host: Host = null;
|
||||||
host = zone.hosts.get(port.host.ip);
|
host = zone.hosts.get(port.host.ip4);
|
||||||
|
|
||||||
if (host === undefined || host === null) {
|
if (host === undefined || host === null) {
|
||||||
host = port.host;
|
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);
|
zones.set(zone.network, zone);
|
||||||
|
|
||||||
const newZones: Map<string, Zone> = new Map();
|
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`);
|
// console.error(`Discovery.DiscoveredPort: Host[${service.port.host.ip}] is not exist`);
|
||||||
// }
|
// }
|
||||||
let host: Host = null;
|
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) {
|
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;
|
host = service.port.host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ export function reducer(state = initialState, action: Actions): State {
|
||||||
port.services.set(service.serviceName, service);
|
port.services.set(service.serviceName, service);
|
||||||
|
|
||||||
host.ports.set(service.port.portNumber, port);
|
host.ports.set(service.port.portNumber, port);
|
||||||
zone.hosts.set(host.ip, host);
|
zone.hosts.set(host.ip4, host);
|
||||||
zones.set(zone.network, zone);
|
zones.set(zone.network, zone);
|
||||||
|
|
||||||
const newZones: Map<string, Zone> = new Map();
|
const newZones: Map<string, Zone> = new Map();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user