@@ -158,7 +158,8 @@ func (c *Client) ParseTcpReq() (*protocol.SSProtocol, error) {
158
158
return ssProtocol , nil
159
159
}
160
160
161
- func (c * Client ) ParseReqData (buf []byte ) ([]byte , error ) {
161
+ //ParseReqData parse request data
162
+ func (c * Client ) ParseReqData (buf []byte ) (out []byte , err error ) {
162
163
const (
163
164
dataLenLen = 2
164
165
hmacSha1Len = 10
@@ -172,7 +173,7 @@ func (c *Client) ParseReqData(buf []byte) ([]byte, error) {
172
173
buf = make ([]byte , headerLen )
173
174
}
174
175
175
- if _ , err : = io .ReadFull (c , buf [:headerLen ]); err != nil {
176
+ if _ , err = io .ReadFull (c , buf [:headerLen ]); err != nil {
176
177
return nil , err
177
178
}
178
179
dataLen := binary .BigEndian .Uint16 (buf [:dataLenLen ])
@@ -183,6 +184,14 @@ func (c *Client) ParseReqData(buf []byte) ([]byte, error) {
183
184
buf = make ([]byte , dataLen )
184
185
}
185
186
187
+ defer func () {
188
+ if r := recover (); r != nil {
189
+ glog .Infof ("bufferlen (%v) datalen(%v) headerlen(%v) dataend(%v)\r \n " , len (buf ), dataLen , headerLen , dataEndIdx )
190
+ glog .Errorf ("panic information %v\r \n " , r )
191
+ err = fmt .Errorf ("panic in parse data" )
192
+ }
193
+ }()
194
+
186
195
if _ , err := io .ReadFull (c , buf [headerLen :dataEndIdx ]); err != nil {
187
196
return nil , err
188
197
}
0 commit comments