Selaa lähdekoodia

Use all wrappers

tags/0.9
9seconds 8 vuotta sitten
vanhempi
commit
a27a8494a6
1 muutettua tiedostoa jossa 8 lisäystä ja 4 poistoa
  1. 8
    4
      server/server.go

+ 8
- 4
server/server.go Näytä tiedosto

@@ -97,7 +97,7 @@ func (s *Server) makeSocketID() string {
97 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 101
 	frame, err := obfuscated2.ExtractFrame(conn)
102 102
 	if err != nil {
103 103
 		return nil, 0, errors.Annotate(err, "Cannot create client stream")
@@ -108,12 +108,14 @@ func (s *Server) getClientStream(conn net.Conn, ctx context.Context, cancel cont
108 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 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 119
 	socket, err := dialToTelegram(dc)
118 120
 	if err != nil {
119 121
 		return nil, errors.Annotate(err, "Cannot dial")
@@ -124,7 +126,9 @@ func (s *Server) getTelegramStream(dc int16, ctx context.Context, cancel context
124 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 133
 	return wConn, nil
130 134
 }

Loading…
Peruuta
Tallenna