mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Need to close connections correctly
This commit is contained in:
parent
23e19b009c
commit
0ee7f75a22
1 changed files with 4 additions and 2 deletions
6
relay.go
6
relay.go
|
@ -114,8 +114,6 @@ func (r *Relay) listener(id int) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Relay) clientCommuncation(id int, connection net.Conn) {
|
func (r *Relay) clientCommuncation(id int, connection net.Conn) {
|
||||||
defer connection.Close()
|
|
||||||
|
|
||||||
logger := log.WithFields(log.Fields{
|
logger := log.WithFields(log.Fields{
|
||||||
"id": id,
|
"id": id,
|
||||||
"ip": connection.RemoteAddr().String(),
|
"ip": connection.RemoteAddr().String(),
|
||||||
|
@ -171,6 +169,10 @@ func (r *Relay) clientCommuncation(id int, connection net.Conn) {
|
||||||
Pipe(con1, con2)
|
Pipe(con1, con2)
|
||||||
logger.Debug("done piping")
|
logger.Debug("done piping")
|
||||||
r.connections.Lock()
|
r.connections.Lock()
|
||||||
|
// close connections
|
||||||
|
r.connections.sender[key].Close()
|
||||||
|
r.connections.receiver[key].Close()
|
||||||
|
// delete connctions
|
||||||
delete(r.connections.sender, key)
|
delete(r.connections.sender, key)
|
||||||
delete(r.connections.receiver, key)
|
delete(r.connections.receiver, key)
|
||||||
delete(r.connections.metadata, key)
|
delete(r.connections.metadata, key)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue