From bab614da2d31acc7b32f971fa17eaa505c11f098 Mon Sep 17 00:00:00 2001 From: txthinking Date: Sun, 1 Jan 2023 10:46:28 +0800 Subject: [PATCH] v20230101 --- cli/brook/main.go | 89 +++++++++++++++++++-- docs/example-zh.md | 8 +- docs/example.md | 8 +- docs/images/linux.png | Bin 0 -> 4809 bytes docs/index.html | 21 ++--- echoclient.go | 74 ++++++++++++++++++ echoserver.go | 174 ++++++++++++++++++++++++++++++++++++++++++ ping/ping.json | 2 +- socks5test.go | 46 +++++------ 9 files changed, 378 insertions(+), 44 deletions(-) create mode 100644 docs/images/linux.png create mode 100644 echoclient.go create mode 100644 echoserver.go 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 0000000000000000000000000000000000000000..7e882a5da099c9f10b5cf39cfda90169c74d546b GIT binary patch literal 4809 zcmV;)5;pCLP)Gq@~R>8KTZ4ONAI0qE#B?@z1tz zZ|ZNme8E2*0i*K@%3P{kBoK3e(R8napbnLHrB1$FTeJNyfb0)Dy~RHZ0ZL|0{?$^j z8Yw1uD62KtMzCm=JgI8&Ve!HR z#Kp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2fXW-JpqAgp>&0H)Y@w`5^Ow5+LwE zM}otm#HMNBAo*ToB8u|_zSaE{s<>Q~TeoOw3qBg*6J&KnGEQ|qf=XZ({&?X@@u(=X zKCHQIRi-z<>+@avLChDW*1v0Q2ZShevD|7&LUmq;5Z}g)$DDg14q~(AiaGQ>xcAkb zcO!;kP^*x*pJa66H4L`pq9}OZ8Vh;sXt^b#5TV{kd#Ex`9pXEv`Wr=gOYfgY3dD}T z5|3)U1DFFM9f+a*BXY+tun2brook<
pacman -S brook
@@ -217,16 +217,19 @@
Windows EXE
- +
- -
OpenWrt IPK
+ +
Linux GUI
- deps + +
- -
Chrome EXT
+ +
OpenWrt IPK
@@ -284,9 +287,9 @@
{{ zh ? '移除某个开机命令' : 'Remove one added command' }}
-