summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2019-10-26 14:10:32 +0200
committerRuben Pollan <meskio@sindominio.net>2019-10-29 18:36:06 +0100
commit85d3e8ac43e2493b5de3cc195ee6ab3da6c67bae (patch)
treebbc53185e3c62e61477d644f621547756bff5861
parentd0cfd88d94f698c8916099b06f58495ccb92a0f6 (diff)
Add logger interface
And deprecate GetLastError
-rw-r--r--shapeshifter.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/shapeshifter.go b/shapeshifter.go
index 5387a6d..f201e07 100644
--- a/shapeshifter.go
+++ b/shapeshifter.go
@@ -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)
}