-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
246 lines (195 loc) · 6.74 KB
/
Makefile
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#GOPATH=$(HOME)/go
packagename = sam-forwarder
samcatd = samcatd
network = host
samhost = sam-host
samport = 7656
args = -r
USER_GH=eyedeekay
PREFIX := /
VAR := var/
RUN := run/
LIB := lib/
LOG := log/
ETC := etc/
USR := usr/
LOCAL := local/
VERSION := 0.33.2
GO111MODULE=on
echo:
@echo "$(GOPATH)"
find . -path ./.go -prune -o -name "*.go" -exec gofmt -w {} \;
find . -path ./.go -prune -o -name "*.i2pkeys" -exec rm {} \;
find . -path ./.go -prune -o -name "*.pem" -exec rm {} \;
find . -path ./.go -prune -o -name "*.go" -exec cat {} \; | nl
tag:
gothub release -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION) -d "I2P Tunnel Management tool for Go applications"
recopy:
#find ./tcp/ -name '*.go' -exec cp -rv {} . \;
#sed -i '1s|^|//AUTO-GENERATED FOR BACKWARD COMPATIBILITY, USE ./tcp in the future\n|' *.go
## TODO: Remove this, replace with something right
fix-debian:
find ./debian -type f -exec sed -i 's|lair repo key|eyedeekay|g' {} \;
find ./debian -type f -exec sed -i 's|[email protected]|[email protected]|g' {} \;
try:
./bin/samcatd-cli -f etc/samcatd/tunnels.ini
test: test-keys test-ntcp test-ssu test-config test-manager
long-test: test-serve test
full-test: test test-serve
test-serve:
go test -v -tags netgo \
-ldflags '-w -extldflags "-static"' ./serve_test
test-ntcp:
go test -v -tags netgo \
-ldflags '-w -extldflags "-static"' ./tcp
test-ssu:
go test -v -tags netgo \
-ldflags '-w -extldflags "-static"' ./udp
test-config:
go test -v -tags netgo \
-ldflags '-w -extldflags "-static"' ./config
test-manager:
go test -v -tags "netgo cli" \
-ldflags '-w -extldflags "-static"' ./manager
test-keys:
go test -v -tags netgo \
-ldflags '-w -extldflags "-static"' ./i2pkeys
refresh:
deps:
go get -u -d github.com/eyedeekay/sam-forwarder/samcatd
install:
install -m755 ./bin/$(samcatd) $(PREFIX)$(USR)$(LOCAL)/bin/
install -m644 ./etc/init.d/samcatd $(PREFIX)$(ETC)/init.d
mkdir -p $(PREFIX)$(ETC)/samcatd/ $(PREFIX)$(ETC)/sam-forwarder/ $(PREFIX)$(ETC)/i2pvpn/
install -m644 ./etc/samcatd/tunnels.ini $(PREFIX)$(ETC)/samcatd/
install -m644 ./etc/sam-forwarder/tunnels.ini $(PREFIX)$(ETC)/sam-forwarder/
daemon: clean-daemon bin/$(samcatd)
daemon-webview: bin/$(samcatd)-webview
daemon-cli: bin/$(samcatd)-cli
bin/$(samcatd)-cli:
mkdir -p bin
go build -a -tags "netgo cli" \
-ldflags '-w -extldflags "-static"' \
-o ./bin/$(samcatd)-cli \
./samcatd/*.go
bin/$(samcatd):
mkdir -p bin
go build -a -tags "netgo static" \
-ldflags '-w -extldflags "-static"' \
-o ./bin/$(samcatd) \
./samcatd/*.go
bin/$(samcatd)-webview:
mkdir -p bin
go build -a -tags "netgo nostatic" \
-o ./bin/$(samcatd)-webview \
./samcatd/*.go
update:
git config --global url."[email protected]:RTradeLtd".insteadOf "https://github.com/RTradeLtd"
all: daemon-cli daemon daemon-webview
clean: clean-all echo
clean-all: clean-daemon
clean-daemon:
rm -f bin/$(samcatd)*
install-forwarder:
install -m755 bin/$(samcatd) /usr/local/bin/$(samcatd)
install-all: install
gendoc:
@echo "$(samcatd) - Router-independent tunnel management for i2p" > USAGE.md
@echo "=========================================================" >> USAGE.md
@echo "" >> USAGE.md
@echo "$(samcatd) is a daemon which runs a group of forwarding proxies to" >> USAGE.md
@echo "provide services over i2p independent of the router. It also serves" >> USAGE.md
@echo "as a generalized i2p networking utility for power-users. It's" >> USAGE.md
@echo "intended to be a Swiss-army knife for the SAM API." >> USAGE.md
@echo "" >> USAGE.md
@echo "usage:" >> USAGE.md
@echo "------" >> USAGE.md
@echo "" >> USAGE.md
@echo '```' >> USAGE.md
./bin/$(samcatd) -h 2>> USAGE.md; true
@echo '```' >> USAGE.md
@echo "" >> USAGE.md
make key-management
make example-config
key-management:
@echo "managing $(samcatd) save-encryption keys" >> USAGE.md
@echo "=====================================" >> USAGE.md
@echo "" >> USAGE.md
@echo "In order to keep from saving the .i2pkeys files in plaintext format, samcatd" >> USAGE.md
@echo "can optionally generate a key and encrypt the .i2pkeys files securely. Of" >> USAGE.md
@echo "course, to fully benefit from this arrangement, you need to move those keys" >> USAGE.md
@echo "away from the machine where the tunnel keys(the .i2pkeys file) are located," >> USAGE.md
@echo "or protect them in some other way(sandboxing, etc). If you want to use" >> USAGE.md
@echo "encrypted .i2pkeys files, you can specify a key file to use with the -cr" >> USAGE.md
@echo "option on the terminal or with keyfile option in the .ini file." >> USAGE.md
@echo "" >> USAGE.md
example-config:
@echo "example config - valid for both ephsite and samcat" >> USAGE.md
@echo "==================================================" >> USAGE.md
@echo "" >> USAGE.md
@echo "Options are still being added, pretty much as fast as I can put them" >> USAGE.md
@echo "in. For up-to-the-minute options, see [the checklist](config/CHECKLIST.md)" >> USAGE.md
@echo "" >> USAGE.md
@echo "(**ephsite** will only use top-level options, but they can be labeled or" >> USAGE.md
@echo "unlabeled)" >> USAGE.md
@echo "" >> USAGE.md
@echo "(**samcatd** treats the first set of options it sees as the default, and" >> USAGE.md
@echo "does not start tunnels based on unlabeled options unless passed the" >> USAGE.md
@echo "-s flag.)" >> USAGE.md
@echo "" >> USAGE.md
@echo '``` ini' >> USAGE.md
cat etc/samcatd/tunnels.ini >> USAGE.md
@echo '```' >> USAGE.md
@echo "" >> USAGE.md
mv USAGE.md docs/USAGE.md
docker-build:
docker build --build-arg user=$(samcatd) \
-f Dockerfile \
-t eyedeekay/$(samcatd) .
docker-run:
docker rm -f $(samcatd); true
docker run -i -t -d \
--cap-add "net_bind_service" \
--network $(network) \
--env samhost=$(samhost) \
--env samport=$(samport) \
--env args=$(args) \
--hostname $(samcatd) \
--name $(samcatd) \
--restart always \
-p 127.0.0.1:7957:7957 \
eyedeekay/$(samcatd)
make follow
follow:
docker logs -f $(samcatd)
docker: docker-build docker-run
index:
cp README.md docs/README.md
cd docs && edgar
visit:
http_proxy=http://127.0.0.1:4444 surf http://566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq.b32.i2p
gojs:
go get -u github.com/gopherjs/gopherjs
GOPHERJS=$(GOPATH)/bin/gopherjs
js:
mkdir -p bin
$(GOPHERJS) build -v --tags netgo \
-o ./javascript/$(samcatd).js \
./samcatd/*.go
cleantar:
rm -f ../$(packagename)_$(VERSION).orig.tar.xz
tar:
tar --exclude .git \
--exclude .go \
--exclude bin \
-cJvf ../$(packagename)_$(VERSION).orig.tar.xz .
sed:
sed -i 's|func(\*Conf)|func(samtunnel.SAMTunnel)|g' ./config/*.go
sed -i 's|func(c \*Conf)|func(c samtunnel.SAMTunnel)|g' ./config/*.go
tasks:
golint ./tcp
#golint ./udp
#golint ./config
#golint ./config
#golint ./config
#golint ./config