log some message

This commit is contained in:
Sense T 2022-09-09 13:31:49 +00:00
parent c385a6b1ea
commit afc125cc1c
2 changed files with 9 additions and 0 deletions

View File

@ -22,6 +22,7 @@ func (c *Connection) Read(p []byte) (int, error) {
if !ok {
return 0, c.Close()
}
c.logger.Trace("dataframe received: ", df)
return df.Read(p)
}
@ -42,11 +43,13 @@ func (c *Connection) Write(p []byte) (int, error) {
if err != nil {
return 0, err
}
c.logger.Trace("dataframe send: ", df)
c.TX <- df
return n, nil
}
func (c *Connection) Close() error {
defer c.logger.Tracef("connection closed")
var lock sync.Mutex
defer close(c.TX)
if !c.closed {

View File

@ -34,18 +34,22 @@ func (m *Manager) SetLogger(logger Logger) {
}
func (m *Manager) Run() {
m.logger.Debug("manager run")
onReceiveQueue := make(chan bool)
for {
select {
case <-m.closed:
return
case df := <-m.incoming:
m.logger.Trace("dataframe->tunnel: ", df)
go df.Encode(m.Tunnel)
case connection := <-m.newConnection:
m.Connections[connection.ID] = connection
m.logger.Tracef("connection '%s' registered", connection.ID)
case connection := <-m.delConnection:
connection.Close()
delete(m.Connections, connection.ID)
m.logger.Tracef("connection '%s' unregistered", connection.ID)
case onReceiveQueue <- true:
go m.onReceive(onReceiveQueue)
}
@ -58,6 +62,8 @@ func (m *Manager) onReceive(ch chan bool) {
if err := df.Decode(m.Tunnel); err != nil {
return
}
m.logger.Trace("dataframe<-tunnel: ", df)
switch df.Type {
case TypeRequest:
m.accept <- df