@@ -75,7 +75,7 @@ var IsRequestTokenAgain bool = false
7575var TTI_i = 30
7676
7777func GmcTokenLogin () (g GMCLogin , err error ) {
78- if PathExists ("deviceInfo.toml" ){
78+ if PathExists ("deviceInfo.toml" ) {
7979 _ , err = toml .DecodeFile ("deviceInfo.toml" , & GTL )
8080 return * GTL , err
8181 } else {
@@ -104,7 +104,7 @@ func (l *Logger) Error(format string, args ...any) {
104104 log .Errorf (format , args )
105105}
106106func (l * Logger ) Debug (format string , args ... any ) {
107- log .Debugf (format , args )
107+ log .Debug (format , args )
108108}
109109func (l * Logger ) Dump (dumped []byte , format string , args ... any ) {
110110}
@@ -204,6 +204,7 @@ func SetRelogin(cli *client.QQClient, retryInterval int, retryCount int) {
204204
205205// ReleaseClient 断开连接并释放资源
206206func ReleaseClient (cli * client.QQClient ) {
207+ DestoryInstance (uint (SR .Uin ), SR .Key )
207208 cli .Release ()
208209 Clients .Delete (cli .Uin ) // 必须先删Clients,影响IsClientExist
209210 LoginTokens .Delete (cli .Uin )
@@ -265,7 +266,9 @@ func Sign(seq uint64, uin string, cmd string, qua string, buff []byte) (sign []b
265266 token , _ = hex .DecodeString (gjson .GetBytes (response , "data.token" ).String ())
266267
267268 json .Unmarshal (response , & RSR )
268- log .Debug (RSR .Data .RequestCallback [0 ], RSR .Data .RequestCallback [1 ])
269+ if len (RSR .Data .RequestCallback ) > 1 {
270+ log .Warn (RSR .Data .RequestCallback [0 ], RSR .Data .RequestCallback [1 ])
271+ }
269272 return sign , extra , token , nil
270273}
271274
@@ -282,17 +285,19 @@ func RegisterSign(uin uint64, androidId []byte, guid []byte, Qimei36 string, sig
282285 // http://your.host:port/register?uin=[QQ]&android_id=[ANDROID_ID]&guid=[GUID]&qimei36=[QIMEI36]&key=[KEY]
283286 _ = os .WriteFile ("signRegisterInfo.toml" , []byte (fmt .Sprintf ("uin= %v \n androidId= \" %s\" \n guid= \" %s\" \n qimei36= \" %s\" \n key= \" %s\" " , uin , hex .EncodeToString (androidId ), hex .EncodeToString (guid ), Qimei36 , signServerAuth )), 0o644 )
284287
285- log .Debug (uin , hex .EncodeToString (androidId ), hex .EncodeToString (guid ), Qimei36 , signServerAuth )
286- log .Debug (fmt .Sprintf ("?uin=%v&android_id=%s&guid=%s&qimei36=%s&key=%s" , uin , hex .EncodeToString (androidId ), hex .EncodeToString (guid ), Qimei36 , signServerAuth ))
288+ log .Warn (uin , hex .EncodeToString (androidId ), hex .EncodeToString (guid ), Qimei36 , signServerAuth )
289+ log .Warn (fmt .Sprintf ("?uin=%v&android_id=%s&guid=%s&qimei36=%s&key=%s" , uin , hex .EncodeToString (androidId ), hex .EncodeToString (guid ), Qimei36 , signServerAuth ))
287290 response , err := download.Request {
288291 Method : http .MethodGet ,
289292 URL : signServer + "register" + fmt .Sprintf ("?uin=%v&android_id=%s&guid=%s&qimei36=%s&key=%s" , uin , hex .EncodeToString (androidId ), hex .EncodeToString (guid ), Qimei36 , signServerAuth ),
290293 }.Bytes ()
291294 if err != nil {
292295 log .Warnf ("初始化 Sign 失败\n " , err )
296+ time .Sleep (time .Second )
297+ RegisterSign (SR .Uin , []byte (SR .AndroidId ), []byte (SR .Guid ), SR .Qimei36 , signServerAuth )
293298 } else {
294299 log .Info ("初始化 Sign 成功" )
295- log .Debug (gjson .GetBytes (response , "msg" ).String ())
300+ log .Warn (gjson .GetBytes (response , "msg" ).String ())
296301 }
297302}
298303
@@ -308,10 +313,11 @@ func SubmitRequestCallback(uin uint64, cmd string, callbackId int, buffer []byte
308313 }.Bytes ()
309314 if err != nil {
310315 log .Warnf (cmd , " " , callbackId , "提交失败\n " , err )
316+ SubmitRequestCallback (uin , cmd , callbackId , buffer )
311317 } else {
312318 log .Info (cmd , " " , callbackId , "提交成功" )
313- log .Debug (string (response ))
314- log .Debug (gjson .GetBytes (response , "msg" ).String ())
319+ log .Warn (string (response ))
320+ log .Warn (gjson .GetBytes (response , "msg" ).String ())
315321 }
316322}
317323
@@ -331,10 +337,28 @@ func RequestToken(uin uint64) {
331337 IsRequestTokenAgain = true
332338 } else if strings .HasPrefix (gjson .GetBytes (response , "msg" ).String (), "QSign" ) {
333339 log .Warn ("QSign not initialized, unable to request_ Token, please submit the initialization package first." )
340+ RequestToken (uin )
334341 } else {
335342 log .Info ("请求 Token 成功" )
336- log .Debug (string (response ))
337- log .Debug (gjson .GetBytes (response , "msg" ).String ())
343+ log .Warn (string (response ))
344+ log .Warn (gjson .GetBytes (response , "msg" ).String ())
345+ }
346+ }
347+
348+ // http://host:port/destroy?uin=[QQ]&key=[key]
349+ func DestoryInstance (uin uint , key string ){
350+ signServer := GTL .SignServer
351+ if ! strings .HasSuffix (signServer , "/" ) {
352+ signServer += "/"
353+ }
354+ response , err := download.Request {
355+ Method : http .MethodGet ,
356+ URL : signServer + "destroy" + fmt .Sprintf ("?uin=%v&key=%s" , uin , key ),
357+ }.Bytes ()
358+ if err != nil {
359+ DestoryInstance (uin , key )
360+ } else {
361+ log .Warn (gjson .GetBytes (response , "msg" ).String ())
338362 }
339363}
340364
0 commit comments