]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/rscript/rscript.cpp
Log errors from plugins to server log.
[stg.git] / projects / stargazer / plugins / other / rscript / rscript.cpp
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
20  */
21
22 /*
23  $Revision: 1.33 $
24  $Date: 2010/04/16 12:30:37 $
25  $Author: faust $
26 */
27
28 #include <sys/time.h>
29
30 #include <csignal>
31 #include <cassert>
32 #include <cstdlib>
33 #include <cerrno>
34 #include <cstring>
35 #include <algorithm>
36
37 #include "stg/common.h"
38 #include "stg/locker.h"
39 #include "stg/user_property.h"
40 #include "stg/plugin_creator.h"
41 #include "stg/logger.h"
42 #include "rscript.h"
43 #include "ur_functor.h"
44 #include "send_functor.h"
45
46 extern volatile const time_t stgTime;
47
48 #define RS_MAX_ROUTERS  (100)
49
50 //-----------------------------------------------------------------------------
51 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
53 PLUGIN_CREATOR<REMOTE_SCRIPT> rsc;
54 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
57 PLUGIN * GetPlugin()
58 {
59 return rsc.GetPlugin();
60 }
61 //-----------------------------------------------------------------------------
62 //-----------------------------------------------------------------------------
63 //-----------------------------------------------------------------------------
64 RS_USER & RS_USER::operator=(const RS_USER & rvalue)
65 {
66 lastSentTime = rvalue.lastSentTime;
67 user = rvalue.user;
68 routers = rvalue.routers;
69 shortPacketsCount = rvalue.shortPacketsCount;
70 return *this;
71 }
72 //-----------------------------------------------------------------------------
73 RS_SETTINGS::RS_SETTINGS()
74     : sendPeriod(0),
75       port(0),
76       errorStr(),
77       netRouters(),
78       userParams(),
79       password(),
80       subnetFile()
81 {
82 }
83 //-----------------------------------------------------------------------------
84 int RS_SETTINGS::ParseSettings(const MODULE_SETTINGS & s)
85 {
86 int p;
87 PARAM_VALUE pv;
88 vector<PARAM_VALUE>::const_iterator pvi;
89 netRouters.clear();
90 ///////////////////////////
91 pv.param = "Port";
92 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
93 if (pvi == s.moduleParams.end())
94     {
95     errorStr = "Parameter \'Port\' not found.";
96     printfd(__FILE__, "Parameter 'Port' not found\n");
97     return -1;
98     }
99 if (ParseIntInRange(pvi->value[0], 2, 65535, &p))
100     {
101     errorStr = "Cannot parse parameter \'Port\': " + errorStr;
102     printfd(__FILE__, "Cannot parse parameter 'Port'\n");
103     return -1;
104     }
105 port = p;
106 ///////////////////////////
107 pv.param = "SendPeriod";
108 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
109 if (pvi == s.moduleParams.end())
110     {
111     errorStr = "Parameter \'SendPeriod\' not found.";
112     printfd(__FILE__, "Parameter 'SendPeriod' not found\n");
113     return -1;
114     }
115
116 if (ParseIntInRange(pvi->value[0], 5, 600, &sendPeriod))
117     {
118     errorStr = "Cannot parse parameter \'SendPeriod\': " + errorStr;
119     printfd(__FILE__, "Cannot parse parameter 'SendPeriod'\n");
120     return -1;
121     }
122 ///////////////////////////
123 pv.param = "UserParams";
124 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
125 if (pvi == s.moduleParams.end())
126     {
127     errorStr = "Parameter \'UserParams\' not found.";
128     printfd(__FILE__, "Parameter 'UserParams' not found\n");
129     return -1;
130     }
131 userParams = pvi->value;
132 ///////////////////////////
133 pv.param = "Password";
134 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
135 if (pvi == s.moduleParams.end())
136     {
137     errorStr = "Parameter \'Password\' not found.";
138     printfd(__FILE__, "Parameter 'Password' not found\n");
139     return -1;
140     }
141 password = pvi->value[0];
142 ///////////////////////////
143 pv.param = "SubnetFile";
144 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
145 if (pvi == s.moduleParams.end())
146     {
147     errorStr = "Parameter \'SubnetFile\' not found.";
148     printfd(__FILE__, "Parameter 'SubnetFile' not found\n");
149     return -1;
150     }
151 subnetFile = pvi->value[0];
152
153 NRMapParser nrMapParser;
154
155 if (!nrMapParser.ReadFile(subnetFile))
156     {
157     netRouters = nrMapParser.GetMap();
158     }
159 else
160     {
161     GetStgLogger()("mod_rscript: error opening subnets file '%s'", subnetFile.c_str());
162     }
163
164 return 0;
165 }
166 //-----------------------------------------------------------------------------
167 //-----------------------------------------------------------------------------
168 //-----------------------------------------------------------------------------
169 REMOTE_SCRIPT::REMOTE_SCRIPT()
170     : ctx(),
171       afterChgIPNotifierList(),
172       authorizedUsers(),
173       errorStr(),
174       rsSettings(),
175       settings(),
176       sendPeriod(15),
177       halfPeriod(8),
178       nonstop(false),
179       isRunning(false),
180       users(NULL),
181       netRouters(),
182       thread(),
183       mutex(),
184       sock(0),
185       onAddUserNotifier(*this),
186       onDelUserNotifier(*this),
187       logger(GetPluginLogger(GetStgLogger(), "rscript"))
188 {
189 pthread_mutex_init(&mutex, NULL);
190 }
191 //-----------------------------------------------------------------------------
192 REMOTE_SCRIPT::~REMOTE_SCRIPT()
193 {
194 pthread_mutex_destroy(&mutex);
195 }
196 //-----------------------------------------------------------------------------
197 void * REMOTE_SCRIPT::Run(void * d)
198 {
199 sigset_t signalSet;
200 sigfillset(&signalSet);
201 pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
202
203 REMOTE_SCRIPT * rs = static_cast<REMOTE_SCRIPT *>(d);
204
205 rs->isRunning = true;
206
207 while (rs->nonstop)
208     {
209     rs->PeriodicSend();
210     sleep(2);
211     }
212
213 rs->isRunning = false;
214 return NULL;
215 }
216 //-----------------------------------------------------------------------------
217 int REMOTE_SCRIPT::ParseSettings()
218 {
219 int ret = rsSettings.ParseSettings(settings);
220 if (ret)
221     errorStr = rsSettings.GetStrError();
222
223 sendPeriod = rsSettings.GetSendPeriod();
224 halfPeriod = sendPeriod / 2;
225
226 return ret;
227 }
228 //-----------------------------------------------------------------------------
229 int REMOTE_SCRIPT::Start()
230 {
231 netRouters = rsSettings.GetSubnetsMap();
232
233 InitEncrypt(&ctx, rsSettings.GetPassword());
234
235 //onAddUserNotifier.SetRemoteScript(this);
236 //onDelUserNotifier.SetRemoteScript(this);
237
238 users->AddNotifierUserAdd(&onAddUserNotifier);
239 users->AddNotifierUserDel(&onDelUserNotifier);
240
241 nonstop = true;
242
243 if (GetUsers())
244     {
245     return -1;
246     }
247
248 if (PrepareNet())
249     {
250     return -1;
251     }
252
253 if (!isRunning)
254     {
255     if (pthread_create(&thread, NULL, Run, this))
256         {
257         errorStr = "Cannot create thread.";
258         logger("Cannot create thread.");
259         printfd(__FILE__, "Cannot create thread\n");
260         return -1;
261         }
262     }
263
264 errorStr = "";
265 return 0;
266 }
267 //-----------------------------------------------------------------------------
268 int REMOTE_SCRIPT::Stop()
269 {
270 if (!IsRunning())
271     return 0;
272
273 nonstop = false;
274
275 std::for_each(
276         authorizedUsers.begin(),
277         authorizedUsers.end(),
278         DisconnectUser(*this)
279         );
280
281 FinalizeNet();
282
283 if (isRunning)
284     {
285     //5 seconds to thread stops itself
286     for (int i = 0; i < 25 && isRunning; i++)
287         {
288         struct timespec ts = {0, 200000000};
289         nanosleep(&ts, NULL);
290         }
291     }
292
293 users->DelNotifierUserDel(&onDelUserNotifier);
294 users->DelNotifierUserAdd(&onAddUserNotifier);
295
296 if (isRunning)
297     {
298     logger("Cannot stop thread.");
299     return -1;
300     }
301
302 return 0;
303 }
304 //-----------------------------------------------------------------------------
305 int REMOTE_SCRIPT::Reload()
306 {
307 NRMapParser nrMapParser;
308
309 if (nrMapParser.ReadFile(rsSettings.GetMapFileName()))
310     {
311     errorStr = nrMapParser.GetErrorStr();
312     logger("Map file reading error: %s", errorStr.c_str());
313     return -1;
314     }
315
316     {
317     STG_LOCKER lock(&mutex, __FILE__, __LINE__);
318
319     printfd(__FILE__, "REMOTE_SCRIPT::Reload()\n");
320
321     netRouters = nrMapParser.GetMap();
322     }
323
324 std::for_each(authorizedUsers.begin(),
325               authorizedUsers.end(),
326               UpdateRouter(*this));
327
328 return 0;
329 }
330 //-----------------------------------------------------------------------------
331 bool REMOTE_SCRIPT::PrepareNet()
332 {
333 sock = socket(AF_INET, SOCK_DGRAM, 0);
334
335 if (sock < 0)
336     {
337     errorStr = "Cannot create socket.";
338     logger("Canot create a socket: %s", strerror(errno));
339     printfd(__FILE__, "Cannot create socket\n");
340     return true;
341     }
342
343 return false;
344 }
345 //-----------------------------------------------------------------------------
346 bool REMOTE_SCRIPT::FinalizeNet()
347 {
348 close(sock);
349 return false;
350 }
351 //-----------------------------------------------------------------------------
352 void REMOTE_SCRIPT::PeriodicSend()
353 {
354 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
355
356 map<uint32_t, RS_USER>::iterator it(authorizedUsers.begin());
357 while (it != authorizedUsers.end())
358     {
359     if (difftime(stgTime, it->second.lastSentTime) - (rand() % halfPeriod) > sendPeriod)
360     //if (stgTime - it->second.lastSentTime > sendPeriod)
361         {
362         Send(it->first, it->second);
363         }
364     ++it;
365     }
366 }
367 //-----------------------------------------------------------------------------
368 #ifdef NDEBUG
369 bool REMOTE_SCRIPT::PreparePacket(char * buf, size_t, uint32_t ip, RS_USER & rsu, bool forceDisconnect) const
370 #else
371 bool REMOTE_SCRIPT::PreparePacket(char * buf, size_t bufSize, uint32_t ip, RS_USER & rsu, bool forceDisconnect) const
372 #endif
373 {
374 RS_PACKET_HEADER packetHead;
375
376 memset(packetHead.padding, 0, sizeof(packetHead.padding));
377 strcpy((char*)packetHead.magic, RS_ID);
378 packetHead.protoVer[0] = '0';
379 packetHead.protoVer[1] = '2';
380 if (forceDisconnect)
381     {
382     packetHead.packetType = RS_DISCONNECT_PACKET;
383     }
384 else
385     {
386     if (rsu.shortPacketsCount % MAX_SHORT_PCKT == 0)
387         {
388         //SendLong
389         packetHead.packetType = rsu.user->IsInetable() ? RS_CONNECT_PACKET : RS_DISCONNECT_PACKET;
390         }
391     else
392         {
393         //SendShort
394         packetHead.packetType = rsu.user->IsInetable() ? RS_ALIVE_PACKET : RS_DISCONNECT_PACKET;
395         }
396     }
397 rsu.shortPacketsCount++;
398 rsu.lastSentTime = stgTime;
399
400 packetHead.ip = htonl(ip);
401 packetHead.id = htonl(rsu.user->GetID());
402 strncpy((char*)packetHead.login, rsu.user->GetLogin().c_str(), RS_LOGIN_LEN);
403 packetHead.login[RS_LOGIN_LEN - 1] = 0;
404
405 memcpy(buf, &packetHead, sizeof(packetHead));
406
407 if (packetHead.packetType == RS_ALIVE_PACKET)
408     {
409     return false;
410     }
411
412 RS_PACKET_TAIL packetTail;
413
414 memset(packetTail.padding, 0, sizeof(packetTail.padding));
415 strcpy((char*)packetTail.magic, RS_ID);
416 vector<string>::const_iterator it;
417 std::string params;
418 for(it = rsSettings.GetUserParams().begin();
419     it != rsSettings.GetUserParams().end();
420     ++it)
421     {
422     std::string parameter(GetUserParam(rsu.user, *it));
423     if (params.length() + parameter.length() > RS_PARAMS_LEN - 1)
424         break;
425     params += parameter + " ";
426     }
427 strncpy((char *)packetTail.params, params.c_str(), RS_PARAMS_LEN);
428 packetTail.params[RS_PARAMS_LEN - 1] = 0;
429
430 assert(sizeof(packetHead) + sizeof(packetTail) <= bufSize && "Insufficient buffer space");
431
432 Encrypt(&ctx, buf + sizeof(packetHead), (char *)&packetTail, sizeof(packetTail) / 8);
433
434 return false;
435 }
436 //-----------------------------------------------------------------------------
437 bool REMOTE_SCRIPT::Send(uint32_t ip, RS_USER & rsu, bool forceDisconnect) const
438 {
439 char buffer[RS_MAX_PACKET_LEN];
440
441 memset(buffer, 0, sizeof(buffer));
442
443 if (PreparePacket(buffer, sizeof(buffer), ip, rsu, forceDisconnect))
444     {
445     printfd(__FILE__, "REMOTE_SCRIPT::Send() - Invalid packet length!\n");
446     return true;
447     }
448
449 std::for_each(
450         rsu.routers.begin(),
451         rsu.routers.end(),
452         PacketSender(sock, buffer, sizeof(buffer), htons(rsSettings.GetPort()))
453         );
454
455 return false;
456 }
457 //-----------------------------------------------------------------------------
458 bool REMOTE_SCRIPT::SendDirect(uint32_t ip, RS_USER & rsu, uint32_t routerIP, bool forceDisconnect) const
459 {
460 char buffer[RS_MAX_PACKET_LEN];
461
462 if (PreparePacket(buffer, sizeof(buffer), ip, rsu, forceDisconnect))
463     {
464     printfd(__FILE__, "REMOTE_SCRIPT::SendDirect() - Invalid packet length!\n");
465     return true;
466     }
467
468 struct sockaddr_in sendAddr;
469
470 sendAddr.sin_family = AF_INET;
471 sendAddr.sin_port = htons(rsSettings.GetPort());
472 sendAddr.sin_addr.s_addr = routerIP;
473
474 int res = sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&sendAddr, sizeof(sendAddr));
475
476 if (res < 0)
477     logger("sendto error: %s", strerror(errno));
478
479 return (res != sizeof(buffer));
480 }
481 //-----------------------------------------------------------------------------
482 bool REMOTE_SCRIPT::GetUsers()
483 {
484 USER_PTR u;
485
486 int h = users->OpenSearch();
487 assert(h && "USERS::OpenSearch is always correct");
488
489 while (!users->SearchNext(h, &u))
490     {
491     SetUserNotifier(u);
492     }
493
494 users->CloseSearch(h);
495 return false;
496 }
497 //-----------------------------------------------------------------------------
498 void REMOTE_SCRIPT::ChangedIP(USER_PTR u, uint32_t oldIP, uint32_t newIP)
499 {
500 /*
501  * When ip changes process looks like:
502  * old => 0, 0 => new
503  *
504  */
505 if (newIP)
506     {
507     RS_USER rsu(IP2Routers(newIP), u);
508     Send(newIP, rsu);
509
510     STG_LOCKER lock(&mutex, __FILE__, __LINE__);
511     authorizedUsers[newIP] = rsu;
512     }
513 else
514     {
515     STG_LOCKER lock(&mutex, __FILE__, __LINE__);
516     const map<uint32_t, RS_USER>::iterator it(
517             authorizedUsers.find(oldIP)
518             );
519     if (it != authorizedUsers.end())
520         {
521         Send(oldIP, it->second, true);
522         authorizedUsers.erase(it);
523         }
524     }
525 }
526 //-----------------------------------------------------------------------------
527 std::vector<uint32_t> REMOTE_SCRIPT::IP2Routers(uint32_t ip)
528 {
529 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
530 for (size_t i = 0; i < netRouters.size(); ++i)
531     {
532     if ((ip & netRouters[i].subnetMask) == (netRouters[i].subnetIP & netRouters[i].subnetMask))
533         {
534         return netRouters[i].routers;
535         }
536     }
537 return std::vector<uint32_t>();
538 }
539 //-----------------------------------------------------------------------------
540 string REMOTE_SCRIPT::GetUserParam(USER_PTR u, const string & paramName) const
541 {
542 string value = "";
543 if (strcasecmp(paramName.c_str(), "cash") == 0)
544     strprintf(&value, "%f", u->GetProperty().cash.Get());
545 else
546 if (strcasecmp(paramName.c_str(), "freeMb") == 0)
547     strprintf(&value, "%f", u->GetProperty().freeMb.Get());
548 else
549 if (strcasecmp(paramName.c_str(), "passive") == 0)
550     strprintf(&value, "%d", u->GetProperty().passive.Get());
551 else
552 if (strcasecmp(paramName.c_str(), "disabled") == 0)
553     strprintf(&value, "%d", u->GetProperty().disabled.Get());
554 else
555 if (strcasecmp(paramName.c_str(), "alwaysOnline") == 0)
556     strprintf(&value, "%d", u->GetProperty().alwaysOnline.Get());
557 else
558 if (strcasecmp(paramName.c_str(), "tariffName") == 0 ||
559     strcasecmp(paramName.c_str(), "tariff") == 0)
560     value = "\"" + u->GetProperty().tariffName.Get() + "\"";
561 else
562 if (strcasecmp(paramName.c_str(), "nextTariff") == 0)
563     value = "\"" + u->GetProperty().nextTariff.Get() + "\"";
564 else
565 if (strcasecmp(paramName.c_str(), "address") == 0)
566     value = "\"" + u->GetProperty().address.Get() + "\"";
567 else
568 if (strcasecmp(paramName.c_str(), "note") == 0)
569     value = "\"" + u->GetProperty().note.Get() + "\"";
570 else
571 if (strcasecmp(paramName.c_str(), "group") == 0)
572     value = "\"" + u->GetProperty().group.Get() + "\"";
573 else
574 if (strcasecmp(paramName.c_str(), "email") == 0)
575     value = "\"" + u->GetProperty().email.Get() + "\"";
576 else
577 if (strcasecmp(paramName.c_str(), "realName") == 0)
578     value = "\"" + u->GetProperty().realName.Get() + "\"";
579 else
580 if (strcasecmp(paramName.c_str(), "credit") == 0)
581     strprintf(&value, "%f", u->GetProperty().credit.Get());
582 else
583 if (strcasecmp(paramName.c_str(), "userdata0") == 0)
584     value = "\"" + u->GetProperty().userdata0.Get() + "\"";
585 else
586 if (strcasecmp(paramName.c_str(), "userdata1") == 0)
587     value = "\"" + u->GetProperty().userdata1.Get() + "\"";
588 else
589 if (strcasecmp(paramName.c_str(), "userdata2") == 0)
590     value = "\"" + u->GetProperty().userdata2.Get() + "\"";
591 else
592 if (strcasecmp(paramName.c_str(), "userdata3") == 0)
593     value = "\"" + u->GetProperty().userdata3.Get() + "\"";
594 else
595 if (strcasecmp(paramName.c_str(), "userdata4") == 0)
596     value = "\"" + u->GetProperty().userdata4.Get() + "\"";
597 else
598 if (strcasecmp(paramName.c_str(), "userdata5") == 0)
599     value = "\"" + u->GetProperty().userdata5.Get() + "\"";
600 else
601 if (strcasecmp(paramName.c_str(), "userdata6") == 0)
602     value = "\"" + u->GetProperty().userdata6.Get() + "\"";
603 else
604 if (strcasecmp(paramName.c_str(), "userdata7") == 0)
605     value = "\"" + u->GetProperty().userdata7.Get() + "\"";
606 else
607 if (strcasecmp(paramName.c_str(), "userdata8") == 0)
608     value = "\"" + u->GetProperty().userdata8.Get() + "\"";
609 else
610 if (strcasecmp(paramName.c_str(), "userdata9") == 0)
611     value = "\"" + u->GetProperty().userdata9.Get() + "\"";
612 else
613 if (strcasecmp(paramName.c_str(), "enabledDirs") == 0)
614     value = u->GetEnabledDirs();
615 else
616     printfd(__FILE__, "Unknown value name: %s\n", paramName.c_str());
617 return value;
618 }
619 //-----------------------------------------------------------------------------
620 void REMOTE_SCRIPT::SetUserNotifier(USER_PTR u)
621 {
622 RS_CHG_AFTER_NOTIFIER<uint32_t> afterChgIPNotifier(*this, u);
623
624 afterChgIPNotifierList.push_front(afterChgIPNotifier);
625
626 u->AddCurrIPAfterNotifier(&(*afterChgIPNotifierList.begin()));
627 }
628 //-----------------------------------------------------------------------------
629 void REMOTE_SCRIPT::UnSetUserNotifier(USER_PTR u)
630 {
631 list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator  ipAIter;
632 std::list<list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator> toErase;
633
634 for (ipAIter = afterChgIPNotifierList.begin(); ipAIter != afterChgIPNotifierList.end(); ++ipAIter)
635     {
636     if (ipAIter->GetUser() == u)
637         {
638         u->DelCurrIPAfterNotifier(&(*ipAIter));
639         toErase.push_back(ipAIter);
640         }
641     }
642
643 std::list<list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator>::iterator eIter;
644
645 for (eIter = toErase.begin(); eIter != toErase.end(); ++eIter)
646     {
647     afterChgIPNotifierList.erase(*eIter);
648     }
649 }
650 //-----------------------------------------------------------------------------
651 template <typename varParamType>
652 void RS_CHG_AFTER_NOTIFIER<varParamType>::Notify(const varParamType & oldValue, const varParamType & newValue)
653 {
654 rs.ChangedIP(user, oldValue, newValue);
655 }
656 //-----------------------------------------------------------------------------
657 void REMOTE_SCRIPT::InitEncrypt(BLOWFISH_CTX * ctx, const string & password) const
658 {
659 unsigned char keyL[PASSWD_LEN];  // Пароль для шифровки
660 memset(keyL, 0, PASSWD_LEN);
661 strncpy((char *)keyL, password.c_str(), PASSWD_LEN);
662 Blowfish_Init(ctx, keyL, PASSWD_LEN);
663 }
664 //-----------------------------------------------------------------------------
665 void REMOTE_SCRIPT::Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, size_t len8) const
666 {
667 if (dst != src)
668     memcpy(dst, src, len8 * 8);
669 for (size_t i = 0; i < len8; ++i)
670     Blowfish_Encrypt(ctx, (uint32_t *)(dst + i * 8), (uint32_t *)(dst + i * 8 + 4));
671 }
672 //-----------------------------------------------------------------------------