Bläddra i källkod

Use all wrappers

tags/0.9
9seconds 8 år sedan
förälder
incheckning
a27a8494a6
1 ändrade filer med 8 tillägg och 4 borttagningar
  1. 8
    4
      server/server.go

+ 8
- 4
server/server.go Visa fil

97
 	return uuid.NewV4().String()
97
 	return uuid.NewV4().String()
98
 }
98
 }
99
 
99
 
100
-func (s *Server) getClientStream(conn net.Conn, ctx context.Context, cancel context.CancelFunc, socketID string) (*CipherReadWriteCloser, int16, error) {
100
+func (s *Server) getClientStream(conn net.Conn, ctx context.Context, cancel context.CancelFunc, socketID string) (io.ReadWriteCloser, int16, error) {
101
 	frame, err := obfuscated2.ExtractFrame(conn)
101
 	frame, err := obfuscated2.ExtractFrame(conn)
102
 	if err != nil {
102
 	if err != nil {
103
 		return nil, 0, errors.Annotate(err, "Cannot create client stream")
103
 		return nil, 0, errors.Annotate(err, "Cannot create client stream")
108
 		return nil, 0, errors.Annotate(err, "Cannot create client stream")
108
 		return nil, 0, errors.Annotate(err, "Cannot create client stream")
109
 	}
109
 	}
110
 
110
 
111
-	wConn := newCipherReadWriteCloser(conn, obfs2)
111
+	wConn := newLogReadWriteCloser(conn, s.logger, socketID, "client")
112
+	wConn = newCipherReadWriteCloser(conn, obfs2)
113
+	wConn = newCtxReadWriteCloser(wConn, ctx, cancel)
112
 
114
 
113
 	return wConn, dc, nil
115
 	return wConn, dc, nil
114
 }
116
 }
115
 
117
 
116
-func (s *Server) getTelegramStream(dc int16, ctx context.Context, cancel context.CancelFunc, socketID string) (*CipherReadWriteCloser, error) {
118
+func (s *Server) getTelegramStream(dc int16, ctx context.Context, cancel context.CancelFunc, socketID string) (io.ReadWriteCloser, error) {
117
 	socket, err := dialToTelegram(dc)
119
 	socket, err := dialToTelegram(dc)
118
 	if err != nil {
120
 	if err != nil {
119
 		return nil, errors.Annotate(err, "Cannot dial")
121
 		return nil, errors.Annotate(err, "Cannot dial")
124
 		return nil, errors.Annotate(err, "Cannot write hadnshake frame")
126
 		return nil, errors.Annotate(err, "Cannot write hadnshake frame")
125
 	}
127
 	}
126
 
128
 
127
-	wConn := newCipherReadWriteCloser(socket, obfs2)
129
+	wConn := newLogReadWriteCloser(socket, s.logger, socketID, "telegram")
130
+	wConn = newCipherReadWriteCloser(wConn, obfs2)
131
+	wConn = newCtxReadWriteCloser(wConn, ctx, cancel)
128
 
132
 
129
 	return wConn, nil
133
 	return wConn, nil
130
 }
134
 }

Laddar…
Avbryt
Spara