Refactor cipherrwc to wrappers

This commit is contained in:
9seconds
2018-06-05 10:48:48 +03:00
parent f962d9c6b4
commit 4486fbb8f4
4 changed files with 62 additions and 78 deletions
+3 -2
View File
@@ -9,6 +9,7 @@ import (
"time"
"github.com/9seconds/mtg/obfuscated2"
"github.com/9seconds/mtg/wrappers"
"github.com/juju/errors"
uuid "github.com/satori/go.uuid"
"go.uber.org/zap"
@@ -124,7 +125,7 @@ func (s *Server) getClientStream(ctx context.Context, cancel context.CancelFunc,
}
wConn = newLogReadWriteCloser(wConn, s.logger, socketID, "client")
wConn = newCipherReadWriteCloser(wConn, obfs2)
wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor)
wConn = newCtxReadWriteCloser(ctx, cancel, wConn)
return wConn, dc, nil
@@ -144,7 +145,7 @@ func (s *Server) getTelegramStream(ctx context.Context, cancel context.CancelFun
}
wConn = newLogReadWriteCloser(wConn, s.logger, socketID, "telegram")
wConn = newCipherReadWriteCloser(wConn, obfs2)
wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor)
wConn = newCtxReadWriteCloser(ctx, cancel, wConn)
return wConn, nil