Skip to content

Commit

Permalink
Add version
Browse files Browse the repository at this point in the history
Signed-off-by: Joeky <joeky5888@gmail.com>
  • Loading branch information
joeky888 committed Dec 20, 2024
1 parent 59ea2de commit f7fbc96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Build
run: |
go build -ldflags "-s -w" -o "$BINARY" -v
go build -ldflags "-s -w" -o "$BINARY -X 'main.version=${{ github.ref_name }}'" -v
[ "$GOOS" = "windows" ] && zip "$PKG_NAME" "$BINARY" || tar zcvf "$PKG_NAME" "$BINARY"
- name: Release Notes
Expand Down
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"time"
"unsafe"

"log/slog"

"github.com/appleboy/graceful"
"github.com/valyala/fasthttp"
"log/slog"
)

const (
Expand All @@ -25,16 +26,20 @@ const (
)

var (
version = "dev"

addrF = flag.String("a", DefaultAddr, `Listen address.`)
maxConcurrentF = flag.Int("c", DefaultMaxConcurrent, "Max concurrency for fasthttp server")
dnsresolversF = flag.String("n", DefaultDNS, `DNS nameserves, E.g. "8.8.8.8:53" or "1.1.1.1:53,8.8.8.8:53". Default is empty`)
timeoutF = flag.Duration("t", DefaultTimeout, `Connection timeout. Examples: 1m or 10s`)
usageF = flag.Bool("h", false, "Show usage")
verF = flag.String("v", version, "Show version")

addr string
maxConcurrent int
dns []string
timeout time.Duration
ver string

defaultResolver = &net.Resolver{
PreferGo: true,
Expand Down Expand Up @@ -91,7 +96,11 @@ func init() {
defaultDialer.Resolver = defaultResolver
}

rand.Seed(time.Now().UnixNano())
if verF != nil {
ver = *verF
} else {
ver = version
}
}

func randomDNS() string {
Expand Down Expand Up @@ -183,6 +192,7 @@ func main() {

// Start server
go func() {
Info("Version: %s\n", ver)
Info("Concurrency: %d\n", maxConcurrent)
Info("Nameservers: %s\n", dns)
Info("Connection timeout is %s\n", timeout)
Expand Down

0 comments on commit f7fbc96

Please sign in to comment.