mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 15:53:23 +02:00
fix bug on port forwarding feature (#629)
* fix bug on port forwarding feature Signed-off-by: Denis barbaron <denis.barbaron@orange.com> * fix lint error Signed-off-by: Denis barbaron <denis.barbaron@orange.com> Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
This commit is contained in:
@@ -112,7 +112,7 @@ module.exports = syrup.serial()
|
||||
}
|
||||
|
||||
plugin.reset = function() {
|
||||
manager.removeAll()
|
||||
manager.removeAll(manager)
|
||||
}
|
||||
|
||||
group.on('leave', plugin.reset)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Copyright © 2023 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
|
||||
**/
|
||||
|
||||
var util = require('util')
|
||||
var events = require('events')
|
||||
var net = require('net')
|
||||
@@ -76,7 +80,6 @@ function ForwardHandler(conn, options) {
|
||||
|
||||
function packetListener(id, packet) {
|
||||
var dest = destHandlersById[id]
|
||||
|
||||
if (packet) {
|
||||
if (!dest) {
|
||||
// Let's create a new connection
|
||||
@@ -132,6 +135,13 @@ function ForwardManager() {
|
||||
this.remove(id)
|
||||
}
|
||||
|
||||
for(const handlerId in handlersById) {
|
||||
if (handlersById[handlerId].options.devicePort === options.devicePort) {
|
||||
this.remove(handlerId)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var handler = new ForwardHandler(conn, options)
|
||||
handler.on('end', endListener.bind(this))
|
||||
|
||||
@@ -145,11 +155,15 @@ function ForwardManager() {
|
||||
if (handler) {
|
||||
handler.end()
|
||||
}
|
||||
delete handlersById[id]
|
||||
this.emit('remove', id)
|
||||
}
|
||||
|
||||
this.removeAll = function() {
|
||||
this.removeAll = function(manager) {
|
||||
Object.keys(handlersById).forEach(function(id) {
|
||||
handlersById[id].end()
|
||||
delete handlersById[id]
|
||||
manager.emit('remove', id)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user