-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshadowsocksr.patch
57 lines (52 loc) · 1.62 KB
/
shadowsocksr.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
diff --git a/src/local.c b/src/local.c
index a7e2d70..d1fb885 100644
--- a/src/local.c
+++ b/src/local.c
@@ -687,7 +687,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
ss_free(hostname);
} else {
- strncpy(host, ip, sizeof(ip));
+ strncpy(host, ip, sizeof(host));
}
}
diff --git a/src/redir.c b/src/redir.c
index 4345a36..88e50f7 100644
--- a/src/redir.c
+++ b/src/redir.c
@@ -1060,6 +1060,7 @@ main(int argc, char **argv)
int pid_flags = 0;
int mptcp = 0;
int mtu = 0;
+ char *up = NULL;
char *user = NULL;
char *local_port = NULL;
char *local_addr = NULL;
@@ -1086,6 +1087,7 @@ main(int argc, char **argv)
{ "mtu", required_argument, 0, 0 },
{ "mptcp", no_argument, 0, 0 },
{ "help", no_argument, 0, 0 },
+ { "up", required_argument, 0, 0 },
{ 0, 0, 0, 0 }
};
@@ -1107,6 +1109,9 @@ main(int argc, char **argv)
} else if (option_index == 2) {
usage();
exit(EXIT_SUCCESS);
+ } else if (option_index == 3) {
+ up = optarg;
+ LOGI("set up script %s", up);
}
break;
case 's':
@@ -1466,6 +1471,13 @@ main(int argc, char **argv)
LOGI("running from root user");
}
+ // Call up script
+ if (up != NULL) {
+ if (fork() == 0) {
+ execlp(up, up, (char *)NULL);
+ }
+ }
+
ev_run(loop, 0);
// TODO: release?