Changeset 10628
- Timestamp:
- 03/12/15 21:07:18 (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-gbox-cards.c
r10625 r10628 377 377 memset(buf, 0, sizeof(buf)); 378 378 379 struct gbox_card *card; 379 380 cs_readlock(&gbox_cards_lock); 380 381 LL_ITER it = ll_iter_create(gbox_cards); 381 struct gbox_card *card;382 382 while((card = ll_iter_next(&it))) 383 383 { 384 384 //send to user only cards which matching CAID from account and lvl > 0 385 385 //do not send peer cards back 386 if(chk_ctab(gbox_get_caid(card->caprovid), &peer->my_user->account->ctab) && (card->lvl > 0) && (!card->origin_peer || card->origin_peer->gbox.id != peer->gbox.id)) 386 if(chk_ctab(gbox_get_caid(card->caprovid), &peer->my_user->account->ctab) && (card->lvl > 0) && 387 (!card->origin_peer || (card->origin_peer && card->origin_peer->gbox.id != peer->gbox.id))) 387 388 { 388 389 *(++ptr) = card->caprovid >> 24; -
trunk/module-gbox.c
r10626 r10628 234 234 { 235 235 if (!peer) { return -1; } 236 NULLFREE(peer->hostname); 236 237 237 peer->online = 0; 238 238 peer->ecm_idx = 0; 239 239 peer->next_hello = 0; 240 240 gbox_delete_cards(GBOX_DELETE_FROM_PEER, peer->gbox.id); 241 // peer->my_user = NULL;241 gbox_write_peer_onl(); 242 242 243 243 return 0; … … 304 304 if (cl->typ == 'c' && cl->gbox_peer_id == cli->gbox_peer_id && cl != cli) 305 305 { 306 cl->reader = NULL; 307 cl->gbox = NULL; 306 308 cs_log_dbg(D_READER, "disconnected double client %s",username(cl)); 307 309 cs_disconnect_client(cl); … … 476 478 { 477 479 peer->filtered_cards = gbox_count_peer_cards(peer->gbox.id); 478 if(!data[ 0xA])480 if(!data[10]) 479 481 { 480 cs_log("-> HelloS in %d packets from %s (%s:%d) V2.%02X with %d cards filtered to %d cards", (data[0x0B] & 0x0f)+1, cli->reader->label, cs_inet_ntoa(cli->ip), cli->reader->r_port, peer->gbox.minor_version, peer->total_cards, peer->filtered_cards); 482 memset(&tmpbuf[0], 0, 7); 483 if (data[11] == 0x80 && !memcmp(data+12,tmpbuf,7)) 484 { 485 cs_log("-> HelloL in %d packets from %s (%s:%d) V2.%02X with %d cards filtered to %d cards", (data[0x0B] & 0x0f)+1, cli->reader->label, cs_inet_ntoa(cli->ip), cli->reader->r_port, peer->gbox.minor_version, peer->total_cards, peer->filtered_cards); 486 peer->online = 1; 487 gbox_write_peer_onl(); 488 } 489 else 490 { cs_log("-> HelloS in %d packets from %s (%s:%d) V2.%02X with %d cards filtered to %d cards", (data[0x0B] & 0x0f)+1, cli->reader->label, cs_inet_ntoa(cli->ip), cli->reader->r_port, peer->gbox.minor_version, peer->total_cards, peer->filtered_cards); } 481 491 gbox_send_hello(cli, GBOX_STAT_HELLOR); 482 492 } … … 487 497 } 488 498 if(!peer->online) 489 { gbox_send_hello(cli, GBOX_STAT_HELLOS); } 490 peer->online = 1; 499 { 500 peer->online = 1; 501 gbox_send_hello(cli, GBOX_STAT_HELLOS); 502 gbox_write_peer_onl(); 503 } 491 504 cli->reader->tcp_connected = 2; //we have card 492 505 if(!peer->filtered_cards) 493 506 { cli->reader->card_status = NO_CARD; } 494 507 else 495 { cli->reader->card_status = CARD_INSERTED; } 496 497 peer->next_hello = 0; 498 gbox_write_cards_info(); 499 gbox_write_peer_onl(); 500 cli->last = time((time_t *)0); //hello is activity on proxy 508 { cli->reader->card_status = CARD_INSERTED; } 501 509 } 510 peer->next_hello = 0; 511 gbox_write_cards_info(); 512 cli->last = time((time_t *)0); //hello is activity on proxy 502 513 } 503 514 else { peer->next_hello++; } … … 1454 1465 { return -1; } 1455 1466 1467 struct s_reader *rdr = cli->reader; 1456 1468 struct gbox_peer *peer = cli->gbox; 1457 struct s_reader *rdr = cli->reader; 1469 1470 memset(peer, 0, sizeof(struct gbox_peer)); 1471 1472 peer->gbox.password = a2i(rdr->r_pwd, 4); 1473 cs_log_dbg(D_READER, "gbox peer password: %s:", rdr->r_pwd); 1474 1475 peer->gbox.id = gbox_convert_password_to_id(peer->gbox.password); 1476 if (get_gbox_proxy(peer->gbox.id) || peer->gbox.id == NO_GBOX_ID || peer->gbox.id == local_gbox.id) 1477 { 1478 cs_log("error, double/invalid gbox id: %04X", peer->gbox.id); 1479 return -1; 1480 } 1481 cs_lock_create(&peer->lock, "gbox_lock", 5000); 1482 1483 gbox_reinit_peer(peer); 1484 1485 cli->gbox_peer_id = peer->gbox.id; 1486 1487 cli->pfd = 0; 1488 cli->crypted = 1; 1458 1489 1459 1490 rdr->card_status = CARD_NEED_INIT; 1460 1491 rdr->tcp_connected = 0; 1461 1462 memset(peer, 0, sizeof(struct gbox_peer));1463 1464 peer->gbox.password = a2i(rdr->r_pwd, 4);1465 cs_log_dbg(D_READER, "gbox peer password: %s:", rdr->r_pwd);1466 1467 peer->gbox.id = gbox_convert_password_to_id(peer->gbox.password);1468 if (get_gbox_proxy(peer->gbox.id) || peer->gbox.id == NO_GBOX_ID || peer->gbox.id == local_gbox.id)1469 {1470 cs_log("error, double/invalid gbox id: %04X", peer->gbox.id);1471 return -1;1472 }1473 cli->gbox_peer_id = peer->gbox.id;1474 1475 cli->pfd = 0;1476 cli->crypted = 1;1477 1492 1478 1493 set_null_ip(&cli->ip); … … 1506 1521 cli->pfd = cli->udp_fd; 1507 1522 1508 cs_lock_create(&peer->lock, "gbox_lock", 5000);1509 1510 gbox_reinit_peer(peer);1511 1512 cli->reader->card_status = CARD_NEED_INIT;1513 1523 gbox_send_hello(cli, GBOX_STAT_HELLOL); 1514 1524 … … 1600 1610 void gbox_cleanup(struct s_client *cl) 1601 1611 { 1612 /* Commented because the remove doubled clients causes trouble 1613 NEEDFIX: How to cleanup when oscam ends 1602 1614 gbox_free_cardlist(); 1603 1615 if(cl && cl->gbox && cl->typ == 'p') 1604 1616 { gbox_send_peer_good_night(cl); } 1617 */ 1605 1618 } 1606 1619
Note:
See TracChangeset
for help on using the changeset viewer.