Sfoglia il codice sorgente

Refactor ctxrw to wrappers

tags/0.9
9seconds 8 anni fa
parent
commit
65f8e2ac30
2 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 2
    2
      proxy/server.go
  2. 2
    2
      wrappers/ctxrwc.go

+ 2
- 2
proxy/server.go Vedi File

@@ -126,7 +126,7 @@ func (s *Server) getClientStream(ctx context.Context, cancel context.CancelFunc,
126 126
 
127 127
 	wConn = newLogReadWriteCloser(wConn, s.logger, socketID, "client")
128 128
 	wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor)
129
-	wConn = newCtxReadWriteCloser(ctx, cancel, wConn)
129
+	wConn = wrappers.NewCtxRWC(ctx, cancel, wConn)
130 130
 
131 131
 	return wConn, dc, nil
132 132
 }
@@ -146,7 +146,7 @@ func (s *Server) getTelegramStream(ctx context.Context, cancel context.CancelFun
146 146
 
147 147
 	wConn = newLogReadWriteCloser(wConn, s.logger, socketID, "telegram")
148 148
 	wConn = wrappers.NewStreamCipherRWC(wConn, obfs2.Encryptor, obfs2.Decryptor)
149
-	wConn = newCtxReadWriteCloser(ctx, cancel, wConn)
149
+	wConn = wrappers.NewCtxRWC(ctx, cancel, wConn)
150 150
 
151 151
 	return wConn, nil
152 152
 }

proxy/ctxrwc.go → wrappers/ctxrwc.go Vedi File

@@ -1,4 +1,4 @@
1
-package proxy
1
+package wrappers
2 2
 
3 3
 import (
4 4
 	"context"
@@ -48,7 +48,7 @@ func (c *CtxReadWriteCloser) Close() error {
48 48
 	return c.conn.Close()
49 49
 }
50 50
 
51
-func newCtxReadWriteCloser(ctx context.Context, cancel context.CancelFunc, conn io.ReadWriteCloser) io.ReadWriteCloser {
51
+func NewCtxRWC(ctx context.Context, cancel context.CancelFunc, conn io.ReadWriteCloser) io.ReadWriteCloser {
52 52
 	return &CtxReadWriteCloser{
53 53
 		conn:   conn,
54 54
 		ctx:    ctx,

Loading…
Annulla
Salva