-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HevSocks5Tunnel: Add tunnel post-up and pre-down script.
- Loading branch information
Showing
11 changed files
with
133 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
============================================================================ | ||
Name : hev-exec.c | ||
Author : hev <r@hev.cc> | ||
Copyright : Copyright (c) 2023 hev | ||
Description : Exec | ||
============================================================================ | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <signal.h> | ||
#include <unistd.h> | ||
#include <sys/wait.h> | ||
|
||
#include "hev-logger.h" | ||
|
||
#include "hev-exec.h" | ||
|
||
static void | ||
signal_handler (int signum) | ||
{ | ||
waitpid (-1, NULL, WNOHANG); | ||
} | ||
|
||
void | ||
hev_exec_run (const char *script_path, const char *tun_name, int wait) | ||
{ | ||
pid_t pid; | ||
|
||
signal (SIGCHLD, signal_handler); | ||
|
||
pid = fork (); | ||
if (pid < 0) { | ||
LOG_E ("exec fork"); | ||
return; | ||
} else if (pid != 0) { | ||
if (wait) | ||
waitpid (pid, NULL, 0); | ||
return; | ||
} | ||
|
||
execl (script_path, script_path, tun_name, NULL); | ||
|
||
LOG_E ("exec %s %s", script_path, tun_name); | ||
exit (-1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
============================================================================ | ||
Name : hev-exec.h | ||
Author : hev <r@hev.cc> | ||
Copyright : Copyright (c) 2023 hev | ||
Description : Exec | ||
============================================================================ | ||
*/ | ||
|
||
#ifndef __HEV_EXEC_H__ | ||
#define __HEV_EXEC_H__ | ||
|
||
void hev_exec_run (const char *script_path, const char *tun_name, int wait); | ||
|
||
#endif /* __HEV_EXEC_H__ */ |