From 65f8e2ac30ae7dd1932ad0744d622b6f34f97835 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Tue, 5 Jun 2018 10:50:57 +0300 Subject: [PATCH] Refactor ctxrw to wrappers --- proxy/server.go | 4 ++-- {proxy => wrappers}/ctxrwc.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename {proxy => wrappers}/ctxrwc.go (88%) diff --git a/proxy/server.go b/proxy/server.go index 8251c6c..14458a0 100644 --- a/proxy/server.go +++ b/proxy/server.go @@ -126,7 +126,7 @@ func (s *Server) getClientStream(ctx context.Context, cancel context.CancelFunc, wConn = newLogReadWriteCloser(wConn, s.logger, socketID, "client") wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor) - wConn = newCtxReadWriteCloser(ctx, cancel, wConn) + wConn = wrappers.NewCtxRWC(ctx, cancel, wConn) return wConn, dc, nil } @@ -146,7 +146,7 @@ func (s *Server) getTelegramStream(ctx context.Context, cancel context.CancelFun wConn = newLogReadWriteCloser(wConn, s.logger, socketID, "telegram") wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor) - wConn = newCtxReadWriteCloser(ctx, cancel, wConn) + wConn = wrappers.NewCtxRWC(ctx, cancel, wConn) return wConn, nil } diff --git a/proxy/ctxrwc.go b/wrappers/ctxrwc.go similarity index 88% rename from proxy/ctxrwc.go rename to wrappers/ctxrwc.go index e605ab3..452d2e3 100644 --- a/proxy/ctxrwc.go +++ b/wrappers/ctxrwc.go @@ -1,4 +1,4 @@ -package proxy +package wrappers import ( "context" @@ -48,7 +48,7 @@ func (c *CtxReadWriteCloser) Close() error { return c.conn.Close() } -func newCtxReadWriteCloser(ctx context.Context, cancel context.CancelFunc, conn io.ReadWriteCloser) io.ReadWriteCloser { +func NewCtxRWC(ctx context.Context, cancel context.CancelFunc, conn io.ReadWriteCloser) io.ReadWriteCloser { return &CtxReadWriteCloser{ conn: conn, ctx: ctx,