Skip to content

Commit

Permalink
Add goarm flag
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Aug 4, 2023
1 parent a1d55e2 commit 67598eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions internal/server/commands/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 8 additions & 2 deletions internal/server/webserver/buildmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type file struct {
Path string
Goos string
Goarch string
Goarm string
FileType string
Hits int
Version string
Expand All @@ -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")
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 67598eb

Please sign in to comment.