log some message
This commit is contained in:
parent
c385a6b1ea
commit
afc125cc1c
@ -22,6 +22,7 @@ func (c *Connection) Read(p []byte) (int, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return 0, c.Close()
|
return 0, c.Close()
|
||||||
}
|
}
|
||||||
|
c.logger.Trace("dataframe received: ", df)
|
||||||
return df.Read(p)
|
return df.Read(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,11 +43,13 @@ func (c *Connection) Write(p []byte) (int, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
c.logger.Trace("dataframe send: ", df)
|
||||||
c.TX <- df
|
c.TX <- df
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Connection) Close() error {
|
func (c *Connection) Close() error {
|
||||||
|
defer c.logger.Tracef("connection closed")
|
||||||
var lock sync.Mutex
|
var lock sync.Mutex
|
||||||
defer close(c.TX)
|
defer close(c.TX)
|
||||||
if !c.closed {
|
if !c.closed {
|
||||||
|
@ -34,18 +34,22 @@ func (m *Manager) SetLogger(logger Logger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Run() {
|
func (m *Manager) Run() {
|
||||||
|
m.logger.Debug("manager run")
|
||||||
onReceiveQueue := make(chan bool)
|
onReceiveQueue := make(chan bool)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-m.closed:
|
case <-m.closed:
|
||||||
return
|
return
|
||||||
case df := <-m.incoming:
|
case df := <-m.incoming:
|
||||||
|
m.logger.Trace("dataframe->tunnel: ", df)
|
||||||
go df.Encode(m.Tunnel)
|
go df.Encode(m.Tunnel)
|
||||||
case connection := <-m.newConnection:
|
case connection := <-m.newConnection:
|
||||||
m.Connections[connection.ID] = connection
|
m.Connections[connection.ID] = connection
|
||||||
|
m.logger.Tracef("connection '%s' registered", connection.ID)
|
||||||
case connection := <-m.delConnection:
|
case connection := <-m.delConnection:
|
||||||
connection.Close()
|
connection.Close()
|
||||||
delete(m.Connections, connection.ID)
|
delete(m.Connections, connection.ID)
|
||||||
|
m.logger.Tracef("connection '%s' unregistered", connection.ID)
|
||||||
case onReceiveQueue <- true:
|
case onReceiveQueue <- true:
|
||||||
go m.onReceive(onReceiveQueue)
|
go m.onReceive(onReceiveQueue)
|
||||||
}
|
}
|
||||||
@ -58,6 +62,8 @@ func (m *Manager) onReceive(ch chan bool) {
|
|||||||
if err := df.Decode(m.Tunnel); err != nil {
|
if err := df.Decode(m.Tunnel); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
m.logger.Trace("dataframe<-tunnel: ", df)
|
||||||
|
|
||||||
switch df.Type {
|
switch df.Type {
|
||||||
case TypeRequest:
|
case TypeRequest:
|
||||||
m.accept <- df
|
m.accept <- df
|
||||||
|
Reference in New Issue
Block a user