Skip to content

Commit

Permalink
use 4096 bytes for buffer by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nwtgck committed Apr 29, 2024
1 parent 166ef13 commit add2e22
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Environment variable:
Available Commands:
client Run client-host
completion Generate the autocompletion script for the specified shell
help Help about any command
server Run server-host
socks Run SOCKS server
Expand All @@ -63,8 +64,8 @@ Flags:
--dns-server string DNS server (e.g. 1.1.1.1:53)
-H, --header stringArray HTTP header
-h, --help help for piping-tunnel
--http-read-buf-size int HTTP read-buffer size in bytes (default 16)
--http-write-buf-size int HTTP write-buffer size in bytes (default 16)
--http-read-buf-size int HTTP read-buffer size in bytes (default 4096)
--http-write-buf-size int HTTP write-buffer size in bytes (default 4096)
-k, --insecure Allow insecure server connections when using SSL
--progress Show progress (default true)
-s, --server string Piping Server URL (default "https://ppng.io")
Expand All @@ -83,7 +84,7 @@ Usage:
Flags:
--cipher-type string Cipher type: aes-ctr, openssl-aes-128-ctr, openssl-aes-256-ctr, openpgp (default "aes-ctr")
--cs-buf-size uint Buffer size of client-to-server in bytes (default 16)
--cs-buf-size uint Buffer size of client-to-server in bytes (default 4096)
-h, --help help for server
--host string Target host (default "localhost")
--pass string Passphrase for encryption
Expand All @@ -98,8 +99,8 @@ Flags:
Global Flags:
--dns-server string DNS server (e.g. 1.1.1.1:53)
-H, --header stringArray HTTP header
--http-read-buf-size int HTTP read-buffer size in bytes (default 16)
--http-write-buf-size int HTTP write-buffer size in bytes (default 16)
--http-read-buf-size int HTTP read-buffer size in bytes (default 4096)
--http-write-buf-size int HTTP write-buffer size in bytes (default 4096)
-k, --insecure Allow insecure server connections when using SSL
--progress Show progress (default true)
-s, --server string Piping Server URL (default "https://ppng.io")
Expand All @@ -121,16 +122,16 @@ Flags:
--pmux Multiplex connection by pmux (experimental)
--pmux-config string pmux config in JSON (experimental) (default "{\"hb\": true}")
-p, --port int TCP port of client host
--sc-buf-size uint Buffer size of server-to-client in bytes (default 16)
--sc-buf-size uint Buffer size of server-to-client in bytes (default 4096)
-c, --symmetric Encrypt symmetrically
--unix-socket string Unix socket of client host
--yamux Multiplex connection by hashicorp/yamux
Global Flags:
--dns-server string DNS server (e.g. 1.1.1.1:53)
-H, --header stringArray HTTP header
--http-read-buf-size int HTTP read-buffer size in bytes (default 16)
--http-write-buf-size int HTTP write-buffer size in bytes (default 16)
--http-read-buf-size int HTTP read-buffer size in bytes (default 4096)
--http-write-buf-size int HTTP write-buffer size in bytes (default 4096)
-k, --insecure Allow insecure server connections when using SSL
--progress Show progress (default true)
-s, --server string Piping Server URL (default "https://ppng.io")
Expand Down Expand Up @@ -158,8 +159,8 @@ Flags:
Global Flags:
--dns-server string DNS server (e.g. 1.1.1.1:53)
-H, --header stringArray HTTP header
--http-read-buf-size int HTTP read-buffer size in bytes (default 16)
--http-write-buf-size int HTTP write-buffer size in bytes (default 16)
--http-read-buf-size int HTTP read-buffer size in bytes (default 4096)
--http-write-buf-size int HTTP write-buffer size in bytes (default 4096)
-k, --insecure Allow insecure server connections when using SSL
--progress Show progress (default true)
-s, --server string Piping Server URL (default "https://ppng.io")
Expand Down
14 changes: 7 additions & 7 deletions cmd/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func init() {
cmd.RootCmd.AddCommand(clientCmd)
clientCmd.Flags().IntVarP(&flag.clientHostPort, "port", "p", 0, "TCP port of client host")
clientCmd.Flags().StringVarP(&flag.clientHostUnixSocket, "unix-socket", "", "", "Unix socket of client host")
clientCmd.Flags().UintVarP(&flag.serverToClientBufSize, "sc-buf-size", "", 16, "Buffer size of server-to-client in bytes")
clientCmd.Flags().UintVarP(&flag.serverToClientBufSize, "sc-buf-size", "", 4096, "Buffer size of server-to-client in bytes")
clientCmd.Flags().BoolVarP(&flag.yamux, cmd.YamuxFlagLongName, "", false, "Multiplex connection by hashicorp/yamux")
clientCmd.Flags().BoolVarP(&flag.pmux, cmd.PmuxFlagLongName, "", false, "Multiplex connection by pmux (experimental)")
clientCmd.Flags().StringVarP(&flag.pmuxConfig, cmd.PmuxConfigFlagLongName, "", `{"hb": true}`, "pmux config in JSON (experimental)")
Expand Down Expand Up @@ -132,13 +132,13 @@ var clientCmd = &cobra.Command{
fin := make(chan error)
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
_, err := io.CopyBuffer(duplex, conn, buf)
fin <- err
}()
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
_, err := io.CopyBuffer(conn, duplex, buf)
fin <- err
}()
Expand Down Expand Up @@ -264,13 +264,13 @@ func clientHandleWithYamux(ln net.Listener, httpClient *http.Client, headers []p
fin := make(chan struct{})
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
io.CopyBuffer(yamuxStream, conn, buf)
fin <- struct{}{}
}()
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
io.CopyBuffer(conn, yamuxStream, buf)
fin <- struct{}{}
}()
Expand Down Expand Up @@ -322,7 +322,7 @@ func clientHandleWithPmux(ln net.Listener, httpClient *http.Client, headers []pi
fin := make(chan struct{})
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
_, err := io.CopyBuffer(conn, stream, buf)
fin <- struct{}{}
if err != nil {
Expand All @@ -336,7 +336,7 @@ func clientHandleWithPmux(ln net.Listener, httpClient *http.Client, headers []pi

go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
_, err := io.CopyBuffer(stream, conn, buf)
fin <- struct{}{}
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func init() {
// NOTE: --insecure, -k is inspired by curl
RootCmd.PersistentFlags().BoolVarP(&Insecure, "insecure", "k", false, "Allow insecure server connections when using SSL")
RootCmd.PersistentFlags().StringArrayVarP(&HeaderKeyValueStrs, "header", "H", []string{}, "HTTP header")
RootCmd.PersistentFlags().IntVarP(&HttpWriteBufSize, "http-write-buf-size", "", 16, "HTTP write-buffer size in bytes")
RootCmd.PersistentFlags().IntVarP(&HttpReadBufSize, "http-read-buf-size", "", 16, "HTTP read-buffer size in bytes")
RootCmd.PersistentFlags().IntVarP(&HttpWriteBufSize, "http-write-buf-size", "", 4096, "HTTP write-buffer size in bytes")
RootCmd.PersistentFlags().IntVarP(&HttpReadBufSize, "http-read-buf-size", "", 4096, "HTTP read-buffer size in bytes")
RootCmd.PersistentFlags().BoolVarP(&ShowProgress, "progress", "", true, "Show progress")
RootCmd.Flags().BoolVarP(&showsVersion, "version", "v", false, "show version")
RootCmd.PersistentFlags().IntVarP(&verboseLoggerLevel, "verbose", "", 0, "Verbose logging level")
Expand Down
14 changes: 7 additions & 7 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func init() {
serverCmd.Flags().StringVarP(&flag.targetHost, "host", "", "localhost", "Target host")
serverCmd.Flags().IntVarP(&flag.serverHostPort, "port", "p", 0, "TCP port of server host")
serverCmd.Flags().StringVarP(&flag.serverHostUnixSocket, "unix-socket", "", "", "Unix socket of server host")
serverCmd.Flags().UintVarP(&flag.clientToServerBufSize, "cs-buf-size", "", 16, "Buffer size of client-to-server in bytes")
serverCmd.Flags().UintVarP(&flag.clientToServerBufSize, "cs-buf-size", "", 4096, "Buffer size of client-to-server in bytes")
serverCmd.Flags().BoolVarP(&flag.yamux, cmd.YamuxFlagLongName, "", false, "Multiplex connection by hashicorp/yamux")
serverCmd.Flags().BoolVarP(&flag.pmux, cmd.PmuxFlagLongName, "", false, "Multiplex connection by pmux (experimental)")
serverCmd.Flags().StringVarP(&flag.pmuxConfig, cmd.PmuxConfigFlagLongName, "", `{"hb": true}`, "pmux config in JSON (experimental)")
Expand Down Expand Up @@ -125,13 +125,13 @@ var serverCmd = &cobra.Command{
fin := make(chan error)
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
_, err := io.CopyBuffer(duplex, conn, buf)
fin <- err
}()
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
_, err := io.CopyBuffer(conn, duplex, buf)
fin <- err
}()
Expand Down Expand Up @@ -248,13 +248,13 @@ func serverHandleWithYamux(httpClient *http.Client, headers []piping_util.KeyVal
fin := make(chan struct{})
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
io.CopyBuffer(yamuxStream, conn, buf)
fin <- struct{}{}
}()
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
io.CopyBuffer(conn, yamuxStream, buf)
fin <- struct{}{}
}()
Expand Down Expand Up @@ -299,7 +299,7 @@ func serverHandleWithPmux(httpClient *http.Client, headers []piping_util.KeyValu
conn := dialLoop()
go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
_, err := io.CopyBuffer(conn, stream, buf)
if err != nil {
cmd.Vlog.Log(
Expand All @@ -313,7 +313,7 @@ func serverHandleWithPmux(httpClient *http.Client, headers []piping_util.KeyValu

go func() {
// TODO: hard code
var buf = make([]byte, 16)
var buf = make([]byte, 4096)
_, err := io.CopyBuffer(stream, conn, buf)
if err != nil {
cmd.Vlog.Log(
Expand Down

0 comments on commit add2e22

Please sign in to comment.