mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
more debug
This commit is contained in:
parent
9d2f07f478
commit
d1e1694631
3 changed files with 10 additions and 6 deletions
|
@ -18,7 +18,7 @@ type Comm struct {
|
|||
func New(c net.Conn) Comm {
|
||||
c.SetReadDeadline(time.Now().Add(3 * time.Hour))
|
||||
c.SetDeadline(time.Now().Add(3 * time.Hour))
|
||||
c.SetWriteDeadline(time.Now().Add(20 * time.Second))
|
||||
c.SetWriteDeadline(time.Now().Add(3 * time.Hour))
|
||||
return Comm{c}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,13 +45,14 @@ func (c *Croc) Send(fname, codephrase string) (err error) {
|
|||
|
||||
// broadcast for peer discovery
|
||||
go func() {
|
||||
log.Debug("starting local croc relay...")
|
||||
go peerdiscovery.Discover(peerdiscovery.Settings{
|
||||
log.Debug("starting local discovery...")
|
||||
discovered, err := peerdiscovery.Discover(peerdiscovery.Settings{
|
||||
Limit: 1,
|
||||
TimeLimit: 600 * time.Second,
|
||||
Delay: 50 * time.Millisecond,
|
||||
Payload: []byte(c.RelayWebsocketPort + "- " + strings.Join(c.RelayTCPPorts, ",")),
|
||||
})
|
||||
log.Debug(discovered, err)
|
||||
}()
|
||||
|
||||
// connect to own relay
|
||||
|
@ -76,6 +77,7 @@ func (c *Croc) Receive(codephrase string) (err error) {
|
|||
|
||||
// use local relay first
|
||||
if !c.NoLocal {
|
||||
log.Debug("trying discovering")
|
||||
// try to discovery codephrase and server through peer network
|
||||
discovered, errDiscover := peerdiscovery.Discover(peerdiscovery.Settings{
|
||||
Limit: 1,
|
||||
|
@ -85,6 +87,8 @@ func (c *Croc) Receive(codephrase string) (err error) {
|
|||
AllowSelf: true,
|
||||
DisableBroadcast: true,
|
||||
})
|
||||
log.Debug("finished")
|
||||
log.Debug(discovered)
|
||||
if errDiscover != nil {
|
||||
log.Debug(errDiscover)
|
||||
}
|
||||
|
|
|
@ -318,11 +318,11 @@ func receive(forceSend int, serverAddress string, tcpPorts []string, isLocal boo
|
|||
}
|
||||
n, err = f.WriteAt(decrypted, int64(locationToWrite))
|
||||
fProgress.WriteString(fmt.Sprintf("%d\n", locationToWrite))
|
||||
log.Debugf("writing to location %d (%2.0f/%2.0f)", locationToWrite, blocksWritten, blocksToWrite)
|
||||
log.Debugf("wrote %d bytes to location %d (%2.0f/%2.0f)", n, locationToWrite, blocksWritten, blocksToWrite)
|
||||
} else {
|
||||
// write to file
|
||||
n, err = f.Write(decrypted)
|
||||
log.Debugf("writing to location %d (%2.0f/%2.0f)", bytesWritten, blocksWritten, blocksToWrite)
|
||||
log.Debugf("wrote %d bytes to location %d (%2.0f/%2.0f)", n, bytesWritten, blocksWritten, blocksToWrite)
|
||||
fProgress.WriteString(fmt.Sprintf("%d\n", bytesWritten))
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -336,7 +336,7 @@ func receive(forceSend int, serverAddress string, tcpPorts []string, isLocal boo
|
|||
// update the progress bar
|
||||
bar.Add(n)
|
||||
if int64(bytesWritten) == fstats.Size || blocksWritten >= blocksToWrite {
|
||||
log.Debug("finished")
|
||||
log.Debug("finished", int64(bytesWritten), fstats.Size, blocksWritten, blocksToWrite)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue