Skip to content

Commit c0519e6

Browse files
committed
Add --version flag to display current program version
1 parent 9778f79 commit c0519e6

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

.github/workflows/release-build.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,70 +81,73 @@ jobs:
8181
run: |
8282
mkdir -p build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}
8383
84+
VERSION="${GITHUB_REF#refs/tags/}"
85+
GO_LDFLAGS="-s -w -X main.Version=${VERSION}"
86+
8487
case "${{ matrix.os }}_${{ matrix.arch }}" in
8588
windows_amd64)
8689
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 \
87-
go build -trimpath -ldflags="-s -w" \
90+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
8891
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus.exe .
8992
;;
9093
windows_arm64)
9194
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 \
92-
go build -trimpath -ldflags="-s -w" \
95+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
9396
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus.exe .
9497
;;
9598
darwin_amd64)
9699
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 \
97-
go build -trimpath -ldflags="-s -w" \
100+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
98101
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
99102
;;
100103
darwin_arm64)
101104
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 \
102-
go build -trimpath -ldflags="-s -w" \
105+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
103106
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
104107
;;
105108
linux_amd64)
106109
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
107-
go build -trimpath -ldflags="-s -w" \
110+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
108111
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
109112
;;
110113
linux_arm64)
111114
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 \
112-
go build -trimpath -ldflags="-s -w" \
115+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
113116
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
114117
;;
115118
linux_armv5)
116119
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 \
117-
go build -trimpath -ldflags="-s -w" \
120+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
118121
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
119122
;;
120123
linux_armv6)
121124
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 \
122-
go build -trimpath -ldflags="-s -w" \
125+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
123126
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
124127
;;
125128
linux_armv7)
126129
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 \
127-
go build -trimpath -ldflags="-s -w" \
130+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
128131
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
129132
;;
130133
linux_mips)
131134
CGO_ENABLED=0 GOOS=linux GOARCH=mips \
132-
go build -trimpath -ldflags="-s -w" \
135+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
133136
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
134137
;;
135138
linux_mipsle)
136139
CGO_ENABLED=0 GOOS=linux GOARCH=mipsle \
137-
go build -trimpath -ldflags="-s -w" \
140+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
138141
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
139142
;;
140143
linux_mips64)
141144
CGO_ENABLED=0 GOOS=linux GOARCH=mips64 \
142-
go build -trimpath -ldflags="-s -w" \
145+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
143146
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
144147
;;
145148
linux_mips64le)
146149
CGO_ENABLED=0 GOOS=linux GOARCH=mips64le \
147-
go build -trimpath -ldflags="-s -w" \
150+
go build -trimpath -ldflags="${GO_LDFLAGS}" \
148151
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
149152
;;
150153
*)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Place the `usque` binary in the same folder as this launcher (`Masque-Plus.exe`
4949
| `--scan-verbose-child` | Print MASQUE child process logs during scan. | false |
5050
| `--scan-tunnel-fail-limit` | Number of 'Failed to connect tunnel' occurrences before skipping an endpoint. | 2 |
5151
| `--scan-ordered` | Scan candidates in CIDR order (disable shuffling). | false |
52+
| `--version` | Show the current version of the program. | |
5253

5354
### Usque-Specific Flags (Passed Directly to `usque socks`)
5455

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net"
1212
"os"
1313
"os/exec"
14+
"runtime"
1415
"strconv"
1516
"strings"
1617
"sync"
@@ -61,9 +62,16 @@ var (
6162
reconnectDelay = 1 * time.Second
6263
sni = defaultSNI
6364
useIpv6 bool
65+
Version = "dev"
6466
)
6567

6668
func main() {
69+
if len(os.Args) == 2 && os.Args[1] == "--version" {
70+
logutil.Msg("INFO", fmt.Sprintf("Masque-Plus Version: %s", Version), nil)
71+
logutil.Msg("INFO", fmt.Sprintf("Environment: %s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH), nil)
72+
os.Exit(0)
73+
}
74+
6775
endpoint := flag.String("endpoint", "", "Endpoint to connect (IPv4, IPv6, domain; host or host:Port; for IPv6 with port use [IPv6]:Port)")
6876
bind := flag.String("bind", defaultBind, "IP:Port to bind SOCKS proxy")
6977
renew := flag.Bool("renew", false, "Force renewal of config even if config.json exists")

0 commit comments

Comments
 (0)