| 469 | } |
| 470 | |
| 471 | void reqauth(mclient &c, uint id, char *name) |
| 472 | { |
| 473 | if(ENET_TIME_DIFFERENCE(servtime, c.lastauth) < AUTH_THROTTLE) |
| 474 | return; |
| 475 | |
| 476 | c.lastauth = servtime; |
| 477 | |
| 478 | purgeauths(c); |
| 479 | |
| 480 | time_t t = time(NULL); |
| 481 | char *ct = ctime(&t); |
| 482 | if(ct) |
| 483 | { |
| 484 | char *newline = strchr(ct, '\n'); |
| 485 | if(newline) *newline = '\0'; |
| 486 | } |
| 487 | string ip; |
| 488 | if(enet_address_get_host_ip(&c.address, ip, sizeof(ip)) < 0) copystring(ip, "-"); |
| 489 | conoutf("%s: attempting \"%s\" as %u from %s", ct ? ct : "-", name, id, ip); |
| 490 | |
| 491 | userinfo *u = users.access(name); |
| 492 | if(!u) |
| 493 | { |
| 494 | outputf(c, "failauth %u\n", id); |
| 495 | return; |
| 496 | } |
| 497 | |
| 498 | if(c.authreqs.length() >= AUTH_LIMIT) |
| 499 | { |
| 500 | outputf(c, "failauth %u\n", c.authreqs[0].id); |
| 501 | // freechallenge(c.authreqs[0].answer); |
| 502 | c.authreqs.remove(0); |
| 503 | } |
| 504 | |
| 505 | authreq &a = c.authreqs.add(); |
| 506 | a.reqtime = servtime; |
| 507 | a.id = id; |
| 508 | // uint seed[3] = { (uint)starttime, (uint)servtime, randomMT() }; |
| 509 | static vector<char> buf; |
| 510 | buf.setsize(0); |
| 511 | // a.answer = genchallenge(u->pubkey, seed, sizeof(seed), buf); |
| 512 | |
| 513 | outputf(c, "chalauth %u %s\n", id, buf.getbuf()); |
| 514 | } |
| 515 | |
| 516 | void confauth(mclient &c, uint id, const char *val) |
| 517 | { |
no test coverage detected