Skip to content

Commit

Permalink
Add graftcp-local version info
Browse files Browse the repository at this point in the history
  • Loading branch information
hmgle committed Dec 6, 2020
1 parent 80c3b25 commit e6235f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ graftcp: main.o util.o string-set.o
$(CC) $(CFLAGS) -c -o $@ $<

$(GRAFTCP_LOCAL_BIN)::
$(MAKE) -C graftcp-local
$(MAKE) -C graftcp-local VERSION=$(VERSION)

install:: graftcp $(GRAFTCP_LOCAL_BIN)
$(INSTALL) $< $(DESTDIR)$(BINDIR)/$<
Expand Down
6 changes: 5 additions & 1 deletion graftcp-local/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export GOPATH := $(CURDIR)/.gopath
export PATH := $(PATH):$(CURDIR)/.gopath/bin

ifneq ($(shell echo $(VERSION) | head -c 1), v)
VERSION=v0.3
endif

PREFIX = /usr/local
BINDIR = $(PREFIX)/bin

Expand All @@ -11,7 +15,7 @@ GO_IMPORT_PATH := github.com/hmgle/graftcp/graftcp-local
all:: graftcp-local

graftcp-local: .gopath/.created $(wildcard *.go)
go build -ldflags "-s -w" $(GO_IMPORT_PATH)
go build -ldflags "-s -w -X main.version=${VERSION}" $(GO_IMPORT_PATH)

.gopath/.created:
rm -rf .gopath
Expand Down
10 changes: 9 additions & 1 deletion graftcp-local/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import (
"github.com/kardianos/service"
)

var selectProxyMode string
var (
selectProxyMode string
version = "v0.3"
)

type App struct {
ListenAddr string
Expand Down Expand Up @@ -86,7 +89,12 @@ func main() {
"Set the mode for select a proxy [auto | random | only_http_proxy | only_socks5]")
flag.StringVar(&configFile, "config", "", "Path to the configuration file")
flag.StringVar(&app.PipePath, "pipepath", "/tmp/graftcplocal.fifo", "Pipe path for graftcp to send address info")
v := flag.Bool("version", false, "Print the graftcp-local version information")
flag.Parse()
if *v {
fmt.Printf("graftcp-local version %s\n", version)
os.Exit(0)
}
ParseConfigFile(configFile, app)
dlog.Noticef("graftcp-local start")

Expand Down

0 comments on commit e6235f7

Please sign in to comment.