mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
ran 'go fmt *.go' to (hopefully) get rid of commit issues
This commit is contained in:
parent
798a0d2c52
commit
6bdbdce655
3 changed files with 774 additions and 774 deletions
32
connect.go
32
connect.go
|
@ -27,7 +27,7 @@ type Connection struct {
|
|||
IsSender bool
|
||||
Debug bool
|
||||
DontEncrypt bool
|
||||
Wait bool
|
||||
Wait bool
|
||||
bars []*uiprogress.Bar
|
||||
rate int
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func NewConnection(flags *Flags) *Connection {
|
|||
c := new(Connection)
|
||||
c.Debug = flags.Debug
|
||||
c.DontEncrypt = flags.DontEncrypt
|
||||
c.Wait = flags.Wait
|
||||
c.Wait = flags.Wait
|
||||
c.Server = flags.Server
|
||||
c.Code = flags.Code
|
||||
c.NumberOfConnections = flags.NumberOfConnections
|
||||
|
@ -162,7 +162,7 @@ func (c *Connection) runClient() error {
|
|||
}
|
||||
gotOK := false
|
||||
gotResponse := false
|
||||
notPresent := false
|
||||
notPresent := false
|
||||
for id := 0; id < c.NumberOfConnections; id++ {
|
||||
go func(id int) {
|
||||
defer wg.Done()
|
||||
|
@ -185,11 +185,11 @@ func (c *Connection) runClient() error {
|
|||
sendMessage("s."+c.HashedCode+"."+hex.EncodeToString(encryptedMetaData)+"-"+salt+"-"+iv, connection)
|
||||
} else {
|
||||
logger.Debugf("telling relay: %s", "r."+c.Code)
|
||||
if c.Wait {
|
||||
sendMessage("r."+c.HashedCode+".0.0.0", connection)
|
||||
} else {
|
||||
sendMessage("c."+c.HashedCode+".0.0.0", connection)
|
||||
}
|
||||
if c.Wait {
|
||||
sendMessage("r."+c.HashedCode+".0.0.0", connection)
|
||||
} else {
|
||||
sendMessage("c."+c.HashedCode+".0.0.0", connection)
|
||||
}
|
||||
}
|
||||
if c.IsSender { // this is a sender
|
||||
logger.Debug("waiting for ok from relay")
|
||||
|
@ -208,11 +208,11 @@ func (c *Connection) runClient() error {
|
|||
message = receiveMessage(connection)
|
||||
m := strings.Split(message, "-")
|
||||
encryptedData, salt, iv, sendersAddress := m[0], m[1], m[2], m[3]
|
||||
if sendersAddress == "0.0.0.0" {
|
||||
notPresent = true
|
||||
if sendersAddress == "0.0.0.0" {
|
||||
notPresent = true
|
||||
time.Sleep(1 * time.Second)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
encryptedBytes, err := hex.DecodeString(encryptedData)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
|
@ -264,10 +264,10 @@ func (c *Connection) runClient() error {
|
|||
wg.Wait()
|
||||
|
||||
if !c.IsSender {
|
||||
if notPresent {
|
||||
fmt.Println("Sender/Code not present")
|
||||
return nil
|
||||
}
|
||||
if notPresent {
|
||||
fmt.Println("Sender/Code not present")
|
||||
return nil
|
||||
}
|
||||
if !gotOK {
|
||||
return errors.New("Transfer interrupted")
|
||||
}
|
||||
|
|
2
main.go
2
main.go
|
@ -15,7 +15,7 @@ var oneGigabytePerSecond = 1000000 // expressed as kbps
|
|||
type Flags struct {
|
||||
Relay bool
|
||||
Debug bool
|
||||
Wait bool
|
||||
Wait bool
|
||||
DontEncrypt bool
|
||||
Server string
|
||||
File string
|
||||
|
|
8
relay.go
8
relay.go
|
@ -156,10 +156,10 @@ func (r *Relay) clientCommuncation(id int, connection net.Conn) {
|
|||
}
|
||||
}
|
||||
r.connections.RUnlock()
|
||||
if connectionType == "c" {
|
||||
sendMessage("0-0-0-0.0.0.0", connection)
|
||||
return
|
||||
}
|
||||
if connectionType == "c" {
|
||||
sendMessage("0-0-0-0.0.0.0", connection)
|
||||
return
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
// send meta data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue