This commit is contained in:
Zack Scholl 2018-09-24 07:00:48 -07:00
parent 90b08abf39
commit e8ef8e1c61
2 changed files with 45 additions and 1 deletions

View File

@ -51,10 +51,14 @@ type Croc struct {
// Init will initiate with the default parameters
func Init(debug bool) (c *Croc) {
c = new(Croc)
c.CurveType = "siec"
c.UseCompression = true
c.UseEncryption = true
c.AllowLocalDiscovery = true
c.RelayWebsocketPort = "8153"
c.RelayTCPPort = "8154"
c.CurveType = "siec"
c.Address = "198.199.67.130"
c.NoRecipientPrompt = true
debugLevel := "info"
if debug {
debugLevel = "debug"

40
src/croc/croc_test.go Normal file
View File

@ -0,0 +1,40 @@
package croc
import (
"crypto/rand"
"io/ioutil"
"os"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestSendReceive(t *testing.T) {
generateRandomFile(100)
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
c := Init(true)
assert.Nil(t, c.Send("100mb.file", "test"))
}()
go func() {
defer wg.Done()
time.Sleep(100 * time.Millisecond)
os.MkdirAll("test", 0755)
os.Chdir("test")
c := Init(true)
assert.Nil(t, c.Receive("test"))
}()
wg.Wait()
}
func generateRandomFile(megabytes int) {
// generate a random file
bigBuff := make([]byte, 1024*1024*megabytes)
rand.Read(bigBuff)
ioutil.WriteFile("100mb.file", bigBuff, 0666)
}