add proxy

This commit is contained in:
Zack Scholl 2020-10-05 07:58:36 -07:00
parent e75b75164f
commit f8ff49be68
3 changed files with 20 additions and 5 deletions

2
go.mod
View File

@ -22,7 +22,7 @@ require (
github.com/stretchr/testify v1.4.0
github.com/tscholl2/siec v0.0.0-20191122224205-8da93652b094
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect
golang.org/x/net v0.0.0-20200904194848-62affa334b73
golang.org/x/sys v0.0.0-20200916084744-dbad9cb7cb7a // indirect
golang.org/x/text v0.3.3 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect

View File

@ -84,6 +84,7 @@ func Run() (err error) {
&cli.StringFlag{Name: "relay6", Value: models.DEFAULT_RELAY6, Usage: "ipv6 address of the relay", EnvVars: []string{"CROC_RELAY6"}},
&cli.StringFlag{Name: "out", Value: ".", Usage: "specify an output folder to receive the file"},
&cli.StringFlag{Name: "pass", Value: "pass123", Usage: "password for the relay", EnvVars: []string{"CROC_PASS"}},
&cli.StringFlag{Name: "socks5", Value: "", Usage: "add a socks5 proxy", EnvVars: []string{"http_proxy"}},
}
app.EnableBashCompletion = true
app.HideHelp = false
@ -92,10 +93,10 @@ func Run() (err error) {
allStringsAreFiles := func(strs []string) bool {
for _, str := range strs {
if !utils.Exists(str) {
return false;
return false
}
}
return true;
return true
}
// if trying to send but forgot send, let the user know
@ -103,7 +104,7 @@ func Run() (err error) {
fnames := []string{}
for _, fpath := range c.Args().Slice() {
_, basename := filepath.Split(fpath)
fnames = append(fnames, "'" + basename + "'")
fnames = append(fnames, "'"+basename+"'")
}
yn := utils.GetInput(fmt.Sprintf("Did you mean to send %s? (y/n) ", strings.Join(fnames, ", ")))
if strings.ToLower(yn) == "y" {

View File

@ -9,8 +9,11 @@ import (
"time"
log "github.com/schollz/logger"
"golang.org/x/net/proxy"
)
var Socks5Proxy = ""
const MAXBYTES = 4000000
// Comm is some basic TCP communication
@ -24,7 +27,18 @@ func NewConnection(address string, timelimit ...time.Duration) (c *Comm, err err
if len(timelimit) > 0 {
tlimit = timelimit[0]
}
connection, err := net.DialTimeout("tcp", address, tlimit)
var connection net.Conn
if Socks5Proxy != "" {
var dialer proxy.Dialer
dialer, err = proxy.SOCKS5("tcp", Socks5Proxy, nil, proxy.Direct)
if err != nil {
err = fmt.Errorf("proxy failed: %w", err)
return
}
connection, err = dialer.Dial("tcp", address)
} else {
connection, err = net.DialTimeout("tcp", address, tlimit)
}
if err != nil {
err = fmt.Errorf("comm.NewConnection failed: %w", err)
return