summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
}