From 67598ebd4e7e5465601d8d95615c92f75f66bc15 Mon Sep 17 00:00:00 2001 From: NHAS Date: Fri, 4 Aug 2023 22:46:32 +1200 Subject: [PATCH] Add goarm flag --- internal/server/commands/link.go | 10 ++++++++-- internal/server/webserver/buildmanager.go | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/server/commands/link.go b/internal/server/commands/link.go index 23736d6..741904a 100644 --- a/internal/server/commands/link.go +++ b/internal/server/commands/link.go @@ -41,7 +41,7 @@ func (l *link) Run(tty io.ReadWriter, line terminal.ParsedLine) error { for _, id := range ids { file := files[id] - t.AddValues("http://"+path.Join(webserver.DefaultConnectBack, id), file.CallbackAddress, file.Goos, file.Goarch, file.Version, file.FileType, fmt.Sprintf("%d", file.Hits)) + t.AddValues("http://"+path.Join(webserver.DefaultConnectBack, id), file.CallbackAddress, file.Goos, file.Goarch+file.Goarm, file.Version, file.FileType, fmt.Sprintf("%d", file.Hits)) } t.Fprint(tty) @@ -89,6 +89,11 @@ func (l *link) Run(tty io.ReadWriter, line terminal.ParsedLine) error { return err } + goarm, err := line.GetArgString("goarm") + if err != nil && err != terminal.ErrFlagNotSet { + return err + } + homeserver_address, err := line.GetArgString("s") if err != nil && err != terminal.ErrFlagNotSet { return err @@ -114,7 +119,7 @@ func (l *link) Run(tty io.ReadWriter, line terminal.ParsedLine) error { return err } - url, err := webserver.Build(goos, goarch, homeserver_address, fingerprint, name, comment, proxy, line.IsSet("shared-object"), line.IsSet("upx"), line.IsSet("garble"), line.IsSet("no-lib-c")) + url, err := webserver.Build(goos, goarch, goarm, homeserver_address, fingerprint, name, comment, proxy, line.IsSet("shared-object"), line.IsSet("upx"), line.IsSet("garble"), line.IsSet("no-lib-c")) if err != nil { return err } @@ -150,6 +155,7 @@ func (e *link) Help(explain bool) string { "\t-C\tComment to add as the public key (acts as the name)", "\t--goos\tSet the target build operating system (default runtime GOOS)", "\t--goarch\tSet the target build architecture (default runtime GOARCH)", + "\t--goarm\tSet the go arm variable (not set by default)", "\t--name\tSet the link download url/filename (default random characters)", "\t--proxy\tSet connect proxy address to bake it", "\t--shared-object\tGenerate shared object file", diff --git a/internal/server/webserver/buildmanager.go b/internal/server/webserver/buildmanager.go index 9eeb0eb..ba51022 100644 --- a/internal/server/webserver/buildmanager.go +++ b/internal/server/webserver/buildmanager.go @@ -23,6 +23,7 @@ type file struct { Path string Goos string Goarch string + Goarm string FileType string Hits int Version string @@ -41,7 +42,7 @@ var ( cachePath string ) -func Build(goos, goarch, suppliedConnectBackAdress, fingerprint, name, comment, proxy string, shared, upx, garble, disableLibC bool) (string, error) { +func Build(goos, goarch, goarm, suppliedConnectBackAdress, fingerprint, name, comment, proxy string, shared, upx, garble, disableLibC bool) (string, error) { if !webserverOn { return "", errors.New("web server is not enabled") } @@ -111,6 +112,8 @@ func Build(goos, goarch, suppliedConnectBackAdress, fingerprint, name, comment, f.Goarch = goarch } + f.Goarm = goarm + f.Path = filepath.Join(cachePath, filename) f.FileType = "executable" f.Version = internal.Version + "_guess" @@ -173,6 +176,9 @@ func Build(goos, goarch, suppliedConnectBackAdress, fingerprint, name, comment, cmd.Env = append(cmd.Env, os.Environ()...) cmd.Env = append(cmd.Env, "GOOS="+f.Goos) cmd.Env = append(cmd.Env, "GOARCH="+f.Goarch) + if len(f.Goarm) != 0 { + cmd.Env = append(cmd.Env, "GOARM="+f.Goarm) + } //Building a shared object for windows needs some extra beans cgoOn := "0" @@ -267,7 +273,7 @@ func List(filter string) (matchingFiles map[string]file, err error) { continue } - if match, _ := filepath.Match(filter, file.Goarch); match { + if match, _ := filepath.Match(filter, file.Goarch+file.Goarm); match { matchingFiles[id] = cache[id] continue }