Changeset 43154f8625f76af133f75133b2517fd6565f6b35
- Timestamp:
- 07/29/10 23:34:53 (22 months ago)
- Children:
- 3cbe0c2fb30e0b5337ba35e14fb6cafda374e7b9
- Parents:
- 732bc1be8e814ff17f8d31268e1de28124d93aeb
- git-committer:
- Neutron Soutmun <neo.neutron@…> (07/29/10 23:34:53)
- Files:
-
- 6 added
- 3 removed
- 18 modified
-
configure.ac (modified) (1 diff)
-
src/Makefile.am (modified) (3 diffs)
-
src/include/linux/netfilter_ipv4/ip_set.h (deleted)
-
src/include/linux/netfilter_ipv4/ip_set_rahunas.h (deleted)
-
src/ipset/ip_set.h (modified) (1 diff)
-
src/ipset/ip_set_hashes.h (added)
-
src/ipset/ip_set_rahunas_ipiphash.h (added)
-
src/rahunasd.c (modified) (6 diffs)
-
src/rahunasd.h (modified) (1 diff)
-
src/rh-config.c (modified) (11 diffs)
-
src/rh-config.h (modified) (5 diffs)
-
src/rh-ipset.c (modified) (2 diffs)
-
src/rh-ipset.h (modified) (1 diff)
-
src/rh-server.c (modified) (1 diff)
-
src/rh-server.h (modified) (2 diffs)
-
src/rh-serviceclass.c (added)
-
src/rh-serviceclass.h (added)
-
src/rh-task-dbset.c (modified) (6 diffs)
-
src/rh-task-memset.c (modified) (2 diffs)
-
src/rh-task-serviceclass.c (added)
-
src/rh-task-serviceclass.h (added)
-
src/rh-task.c (modified) (1 diff)
-
src/rh-task.h (modified) (1 diff)
-
src/rh-xmlrpc-server.c (modified) (4 diffs)
-
tools/rahunas-firewall.in (modified) (18 diffs)
-
tools/rahunas-vipmap.in (deleted)
-
weblogin/login.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
configure.ac
r91cc1f0 r43154f8 62 62 tools/rahunas-firewall 63 63 tools/rahunas-bandwidth 64 tools/rahunas-vipmap65 64 tools/rahunas-weblogin-config-update 66 65 example/Makefile -
src/Makefile.am
r91cc1f0 r43154f8 9 9 $(LIBGDA_CFLAGS) \ 10 10 -I$(top_srcdir)/src/ \ 11 -I$(top_srcdir)/src/include/ \12 11 -DRAHUNAS_VERSION=\"$(RAHUNAS_VERSION)\" \ 13 12 -DPROGRAM=\"$(PROGRAM)\" \ … … 45 44 rh-task-bandwidth.c \ 46 45 rh-task-bandwidth.h \ 46 rh-task-serviceclass.c \ 47 rh-task-serviceclass.h \ 47 48 rh-radius.h \ 48 49 rh-config.c \ 49 rh-config.h 50 rh-config.h \ 51 rh-serviceclass.h \ 52 rh-serviceclass.c 50 53 51 54 rahunasd_LDADD = \ … … 54 57 $(LIBGNET_LIBS) \ 55 58 $(LIBGDA_LIBS) 56 57 noinst_HEADERS = \58 include/linux/netfilter_ipv4/ip_set.h \59 include/linux/netfilter_ipv4/ip_set_rahunas.h60 -
src/ipset/ip_set.h
rb813a36 r43154f8 1 1 #ifndef _IP_SET_H 2 2 #define _IP_SET_H 3 4 #include <inttypes.h> 3 5 4 6 /* Copyright (C) 2000-2002 Joakim Axelsson <gozem@linux.nu> -
src/rahunasd.c
r220ede9 r43154f8 29 29 struct main_server rh_main_server_instance = { 30 30 .vserver_list = NULL, 31 .serviceclass_list = NULL, 31 32 .task_list = NULL, 32 33 }; … … 177 178 } 178 179 180 /* Get serviceclass config, again */ 181 if (rh_main_server->main_config->serviceclass_conf_dir != NULL) { 182 get_serviceclass_config(rh_main_server->main_config->serviceclass_conf_dir, 183 rh_main_server); 184 } else { 185 syslog(LOG_ERR, "The main configuration file is incompleted, lack of serviceclass_conf_dir\n"); 186 exit(EXIT_FAILURE); 187 } 188 189 walk_through_serviceclass(&serviceclass_reload, rh_main_server); 190 serviceclass_unused_cleanup(rh_main_server); 191 179 192 walk_through_vserver(&vserver_reload, rh_main_server); 180 193 vserver_unused_cleanup(rh_main_server); … … 284 297 if (member->session_id && member->session_id != termstring) 285 298 free(member->session_id); 299 300 if (member->serviceclass_name && member->serviceclass_name != termstring) 301 free(member->serviceclass_name); 302 303 if (member->mapping_ip && member->mapping_ip != termstring) 304 free(member->mapping_ip); 286 305 } 287 306 … … 299 318 union rahunas_config rh_main_config = { 300 319 .rh_main.conf_dir = NULL, 320 .rh_main.serviceclass_conf_dir = NULL, 301 321 .rh_main.log_file = NULL, 302 322 .rh_main.dhcp = NULL, 303 323 .rh_main.polling_interval = POLLING, 304 324 .rh_main.bandwidth_shape = BANDWIDTH_SHAPE, 325 .rh_main.serviceclass = 0, 305 326 }; 306 327 … … 343 364 } 344 365 366 if (rh_main_server->main_config->serviceclass) { 367 /* Get serviceclass config */ 368 if (rh_main_server->main_config->serviceclass_conf_dir != NULL) { 369 get_serviceclass_config(rh_main_server->main_config->serviceclass_conf_dir, 370 rh_main_server); 371 } else { 372 syslog(LOG_ERR, "The main configuration file is incompleted, lack of serviceclass_conf_dir\n"); 373 exit(EXIT_FAILURE); 374 } 375 } 376 377 345 378 snprintf(version, sizeof (version), "Starting %s - Version %s", PROGRAM, 346 379 RAHUNAS_VERSION); … … 349 382 rh_task_register(rh_main_server); 350 383 rh_task_startservice(rh_main_server); 384 385 if (rh_main_server->main_config->serviceclass) 386 walk_through_serviceclass(&serviceclass_init, rh_main_server); 351 387 352 388 walk_through_vserver(&rh_task_init, rh_main_server); -
src/rahunasd.h
r91cc1f0 r43154f8 59 59 long bandwidth_max_up; 60 60 unsigned short bandwidth_slot_id; 61 char *serviceclass_name; 62 uint32_t serviceclass_slot_id; 63 char *mapping_ip; 61 64 char *username; 62 65 char *session_id; -
src/rh-config.c
r91cc1f0 r43154f8 45 45 if (strncmp(main_key, "main", 4) == 0) { 46 46 cfg_type = MAIN; 47 48 } if (strncmp(main_key, "service_class", strlen ("service_class")) == 0) { 47 } else if (strncmp(main_key, "service_class", strlen ("service_class")) == 0) { 49 48 cfg_type = SERVICECLASS; 50 49 } else { … … 60 59 free(config->rh_main.conf_dir); 61 60 config->rh_main.conf_dir = strdup(value); 61 } else if (strncmp(sub_key, "serviceclass_conf_dir", 21) == 0) { 62 if (config->rh_main.serviceclass_conf_dir != NULL) 63 free(config->rh_main.serviceclass_conf_dir); 64 config->rh_main.serviceclass_conf_dir = strdup(value); 62 65 } else if (strncmp(sub_key, "log_file", 8) == 0) { 63 66 if (config->rh_main.log_file != NULL) … … 68 71 free(config->rh_main.dhcp); 69 72 config->rh_main.dhcp = strdup(value); 73 } else if (strncmp(sub_key, "serviceclass", 12) == 0) { 74 config->rh_main.serviceclass = strncmp(value, "yes", 3) == 0 ? 1 : 0; 70 75 } else if (strncmp(sub_key, "bandwidth_shape", 15) == 0) { 71 if (strncmp(value, "yes", 3) == 0) 72 config->rh_main.bandwidth_shape = 1; 73 else 74 config->rh_main.bandwidth_shape = 0; 76 config->rh_main.bandwidth_shape = strncmp(value, "yes", 3) == 0 ? 1 : 0; 75 77 } else if (strncmp(sub_key, "bittorrent_download_max", 23) == 0) { 76 78 config->rh_main.bittorrent_download_max = atoi(value); … … 83 85 84 86 case SERVICECLASS: 85 if (strncmp (sub_key, "name", strlen("name")) == 0) { 86 if (config->rh_serviceclass.name != NULL) 87 free(config->rh_serviceclass.name); 88 config->rh_serviceclass.name = strdup(value); 87 if (strncmp (sub_key, "serviceclass_id", 88 strlen("serviceclass_id")) == 0) { 89 config->rh_serviceclass.serviceclass_id = atoi (value); 90 } else if (strncmp (sub_key, "serviceclass_name", strlen("serviceclass_name")) == 0) { 91 if (config->rh_serviceclass.serviceclass_name != NULL) 92 free(config->rh_serviceclass.serviceclass_name); 93 config->rh_serviceclass.serviceclass_name = strdup(value); 89 94 } else if (strncmp (sub_key, "description", strlen("description")) == 0) { 90 95 if (config->rh_serviceclass.description != NULL) … … 114 119 else 115 120 { 116 // Start address should not be the network address117 config->rh_serviceclass.start_addr.s_addr += 1;118 121 DP ("service_class: %s - start ip = %s, size: %d", 119 config->rh_serviceclass. name,122 config->rh_serviceclass.serviceclass_name, 120 123 inet_ntoa (config->rh_serviceclass.start_addr), 121 124 config->rh_serviceclass.network_size); … … 130 133 131 134 if (!valid) { 132 if (config->rh_serviceclass. name != NULL) {135 if (config->rh_serviceclass.serviceclass_name != NULL) { 133 136 syslog(LOG_ERR, "\"%s\" service_class config config error: " 134 137 "invalid network %s", 135 config->rh_serviceclass. name, value);138 config->rh_serviceclass.serviceclass_name, value); 136 139 } else { 137 140 syslog(LOG_ERR, "unknown service_class config error: " … … 139 142 } 140 143 } 141 } else if (strncmp (sub_key, "fake_arpd", strlen("fake_arpd")) == 0) {142 if (config->rh_serviceclass.fake_arpd != NULL)143 free(config->rh_serviceclass.fake_arpd);144 config->rh_serviceclass.fake_arpd = strdup(value);145 144 } else if (strncmp (sub_key, "fake_arpd_iface", 146 145 strlen("fake_arpd_iface")) == 0) { … … 148 147 free(config->rh_serviceclass.fake_arpd_iface); 149 148 config->rh_serviceclass.fake_arpd_iface = strdup(value); 149 } else if (strncmp (sub_key, "fake_arpd", strlen("fake_arpd")) == 0) { 150 if (config->rh_serviceclass.fake_arpd != NULL) 151 free(config->rh_serviceclass.fake_arpd); 152 config->rh_serviceclass.fake_arpd = strdup(value); 150 153 } 151 154 break; … … 374 377 } 375 378 379 int get_serviceclass_config(const char *conf_dir, struct main_server *server) 380 { 381 DIR *dp; 382 struct dirent *dirp; 383 void *data = NULL; 384 size_t len; 385 char conf_file[200]; 386 387 if ((dp = opendir(conf_dir)) == NULL) 388 return errno; 389 390 while ((dirp = readdir(dp)) != NULL) { 391 if (strstr(dirp->d_name, ".conf") == NULL) 392 continue; 393 394 memset(conf_file, 0, sizeof(conf_file)); 395 396 strncat(conf_file, conf_dir, sizeof(conf_file)); 397 strncat(conf_file, "/", 1); 398 strncat(conf_file, dirp->d_name, sizeof(conf_file)); 399 400 syslog(LOG_INFO, "Loading service class config file: %s", conf_file); 401 402 register_serviceclass(server, conf_file); 403 } 404 405 closedir(dp); 406 return 0; 407 } 376 408 377 409 int cleanup_vserver_config(struct rahunas_vserver_config *config) … … 416 448 int cleanup_serviceclass_config(struct rahunas_serviceclass_config *config) 417 449 { 418 rh_free(&(config-> name));450 rh_free(&(config->serviceclass_name)); 419 451 rh_free(&(config->description)); 420 452 rh_free(&(config->network)); … … 428 460 { 429 461 rh_free(&(config->conf_dir)); 462 rh_free(&(config->serviceclass_conf_dir)); 430 463 rh_free(&(config->log_file)); 431 464 rh_free(&(config->dhcp)); -
src/rh-config.h
r91cc1f0 r43154f8 9 9 #include "../lcfg/lcfg_static.h" 10 10 #include "rh-server.h" 11 #include "rh-serviceclass.h" 11 12 12 13 #define DEFAULT_LOG RAHUNAS_LOG_DIR "rahunas.log" … … 35 36 struct rahunas_main_config { 36 37 char *conf_dir; 38 char *serviceclass_conf_dir; 37 39 char *log_file; 38 40 char *dhcp; 41 int serviceclass; 39 42 int bandwidth_shape; 40 43 int bittorrent_download_max; 41 44 int bittorrent_upload_max; 42 45 int polling_interval; 43 int service_class_enabled;44 46 }; 45 47 … … 85 87 86 88 struct rahunas_serviceclass_config { 87 char *name; 89 char *serviceclass_name; 90 int serviceclass_id; 91 int init_flag; 88 92 char *description; 89 93 char *network; … … 114 118 }; 115 119 120 enum serviceclass_config_init_flag { 121 SC_NONE, 122 SC_INIT, 123 SC_RELOAD, 124 SC_RESET, 125 SC_DONE 126 }; 127 116 128 extern GList *interfaces_list; 117 129 … … 119 131 int get_value(const char *cfg_file, const char *key, void **data, size_t *len); 120 132 int get_vservers_config(const char *conf_dir, struct main_server *server); 133 int get_serviceclass_config(const char *conf_dir, struct main_server *server); 121 134 int cleanup_vserver_config(struct rahunas_vserver_config *config); 122 135 int cleanup_serviceclass_config(struct rahunas_serviceclass_config *config); -
src/rh-ipset.c
r220ede9 r43154f8 10 10 #include <unistd.h> 11 11 #include <syslog.h> 12 #include <ipset/ip_set_rahunas_ipiphash.h> 12 13 #include "rh-ipset.h" 13 14 #include "rh-utils.h" … … 297 298 } 298 299 300 int set_ipiphash_adtip(struct set *rahunas_set, const char *ip, 301 const char *ip1, unsigned op) 302 { 303 ip_set_ip_t _ip; 304 ip_set_ip_t _ip1; 305 parse_ip(ip, &_ip); 306 parse_ip(ip1, &_ip1); 307 308 return set_adtip_nb(rahunas_set, &_ip, &_ip1, op); 309 } 310 311 int set_ipiphash_adtip_nb(struct set *rahunas_set, ip_set_ip_t *ip, 312 ip_set_ip_t *ip1, unsigned op) 313 { 314 struct ip_set_req_adt *req_adt = NULL; 315 struct ip_set_req_rahunas_ipiphash req; 316 317 size_t size; 318 void *data; 319 int res = 0; 320 321 check_protocolversion (); 322 323 if (rahunas_set == NULL) 324 return -1; 325 326 size = ALIGNED(sizeof(struct ip_set_req_adt)) + sizeof(struct ip_set_req_rahunas_ipiphash); 327 data = rh_malloc(size); 328 329 memcpy(&req.ip, ip, sizeof(ip_set_ip_t)); 330 memcpy(&req.ip1, ip1, sizeof(ip_set_ip_t)); 331 332 req_adt = (struct ip_set_req_adt *) data; 333 req_adt->op = op; 334 req_adt->index = rahunas_set->index; 335 memcpy(data + ALIGNED(sizeof(struct ip_set_req_adt)), &req, 336 sizeof(struct ip_set_req_rahunas_ipiphash)); 337 338 if (kernel_sendto_handleerrno(op, data, size) == -1) 339 switch (op) { 340 case IP_SET_OP_ADD_IP: 341 DP("%s:%s is already in set", ip_tostring(ip), ip_tostring(ip1)); 342 res = RH_IS_IN_SET; 343 break; 344 case IP_SET_OP_DEL_IP: 345 DP("%s:%s is not in set", ip_tostring(ip), ip_tostring(ip1)); 346 res = RH_IS_NOT_IN_SET; 347 break; 348 case IP_SET_OP_TEST_IP: 349 DP("%s:%s is in set", ip_tostring(ip), ip_tostring(ip1)); 350 res = RH_IS_IN_SET; 351 break; 352 default: 353 break; 354 } 355 else 356 switch (op) { 357 case IP_SET_OP_TEST_IP: 358 DP("%s:%s is not in set", ip_tostring(ip), ip_tostring(ip1)); 359 res = RH_IS_NOT_IN_SET; 360 break; 361 default: 362 break; 363 } 364 365 rh_free(&data); 366 367 return res; 368 } 369 299 370 void set_flush(const char *name) 300 371 { -
src/rh-ipset.h
r220ede9 r43154f8 83 83 84 84 int set_adtip_nb(struct set *rahunas_set, ip_set_ip_t *adtip, 85 unsigned char adtmac[ETH_ALEN], unsigned op); 85 unsigned char adtmac[ETH_ALEN], unsigned op); 86 87 int set_ipiphash_adtip(struct set *rahunas_set, const char *ip, 88 const char *ip1, unsigned op); 89 int set_ipiphash_adtip_nb(struct set *rahunas_set, ip_set_ip_t *ip, 90 ip_set_ip_t *ip1, unsigned op); 86 91 87 92 void set_flush(const char *name); -
src/rh-server.c
r91cc1f0 r43154f8 176 176 new_vserver->vserver_config = vserver_config; 177 177 178 new_vserver->main_server = ms; 178 179 new_vserver->vserver_config->init_flag = VS_INIT; 179 180 ms->vserver_list = g_list_append(ms->vserver_list, new_vserver); -
src/rh-server.h
r91cc1f0 r43154f8 10 10 #include "rh-config.h" 11 11 12 struct main_server { 13 struct rahunas_main_config *main_config; 14 GList *vserver_list; 15 GList *serviceclass_list; 16 GList *task_list; 17 int log_fd; 18 int polling_blocked; 19 }; 20 12 21 struct vserver { 13 22 struct rahunas_vserver_config *vserver_config; … … 15 24 struct rahunas_map *v_map; 16 25 struct set *v_set; 17 }; 18 19 struct main_server { 20 struct rahunas_main_config *main_config; 21 GList *vserver_list; 22 GList *task_list; 23 int log_fd; 24 int polling_blocked; 26 struct main_server *main_server; 25 27 }; 26 28 -
src/rh-task-dbset.c
r515ff2d r43154f8 26 26 long bandwidth_max_down; 27 27 long bandwidth_max_up; 28 gchar *service_class; 29 uint32_t service_class_slot_id; 28 30 }; 29 31 … … 101 103 } else if (strncmp("bandwidth_max_up", title, 18) == 0) { 102 104 row->bandwidth_max_up = atol(str); 105 } else if (strncmp("service_class_slot_id", title, 106 strlen("service_class_slot_id")) == 0) { 107 row->service_class_slot_id = atol(str); 108 } else if (strncmp("service_class", title, 109 strlen("service_class")) == 0) { 110 row->service_class = g_strdup(str); 103 111 } 104 112 } … … 187 195 g_free(row->ip); 188 196 g_free(row->mac); 197 g_free(row->service_class); 189 198 } 190 199 … … 235 244 req.bandwidth_max_up = row->bandwidth_max_up; 236 245 246 req.serviceclass_name = row->service_class; 247 req.serviceclass_slot_id = row->service_class_slot_id; 248 237 249 rh_task_startsess(vs, &req); 238 250 } … … 354 366 "(session_id,vserver_id,username,ip,mac,session_start," 355 367 "session_timeout,bandwidth_slot_id,bandwidth_max_down," 356 "bandwidth_max_up ) "357 "VALUES('%s','%d','%s','%s','%s',%s,%s,%u,%lu,%lu )",368 "bandwidth_max_up,service_class,service_class_slot_id) " 369 "VALUES('%s','%d','%s','%s','%s',%s,%s,%u,%lu,%lu,'%s',%lu)", 358 370 req->session_id, 359 371 vs->vserver_config->vserver_id, … … 365 377 member->bandwidth_slot_id, 366 378 req->bandwidth_max_down, 367 req->bandwidth_max_up); 379 req->bandwidth_max_up, 380 member->serviceclass_name, 381 member->serviceclass_slot_id); 368 382 369 383 DP("SQL: %s", startsess_cmd); -
src/rh-task-memset.c
r927d0c7 r43154f8 149 149 free(member->session_id); 150 150 151 if (member->serviceclass_name && member->serviceclass_name != termstring) 152 free(member->serviceclass_name); 153 154 if (member->mapping_ip && member->mapping_ip != termstring) 155 free(member->mapping_ip); 156 151 157 member->username = strdup(req->username); 152 158 if (!member->username) … … 156 162 if (!member->session_id) 157 163 member->session_id = termstring; 164 165 member->serviceclass_name = NULL; 166 member->serviceclass_slot_id = 0; 167 member->mapping_ip = termstring; 158 168 159 169 if (req->session_start == 0) { -
src/rh-task.c
r91cc1f0 r43154f8 55 55 rh_task_memset_reg(ms); 56 56 rh_task_ipset_reg(ms); 57 58 if (ms->main_config->serviceclass) 59 rh_task_serviceclass_reg(ms); 57 60 58 61 if (ms->main_config->bandwidth_shape) -
src/rh-task.h
r91cc1f0 r43154f8 23 23 unsigned long bandwidth_max_down; 24 24 unsigned long bandwidth_max_up; 25 const char *serviceclass_name; 26 uint32_t serviceclass_slot_id; 25 27 unsigned short req_opt; 26 28 }; -
src/rh-xmlrpc-server.c
r91cc1f0 r43154f8 35 35 gchar *bandwidth_max_down = NULL; 36 36 gchar *bandwidth_max_up = NULL; 37 gchar *service _class= NULL;37 gchar *serviceclass_name = NULL; 38 38 gchar *vserver_id = NULL; 39 39 uint32_t id; … … 53 53 bandwidth_max_down = rh_string_get_sep(param, "|", 6); 54 54 bandwidth_max_up = rh_string_get_sep(param, "|", 7); 55 service _class= rh_string_get_sep(param, "|", 8);55 serviceclass_name = rh_string_get_sep(param, "|", 8); 56 56 vserver_id = rh_string_get_sep(param, "|", 9); 57 57 … … 111 111 member = (struct rahunas_member *)member_node->data; 112 112 *reply_string = g_strdup_printf("Greeting! Got: IP %s, User %s, ID %s, " 113 " VIP-IP%s",113 "Service Class %s, Mapping %s", 114 114 ip, member->username, 115 member->session_id, ""); 115 member->session_id, 116 member->serviceclass_name, 117 member->mapping_ip); 116 118 goto cleanup; 117 119 } … … 130 132 g_free(bandwidth_max_down); 131 133 g_free(bandwidth_max_up); 132 g_free(service _class);134 g_free(serviceclass_name); 133 135 g_free(vserver_id); 134 136 return 0; -
tools/rahunas-firewall.in
r51ab753 r43154f8 40 40 file=$3 41 41 42 cat $file | sed -e "0,/$section = {/ ! { /}/,/$section = {/ ! s/^/>>/ }" | grep "^>>" | sed -e "s/^>>//g" | grep -w "$key " | cut -d= -f2 | sed "s/^ *\(.*[^ ]\) *$/\1/" | sed 's/"//g'42 cat $file | sed -e "0,/$section = {/ ! { /}/,/$section = {/ ! s/^/>>/ }" | grep "^>>" | sed -e "s/^>>//g" | grep -w "$key[ ]*=" | cut -d= -f2 | sed "s/^ *\(.*[^ ]\) *$/\1/" | sed 's/"//g' 43 43 } 44 44 … … 49 49 # Main 50 50 MAIN_CONF_DIR=`get_config_value main conf_dir $RAHUNAS_CONFIG` 51 MAIN_SERVICECLASS=`get_config_value main serviceclass $RAHUNAS_CONFIG` 51 52 MAIN_BANDWIDTH_SHAPE=`get_config_value main bandwidth_shape $RAHUNAS_CONFIG` 52 53 MAIN_BITTORRENT_DOWNLOAD_MAX=`get_config_value main bittorrent_download_max $RAHUNAS_CONFIG` … … 79 80 VSERVER_PORTS_INTERCEPT= 80 81 SETNAME= 81 VIPMAP=82 VIPMAP_FAKE_ARP=83 82 fi 84 83 … … 101 100 CHAIN_NAT_POSTROUTING= 102 101 CHAIN_NAT_AUTHEN= 103 CHAIN_NAT_VIP_PREROUTING=104 CHAIN_NAT_VIP_POSTROUTING=105 102 CHAIN_P2P_DETECT= 106 103 CHAIN_P2P_RECHECK= … … 151 148 VSERVER_PORTS_ALLOW=`get_config_value $SETNAME vserver_ports_allow $file` 152 149 VSERVER_PORTS_INTERCEPT=`get_config_value $SETNAME vserver_ports_intercept $file` 153 VIPMAP=`get_config_value $SETNAME vipmap $file`154 VIPMAP_NETWORK=`get_config_value $SETNAME vipmap_network $file`155 VIPMAP_FAKE_ARP=`get_config_value $SETNAME vipmap_fake_arp $file`156 150 fi 157 151 … … 180 174 CHAIN_NAT_POSTROUTING="${SETNAME}_nat_post" 181 175 CHAIN_NAT_AUTHEN="${SETNAME}_nat_authen" 182 CHAIN_NAT_VIP_PREROUTING="${SETNAME}_nat_vip_pre"183 CHAIN_NAT_VIP_POSTROUTING="${SETNAME}_nat_vip_post"184 176 185 177 # P2P checking chains declaration … … 230 222 $IPSET -N $SETNAME rahunas $ipset_opt $ipset_ignoremac 231 223 232 if [ "$VIPMAP" = "yes" ]; then233 $IPSET -N ${SETNAME}-vip rahunas $ipset_opt $ipset_ignoremac234 fi235 236 224 if [ "$BITTORRENT" = "throttle" ]; then 237 225 $IPSET -N $P2P_SET iphash … … 253 241 $IPSET -F $SETNAME 254 242 $IPSET -X $SETNAME 255 256 if [ "$VIPMAP" = "yes" ]; then257 $IPSET -F ${SETNAME}-vip258 $IPSET -X ${SETNAME}-vip259 fi260 243 261 244 if [ "$BITTORRENT" = "throttle" ]; then … … 374 357 -j $CHAIN_NAT_POSTROUTING 375 358 done 376 } 359 360 361 } 362 377 363 378 364 ## … … 412 398 $IPTABLES -t nat -F $CHAIN_NAT_AUTHEN 413 399 $IPTABLES -t nat -X $CHAIN_NAT_AUTHEN 414 415 if [ "$VIPMAP" = "yes" ]; then416 $IPTABLES -t nat -F $CHAIN_NAT_VIP_PREROUTING417 $IPTABLES -t nat -X $CHAIN_NAT_VIP_PREROUTING418 419 $IPTABLES -t nat -F $CHAIN_NAT_VIP_POSTROUTING420 $IPTABLES -t nat -X $CHAIN_NAT_VIP_POSTROUTING421 fi422 400 423 401 if [ "$BITTORRENT" = "throttle" ]; then … … 448 426 $IPTABLES -t nat -N $CHAIN_NAT_AUTHEN 449 427 450 if [ "$VIPMAP" = "yes" ]; then451 $IPTABLES -t nat -N $CHAIN_NAT_VIP_PREROUTING452 $IPTABLES -t nat -N $CHAIN_NAT_VIP_POSTROUTING453 fi454 455 428 if [ "$BITTORRENT" = "throttle" ]; then 456 429 $IPTABLES -t mangle -N $CHAIN_P2P_CHECK … … 675 648 fi 676 649 677 if [ "$ VIPMAP" = "yes" ]; then650 if [ "$MAIN_SERVICECLASS" = "yes" ]; then 678 651 $IPTABLES -t nat -A $CHAIN_NAT_PREROUTING \ 679 -m set --set ${SETNAME}-vip src -j $CHAIN_NAT_VIP_PREROUTING 680 681 $IPTABLES -t nat -A $CHAIN_NAT_VIP_PREROUTING -j ACCEPT 652 -m set --set rahunas_serviceclass src -j ACCEPT 682 653 fi 683 654 … … 686 657 then 687 658 $IPTABLES -t nat -A $CHAIN_NAT_PREROUTING -p tcp --dport http \ 688 -d !$VSERVER_IP \659 ! -d $VSERVER_IP \ 689 660 -m connmark --mark 2/2 -j REDIRECT --to-ports $PROXY_PORT 690 661 else 691 662 $IPTABLES -t nat -A $CHAIN_NAT_PREROUTING -p tcp --dport http \ 692 -d !$VSERVER_IP \663 ! -d $VSERVER_IP \ 693 664 -m connmark --mark 2/2 \ 694 665 -j DNAT --to-destination $PROXY_HOST:$PROXY_PORT … … 702 673 703 674 $IPTABLES -t nat -A $CHAIN_NAT_PREROUTING -p tcp -m multiport \ 704 --dports $VSERVER_PORTS_INTERCEPT -d !$VSERVER_IP \675 --dports $VSERVER_PORTS_INTERCEPT ! -d $VSERVER_IP \ 705 676 -m connmark ! --mark 2/2 \ 706 677 -j $CHAIN_NAT_AUTHEN … … 712 683 # MASQUERADE 713 684 ## 714 if [ "$VIPMAP" = "yes" ]; then715 $IPTABLES -t nat -A $CHAIN_NAT_POSTROUTING \716 -m set --set ${SETNAME}-vip src -j $CHAIN_NAT_VIP_POSTROUTING717 fi718 719 685 if [ "$MASQUERADE" = "yes" ]; then 720 686 $IPTABLES -t nat -A $CHAIN_NAT_POSTROUTING -j MASQUERADE … … 744 710 $IPTABLES -t nat -A $CHAIN_NAT_PREROUTING -j RETURN 745 711 $IPTABLES -t nat -A $CHAIN_NAT_POSTROUTING -j RETURN 746 747 if [ "$VIPMAP" = "yes" ]; then 748 $IPTABLES -t nat -A $CHAIN_NAT_VIP_PREROUTING -j RETURN 749 $IPTABLES -t nat -A $CHAIN_NAT_VIP_POSTROUTING -j RETURN 750 751 if [ "$VIPMAP_FAKE_ARP" = "yes" ]; then 752 for dev in $DEV_EXTERNAL_LIST; do 753 $FARPD -i $dev $VIPMAP_NETWORK 754 done 755 fi 712 } 713 714 ## 715 # Service class set 716 ## 717 serviceclass_set () { 718 opt=$1 719 if [ "$opt" = "start" ]; then 720 $IPSET -N rahunas_serviceclass rahunas_ipiphash 721 elif [ "$opt" = "cleanup" ]; then 722 $IPSET -F rahunas_serviceclass 723 $IPSET -X rahunas_serviceclass 724 fi 725 } 726 727 ## 728 # Service class rules 729 ## 730 serviceclass_rules () { 731 opt=$1 732 if [ "$opt" = "start" ]; then 733 action="-I" 734 elif [ "$opt" = "stop" ]; then 735 action="-D" 736 fi 737 738 if [ "$MAIN_SERVICECLASS" = "yes" -o "$opt" = "stop" ]; then 739 # RAW - Service class 740 $IPTABLES -t raw $action PREROUTING \ 741 -m set --set rahunas_serviceclass src \ 742 -j RAHURAWDNAT --bind-set rahunas_serviceclass 743 744 $IPTABLES -t rawpost $action POSTROUTING \ 745 -m set --set rahunas_serviceclass dst \ 746 -j RAHURAWSNAT --bind-set rahunas_serviceclass 756 747 fi 757 748 } … … 790 781 policy 791 782 783 if [ "$MAIN_SERVICECLASS" = "yes" ]; then 784 serviceclass_set start 785 serviceclass_rules start 786 fi 787 792 788 touch $RUN 793 789 } … … 795 791 stop () { 796 792 test -f $RUN || return 0 793 794 serviceclass_rules stop 795 serviceclass_set cleanup 797 796 798 797 cleanup_policy -
weblogin/login.php
r51ab753 r43154f8 46 46 $config = get_config_by_network($ip, $config_list); 47 47 $vserver_id = $config["VSERVER_ID"]; 48 $vip_user = 0;49 48 50 49 $forward = false; … … 103 102 $racct->gen_session_id(); 104 103 105 if ($config["VIPMAP"] == "yes" &&106 !empty ($rauth->attributes[$config["VIPMAP_ATTRIBUTE"]])) {107 $vip_user = 1;108 }109 110 111 104 try { 112 105 $prepareData = array ( … … 118 111 "Bandwidth-Max-Down" => $rauth->attributes['WISPr-Bandwidth-Max-Down'], 119 112 "Bandwidth-Max-Up" => $rauth->attributes['WISPr-Bandwidth-Max-Up'], 120 " Vip_User" => $vip_user,113 "Class-Of-Service" => $rauth->attributes['WISPr-Billing-Class-Of-Service'], 121 114 ); 122 115 $result = $xmlrpc->do_startsession($vserver_id, $prepareData); … … 125 118 $forward = false; 126 119 } else if (strstr($result, "Greeting")) { 127 $split = explode (" VIP-IP", $result);120 $split = explode ("Mapping ", $result); 128 121 $called_station_id = $split[1]; 129 122 if (!empty ($called_station_id))
