Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36f573f7df | ||
|
|
10de575f60 | ||
|
|
bd60f76519 |
|
|
@ -85,7 +85,8 @@ 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"}},
|
||||
&cli.StringFlag{Name: "socks5", Value: "", Usage: "add a socks5 proxy", EnvVars: []string{"socks5_proxy"}},
|
||||
&cli.StringFlag{Name: "proxy", Value: "", Usage: "add a http proxy", EnvVars: []string{"http_proxy"}},
|
||||
}
|
||||
app.EnableBashCompletion = true
|
||||
app.HideHelp = false
|
||||
|
|
@ -162,6 +163,7 @@ func determinePass(c *cli.Context) (pass string) {
|
|||
func send(c *cli.Context) (err error) {
|
||||
setDebugLevel(c)
|
||||
comm.Socks5Proxy = c.String("socks5")
|
||||
comm.HTTPProxy = c.String("proxy")
|
||||
crocOptions := croc.Options{
|
||||
SharedSecret: c.String("code"),
|
||||
IsSender: true,
|
||||
|
|
@ -360,6 +362,7 @@ func saveConfig(c *cli.Context, crocOptions croc.Options) {
|
|||
|
||||
func receive(c *cli.Context) (err error) {
|
||||
comm.Socks5Proxy = c.String("socks5")
|
||||
comm.HTTPProxy = c.String("proxy")
|
||||
crocOptions := croc.Options{
|
||||
SharedSecret: c.String("code"),
|
||||
IsSender: false,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/schollz/croc/v8/src/utils"
|
||||
|
|
@ -14,6 +15,7 @@ import (
|
|||
)
|
||||
|
||||
var Socks5Proxy = ""
|
||||
var HTTPProxy = ""
|
||||
|
||||
const MAXBYTES = 4000000
|
||||
|
||||
|
|
@ -33,7 +35,26 @@ func NewConnection(address string, timelimit ...time.Duration) (c *Comm, err err
|
|||
var dialer proxy.Dialer
|
||||
dialer, err = proxy.SOCKS5("tcp", Socks5Proxy, nil, proxy.Direct)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("proxy failed: %w", err)
|
||||
err = fmt.Errorf("socks5 proxy failed: %w", err)
|
||||
return
|
||||
}
|
||||
connection, err = dialer.Dial("tcp", address)
|
||||
} else if HTTPProxy != "" && !utils.IsLocalIP(address) {
|
||||
var u *url.URL
|
||||
u, err = url.Parse(address)
|
||||
if err != nil {
|
||||
u, err = url.Parse("http://" + address)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var dialer proxy.Dialer
|
||||
proxy.RegisterDialerType("http", func(u *url.URL, d proxy.Dialer) (proxy.Dialer, error) {
|
||||
return proxy.FromURL(u, proxy.Direct)
|
||||
})
|
||||
dialer, err = proxy.FromURL(u, proxy.Direct)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("http proxy failed: %w", err)
|
||||
return
|
||||
}
|
||||
connection, err = dialer.Dial("tcp", address)
|
||||
|
|
|
|||
Loading…
Reference in New Issue