mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 10:35:53 +02:00
wireguard: add wireguardctrl
commit f552e23da404adf4555299c887a0279016323df4 Author: Michael Tremer <michael.tremer@ipfire.org> Date: Wed Apr 17 17:13:32 2024 +0000 misc-progs: Add wireguardctrl Signed-off-by: Michael Tremer <michael.tremer@ipfire.org> Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ SUID_PROGS = squidctrl sshctrl ipfirereboot \
|
||||
smartctrl clamavctrl addonctrl pakfire wlanapctrl \
|
||||
setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes \
|
||||
getconntracktable wirelessclient torctrl ddnsctrl unboundctrl \
|
||||
captivectrl tcpddosctrl
|
||||
captivectrl wireguardctrl tcpddosctrl
|
||||
|
||||
OBJS = $(patsubst %,%.o,$(PROGS) $(SUID_PROGS))
|
||||
|
||||
|
||||
44
src/misc-progs/wireguardctrl.c
Normal file
44
src/misc-progs/wireguardctrl.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* This file is part of the IPFire Firewall.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "setuid.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// Become root
|
||||
if (!initsetuid())
|
||||
exit(1);
|
||||
|
||||
// Check if we have enough arguments
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "\nNot enough arguments.\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "start") == 0) {
|
||||
return run("/etc/rc.d/init.d/wireguard", argv + 1);
|
||||
|
||||
} else if (strcmp(argv[1], "stop") == 0) {
|
||||
return run("/etc/rc.d/init.d/wireguard", argv + 1);
|
||||
|
||||
} else if (strcmp(argv[1], "dump") == 0) {
|
||||
char* args[] = {
|
||||
"show",
|
||||
(argc > 2) ? argv[2] : "wg0",
|
||||
"dump",
|
||||
NULL,
|
||||
};
|
||||
|
||||
return run("/usr/bin/wg", args);
|
||||
|
||||
}
|
||||
|
||||
fprintf(stderr, "Invalid command\n");
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user