Skip to content

Commit ebfb957

Browse files
committed
Merge
2 parents ce9ece6 + 74abab4 commit ebfb957

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1023
-4106
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
graftcp
2+
local/cmd/graftcp-local/graftcp-local
3+
local/cmd/mgraftcp/mgraftcp
4+
5+
*.o
6+
*.d
7+
*.a

Makefile

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# "Makefile" for graftcp.
2-
# Copyright (C) 2016, 2018, 2020 Hmgle <[email protected]>
2+
# Copyright (C) 2016, 2018, 2020, 2021 Hmgle <[email protected]>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -36,33 +36,37 @@ else
3636
endif
3737

3838
ifneq ($(shell echo $(VERSION) | head -c 1), v)
39-
VERSION=v0.3
39+
VERSION=v0.4
4040
endif
4141
CFLAGS += -DVERSION=\"$(VERSION)\"
4242

4343
SRC := $(wildcard *.c)
4444

45-
GRAFTCP_LOCAL_BIN = graftcp-local/graftcp-local
45+
GRAFTCP_LOCAL_BIN = local/graftcp-local local/mgraftcp
4646
TARGET = graftcp $(GRAFTCP_LOCAL_BIN)
4747

4848
all:: $(TARGET)
4949

50-
graftcp: main.o util.o string-set.o
50+
51+
graftcp: main.o graftcp.o util.o string-set.o
5152
$(CC) $^ -o $@
5253

54+
libgraftcp.a: graftcp.o util.o string-set.o
55+
$(AR) rcs $@ $^
56+
5357
%.o: %.c
5458
$(CC) $(CFLAGS) -c -o $@ $<
5559

5660
$(GRAFTCP_LOCAL_BIN)::
57-
$(MAKE) -C graftcp-local VERSION=$(VERSION)
61+
$(MAKE) -C local VERSION=$(VERSION)
5862

5963
install:: graftcp $(GRAFTCP_LOCAL_BIN)
6064
$(INSTALL) $< $(DESTDIR)$(BINDIR)/$<
61-
$(MAKE) -C graftcp-local $@
65+
$(MAKE) -C local $@
6266

6367
uninstall::
6468
-rm -f $(DESTDIR)$(BINDIR)/graftcp
65-
$(MAKE) -C graftcp-local $@
69+
$(MAKE) -C local $@
6670

6771
install_graftcp:: graftcp
6872
$(INSTALL) $< $(DESTDIR)$(BINDIR)/$<
@@ -71,16 +75,16 @@ uninstall_graftcp::
7175
-rm -f $(DESTDIR)$(BINDIR)/graftcp
7276

7377
install_systemd::
74-
$(MAKE) -C graftcp-local install_systemd
78+
$(MAKE) -C local install_systemd
7579

7680
uninstall_systemd::
77-
$(MAKE) -C graftcp-local uninstall_systemd
81+
$(MAKE) -C local uninstall_systemd
7882

7983
install_graftcp_local::
80-
$(MAKE) -C graftcp-local install
84+
$(MAKE) -C local install
8185

8286
uninstall_graftcp_local::
83-
$(MAKE) -C graftcp-local uninstall
87+
$(MAKE) -C local uninstall
8488

8589
sinclude $(SRC:.c=.d)
8690

@@ -91,5 +95,5 @@ sinclude $(SRC:.c=.d)
9195
rm -f $@.$$$$
9296

9397
clean::
94-
-rm -f *.o graftcp *.d
95-
$(MAKE) -C graftcp-local $@
98+
-rm -f *.o *.a graftcp *.d
99+
$(MAKE) -C local $@

README.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ git clone https://github.com/hmgle/graftcp.git
2828
cd graftcp
2929
make
3030
```
31-
After make finishes, you'll be able to use `graftcp-local/graftcp-local` and `./graftcp`.
31+
After make finishes, you'll be able to use `local/graftcp-local` and `./graftcp`.
3232
Optionally, you can also install them to system:
3333

3434
```sh
@@ -46,8 +46,8 @@ Download the [Debian](https://github.com/hmgle/graftcp/releases/download/v0.3.1/
4646
`graftcp-local`:
4747

4848
```console
49-
$ graftcp-local/graftcp-local -h
50-
Usage of graftcp-local/graftcp-local:
49+
$ local/graftcp-local -h
50+
Usage of local/graftcp-local:
5151
-config string
5252
Path to the configuration file
5353
-http_proxy string
@@ -96,12 +96,51 @@ Options:
9696
Display this help and exit
9797
```
9898

99+
`mgraftcp`: Combined `graftcp-local` and `graftcp` (`mgraftcp` = `graftcp-local` + `graftcp`).
100+
`mgraftcp` can be used to replace `graftcp` without running `graftcp-local`.
101+
102+
```console
103+
Usage: mgraftcp [-hn] [-b value] [--enable-debug-log] [--http_proxy value] [--select_proxy_mode value] \
104+
[--socks5 value] [--socks5_password value] [--socks5_username value] [--version] [-w value] prog [prog-args]
105+
-b, --blackip-file=value
106+
The IP in black-ip-file will connect direct
107+
--enable-debug-log
108+
enable debug log
109+
-h, --help Display this help and exit
110+
--http_proxy=value
111+
http proxy address, e.g.: 127.0.0.1:8080
112+
-n, --not-ignore-local
113+
Connecting to local is not changed by default, this option
114+
will redirect it to SOCKS5
115+
--select_proxy_mode=value
116+
Set the mode for select a proxy [auto | random |
117+
only_http_proxy | only_socks5 | direct] [auto]
118+
--socks5=value
119+
SOCKS5 address [127.0.0.1:1080]
120+
--socks5_password=value
121+
SOCKS5 password
122+
--socks5_username=value
123+
SOCKS5 username
124+
--version Print the mgraftcp version information
125+
-w, --whiteip-file=value
126+
Only redirect the connect that destination ip in the
127+
white-ip-file to SOCKS5
128+
```
129+
130+
### Configuration
131+
132+
`graftcp-local` and `mgraftcp` look for config file in following order:
133+
134+
1. File provided as a `--config` argument
135+
2. `$(the path of the executeable)/graftcp-local.conf`
136+
3. `/etc/graftcp-local/graftcp-local.conf`
137+
99138
## Demo
100139

101140
Assume you are running the SOCKS5 proxy with the default IP address: "localhost:1080". Start the `graftcp-local` first:
102141

103142
```sh
104-
graftcp-local/graftcp-local
143+
local/graftcp-local
105144
```
106145

107146
Install the Go package from golang.org (now is blocked by the GFW) via `graftcp`:
@@ -204,6 +243,6 @@ No. macOS's [`ptrace(2)`](http://polarhome.com/service/man/?qf=ptrace&af=0&sf=0&
204243

205244
## LICENSE
206245

207-
Copyright &copy; 2016, 2018-2020 Hmgle <[email protected]>
246+
Copyright &copy; 2016, 2018-2021 Hmgle <[email protected]>
208247

209248
Released under the terms of the [GNU General Public License, version 3](https://www.gnu.org/licenses/gpl-3.0.html)

README.zh-CN.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,44 @@ Options:
9090
Display this help and exit
9191
```
9292

93+
`mgraftcp`: 是 `graftcp-local``graftcp` 的结合(`mgraftcp` = `graftcp-local` + `graftcp`),可以用 `mgraftcp` 来代替 `graftcp` 而无需启动 `graftcp-local`
94+
95+
```console
96+
Usage: mgraftcp [-hn] [-b value] [--enable-debug-log] [--http_proxy value] [--select_proxy_mode value] \
97+
[--socks5 value] [--socks5_password value] [--socks5_username value] [--version] [-w value] prog [prog-args]
98+
-b, --blackip-file=value
99+
The IP in black-ip-file will connect direct
100+
--enable-debug-log
101+
enable debug log
102+
-h, --help Display this help and exit
103+
--http_proxy=value
104+
http proxy address, e.g.: 127.0.0.1:8080
105+
-n, --not-ignore-local
106+
Connecting to local is not changed by default, this option
107+
will redirect it to SOCKS5
108+
--select_proxy_mode=value
109+
Set the mode for select a proxy [auto | random |
110+
only_http_proxy | only_socks5 | direct] [auto]
111+
--socks5=value
112+
SOCKS5 address [127.0.0.1:1080]
113+
--socks5_password=value
114+
SOCKS5 password
115+
--socks5_username=value
116+
SOCKS5 username
117+
--version Print the mgraftcp version information
118+
-w, --whiteip-file=value
119+
Only redirect the connect that destination ip in the
120+
white-ip-file to SOCKS5
121+
```
122+
123+
### 配置文件
124+
125+
`graftcp-local``mgraftcp` 按下面的顺序查找配置文件:
126+
127+
1. 参数 `--config` 指定的文件
128+
2. `$(可执行文件所在的目录)/graftcp-local.conf`
129+
3. `/etc/graftcp-local/graftcp-local.conf`
130+
93131
## 使用示例
94132

95133
假设你正在运行默认地址 "localhost:1080" 的 SOCKS5 代理,首先启动 `graftcp-local`
@@ -198,6 +236,6 @@ Linux 提供了一种限制被 `ptrace(2)` 跟踪的方法:设置 [`/proc/sys/
198236

199237
## License
200238

201-
Copyright &copy; 2016, 2018-2020 Hmgle <[email protected]>
239+
Copyright &copy; 2016, 2018-2021 Hmgle <[email protected]>
202240

203241
根据 [GPLv3 许可](https://www.gnu.org/licenses/gpl-3.0.html)发布。

graftcp-local/vendor/github.com/hashicorp/go-syslog/LICENSE

Lines changed: 0 additions & 20 deletions
This file was deleted.

graftcp-local/vendor/github.com/hashicorp/go-syslog/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)