Skip to content

Commit 3481b76

Browse files
committed
bug(live ips not working): improved ip catching
1 parent 8933f4d commit 3481b76

6 files changed

Lines changed: 20 additions & 10 deletions

File tree

dmon-web/src/components/layout/header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, createContext, useMemo } from 'react';
22

3-
import { Nav, Navbar, NavDropdown } from 'react-bootstrap';
3+
import { Nav, Navbar } from 'react-bootstrap';
44
import Autosuggest from 'react-autosuggest';
55

66
import './header.css';

dmon-web/src/containers/live/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useMemo, useContext, useEffect } from 'react';
22

3-
import { Breadcrumb, Container, Row } from 'react-bootstrap'
3+
import { Breadcrumb, Container, Row } from 'react-bootstrap';
44

55
import useLive from './useLive';
66
import context from './context';
@@ -48,7 +48,9 @@ export default ({ match: { params }, history }) => {
4848
...updateTransmissionPacket(prev, packet, stateKeys),
4949
}))
5050
},
51-
!!params.ip ? [params.ip] : ips,
51+
// this in a way is a "hack", the server will
52+
// return us everything if the ips array is empty
53+
!!params.ip ? [params.ip] : [],
5254
[transmissionPackets, params.id]
5355
);
5456

host-monitor/lib/bridge/live-socket-pool.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,26 @@ class LiveSocketPool {
1212
/**
1313
* registers a active units
1414
* @param {any} socketInstance
15+
* @param {any} ips
1516
* @param {any} cb
1617
*/
17-
register(socketInstance, cb) {
18-
this.active[socketInstance] = cb;
18+
register(socketInstance, ips, cb) {
19+
this.active[socketInstance] = {ips, cb};
1920
}
2021

2122
/**
2223
* writes to open socket
24+
* @param {*} ip
2325
* @param {*} request
2426
*/
25-
async writeSocket(request) {
26-
Object.values(this.active).forEach((cb) => {
27-
if (typeof cb === 'function') {
27+
async writeSocket(ip, request) {
28+
Object.values(this.active).forEach((props) => {
29+
if (props === undefined) {
30+
return;
31+
}
32+
33+
const {ips, cb} = props;
34+
if (ips.includes(ip) || ips.length === 0) {
2835
cb(request);
2936
}
3037
});

host-monitor/lib/rpc-handlers/transmit-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default async (request) => {
1414

1515
// writes to an open socket if found
1616
liveSocketPool.writeSocket(
17-
updatedRequest,
17+
request.IP, updatedRequest,
1818
);
1919

2020
const elasticResp = await ElasticClient.index(

host-monitor/lib/ws-handlers/live.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default async (socket) => {
77
socket.on('subscribeToLiveTransmission', async (ips) => {
88
liveSocketPool.register(
99
connectionInstance,
10+
ips,
1011
(data) => {
1112
socket.emit(
1213
'liveTransmission',

host-monitor/test/functional-grpc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const TRANSMIT_PACKETS = [{
3535
DeviceID: 'example_device',
3636

3737
Version: 'basic',
38-
IP: 'duh',
38+
IP: 'duh2',
3939

4040
InboundBandwith: 2,
4141
OutboundBandwith: 9,

0 commit comments

Comments
 (0)