Skip to content
Snippets Groups Projects
Unverified Commit 85d3e8ac authored by meskio's avatar meskio :tent:
Browse files

Add logger interface

And deprecate GetLastError
parent d0cfd88d
Branches
No related tags found
No related merge requests found
......@@ -13,11 +13,16 @@ import (
"golang.org/x/net/proxy"
)
type Logger interface {
Log(msg string)
}
type ShapeShifter struct {
Cert string
IatMode int
Target string // remote ip:port obfs4 server
SocksAddr string // -proxylistenaddr in shapeshifter-dispatcher
Logger Logger
ln net.Listener
errChan chan error
}
......@@ -54,13 +59,6 @@ func (ss *ShapeShifter) GetErrorChannel() chan error {
return ss.errChan
}
func (ss *ShapeShifter) GetLastError() error {
if ss.errChan == nil {
ss.errChan = make(chan error, 2)
}
return <-ss.errChan
}
func (ss ShapeShifter) clientAcceptLoop() error {
for {
conn, err := ss.ln.Accept()
......@@ -147,6 +145,11 @@ func (ss *ShapeShifter) checkOptions() error {
}
func (ss *ShapeShifter) sendError(format string, a ...interface{}) {
if ss.Logger != nil {
ss.Logger.Log(fmt.Sprintf(format, a...))
return
}
if ss.errChan == nil {
ss.errChan = make(chan error, 2)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment