update progressbar, show external ip on receiver

This commit is contained in:
Zack Scholl 2020-03-31 13:33:27 -07:00
parent b0125b63e7
commit 72378947b5
3 changed files with 11 additions and 8 deletions

2
go.mod
View File

@ -16,7 +16,7 @@ require (
github.com/schollz/mnemonicode v1.0.1
github.com/schollz/pake/v2 v2.0.2
github.com/schollz/peerdiscovery v1.5.0
github.com/schollz/progressbar/v2 v2.15.0
github.com/schollz/progressbar/v3 v3.0.0
github.com/schollz/spinner v0.0.0-20180925172146-6bbc5f7804f9
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/stretchr/testify v1.4.0

2
go.sum
View File

@ -46,6 +46,8 @@ github.com/schollz/peerdiscovery v1.5.0 h1:olfRgADOF4iVHfA6QSf5fNTCXWf9bQ0CcAHu+
github.com/schollz/peerdiscovery v1.5.0/go.mod h1:rtU51ZXRfyF8ugujcsOTxM8Jerx19+62Wq2zx2QGYsg=
github.com/schollz/progressbar/v2 v2.15.0 h1:dVzHQ8fHRmtPjD3K10jT3Qgn/+H+92jhPrhmxIJfDz8=
github.com/schollz/progressbar/v2 v2.15.0/go.mod h1:UdPq3prGkfQ7MOzZKlDRpYKcFqEMczbD7YmbPgpzKMI=
github.com/schollz/progressbar/v3 v3.0.0 h1:N4MqUpgTO75vC0VmVtDNcnBNQinQjbPpKah6F+d34QY=
github.com/schollz/progressbar/v3 v3.0.0/go.mod h1:d+PD64vPuv+GL2EhUpvV579FR91WWhRHEnImqGsIBU4=
github.com/schollz/spinner v0.0.0-20180925172146-6bbc5f7804f9 h1:y08o5oQ/slxXE/F0uh5dd8mdVvb+w4NLcNSDSq4c2F0=
github.com/schollz/spinner v0.0.0-20180925172146-6bbc5f7804f9/go.mod h1:kCMoQsqzx4MzGJWaALr6tKyCnlrY0kILGLkA1FOiLF4=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=

View File

@ -29,7 +29,7 @@ import (
log "github.com/schollz/logger"
"github.com/schollz/pake/v2"
"github.com/schollz/peerdiscovery"
"github.com/schollz/progressbar/v2"
"github.com/schollz/progressbar/v3"
"github.com/schollz/spinner"
"github.com/tscholl2/siec"
)
@ -707,15 +707,16 @@ func (c *Client) processMessageSalt(m message.Message) (done bool, err error) {
if c.Options.IsSender {
log.Debug("sending external IP")
err = message.Send(c.conn[0], c.Key, message.Message{
Type: "externalip",
Bytes: m.Bytes,
Type: "externalip",
Message: c.ExternalIP,
Bytes: m.Bytes,
})
}
return
}
func (c *Client) processExternalIP(m message.Message) (done bool, err error) {
log.Debug("received external IP")
log.Debug("received external IP: %+v", m)
if !c.Options.IsSender {
err = message.Send(c.conn[0], c.Key, message.Message{
Type: "externalip",
@ -970,7 +971,7 @@ func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error)
progressbar.OptionSetWidth(20),
progressbar.OptionSetDescription(description),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetBytes64(1),
progressbar.OptionShowBytes(true),
progressbar.OptionSetWriter(os.Stderr),
)
c.bar.Finish()
@ -1054,7 +1055,7 @@ func (c *Client) updateState() (err error) {
progressbar.OptionSetWidth(20),
progressbar.OptionSetDescription(description),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetBytes64(1),
progressbar.OptionShowBytes(true),
progressbar.OptionSetWriter(os.Stderr),
)
c.bar.Finish()
@ -1097,7 +1098,7 @@ func (c *Client) setBar() {
progressbar.OptionSetWidth(20),
progressbar.OptionSetDescription(description),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetBytes64(c.FilesToTransfer[c.FilesToTransferCurrentNum].Size),
progressbar.OptionShowBytes(true),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionThrottle(100*time.Millisecond),
)