Changeset 11361
- Timestamp:
- 02/27/17 10:41:36 (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-gbox.c
r11360 r11361 33 33 34 34 static struct gbox_data local_gbox; 35 static uint8_t local_gbox_initialized = 0;35 static int8_t local_gbox_initialized = 0; 36 36 static uint8_t local_cards_initialized = 0; 37 37 static time_t last_stats_written; … … 121 121 } 122 122 if(txt_id == 0) 123 {fprintf(fhandle, "ATTACK ALERT FROM %04X %s - wrong local password - %s", rcvd_id, cs_inet_ntoa(cli->ip), tsbuf);}123 {fprintf(fhandle, "ATTACK ALERT FROM %04X %s - peer sends wrong local password - %s", rcvd_id, cs_inet_ntoa(cli->ip), tsbuf);} 124 124 if(txt_id == 1) 125 125 {fprintf(fhandle, "ATTACK ALERT FROM %04X %s - peer is ignored - %s", rcvd_id, cs_inet_ntoa(cli->ip), tsbuf);} 126 126 if(txt_id == 2) 127 {fprintf(fhandle, "ATTACK ALERT FROM %04X %s - unknown peer password - %s", rcvd_id, cs_inet_ntoa(cli->ip), tsbuf);}127 {fprintf(fhandle, "ATTACK ALERT FROM %04X %s - peer sends unknown peer password - %s", rcvd_id, cs_inet_ntoa(cli->ip), tsbuf);} 128 128 if(txt_id == 3) 129 129 {fprintf(fhandle, "ATTACK ALERT FROM %04X %s - authentification failed - %s", rcvd_id, cs_inet_ntoa(cli->ip), tsbuf);} … … 134 134 } 135 135 136 static void write_msg_ to_osd(struct s_client *cli, uint8_t msg_id, uint8_t txt_id, uint16_t misc)136 static void write_msg_info (struct s_client *cli, uint8_t msg_id, uint8_t txt_id, uint16_t misc) 137 137 { 138 138 if (msg_id == MSGID_GSMS && misc == 0x31) {return;} 139 char *fext= FILE_MSG_ OSD;140 char *fname = get_gbox_tmp_fname(fext); 139 char *fext= FILE_MSG_INFO; 140 char *fname = get_gbox_tmp_fname(fext); 141 141 if (file_exists(fname)) 142 142 { … … 190 190 peer->onlinestat = 1; 191 191 cs_log("comeONLINE: %s %s boxid: %04X v2.%02X cards:%d",cl->reader->device, cs_inet_ntoa(cl->ip),peer->gbox.id, peer->gbox.minor_version, peer->filtered_cards); 192 write_msg_ to_osd(cl, MSGID_COMEONLINE, 0, peer->filtered_cards);192 write_msg_info(cl, MSGID_COMEONLINE, 0, peer->filtered_cards); 193 193 } 194 194 } … … 200 200 peer->onlinestat = 0; 201 201 cs_log("goneOFFLINE: %s %s boxid: %04X",cl->reader->device, cs_inet_ntoa(cl->ip),peer->gbox.id); 202 write_msg_ to_osd(cl, MSGID_GONEOFFLINE, 0, 0);202 write_msg_info(cl, MSGID_GONEOFFLINE, 0, 0); 203 203 } 204 204 } … … 285 285 peer->online = online; 286 286 gbox_write_peer_onl(); 287 return 0; 288 } 289 290 static int8_t gbox_ reinit_peer(struct gbox_peer *peer)287 return 0; 288 } 289 290 static int8_t gbox_clear_peer(struct gbox_peer *peer) 291 291 { 292 292 if (!peer) { return -1; } … … 306 306 307 307 struct gbox_peer *peer = proxy->gbox; 308 gbox_ reinit_peer(peer);308 gbox_clear_peer(peer); 309 309 if (!proxy->reader) { return -1; } 310 310 proxy->reader->tcp_connected = 0; … … 699 699 { 700 700 cs_log("-> Good Night from %s %s",username(cli), cli->reader->device); 701 write_msg_ to_osd(cli, MSGID_GOODNIGHT, 0, 0);701 write_msg_info(cli, MSGID_GOODNIGHT, 0, 0); 702 702 gbox_reinit_proxy(cli); 703 703 } … … 840 840 { 841 841 write_attack_file(cli, 4, requesting_peer); 842 write_msg_ to_osd(cli, MSGID_ATTACK, 4, requesting_peer);842 write_msg_info(cli, MSGID_ATTACK, 4, requesting_peer); 843 843 cs_log("ECM from peer %04X blocked by config", requesting_peer); 844 844 return -1; … … 1017 1017 //msg goodbye is an indication from peer that requested ECM failed (not found/rejected...) 1018 1018 //TODO: implement on suitable place - rebroadcast ECM to other peers 1019 write_msg_ to_osd(proxy, MSGID_GOODBYE, 0, 0);1019 write_msg_info(proxy, MSGID_GOODBYE, 0, 0); 1020 1020 break; 1021 1021 case MSG_UNKNWN: 1022 1022 cs_log("-> MSG_UNKNWN 48F9 from %s %s", username(proxy), proxy->reader->device); 1023 write_msg_ to_osd(proxy, MSGID_UNKNOWNMSG, 0, 0);1023 write_msg_info(proxy, MSGID_UNKNOWNMSG, 0, 0); 1024 1024 break; 1025 1025 case MSG_GSMS: … … 1029 1029 gbox_send_gsms_ack(proxy); 1030 1030 write_gsms_msg(proxy, data +16, data[14], data[15]); 1031 write_msg_ to_osd(proxy, MSGID_GSMS, 0, data[14]); // Notification only, no message content1031 write_msg_info(proxy, MSGID_GSMS, 0, data[14]); 1032 1032 } 1033 1033 else {gsms_unavail();} … … 1196 1196 { 1197 1197 write_attack_file(cli, 1, peer_recvd_id); 1198 write_msg_ to_osd(cli, MSGID_ATTACK, 1, peer_recvd_id);1198 write_msg_info(cli, MSGID_ATTACK, 1, peer_recvd_id); 1199 1199 cs_log("Peer blocked by conf - ignoring gbox peer_id: %04X", peer_recvd_id); 1200 1200 return -1; … … 1203 1203 { 1204 1204 write_attack_file(cli, 2, peer_recvd_id); 1205 write_msg_ to_osd(cli, MSGID_ATTACK, 2, peer_recvd_id);1205 write_msg_info(cli, MSGID_ATTACK, 2, peer_recvd_id); 1206 1206 cs_log("peer: %04X - peerpass: %08X unknown -> check [reader] section", peer_recvd_id, peer_received_pw); 1207 1207 return -1; … … 1212 1212 { 1213 1213 write_attack_file(cli, 3, peer_recvd_id); 1214 write_msg_ to_osd(cli, MSGID_ATTACK, 3, peer_recvd_id);1214 write_msg_info(cli, MSGID_ATTACK, 3, peer_recvd_id); 1215 1215 cs_log ("Authentication failed. Check config ..."); 1216 1216 return -1; … … 1246 1246 else // error my passw 1247 1247 { 1248 cs_log("-> ATTACK ALERT from IP %s - wrong or missing local password", cs_inet_ntoa(cli->ip));1248 cs_log("-> ATTACK ALERT from IP %s - peer sends wrong local password", cs_inet_ntoa(cli->ip)); 1249 1249 cs_log_dbg(D_READER,"-> received data: %s", cs_hexdump(0, data, n, tmp, sizeof(tmp))); 1250 1250 write_attack_file(cli, 0, 0); 1251 write_msg_ to_osd(cli, MSGID_ATTACK, 0, 0);1251 write_msg_info(cli, MSGID_ATTACK, 0, 0); 1252 1252 return -1; 1253 1253 } … … 1258 1258 cs_log("IP change received - peer %04X. Previous IP = %s. Reconnecting...", cli->gbox_peer_id, cs_inet_ntoa(proxy->ip)); 1259 1259 gbox_reconnect_client(cli->gbox_peer_id); 1260 write_msg_ to_osd(cli, MSGID_IPCHANGE, 0, 0);1260 write_msg_info(cli, MSGID_IPCHANGE, 0, 0); 1261 1261 return -1; 1262 1262 } … … 1609 1609 1610 1610 //init my gbox with id, password and cards crc 1611 static void init_local_gbox(void) 1612 { 1611 static int8_t init_local_gbox(void) 1612 { 1613 int32_t i; 1613 1614 local_gbox.id = 0; 1614 1615 local_gbox.password = 0; … … 1616 1617 local_gbox.cpu_api = gbox_get_my_cpu_api(); 1617 1618 init_gbox_cards(); 1618 1619 if(cfg.gbox_password == 0) { return; } 1620 1619 1620 if(!cfg.gbox_port[0]) 1621 { 1622 cs_log("error, no/invalid port=%d configured in oscam.conf!", cfg.gbox_port[0] ? cfg.gbox_port[0] : 0); 1623 return -1; 1624 } 1625 if(!cfg.gbox_hostname || strlen(cfg.gbox_hostname) > 128) 1626 { 1627 cs_log("error, no/invalid hostname '%s' configured in oscam.conf!", 1628 cfg.gbox_hostname ? cfg.gbox_hostname : ""); 1629 return -1; 1630 } 1631 if(!cfg.gbox_password ) 1632 { 1633 cs_log("error, 'my_password' not configured in oscam.conf!"); 1634 return -1; 1635 } 1621 1636 local_gbox.password = cfg.gbox_password; 1622 1637 local_gbox.id = gbox_convert_password_to_id(local_gbox.password); 1623 if (local_gbox.id == NO_GBOX_ID) 1624 { 1625 cs_log("invalid local gbox id: %04X", local_gbox.id); 1626 } 1638 1639 if(!local_gbox.id) 1640 { 1641 cs_log("invalid my_password '%08X' -> local gbox id: %04X, choose another 'my_password'", cfg.gbox_password, local_gbox.id); 1642 return -1; 1643 } 1644 1645 local_gbox_initialized = 1; 1646 1647 for(i = 0; i < CS_MAXPORTS; i++) 1648 { 1649 if(!cfg.gbox_port[i]) 1650 { 1651 cs_log("we are online - %d ports to monitor", i); 1652 break; 1653 } 1654 } 1655 1627 1656 last_stats_written = time(NULL); 1628 1657 last_locals_checked = time(NULL); 1629 1658 gbox_write_version(); 1630 local_gbox_initialized = 1; 1631 } 1632 1633 static int32_t gbox_client_init(struct s_client *cli) 1659 start_sms_sender(); 1660 return local_gbox_initialized; 1661 } 1662 1663 static int32_t gbox_peer_init(struct s_client *cli) 1634 1664 { 1635 1665 if (!cli || cli->typ != 'p' || !cli->reader) 1636 1666 { 1637 cs_log("error, wrong call to gbox_ client_init!");1667 cs_log("error, wrong call to gbox_peer_init!"); 1638 1668 return -1; 1639 1669 } 1640 1670 1671 if (local_gbox_initialized < 0) { return -1; } 1672 1673 int8_t ret; 1641 1674 if (!local_gbox_initialized) 1642 { init_local_gbox(); } 1643 1644 if(!cfg.gbox_port[0]) 1645 { 1646 cs_log("error, no/invalid port=%d configured in oscam.conf!", cfg.gbox_port[0] ? cfg.gbox_port[0] : 0); 1647 return -1; 1648 } 1649 1650 if(!cfg.gbox_hostname || strlen(cfg.gbox_hostname) > 128) 1651 { 1652 cs_log("error, no/invalid hostname '%s' configured in oscam.conf!", 1653 cfg.gbox_hostname ? cfg.gbox_hostname : ""); 1654 return -1; 1655 } 1656 1657 if(!local_gbox.id) 1658 { 1659 cs_log("error, no/invalid password '%08X' configured in oscam.conf!", cfg.gbox_password); 1660 return -1; 1661 } 1675 { 1676 local_gbox_initialized = 1; 1677 ret = init_local_gbox(); 1678 if (ret < 0) 1679 { 1680 local_gbox_initialized = -1; 1681 cs_log("local gbox initialization failed"); 1682 write_msg_info(cli, MSGID_GBOXONL, 0, 0); 1683 return -1; 1684 } 1685 write_msg_info(cli, MSGID_GBOXONL, 0, 1); 1686 } 1662 1687 1663 1688 if(!cs_malloc(&cli->gbox, sizeof(struct gbox_peer))) … … 1679 1704 cs_lock_create(__func__, &peer->lock, "gbox_lock", 5000); 1680 1705 1681 gbox_ reinit_peer(peer);1706 gbox_clear_peer(peer); 1682 1707 1683 1708 cli->gbox_peer_id = peer->gbox.id; … … 1734 1759 { cli->reader->gbox_cccam_reshare = GBOX_MAXHOPS; } 1735 1760 1736 start_sms_sender();1737 1738 1761 return 0; 1739 1762 } … … 1775 1798 { 1776 1799 cs_log("Lost connection to: %s %s boxid: %04X",proxy->reader->device, cs_inet_ntoa(proxy->ip), cl->gbox_peer_id); 1777 write_msg_ to_osd(proxy, MSGID_LOSTCONNECT, 0, 0);1800 write_msg_info(proxy, MSGID_LOSTCONNECT, 0, 0); 1778 1801 } 1779 1802 gbox_reinit_proxy(proxy); … … 1863 1886 ph->ptab.ports[i].s_port = cfg.gbox_port[i]; 1864 1887 } 1865 1866 1888 ph->desc = "gbox"; 1867 1889 ph->num = R_GBOX; … … 1876 1898 1877 1899 ph->recv = gbox_recv; 1878 ph->c_init = gbox_ client_init;1900 ph->c_init = gbox_peer_init; 1879 1901 ph->c_recv_chk = gbox_recv_chk; 1880 1902 ph->c_send_ecm = gbox_send_ecm; -
trunk/module-gbox.h
r11354 r11361 45 45 #define FILE_GBOX_PEER_ONL "share.onl" 46 46 #define FILE_STATS "stats.info" 47 #define FILE_MSG_ OSD "msg.osd"47 #define FILE_MSG_INFO "msg.info" 48 48 #define FILE_LOCAL_CARDS_INFO "sc.info" 49 49 … … 56 56 #define MSGID_ATTACK 6 57 57 #define MSGID_IPCHANGE 7 58 #define MSGID_UNKNOWNMSG 8 58 #define MSGID_GBOXONL 8 59 #define MSGID_UNKNOWNMSG 9 59 60 60 61 #define GBOX_STAT_HELLOL 0 -
trunk/module-webif.c
r11360 r11361 134 134 #define MNU_GBX_FSTAINF 27 135 135 #define MNU_GBX_FEXPINF 28 136 137 #define MNU_CFG_TOTAL_ITEMS 29 // sum of items above. Use it for "All inactive" in function calls too. 136 #define MNU_GBX_INFOLOG 29 137 138 #define MNU_CFG_TOTAL_ITEMS 30 // sum of items above. Use it for "All inactive" in function calls too. 138 139 139 140 static void set_status_info_var(struct templatevars *vars, char *varname, int no_data, char *fmt, double value) { … … 6334 6335 { "stats.info", MNU_GBX_FSTAINF, FTYPE_GBOX }, // id 27 6335 6336 { "expired.info", MNU_GBX_FEXPINF, FTYPE_GBOX }, // id 28 6337 { "info.log", MNU_GBX_INFOLOG, FTYPE_GBOX }, // id 29 6336 6338 #endif 6337 6339 { NULL, 0, 0 }, -
trunk/webif/files/menu.html
r11355 r11361 10 10 <LI CLASS="##CMENUACTIVE7##"><A HREF="files.html?file=logfile">logfile</A></LI> 11 11 <LI CLASS="##CMENUACTIVE8##"><A HREF="files.html?file=userfile">userfile</A></LI> 12 ##TPLFILEMENUGBOX## <!-- CMENUACTIVE19-2 8-->12 ##TPLFILEMENUGBOX## <!-- CMENUACTIVE19-29 --> 13 13 <LI CLASS="##CMENUACTIVE9## ##CMENUACTIVE10## ##CMENUACTIVE11## ##CMENUACTIVE12## ##CMENUACTIVE13## ##CMENUACTIVE14## ##CMENUACTIVE15## ##CMENUACTIVE16## ##CMENUACTIVE17## ##CMENUACTIVE18##"><A HREF="#" class="drop">other files<b class="subcaret"></b></A> 14 14 <UL CLASS="dropdown_nav"> -
trunk/webif/files/menu_gbox.html
r11354 r11361 11 11 <LI CLASS="##CMENUACTIVE27##"><A HREF="files.html?file=stats.info">stats.info</A></LI> 12 12 <LI CLASS="##CMENUACTIVE28##"><A HREF="files.html?file=expired.info">expired.info</A></LI> 13 <LI CLASS="##CMENUACTIVE29##"><A HREF="files.html?file=info.log">info.log</A></LI> 13 14 </UL>
Note:
See TracChangeset
for help on using the changeset viewer.