add proxy settings

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-04-11 22:27:13 +02:00
parent fa58485712
commit 86988d9afe
20 changed files with 1276 additions and 38 deletions

View File

@@ -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