mirror of https://github.com/schollz/croc.git
raise tcp size
This commit is contained in:
parent
15ecc73f67
commit
6635c84f70
3
go.mod
3
go.mod
|
@ -5,6 +5,7 @@ require (
|
||||||
github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d
|
github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d
|
||||||
github.com/fatih/color v1.7.0 // indirect
|
github.com/fatih/color v1.7.0 // indirect
|
||||||
github.com/gorilla/websocket v1.4.0
|
github.com/gorilla/websocket v1.4.0
|
||||||
|
github.com/mars9/crypt v0.0.0-20150406101210-65899cf653ff // indirect
|
||||||
github.com/mattn/go-colorable v0.0.9 // indirect
|
github.com/mattn/go-colorable v0.0.9 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.4 // indirect
|
github.com/mattn/go-isatty v0.0.4 // indirect
|
||||||
github.com/pkg/errors v0.8.0
|
github.com/pkg/errors v0.8.0
|
||||||
|
@ -13,6 +14,8 @@ require (
|
||||||
github.com/schollz/peerdiscovery v1.2.2
|
github.com/schollz/peerdiscovery v1.2.2
|
||||||
github.com/schollz/progressbar/v2 v2.5.3
|
github.com/schollz/progressbar/v2 v2.5.3
|
||||||
github.com/schollz/spinner v0.0.0-20180922210718-ea497ee41258
|
github.com/schollz/spinner v0.0.0-20180922210718-ea497ee41258
|
||||||
|
github.com/schollz/utils v1.0.0
|
||||||
|
github.com/stretchr/testify v1.2.2
|
||||||
github.com/tscholl2/siec v0.0.0-20180721101609-21667da05937
|
github.com/tscholl2/siec v0.0.0-20180721101609-21667da05937
|
||||||
github.com/urfave/cli v1.20.0
|
github.com/urfave/cli v1.20.0
|
||||||
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b
|
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b
|
||||||
|
|
|
@ -13,18 +13,23 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func sendAndReceive(t *testing.T, forceSend int) {
|
func sendAndReceive(t *testing.T, forceSend int, local bool) {
|
||||||
var startTime time.Time
|
var startTime time.Time
|
||||||
var durationPerMegabyte float64
|
var durationPerMegabyte float64
|
||||||
megabytes := 10
|
megabytes := 10
|
||||||
|
if local {
|
||||||
|
megabytes = 100
|
||||||
|
}
|
||||||
fname := generateRandomFile(megabytes)
|
fname := generateRandomFile(megabytes)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
c := Init(true)
|
c := Init(true)
|
||||||
c.NoLocal = true
|
c.NoLocal = !local
|
||||||
c.ForceSend = forceSend
|
c.ForceSend = forceSend
|
||||||
|
c.UseEncryption = false
|
||||||
|
c.UseEncryption = false
|
||||||
assert.Nil(t, c.Send(fname, "test"))
|
assert.Nil(t, c.Send(fname, "test"))
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -33,7 +38,7 @@ func sendAndReceive(t *testing.T, forceSend int) {
|
||||||
os.MkdirAll("test", 0755)
|
os.MkdirAll("test", 0755)
|
||||||
os.Chdir("test")
|
os.Chdir("test")
|
||||||
c := Init(true)
|
c := Init(true)
|
||||||
c.NoLocal = true
|
c.NoLocal = !local
|
||||||
c.ForceSend = forceSend
|
c.ForceSend = forceSend
|
||||||
startTime = time.Now()
|
startTime = time.Now()
|
||||||
assert.Nil(t, c.Receive("test"))
|
assert.Nil(t, c.Receive("test"))
|
||||||
|
@ -46,11 +51,21 @@ func sendAndReceive(t *testing.T, forceSend int) {
|
||||||
os.Remove(fname)
|
os.Remove(fname)
|
||||||
fmt.Printf("\n-----\n%2.1f MB/s\n----\n", durationPerMegabyte)
|
fmt.Printf("\n-----\n%2.1f MB/s\n----\n", durationPerMegabyte)
|
||||||
}
|
}
|
||||||
func TestSendReceiveWebsockets(t *testing.T) {
|
|
||||||
sendAndReceive(t, 1)
|
func TestSendReceivePubWebsockets(t *testing.T) {
|
||||||
|
sendAndReceive(t, 1, false)
|
||||||
}
|
}
|
||||||
func TestSendReceiveTCP(t *testing.T) {
|
|
||||||
sendAndReceive(t, 2)
|
func TestSendReceivePubTCP(t *testing.T) {
|
||||||
|
sendAndReceive(t, 2, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSendReceiveLocalWebsockets(t *testing.T) {
|
||||||
|
sendAndReceive(t, 1, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSendReceiveLocalTCP(t *testing.T) {
|
||||||
|
sendAndReceive(t, 2, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateRandomFile(megabytes int) (fname string) {
|
func generateRandomFile(megabytes int) (fname string) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
const WEBSOCKET_BUFFER_SIZE = 1024 * 1024 * 32
|
const WEBSOCKET_BUFFER_SIZE = 1024 * 1024 * 32
|
||||||
const TCP_BUFFER_SIZE = 1024 * 2
|
const TCP_BUFFER_SIZE = 1024 * 64
|
||||||
|
|
Loading…
Reference in New Issue