mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
use single variable for buffer size
This commit is contained in:
parent
c9dab1ca44
commit
8797d35fa1
2 changed files with 5 additions and 4 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
log "github.com/cihub/seelog"
|
log "github.com/cihub/seelog"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
"github.com/schollz/croc/src/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -19,12 +20,12 @@ const (
|
||||||
pingPeriod = (pongWait * 9) / 10
|
pingPeriod = (pongWait * 9) / 10
|
||||||
|
|
||||||
// Maximum message size allowed from peer.
|
// Maximum message size allowed from peer.
|
||||||
maxMessageSize = 1024 * 1024 * 16
|
maxMessageSize = models.WEBSOCKET_BUFFER_SIZE / 2
|
||||||
)
|
)
|
||||||
|
|
||||||
var upgrader = websocket.Upgrader{
|
var upgrader = websocket.Upgrader{
|
||||||
ReadBufferSize: 1024 * 1024 * 32,
|
ReadBufferSize: models.WEBSOCKET_BUFFER_SIZE,
|
||||||
WriteBufferSize: 1024 * 1024 * 32,
|
WriteBufferSize: models.WEBSOCKET_BUFFER_SIZE,
|
||||||
}
|
}
|
||||||
|
|
||||||
// connection is an middleman between the websocket connection and the hub.
|
// connection is an middleman between the websocket connection and the hub.
|
||||||
|
|
|
@ -194,7 +194,7 @@ func send(isLocal bool, c *websocket.Conn, fname string, codephrase string, useC
|
||||||
fmt.Fprintf(os.Stderr, "\rSending (->%s)...\n", otherIP)
|
fmt.Fprintf(os.Stderr, "\rSending (->%s)...\n", otherIP)
|
||||||
// send file, compure hash simultaneously
|
// send file, compure hash simultaneously
|
||||||
startTransfer = time.Now()
|
startTransfer = time.Now()
|
||||||
buffer := make([]byte, 1024*1024*8)
|
buffer := make([]byte, models.WEBSOCKET_BUFFER_SIZE/8)
|
||||||
bar := progressbar.NewOptions(
|
bar := progressbar.NewOptions(
|
||||||
int(fstats.Size),
|
int(fstats.Size),
|
||||||
progressbar.OptionSetRenderBlankState(true),
|
progressbar.OptionSetRenderBlankState(true),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue