mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 05:11:06 +02:00
add http proxy
This commit is contained in:
parent
3396743d73
commit
bd60f76519
2 changed files with 8 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
)
|
||||
|
||||
var Socks5Proxy = ""
|
||||
var HTTPProxy = ""
|
||||
|
||||
const MAXBYTES = 4000000
|
||||
|
||||
|
@ -37,6 +38,9 @@ func NewConnection(address string, timelimit ...time.Duration) (c *Comm, err err
|
|||
return
|
||||
}
|
||||
connection, err = dialer.Dial("tcp", address)
|
||||
} else if HTTPProxy != "" && !utils.IsLocalIP(address) {
|
||||
var dialer proxy.Dialer
|
||||
dialer, err = proxy.FromURL(nil, proxy.Direct)
|
||||
} else {
|
||||
connection, err = net.DialTimeout("tcp", address, tlimit)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue