mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
allow disabling the multiplexing
This commit is contained in:
parent
2cf9480302
commit
1ae7a2ff97
2 changed files with 55 additions and 18 deletions
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/schollz/croc/v6/src/models"
|
"github.com/schollz/croc/v6/src/models"
|
||||||
"github.com/schollz/croc/v6/src/tcp"
|
"github.com/schollz/croc/v6/src/tcp"
|
||||||
"github.com/schollz/croc/v6/src/utils"
|
"github.com/schollz/croc/v6/src/utils"
|
||||||
|
"github.com/schollz/croc/v6/src/webrelay"
|
||||||
log "github.com/schollz/logger"
|
log "github.com/schollz/logger"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
@ -51,6 +52,7 @@ func Run() (err error) {
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{Name: "code, c", Usage: "codephrase used to connect to relay"},
|
cli.StringFlag{Name: "code, c", Usage: "codephrase used to connect to relay"},
|
||||||
cli.BoolFlag{Name: "no-local", Usage: "disable local relay when sending"},
|
cli.BoolFlag{Name: "no-local", Usage: "disable local relay when sending"},
|
||||||
|
cli.BoolFlag{Name: "no-multi", Usage: "disable multiplexing"},
|
||||||
cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the local relay (optional)"},
|
cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the local relay (optional)"},
|
||||||
},
|
},
|
||||||
HelpName: "croc send",
|
HelpName: "croc send",
|
||||||
|
@ -70,6 +72,18 @@ func Run() (err error) {
|
||||||
cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the relay"},
|
cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the relay"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "web",
|
||||||
|
Usage: "start your own web relay (optional)",
|
||||||
|
Description: "start web relay",
|
||||||
|
HelpName: "croc web",
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
return startWebRelay(c)
|
||||||
|
},
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
cli.StringFlag{Name: "port", Value: "9014", Usage: "port of the web relay"},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
cli.BoolFlag{Name: "remember", Usage: "save these settings to reuse next time"},
|
cli.BoolFlag{Name: "remember", Usage: "save these settings to reuse next time"},
|
||||||
|
@ -136,15 +150,16 @@ func getConfigFile() string {
|
||||||
func send(c *cli.Context) (err error) {
|
func send(c *cli.Context) (err error) {
|
||||||
setDebugLevel(c)
|
setDebugLevel(c)
|
||||||
crocOptions := croc.Options{
|
crocOptions := croc.Options{
|
||||||
SharedSecret: c.String("code"),
|
SharedSecret: c.String("code"),
|
||||||
IsSender: true,
|
IsSender: true,
|
||||||
Debug: c.GlobalBool("debug"),
|
Debug: c.GlobalBool("debug"),
|
||||||
NoPrompt: c.GlobalBool("yes"),
|
NoPrompt: c.GlobalBool("yes"),
|
||||||
RelayAddress: c.GlobalString("relay"),
|
RelayAddress: c.GlobalString("relay"),
|
||||||
Stdout: c.GlobalBool("stdout"),
|
Stdout: c.GlobalBool("stdout"),
|
||||||
DisableLocal: c.Bool("no-local"),
|
DisableLocal: c.Bool("no-local"),
|
||||||
RelayPorts: strings.Split(c.String("ports"), ","),
|
RelayPorts: strings.Split(c.String("ports"), ","),
|
||||||
Ask: c.GlobalBool("ask"),
|
Ask: c.GlobalBool("ask"),
|
||||||
|
NoMultiplexing: c.Bool("no-multi"),
|
||||||
}
|
}
|
||||||
b, errOpen := ioutil.ReadFile(getConfigFile())
|
b, errOpen := ioutil.ReadFile(getConfigFile())
|
||||||
if errOpen == nil && !c.GlobalBool("remember") {
|
if errOpen == nil && !c.GlobalBool("remember") {
|
||||||
|
@ -381,3 +396,12 @@ func relay(c *cli.Context) (err error) {
|
||||||
}
|
}
|
||||||
return tcp.Run(debugString, ports[0], tcpPorts)
|
return tcp.Run(debugString, ports[0], tcpPorts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startWebRelay(c *cli.Context) (err error) {
|
||||||
|
debugString := "info"
|
||||||
|
if c.GlobalBool("debug") {
|
||||||
|
debugString = "debug"
|
||||||
|
}
|
||||||
|
|
||||||
|
return webrelay.Run(debugString, c.String("port"))
|
||||||
|
}
|
||||||
|
|
|
@ -48,15 +48,16 @@ func Debug(debug bool) {
|
||||||
|
|
||||||
// Options specifies user specific options
|
// Options specifies user specific options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
IsSender bool
|
IsSender bool
|
||||||
SharedSecret string
|
SharedSecret string
|
||||||
Debug bool
|
Debug bool
|
||||||
RelayAddress string
|
RelayAddress string
|
||||||
RelayPorts []string
|
RelayPorts []string
|
||||||
Stdout bool
|
Stdout bool
|
||||||
NoPrompt bool
|
NoPrompt bool
|
||||||
DisableLocal bool
|
NoMultiplexing bool
|
||||||
Ask bool
|
DisableLocal bool
|
||||||
|
Ask bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client holds the state of the croc transfer
|
// Client holds the state of the croc transfer
|
||||||
|
@ -286,6 +287,10 @@ func (c *Client) transferOverLocalRelay(options TransferOptions, errchan chan<-
|
||||||
log.Debug("exchanged header message")
|
log.Debug("exchanged header message")
|
||||||
c.Options.RelayAddress = "localhost"
|
c.Options.RelayAddress = "localhost"
|
||||||
c.Options.RelayPorts = strings.Split(banner, ",")
|
c.Options.RelayPorts = strings.Split(banner, ",")
|
||||||
|
if c.Options.NoMultiplexing {
|
||||||
|
log.Debug("no multiplexing")
|
||||||
|
c.Options.RelayPorts = []string{c.Options.RelayPorts[0]}
|
||||||
|
}
|
||||||
c.ExternalIP = ipaddr
|
c.ExternalIP = ipaddr
|
||||||
errchan <- c.transfer(options)
|
errchan <- c.transfer(options)
|
||||||
}
|
}
|
||||||
|
@ -363,6 +368,10 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
||||||
|
|
||||||
c.conn[0] = conn
|
c.conn[0] = conn
|
||||||
c.Options.RelayPorts = strings.Split(banner, ",")
|
c.Options.RelayPorts = strings.Split(banner, ",")
|
||||||
|
if c.Options.NoMultiplexing {
|
||||||
|
log.Debug("no multiplexing")
|
||||||
|
c.Options.RelayPorts = []string{c.Options.RelayPorts[0]}
|
||||||
|
}
|
||||||
c.ExternalIP = ipaddr
|
c.ExternalIP = ipaddr
|
||||||
log.Debug("exchanged header message")
|
log.Debug("exchanged header message")
|
||||||
errchan <- c.transfer(options)
|
errchan <- c.transfer(options)
|
||||||
|
@ -464,6 +473,10 @@ func (c *Client) Receive() (err error) {
|
||||||
|
|
||||||
c.conn[0].Send([]byte("handshake"))
|
c.conn[0].Send([]byte("handshake"))
|
||||||
c.Options.RelayPorts = strings.Split(banner, ",")
|
c.Options.RelayPorts = strings.Split(banner, ",")
|
||||||
|
if c.Options.NoMultiplexing {
|
||||||
|
log.Debug("no multiplexing")
|
||||||
|
c.Options.RelayPorts = []string{c.Options.RelayPorts[0]}
|
||||||
|
}
|
||||||
log.Debug("exchanged header message")
|
log.Debug("exchanged header message")
|
||||||
fmt.Fprintf(os.Stderr, "\rsecuring channel...")
|
fmt.Fprintf(os.Stderr, "\rsecuring channel...")
|
||||||
return c.transfer(TransferOptions{})
|
return c.transfer(TransferOptions{})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue