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
|
IsSender bool
|
||||||
Debug bool
|
Debug bool
|
||||||
DontEncrypt bool
|
DontEncrypt bool
|
||||||
Wait bool
|
Wait bool
|
||||||
bars []*uiprogress.Bar
|
bars []*uiprogress.Bar
|
||||||
rate int
|
rate int
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func NewConnection(flags *Flags) *Connection {
|
||||||
c := new(Connection)
|
c := new(Connection)
|
||||||
c.Debug = flags.Debug
|
c.Debug = flags.Debug
|
||||||
c.DontEncrypt = flags.DontEncrypt
|
c.DontEncrypt = flags.DontEncrypt
|
||||||
c.Wait = flags.Wait
|
c.Wait = flags.Wait
|
||||||
c.Server = flags.Server
|
c.Server = flags.Server
|
||||||
c.Code = flags.Code
|
c.Code = flags.Code
|
||||||
c.NumberOfConnections = flags.NumberOfConnections
|
c.NumberOfConnections = flags.NumberOfConnections
|
||||||
|
@ -162,7 +162,7 @@ func (c *Connection) runClient() error {
|
||||||
}
|
}
|
||||||
gotOK := false
|
gotOK := false
|
||||||
gotResponse := false
|
gotResponse := false
|
||||||
notPresent := false
|
notPresent := false
|
||||||
for id := 0; id < c.NumberOfConnections; id++ {
|
for id := 0; id < c.NumberOfConnections; id++ {
|
||||||
go func(id int) {
|
go func(id int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
@ -185,11 +185,11 @@ func (c *Connection) runClient() error {
|
||||||
sendMessage("s."+c.HashedCode+"."+hex.EncodeToString(encryptedMetaData)+"-"+salt+"-"+iv, connection)
|
sendMessage("s."+c.HashedCode+"."+hex.EncodeToString(encryptedMetaData)+"-"+salt+"-"+iv, connection)
|
||||||
} else {
|
} else {
|
||||||
logger.Debugf("telling relay: %s", "r."+c.Code)
|
logger.Debugf("telling relay: %s", "r."+c.Code)
|
||||||
if c.Wait {
|
if c.Wait {
|
||||||
sendMessage("r."+c.HashedCode+".0.0.0", connection)
|
sendMessage("r."+c.HashedCode+".0.0.0", connection)
|
||||||
} else {
|
} else {
|
||||||
sendMessage("c."+c.HashedCode+".0.0.0", connection)
|
sendMessage("c."+c.HashedCode+".0.0.0", connection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.IsSender { // this is a sender
|
if c.IsSender { // this is a sender
|
||||||
logger.Debug("waiting for ok from relay")
|
logger.Debug("waiting for ok from relay")
|
||||||
|
@ -208,11 +208,11 @@ func (c *Connection) runClient() error {
|
||||||
message = receiveMessage(connection)
|
message = receiveMessage(connection)
|
||||||
m := strings.Split(message, "-")
|
m := strings.Split(message, "-")
|
||||||
encryptedData, salt, iv, sendersAddress := m[0], m[1], m[2], m[3]
|
encryptedData, salt, iv, sendersAddress := m[0], m[1], m[2], m[3]
|
||||||
if sendersAddress == "0.0.0.0" {
|
if sendersAddress == "0.0.0.0" {
|
||||||
notPresent = true
|
notPresent = true
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
encryptedBytes, err := hex.DecodeString(encryptedData)
|
encryptedBytes, err := hex.DecodeString(encryptedData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
@ -264,10 +264,10 @@ func (c *Connection) runClient() error {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
if !c.IsSender {
|
if !c.IsSender {
|
||||||
if notPresent {
|
if notPresent {
|
||||||
fmt.Println("Sender/Code not present")
|
fmt.Println("Sender/Code not present")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !gotOK {
|
if !gotOK {
|
||||||
return errors.New("Transfer interrupted")
|
return errors.New("Transfer interrupted")
|
||||||
}
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -15,7 +15,7 @@ var oneGigabytePerSecond = 1000000 // expressed as kbps
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
Relay bool
|
Relay bool
|
||||||
Debug bool
|
Debug bool
|
||||||
Wait bool
|
Wait bool
|
||||||
DontEncrypt bool
|
DontEncrypt bool
|
||||||
Server string
|
Server string
|
||||||
File 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()
|
r.connections.RUnlock()
|
||||||
if connectionType == "c" {
|
if connectionType == "c" {
|
||||||
sendMessage("0-0-0-0.0.0.0", connection)
|
sendMessage("0-0-0-0.0.0.0", connection)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
}
|
}
|
||||||
// send meta data
|
// send meta data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue