Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the tor dos window on windows #32

Merged
merged 1 commit into from Jan 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions process/process.go
Expand Up @@ -40,25 +40,26 @@ type Creator interface {
New(ctx context.Context, args ...string) (Process, error)
}

type exeProcessCreator struct {
exePath string
}
type CmdCreatorFunc func(ctx context.Context, args ...string) (*exec.Cmd, error)

// NewCreator creates a Creator for external Tor process execution based on the
// given exe path.
func NewCreator(exePath string) Creator {
return &exeProcessCreator{exePath}
return CmdCreatorFunc(func(ctx context.Context, args ...string) (*exec.Cmd, error) {
cmd := exec.CommandContext(ctx, exePath, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd, nil
})
}

type exeProcess struct {
*exec.Cmd
}

func (e *exeProcessCreator) New(ctx context.Context, args ...string) (Process, error) {
cmd := exec.CommandContext(ctx, e.exePath, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return &exeProcess{cmd}, nil
func (c CmdCreatorFunc) New(ctx context.Context, args ...string) (Process, error) {
cmd, err := c(ctx, args...)
return &exeProcess{cmd}, err
}

// ErrControlConnUnsupported is returned by Process.EmbeddedControlConn when
Expand Down