2 #include <netinet/ip6.h>
10 int plugin_api_version
= PLUGIN_API_VERSION
;
11 static struct pluginfuncs
*f
= 0;
13 char *plugin_control_help
[] = {
14 " drop USER|SID [REASON] Shutdown user session",
15 " kill USER|SID [REASON] Kill user session",
19 int plugin_control(struct param_control
*data
)
29 if (strcmp(data
->argv
[0], "drop") && strcmp(data
->argv
[0], "kill"))
30 return PLUGIN_RET_OK
; // not for us
32 if (!data
->iam_master
)
33 return PLUGIN_RET_NOTMASTER
;
35 if (data
->argc
< 2 || data
->argc
> 3)
37 data
->response
= NSCTL_RES_ERR
;
38 data
->additional
= "requires username or session id and optional reason";
39 return PLUGIN_RET_STOP
;
42 if (!(session
= strtol(data
->argv
[1], &end
, 10)) || *end
)
43 session
= f
->get_session_by_username(data
->argv
[1]);
46 s
= f
->get_session_by_id(session
);
50 data
->response
= NSCTL_RES_ERR
;
51 data
->additional
= "session not found";
52 return PLUGIN_RET_STOP
;
56 reason
= data
->argv
[2];
58 reason
= "Requested by administrator.";
60 if (data
->argv
[0][0] == 'd')
61 f
->sessionshutdown(session
, reason
, CDN_ADMIN_DISC
, TERM_ADMIN_RESET
);
63 f
->sessionkill(session
, reason
);
65 data
->response
= NSCTL_RES_OK
;
68 return PLUGIN_RET_STOP
;
71 int plugin_init(struct pluginfuncs
*funcs
)
73 return ((f
= funcs
)) ? 1 : 0;