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/tcp"
|
||||
"github.com/schollz/croc/v6/src/utils"
|
||||
"github.com/schollz/croc/v6/src/webrelay"
|
||||
log "github.com/schollz/logger"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -51,6 +52,7 @@ func Run() (err error) {
|
|||
Flags: []cli.Flag{
|
||||
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-multi", Usage: "disable multiplexing"},
|
||||
cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the local relay (optional)"},
|
||||
},
|
||||
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"},
|
||||
},
|
||||
},
|
||||
{
|
||||
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{
|
||||
cli.BoolFlag{Name: "remember", Usage: "save these settings to reuse next time"},
|
||||
|
@ -145,6 +159,7 @@ func send(c *cli.Context) (err error) {
|
|||
DisableLocal: c.Bool("no-local"),
|
||||
RelayPorts: strings.Split(c.String("ports"), ","),
|
||||
Ask: c.GlobalBool("ask"),
|
||||
NoMultiplexing: c.Bool("no-multi"),
|
||||
}
|
||||
b, errOpen := ioutil.ReadFile(getConfigFile())
|
||||
if errOpen == nil && !c.GlobalBool("remember") {
|
||||
|
@ -381,3 +396,12 @@ func relay(c *cli.Context) (err error) {
|
|||
}
|
||||
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"))
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ type Options struct {
|
|||
RelayPorts []string
|
||||
Stdout bool
|
||||
NoPrompt bool
|
||||
NoMultiplexing bool
|
||||
DisableLocal bool
|
||||
Ask bool
|
||||
}
|
||||
|
@ -286,6 +287,10 @@ func (c *Client) transferOverLocalRelay(options TransferOptions, errchan chan<-
|
|||
log.Debug("exchanged header message")
|
||||
c.Options.RelayAddress = "localhost"
|
||||
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
|
||||
errchan <- c.transfer(options)
|
||||
}
|
||||
|
@ -363,6 +368,10 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
|||
|
||||
c.conn[0] = conn
|
||||
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
|
||||
log.Debug("exchanged header message")
|
||||
errchan <- c.transfer(options)
|
||||
|
@ -464,6 +473,10 @@ func (c *Client) Receive() (err error) {
|
|||
|
||||
c.conn[0].Send([]byte("handshake"))
|
||||
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")
|
||||
fmt.Fprintf(os.Stderr, "\rsecuring channel...")
|
||||
return c.transfer(TransferOptions{})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue