mirror of
https://github.com/anotherhadi/iknowyou.git
synced 2026-04-12 00:47:26 +02:00
add proxy settings
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/creack/pty"
|
||||
)
|
||||
|
||||
@@ -14,7 +15,14 @@ var oscRe = regexp.MustCompile(`\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)`)
|
||||
|
||||
// RunWithPTY runs cmd under a pseudo-terminal (preserving ANSI colours) and
|
||||
// returns the full output once the process exits.
|
||||
// If a proxychains config path is stored in ctx, the command is transparently
|
||||
// wrapped with proxychains4.
|
||||
func RunWithPTY(ctx context.Context, cmd *exec.Cmd) (string, error) {
|
||||
if confPath := proxy.ProxychainsConfFromContext(ctx); confPath != "" {
|
||||
args := append([]string{"-q", "-f", confPath, cmd.Path}, cmd.Args[1:]...)
|
||||
cmd = exec.CommandContext(ctx, "proxychains4", args...)
|
||||
}
|
||||
|
||||
ptmx, err := pty.StartWithSize(cmd, &pty.Winsize{Rows: 50, Cols: 220})
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user