mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Refactor ctxrw to wrappers
This commit is contained in:
+2
-2
@@ -126,7 +126,7 @@ func (s *Server) getClientStream(ctx context.Context, cancel context.CancelFunc,
|
|||||||
|
|
||||||
wConn = newLogReadWriteCloser(wConn, s.logger, socketID, "client")
|
wConn = newLogReadWriteCloser(wConn, s.logger, socketID, "client")
|
||||||
wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor)
|
wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor)
|
||||||
wConn = newCtxReadWriteCloser(ctx, cancel, wConn)
|
wConn = wrappers.NewCtxRWC(ctx, cancel, wConn)
|
||||||
|
|
||||||
return wConn, dc, nil
|
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 = newLogReadWriteCloser(wConn, s.logger, socketID, "telegram")
|
||||||
wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor)
|
wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor)
|
||||||
wConn = newCtxReadWriteCloser(ctx, cancel, wConn)
|
wConn = wrappers.NewCtxRWC(ctx, cancel, wConn)
|
||||||
|
|
||||||
return wConn, nil
|
return wConn, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package proxy
|
package wrappers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -48,7 +48,7 @@ func (c *CtxReadWriteCloser) Close() error {
|
|||||||
return c.conn.Close()
|
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{
|
return &CtxReadWriteCloser{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
Reference in New Issue
Block a user