diff --git a/cli/brook/main.go b/cli/brook/main.go index 512be8e4..65b9ee6a 100644 --- a/cli/brook/main.go +++ b/cli/brook/main.go @@ -50,7 +50,7 @@ var debugAddress string func main() { app := cli.NewApp() app.Name = "Brook" - app.Version = "20221212" + app.Version = "20230101" app.Usage = "A cross-platform network tool designed for developers" app.Authors = []*cli.Author{ { @@ -221,7 +221,7 @@ func main() { }, &cli.StringFlag{ Name: "http", - Usage: "Where to listen for HTTP connections", + Usage: "Where to listen for HTTP proxy connections", }, &cli.IntFlag{ Name: "tcpTimeout", @@ -443,7 +443,7 @@ func main() { }, &cli.StringFlag{ Name: "http", - Usage: "Where to listen for HTTP connections", + Usage: "Where to listen for HTTP proxy connections", }, &cli.IntFlag{ Name: "tcpTimeout", @@ -712,7 +712,7 @@ func main() { }, &cli.StringFlag{ Name: "http", - Usage: "Where to listen for HTTP connections", + Usage: "Where to listen for HTTP proxy connections", }, &cli.IntFlag{ Name: "tcpTimeout", @@ -1509,7 +1509,7 @@ func main() { }, &cli.StringFlag{ Name: "http", - Usage: "Where to listen for HTTP connections", + Usage: "Where to listen for HTTP proxy connections", }, &cli.IntFlag{ Name: "tcpTimeout", @@ -2090,7 +2090,12 @@ func main() { var cmd *exec.Cmd var err error go func() { - cmd = exec.Command("brook", "connect", "--link", c.String("link"), "--socks5", c.String("socks5")) + var s string + s, err = os.Executable() + if err != nil { + return + } + cmd = exec.Command(s, "connect", "--link", c.String("link"), "--socks5", c.String("socks5")) b, _ := cmd.CombinedOutput() err = errors.New(string(b)) }() @@ -2103,6 +2108,76 @@ func main() { return err1 }, }, + &cli.Command{ + Name: "echoserver", + Usage: "Echo server, echo UDP and TCP address of routes", + BashComplete: func(c *cli.Context) { + l := c.Command.VisibleFlags() + for _, v := range l { + fmt.Println("--" + v.Names()[0]) + } + }, + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "listen", + Aliases: []string{"l"}, + Usage: "Listen address, like: ':7777'", + }, + }, + Action: func(c *cli.Context) error { + if c.String("listen") == "" { + return cli.ShowSubcommandHelp(c) + } + s, err := brook.NewEchoServer(c.String("listen")) + if err != nil { + return err + } + g := runnergroup.New() + g.Add(&runnergroup.Runner{ + Start: func() error { + return s.ListenAndServe() + }, + Stop: func() error { + return s.Shutdown() + }, + }) + go func() { + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) + <-sigs + g.Done() + }() + return g.Wait() + }, + }, + &cli.Command{ + Name: "echoclient", + Usage: "Connect to echoserver, echo UDP and TCP address of routes", + BashComplete: func(c *cli.Context) { + l := c.Command.VisibleFlags() + for _, v := range l { + fmt.Println("--" + v.Names()[0]) + } + }, + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "server", + Aliases: []string{"s"}, + Usage: "Echo server address, such as 1.2.3.4:7777", + }, + &cli.IntFlag{ + Name: "times", + Value: 1, + Usage: "Times of interactions", + }, + }, + Action: func(c *cli.Context) error { + if c.String("server") == "" { + return cli.ShowSubcommandHelp(c) + } + return brook.EchoClient(c.String("server"), c.Int("times")) + }, + }, &cli.Command{ Name: "completion", Usage: "Generate shell completions", @@ -2188,7 +2263,7 @@ complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete brook }, }, &cli.Command{ - Name: "markdown", + Name: "mdpage", Usage: "Generate markdown page", BashComplete: func(c *cli.Context) { l := c.Command.VisibleFlags() diff --git a/docs/example-zh.md b/docs/example-zh.md index 5fc0da5d..ced85b46 100644 --- a/docs/example-zh.md +++ b/docs/example-zh.md @@ -259,7 +259,8 @@ brook dnsserveroverbrook ... --listen 127.0.0.1:53 **无需操作 iptables!** ``` -opkg install ca-certificates openssl-util ca-bundle coreutils-nohup iptables-mod-tproxy +opkg update +opkg install ca-certificates openssl-util ca-bundle coreutils-nohup iptables-mod-tproxy iptables-mod-socket ``` ``` @@ -310,7 +311,10 @@ brook tproxy --link 'brook://...' --dnsListen :53 ### 官网原版 OpenWrt 图形客户端 -> **依赖: ca-certificates openssl-util ca-bundle coreutils-nohup iptables-mod-tproxy** +``` +opkg update +opkg install ca-certificates openssl-util ca-bundle coreutils-nohup iptables-mod-tproxy iptables-mod-socket +``` **无需操作 iptables!** diff --git a/docs/example.md b/docs/example.md index 9b8b554e..aa78b049 100644 --- a/docs/example.md +++ b/docs/example.md @@ -259,7 +259,8 @@ Rule **No need to manipulate iptables!** ``` -opkg install ca-certificates openssl-util ca-bundle coreutils-nohup iptables-mod-tproxy +opkg update +opkg install ca-certificates openssl-util ca-bundle coreutils-nohup iptables iptables-mod-tproxy iptables-mod-socket ``` ``` @@ -310,7 +311,10 @@ brook tproxy --link 'brook://...' --dnsListen :53 ### GUI for official OpenWrt -> **Dependencies: ca-certificates openssl-util ca-bundle coreutils-nohup iptables-mod-tproxy** +``` +opkg update +opkg install ca-certificates openssl-util ca-bundle coreutils-nohup iptables iptables-mod-tproxy iptables-mod-socket +``` **No need to manipulate iptables!** diff --git a/docs/images/linux.png b/docs/images/linux.png new file mode 100644 index 00000000..7e882a5d Binary files /dev/null and b/docs/images/linux.png differ diff --git a/docs/index.html b/docs/index.html index d889eaa3..7afe6e88 100644 --- a/docs/index.html +++ b/docs/index.html @@ -175,7 +175,7 @@
pacman -S brook
@@ -217,16 +217,19 @@