Changeset 4404
- Timestamp:
- 01/11/11 12:11:58 (13 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Maketype
r4297 r4404 62 62 $(LIBFILE1)(module-constcw.o) \ 63 63 $(LIBFILE1)(module-dvbapi.o) \ 64 $(LIBFILE1)(module-obj-llist.o) \65 64 $(LIBFILE1)(module-stat.o) \ 66 65 $(LIBFILE1)(module-datastruct-llist.o) \ -
trunk/globals.h
r4398 r4404 30 30 #include <pthread.h> 31 31 32 #include "module-obj-llist.h"33 32 #include "module-datastruct-llist.h" 34 33 … … 1071 1070 int failbantime; 1072 1071 int failbancount; 1073 LLIST _D_*v_list; //failban list1072 LLIST *v_list; //failban list 1074 1073 int c33_port; 1075 1074 in_addr_t c33_srvip; -
trunk/module-cccam.c
r4361 r4404 3525 3525 struct s_reader *rdr = cl->reader; 3526 3526 struct cc_data *cc = cl->cc; 3527 rdr->card_status = CARD_FAILURE; 3527 3528 3528 3529 if (cc && cc->mode != CCCAM_MODE_NORMAL) … … 3568 3569 if ((n = cc_recv_to(cl, data, 16)) != 16) { 3569 3570 int err = errno; 3570 cs_log("%s server does not return 16 bytes (n=%d, handle=%d, udp_fd=%d, errno=%d)", 3571 rdr->label, n, handle, cl->udp_fd, err); 3571 if (n <= 0) 3572 cs_log("%s server blocked connection!", rdr->label); 3573 else 3574 cs_log("%s server does not return 16 bytes (n=%d, errno=%d)", 3575 rdr->label, n, err); 3572 3576 block_connect(rdr); 3573 3577 return -2; -
trunk/module-datastruct-llist.c
r4066 r4404 136 136 void ll_iter_reset(LL_ITER *it) 137 137 { 138 it->cur = it->l->initial; 138 if (it && it->l) 139 it->cur = it->l->initial; 139 140 } 140 141 141 142 void ll_iter_insert(LL_ITER *it, void *obj) 142 143 { 143 if(obj) { 144 LL_NODE *n = calloc(1, sizeof(LL_NODE)); 145 n->obj = obj; 146 n->nxt = it->cur; 147 n->prv = it->cur->prv; 148 149 it->cur->prv->nxt = n; 150 it->cur->prv = n; 144 if(it && obj) { 145 if (!it->cur) 146 ll_append(it->l, obj); 147 else { 148 LL_NODE *n = calloc(1, sizeof(LL_NODE)); 149 n->obj = obj; 150 n->nxt = it->cur; 151 n->prv = it->cur->prv; 152 153 it->cur->prv->nxt = n; 154 it->cur->prv = n; 155 } 151 156 } 152 157 } … … 154 159 void *ll_iter_remove(LL_ITER *it) 155 160 { 156 if (it ) {161 if (it && it->l) { 157 162 LL_NODE *n; 158 163 … … 186 191 int ll_count(LLIST *l) 187 192 { 193 if (!l) 194 return 0; 195 188 196 void *obj; 189 197 int c = 0; -
trunk/oscam-config.c
r4400 r4404 1260 1260 int tag=TAG_GLOBAL; 1261 1261 FILE *fp; 1262 char *value ;1262 char *value=NULL; 1263 1263 1264 1264 #ifndef CS_EMBEDDED -
trunk/oscam-http.c
r4403 r4404 891 891 892 892 tpl_addVar(vars, 0, "PINCODE", rdr->pincode); 893 tpl_addVar(vars, 0, "EMMFILE", (char *)rdr->emmfile);893 if (rdr->emmfile) tpl_addVar(vars, 0, "EMMFILE", (char *)rdr->emmfile); 894 894 tpl_printf(vars, 0, "INACTIVITYTIMEOUT", "%d", rdr->tcp_ito); 895 895 tpl_printf(vars, 0, "RECEIVETIMEOUT", "%d", rdr->tcp_rto); … … 2733 2733 2734 2734 uint ip2delete = 0; 2735 LL IST_D__ITR itr;2736 V_BAN *v_ban_entry = llist_itr_init(cfg->v_list, &itr);2735 LL_ITER *itr = ll_iter_create(cfg->v_list); 2736 V_BAN *v_ban_entry; 2737 2737 2738 2738 if (strcmp(getParam(params, "action"), "delete") == 0) { 2739 2739 sscanf(getParam(params, "intip"), "%u", &ip2delete); 2740 while ( v_ban_entry) {2740 while ((v_ban_entry=ll_iter_next(itr))) { 2741 2741 if (v_ban_entry->v_ip == ip2delete) { 2742 free(v_ban_entry); 2743 llist_itr_remove(&itr); 2742 ll_iter_remove_data(itr); 2744 2743 break; 2745 2744 } 2746 v_ban_entry = llist_itr_next(&itr);2747 2748 }2749 2745 } 2746 } 2747 ll_iter_reset(itr); 2748 2750 2749 time_t now = time((time_t)0); 2751 v_ban_entry = llist_itr_init(cfg->v_list, &itr); 2752 2753 while (v_ban_entry) { 2750 2751 while ((v_ban_entry=ll_iter_next(itr))) { 2754 2752 2755 2753 if (!cfg->http_js_icons) … … 2788 2786 tpl_printf(vars, 0, "INTIP", "%u", v_ban_entry->v_ip); 2789 2787 tpl_addVar(vars, 1, "FAILBANROW", tpl_getTpl(vars, "FAILBANBIT")); 2790 v_ban_entry = llist_itr_next(&itr);2791 }2792 2788 } 2789 ll_iter_release(itr); 2790 2793 2791 return tpl_getTpl(vars, "FAILBAN"); 2794 2792 } -
trunk/oscam.c
r4398 r4404 87 87 } 88 88 89 int cs_check_v(uint ip, int add) { 90 int result = 0; 91 if (cfg->failbantime) { 92 93 if (!cfg->v_list) 94 cfg->v_list = ll_create(); 95 96 time_t now = time((time_t)0); 97 LL_ITER *itr = ll_iter_create(cfg->v_list); 98 V_BAN *v_ban_entry; 99 int ftime = cfg->failbantime*60; 100 101 //run over all banned entries to do housekeeping: 102 while ((v_ban_entry=ll_iter_next(itr))) { 103 104 // housekeeping: 105 if ((now - v_ban_entry->v_time) >= ftime) { // entry out of time->remove 106 ll_iter_remove_data(itr); 107 continue; 108 } 109 110 if (ip == v_ban_entry->v_ip) { 111 result=1; 112 if (!add) { 113 if (v_ban_entry->v_count >= cfg->failbancount) { 114 cs_debug_mask(D_TRACE, "failban: banned ip %s - %ld seconds left", 115 cs_inet_ntoa(v_ban_entry->v_ip),ftime - (now - v_ban_entry->v_time)); 116 } else { 117 cs_debug_mask(D_TRACE, "failban: ip %s chance %d of %d", 118 cs_inet_ntoa(v_ban_entry->v_ip), v_ban_entry->v_count, cfg->failbancount); 119 v_ban_entry->v_count++; 120 } 121 } 122 else { 123 cs_debug_mask(D_TRACE, "failban: banned ip %s - already exist in list", cs_inet_ntoa(v_ban_entry->v_ip)); 124 } 125 126 } 127 } 128 if (add && !result) { 129 v_ban_entry = malloc(sizeof(V_BAN)); 130 memset(v_ban_entry, 0, sizeof(V_BAN)); 131 132 v_ban_entry->v_time = time((time_t *)0); 133 v_ban_entry->v_ip = ip; 134 135 ll_iter_insert(itr, v_ban_entry); 136 137 cs_debug_mask(D_TRACE, "failban: ban ip %s with timestamp %d", cs_inet_ntoa(v_ban_entry->v_ip), v_ban_entry->v_time); 138 } 139 ll_iter_release(itr); 140 } 141 return result; 142 } 143 89 144 int cs_check_violation(uint ip) { 90 if (cfg->failbantime) { 91 92 time_t now = time((time_t)0); 93 LLIST_D__ITR itr; 94 V_BAN *v_ban_entry = llist_itr_init(cfg->v_list, &itr); 95 96 while (v_ban_entry) { 97 if (ip == v_ban_entry->v_ip) { 98 if ((now - v_ban_entry->v_time) >= (cfg->failbantime * 60)) { 99 // housekeeping 100 free(v_ban_entry); 101 llist_itr_remove(&itr); 102 return 0; 103 } else { 104 if (v_ban_entry->v_count >= cfg->failbancount) { 105 cs_debug_mask(D_TRACE, "failban: banned ip %s - %ld seconds left", 106 cs_inet_ntoa(v_ban_entry->v_ip),(cfg->failbantime * 60) - (now - v_ban_entry->v_time)); 107 return 1; 108 } else { 109 cs_debug_mask(D_TRACE, "failban: ip %s chance %d of %d", 110 cs_inet_ntoa(v_ban_entry->v_ip), v_ban_entry->v_count, cfg->failbancount); 111 v_ban_entry->v_count++; 112 return 0; 113 } 114 } 115 } 116 v_ban_entry = llist_itr_next(&itr); 117 } 118 return 0; 119 } 120 return 0; 121 } 122 145 return cs_check_v(ip, 0); 146 } 123 147 void cs_add_violation(uint ip) { 124 if (cfg->failbantime) { 125 126 if (!cfg->v_list) 127 cfg->v_list = llist_create(); 128 129 LLIST_D__ITR itr; 130 V_BAN *v_ban_entry = llist_itr_init(cfg->v_list, &itr); 131 while (v_ban_entry) { 132 if (ip == v_ban_entry->v_ip) { 133 cs_debug_mask(D_TRACE, "failban: banned ip %s - already exist in list", cs_inet_ntoa(v_ban_entry->v_ip)); 134 return ; 135 } 136 v_ban_entry = llist_itr_next(&itr); 137 } 138 139 v_ban_entry = malloc(sizeof(V_BAN)); 140 memset(v_ban_entry, 0, sizeof(V_BAN)); 141 142 v_ban_entry->v_time = time((time_t *)0); 143 v_ban_entry->v_ip = ip; 144 145 llist_append(cfg->v_list, v_ban_entry); 146 147 cs_debug_mask(D_TRACE, "failban: ban ip %s with timestamp %d", cs_inet_ntoa(v_ban_entry->v_ip), v_ban_entry->v_time); 148 149 } 150 } 148 cs_check_v(ip, 1); 149 } 150 151 151 //Alno Test End 152 152 /***************************************************************************** … … 539 539 } 540 540 add_garbage(cl->ecmtask); 541 cl->ecmtask = NULL; 541 542 } 542 543
Note:
See TracChangeset
for help on using the changeset viewer.