réplica de
https://github.com/therootcompany/telebit.git
synced 2025-07-01 18:06:35 +00:00
- added support for context passing between the various functions - support for withCancel, allowing administrative canceling, and a clean up of Go Routines. - generic listener now supports a single port for both encrypted and clear text protocols. - employee the buffered wedge connection for peaking into the protocol - implementation of the oneListener. - when TLS, leveraged the NewListener which uses oneListener as n inner lister. - once the stream is decrypted, or if it was already clear text it is passed to handleStream which performs application detection.
35 líneas
520 B
Go
35 líneas
520 B
Go
package genericlistener
|
|
|
|
import (
|
|
"io"
|
|
"net"
|
|
)
|
|
|
|
type oneConnListener struct {
|
|
conn net.Conn
|
|
}
|
|
|
|
func (l *oneConnListener) Accept() (c net.Conn, err error) {
|
|
c = l.conn
|
|
|
|
if c == nil {
|
|
err = io.EOF
|
|
loginfo.Println("Accept")
|
|
return
|
|
}
|
|
err = nil
|
|
l.conn = nil
|
|
loginfo.Println("Accept", c.LocalAddr().String(), c.RemoteAddr().String())
|
|
return
|
|
}
|
|
|
|
func (l *oneConnListener) Close() error {
|
|
loginfo.Println("close")
|
|
return nil
|
|
}
|
|
|
|
func (l *oneConnListener) Addr() net.Addr {
|
|
loginfo.Println("addr")
|
|
return nil
|
|
}
|