This commit is contained in:
Brendan O'Dea 2004-10-30 07:35:31 +00:00
parent 8e9fcdba98
commit 6f73a1b071
2 changed files with 20 additions and 19 deletions

23
cli.c
View file

@ -2,7 +2,7 @@
// vim: sw=8 ts=8 // vim: sw=8 ts=8
char const *cvs_name = "$Name: $"; char const *cvs_name = "$Name: $";
char const *cvs_id_cli = "$Id: cli.c,v 1.18 2004-10-28 03:31:11 bodea Exp $"; char const *cvs_id_cli = "$Id: cli.c,v 1.19 2004-10-30 07:35:31 bodea Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
@ -566,6 +566,7 @@ int cmd_show_tunnels(struct cli_def *cli, char *command, char **argv, int argc)
"IP", "IP",
"State", "State",
"Sessions"); "Sessions");
for (i = 1; i < MAXTUNNEL; i++) for (i = 1; i < MAXTUNNEL; i++)
{ {
int sessions = 0; int sessions = 0;
@ -579,6 +580,7 @@ int cmd_show_tunnels(struct cli_def *cli, char *command, char **argv, int argc)
states[tunnel[i].state], states[tunnel[i].state],
sessions); sessions);
} }
return CLI_OK; return CLI_OK;
} }
@ -968,12 +970,9 @@ int cmd_show_plugins(struct cli_def *cli, char *command, char **argv, int argc)
cli_print(cli, "Plugins currently loaded:"); cli_print(cli, "Plugins currently loaded:");
for (i = 0; i < MAXPLUGINS; i++) for (i = 0; i < MAXPLUGINS; i++)
{
if (*config->plugins[i]) if (*config->plugins[i])
{
cli_print(cli, " %s", config->plugins[i]); cli_print(cli, " %s", config->plugins[i]);
}
}
return CLI_OK; return CLI_OK;
} }
@ -996,6 +995,7 @@ int cmd_show_throttle(struct cli_def *cli, char *command, char **argv, int argc)
session[i].tbf_in, session[i].tbf_in,
session[i].tbf_out); session[i].tbf_out);
} }
return CLI_OK; return CLI_OK;
} }
@ -1201,7 +1201,7 @@ int cmd_snoop(struct cli_def *cli, char *command, char **argv, int argc)
if (argc < 3) if (argc < 3)
{ {
cli_print(cli, "Specify username ip port"); cli_print(cli, "Specify username, ip and port");
return CLI_OK; return CLI_OK;
} }
@ -1240,7 +1240,7 @@ int cmd_no_snoop(struct cli_def *cli, char *command, char **argv, int argc)
if (CLI_HELP_REQUESTED) if (CLI_HELP_REQUESTED)
return cli_arg_help(cli, argc > 1, return cli_arg_help(cli, argc > 1,
"USER", "Username of session to un-snoop", NULL); "USER", "Username of session to unsnoop", NULL);
if (!config->cluster_iam_master) if (!config->cluster_iam_master)
{ {
@ -1250,7 +1250,7 @@ int cmd_no_snoop(struct cli_def *cli, char *command, char **argv, int argc)
if (!argc) if (!argc)
{ {
cli_print(cli, "Specify a user"); cli_print(cli, "Specify a user to unsnoop");
return CLI_OK; return CLI_OK;
} }
@ -1265,6 +1265,7 @@ int cmd_no_snoop(struct cli_def *cli, char *command, char **argv, int argc)
cli_print(cli, "Not snooping user %s", argv[i]); cli_print(cli, "Not snooping user %s", argv[i]);
cli_session_actions[s].action |= CLI_SESS_NOSNOOP; cli_session_actions[s].action |= CLI_SESS_NOSNOOP;
} }
return CLI_OK; return CLI_OK;
} }
@ -1300,7 +1301,7 @@ int cmd_throttle(struct cli_def *cli, char *command, char **argv, int argc)
if (argc == 0) if (argc == 0)
{ {
cli_print(cli, "You must specify at least a username"); cli_print(cli, "Specify a user to throttle");
return CLI_OK; return CLI_OK;
} }
@ -1334,7 +1335,7 @@ int cmd_no_throttle(struct cli_def *cli, char *command, char **argv, int argc)
if (CLI_HELP_REQUESTED) if (CLI_HELP_REQUESTED)
return cli_arg_help(cli, argc > 1, return cli_arg_help(cli, argc > 1,
"USER", "Username of session to un-throttle", NULL); "USER", "Username of session to unthrottle", NULL);
if (!config->cluster_iam_master) if (!config->cluster_iam_master)
{ {
@ -1344,7 +1345,7 @@ int cmd_no_throttle(struct cli_def *cli, char *command, char **argv, int argc)
if (!argc) if (!argc)
{ {
cli_print(cli, "Specify a user"); cli_print(cli, "Specify a user to unthrottle");
return CLI_OK; return CLI_OK;
} }

View file

@ -7,7 +7,7 @@
#include "plugin.h" #include "plugin.h"
#include "control.h" #include "control.h"
char const *cvs_id = "$Id: garden.c,v 1.7 2004-06-28 02:43:13 fred_nerk Exp $"; char const *cvs_id = "$Id: garden.c,v 1.8 2004-10-30 07:35:31 bodea Exp $";
int __plugin_api_version = 1; int __plugin_api_version = 1;
static struct pluginfuncs *p = 0; static struct pluginfuncs *p = 0;
@ -18,7 +18,7 @@ char *up_commands[] = {
"iptables -t nat -N garden >/dev/null 2>&1", // Create a chain that all gardened users will go through "iptables -t nat -N garden >/dev/null 2>&1", // Create a chain that all gardened users will go through
"iptables -t nat -F garden", "iptables -t nat -F garden",
". " PLUGINCONF "/build-garden", // Populate with site-specific DNAT rules ". " PLUGINCONF "/build-garden", // Populate with site-specific DNAT rules
"iptables -t nat -N garden_users >/dev/null 2>&1",// Empty chain, users added/removed by garden_session "iptables -t nat -N garden_users >/dev/null 2>&1", // Empty chain, users added/removed by garden_session
"iptables -t nat -F garden_users", "iptables -t nat -F garden_users",
"iptables -t nat -A PREROUTING -j garden_users", // DNAT any users on the garden_users chain "iptables -t nat -A PREROUTING -j garden_users", // DNAT any users on the garden_users chain
"sysctl -w net.ipv4.ip_conntrack_max=256000 >/dev/null", // lots of entries "sysctl -w net.ipv4.ip_conntrack_max=256000 >/dev/null", // lots of entries
@ -149,7 +149,7 @@ int garden_session(sessiont *s, int flag)
if (flag == 1) if (flag == 1)
{ {
p->log(2, 0, 0, s->tunnel, "Garden user %s (%s)\n", s->user, p->inet_toa(htonl(s->ip))); p->log(2, 0, 0, s->tunnel, "Garden user %s (%s)\n", s->user, p->inet_toa(htonl(s->ip)));
snprintf(cmd, 2048, "iptables -t nat -A garden_users -s %s -j garden", p->inet_toa(htonl(s->ip))); snprintf(cmd, sizeof(cmd), "iptables -t nat -A garden_users -s %s -j garden", p->inet_toa(htonl(s->ip)));
p->log(3, 0, 0, s->tunnel, "%s\n", cmd); p->log(3, 0, 0, s->tunnel, "%s\n", cmd);
system(cmd); system(cmd);
s->walled_garden = 1; s->walled_garden = 1;
@ -170,7 +170,7 @@ int garden_session(sessiont *s, int flag)
s->cin = s->cout = 0; s->cin = s->cout = 0;
s->pin = s->pout = 0; s->pin = s->pout = 0;
snprintf(cmd, 2048, "iptables -t nat -D garden_users -s %s -j garden", p->inet_toa(htonl(s->ip))); snprintf(cmd, sizeof(cmd), "iptables -t nat -D garden_users -s %s -j garden", p->inet_toa(htonl(s->ip)));
p->log(3, 0, 0, s->tunnel, "%s\n", cmd); p->log(3, 0, 0, s->tunnel, "%s\n", cmd);
while (--count) while (--count)
{ {