add windows support (#193)
* add windows support * build for win * fix win build
This commit is contained in:
parent
2482fd67c7
commit
d2b002000e
7 changed files with 74 additions and 16 deletions
|
|
@ -10,7 +10,7 @@ builds:
|
|||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
# - windows
|
||||
- windows
|
||||
# - darwin
|
||||
goarch:
|
||||
- amd64
|
||||
|
|
@ -36,11 +36,11 @@ builds:
|
|||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
# - darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
# - windows
|
||||
# - darwin
|
||||
main: ./plugin/workingdir
|
||||
binary: plugins/workingdir
|
||||
tags:
|
||||
|
|
@ -50,10 +50,11 @@ builds:
|
|||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
# - darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
# - windows
|
||||
# - darwin
|
||||
main: ./plugin/yaml
|
||||
binary: plugins/yaml
|
||||
|
|
@ -64,11 +65,11 @@ builds:
|
|||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
# - windows
|
||||
# - darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
# - windows
|
||||
# - darwin
|
||||
main: ./plugin/docker
|
||||
binary: plugins/docker
|
||||
tags:
|
||||
|
|
@ -78,11 +79,11 @@ builds:
|
|||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
# - windows
|
||||
# - darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
# - windows
|
||||
# - darwin
|
||||
main: ./plugin/kubernetes
|
||||
binary: plugins/kubernetes
|
||||
tags:
|
||||
|
|
@ -92,11 +93,11 @@ builds:
|
|||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
# - darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
# - windows
|
||||
# - darwin
|
||||
main: ./plugin/fixed
|
||||
binary: plugins/fixed
|
||||
tags:
|
||||
|
|
@ -106,11 +107,11 @@ builds:
|
|||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
# - darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
# - windows
|
||||
# - darwin
|
||||
main: ./plugin/failtoban
|
||||
binary: plugins/failtoban
|
||||
tags:
|
||||
|
|
@ -118,6 +119,7 @@ builds:
|
|||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
allow_different_binary_count: true
|
||||
# this name template makes the OS and Arch compatible with the results of uname.
|
||||
name_template: >-
|
||||
sshpiperd_with_plugins_
|
||||
|
|
@ -130,9 +132,14 @@ archives:
|
|||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
# builds:
|
||||
# - sshpiperd
|
||||
# - plugin_workingdir
|
||||
builds:
|
||||
- sshpiperd
|
||||
- plugin_workingdir
|
||||
- plugin_yaml
|
||||
- plugin_fixed
|
||||
- plugin_failtoban
|
||||
- plugin_docker
|
||||
- plugin_kubernetes
|
||||
dockers:
|
||||
- image_templates:
|
||||
- "farmer1992/sshpiperd:{{ .Version }}-amd64"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//go:build !linux
|
||||
//go:build !linux && !windows
|
||||
|
||||
package main
|
||||
|
||||
|
|
@ -6,3 +6,7 @@ import "os/exec"
|
|||
|
||||
func setPdeathsig(cmd *exec.Cmd) {
|
||||
}
|
||||
|
||||
func addProcessToJob(cmd *exec.Cmd) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ import (
|
|||
func setPdeathsig(cmd *exec.Cmd) {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGTERM}
|
||||
}
|
||||
|
||||
func addProcessToJob(cmd *exec.Cmd) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
35
cmd/sshpiperd/cmd_windows.go
Normal file
35
cmd/sshpiperd/cmd_windows.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tg123/jobobject"
|
||||
)
|
||||
|
||||
func setPdeathsig(cmd *exec.Cmd) {
|
||||
}
|
||||
|
||||
func addProcessToJob(cmd *exec.Cmd) error {
|
||||
if jobObject == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if cmd.Process == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return jobObject.AddProcess(cmd.Process)
|
||||
}
|
||||
|
||||
var jobObject *jobobject.JobObject
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
jobObject, err = jobobject.Create()
|
||||
if err != nil {
|
||||
log.Warnf("failed to create job object: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -62,6 +62,10 @@ func createCmdPlugin(args []string) (*plugin.CmdPlugin, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := addProcessToJob(cmd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p.Name = exe
|
||||
|
||||
return p, nil
|
||||
|
|
|
|||
1
go.mod
1
go.mod
|
|
@ -15,6 +15,7 @@ require (
|
|||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/pires/go-proxyproto v0.6.2
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/tg123/jobobject v0.1.0
|
||||
github.com/tg123/remotesigner v0.0.1
|
||||
github.com/urfave/cli/v2 v2.25.7
|
||||
golang.org/x/crypto v0.12.0
|
||||
|
|
|
|||
3
go.sum
3
go.sum
|
|
@ -157,6 +157,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
|||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/tg123/jobobject v0.1.0 h1:deOWVH+SvsnFtT/M+HFhtZ7t9GMYPzYMvvF25IIMRRE=
|
||||
github.com/tg123/jobobject v0.1.0/go.mod h1:TtbMLKdmTPY6eMo4aqDXiQWv0yTfAgDt1mxv6J9pM8o=
|
||||
github.com/tg123/remotesigner v0.0.1 h1:fFCKgpBOv0nfpWOuuWMke9vECKQu6PTrm4iktDwwMMM=
|
||||
github.com/tg123/remotesigner v0.0.1/go.mod h1:leliuGRH9ayYYwRo6JO8yg+KyWcltK69XJdLv1x7slM=
|
||||
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
||||
|
|
@ -202,6 +204,7 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue