-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
Makefile
52 lines (39 loc) · 1.71 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
ifdef RSSH_HOMESERVER
LDFLAGS += -X main.destination=$(RSSH_HOMESERVER)
endif
ifdef RSSH_FINGERPRINT
LDFLAGS += -X main.fingerprint=$(RSSH_FINGERPRINT)
endif
ifdef RSSH_PROXY
LDFLAGS += -X main.proxy=$(RSSH_PROXY)
endif
ifdef IGNORE
LDFLAGS += -X main.ignoreInput=$(IGNORE)
endif
ifndef CGO_ENABLED
export CGO_ENABLED=0
endif
BUILD_FLAGS := -trimpath
LDFLAGS += -X 'github.com/NHAS/reverse_ssh/internal.Version=$(shell git describe --tags)'
LDFLAGS_RELEASE = $(LDFLAGS) -s -w
debug: .generate_keys
go build $(BUILD_FLAGS) -ldflags="$(LDFLAGS)" -o bin ./...
GOOS=windows GOARCH=amd64 go build $(BUILD_FLAGS) -ldflags="$(LDFLAGS)" -o bin ./cmd/client
release: .generate_keys
go build $(BUILD_FLAGS) -ldflags="$(LDFLAGS_RELEASE)" -o bin ./...
GOOS=windows GOARCH=amd64 go build $(BUILD_FLAGS) -ldflags="$(LDFLAGS_RELEASE)" -o bin ./cmd/client
client: .generate_keys
go build $(BUILD_FLAGS) -ldflags="$(LDFLAGS_RELEASE)" -o bin ./cmd/client
client_dll: .generate_keys
test -n "$(RSSH_HOMESERVER)" # Shared objects cannot take arguments, so must have a callback server baked in (define RSSH_HOMESERVER)
CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags=cshared -buildmode=c-shared -ldflags="$(LDFLAGS_RELEASE)" -o bin/client.dll ./cmd/client
server:
mkdir -p bin
go build $(BUILD_FLAGS) -ldflags="$(LDFLAGS_RELEASE)" -o bin ./cmd/server
.generate_keys:
mkdir -p bin
# Supress errors if user doesn't overwrite existing key
ssh-keygen -t ed25519 -N '' -C '' -f internal/client/keys/private_key || true
# Avoid duplicate entries
touch bin/authorized_controllee_keys
@grep -q "$$(cat internal/client/keys/private_key.pub)" bin/authorized_controllee_keys || cat internal/client/keys/private_key.pub >> bin/authorized_controllee_keys