-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
972f14b
commit 0e99c27
Showing
12 changed files
with
442 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package cmd | ||
|
||
var IsRDPUserRequired = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// +build linux | ||
package cmd | ||
|
||
var IsRDPUserRequired = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package rdp | ||
|
||
import ( | ||
"io" | ||
"os/exec" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
type Executor struct { | ||
CommandProvider func(filePath string) (cmd string, args []string) | ||
StdOut io.Writer | ||
Stdin io.Reader | ||
StdErr io.Writer | ||
} | ||
|
||
func (re *Executor) StartRdp(filePath string) error { | ||
rdpCmd, args := re.CommandProvider(filePath) | ||
c := exec.Command(rdpCmd, args...) | ||
|
||
c.Stdout = re.StdOut | ||
c.Stdin = re.Stdin | ||
c.Stderr = re.StdErr | ||
|
||
err := c.Run() | ||
logrus.Debugf("will run %s", c.String()) | ||
if err != nil { | ||
return err | ||
} | ||
logrus.Debugf("finished run %s", c.String()) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build linux | ||
|
||
package rdp | ||
|
||
func CommandProvider(filePath string) (cmd string, args []string) { | ||
return "xfreerdp", []string{filePath} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build darwin | ||
|
||
package rdp | ||
|
||
func CommandProvider(filePath string) (cmd string, args []string) { | ||
return "open", []string{filePath} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package rdp | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestExecutor(t *testing.T) { | ||
stdOut := &bytes.Buffer{} | ||
const filePath = "file123" | ||
e := &Executor{ | ||
CommandProvider: func(fp string) (cmd string, args []string) { | ||
assert.Equal(t, filePath, fp) | ||
return "echo", []string{"123"} | ||
}, | ||
StdOut: stdOut, | ||
} | ||
|
||
err := e.StartRdp(filePath) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "123\n", stdOut.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build windows | ||
|
||
package rdp | ||
|
||
func CommandProvider(filePath string) (cmd string, args []string) { | ||
return "start", []string{filePath} | ||
} |
Oops, something went wrong.