mirror of
https://github.com/tuxdotrs/trok.git
synced 2025-07-06 20:06:34 +05:30
refactor: seperate bind conn
This commit is contained in:
@ -52,7 +52,6 @@ func (t *Trok) ControlConnHandler(conn net.Conn) {
|
|||||||
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
|
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
|
||||||
log.Warn().Msgf("connection timed out: %s", conn.RemoteAddr())
|
log.Warn().Msgf("connection timed out: %s", conn.RemoteAddr())
|
||||||
} else {
|
} else {
|
||||||
log.Logger.Info().Msgf("connection closed: %s", err)
|
|
||||||
log.Logger.Info().Msgf("connection closed: %s", conn.RemoteAddr())
|
log.Logger.Info().Msgf("connection closed: %s", conn.RemoteAddr())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -114,8 +113,7 @@ func (t *Trok) handleCMDACPT(conn net.Conn, m *lib.Message) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
go io.Copy(pc.conn, conn)
|
t.Bind(pc.conn, conn)
|
||||||
io.Copy(conn, pc.conn)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Trok) PublicConnHandler(ln net.Listener, uidChan chan<- string) {
|
func (t *Trok) PublicConnHandler(ln net.Listener, uidChan chan<- string) {
|
||||||
@ -141,3 +139,10 @@ func (t *Trok) PublicConnHandler(ln net.Listener, uidChan chan<- string) {
|
|||||||
uidChan <- id
|
uidChan <- id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Trok) Bind(src, dst net.Conn) {
|
||||||
|
defer src.Close()
|
||||||
|
defer dst.Close()
|
||||||
|
go io.Copy(src, dst)
|
||||||
|
io.Copy(dst, src)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user