update croc

This commit is contained in:
Zack Scholl 2019-04-29 16:54:31 -06:00
parent 1f49966bb1
commit 1045bd17b5
2 changed files with 24 additions and 41 deletions

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/schollz/croc
module github.com/schollz/croc/v6
require (
github.com/BurntSushi/toml v0.3.1

View File

@ -15,15 +15,16 @@ import (
"sync"
"time"
log "github.com/cihub/seelog"
"github.com/denisbrodbeck/machineid"
"github.com/go-redis/redis"
"github.com/mattn/go-colorable"
"github.com/pions/webrtc"
"github.com/schollz/croc/v5/src/crypt"
"github.com/schollz/croc/v5/src/utils"
"github.com/schollz/croc/v5/src/webrtc/pkg/session/common"
"github.com/schollz/croc/v5/src/webrtc/pkg/session/receiver"
"github.com/schollz/croc/v5/src/webrtc/pkg/session/sender"
"github.com/schollz/croc/v6/src/comm"
"github.com/schollz/croc/v6/src/crypt"
"github.com/schollz/croc/v6/src/logger"
"github.com/schollz/croc/v6/src/utils"
"github.com/schollz/croc/v6/src/webrtc/pkg/session/common"
"github.com/schollz/croc/v6/src/webrtc/pkg/session/receiver"
"github.com/schollz/croc/v6/src/webrtc/pkg/session/sender"
"github.com/schollz/pake"
"github.com/schollz/progressbar/v2"
"github.com/schollz/spinner"
@ -33,29 +34,29 @@ import (
const BufferSize = 4096 * 10
const Channels = 1
var log = logrus.New()
func init() {
log.SetFormatter(&logrus.TextFormatter{ForceColors: true})
log.SetOutput(colorable.NewColorableStdout())
Debug(false)
logger.SetLogLevel("debug")
}
func Debug(debug bool) {
receiver.Debug(debug)
sender.Debug(debug)
if debug {
log.SetLevel(logrus.DebugLevel)
logger.SetLogLevel("debug")
} else {
log.SetLevel(logrus.WarnLevel)
logger.SetLogLevel("warn")
}
}
type Options struct {
IsSender bool
SharedSecret string
Debug bool
AddressRelay string
Stdout bool
NoPrompt bool
}
type Client struct {
Options Options
// basic setup
redisdb *redis.Client
log *logrus.Entry
Pake *pake.Pake
// steps involved in forming relationship
@ -63,7 +64,7 @@ type Client struct {
Step2FileInfoTransfered bool
Step3RecipientRequestFile bool
Step4FileTransfer bool
Step5CloseChannels bool // TODO: Step5 should close files and reset things
Step5CloseChannels bool
// send / receive information of all files
FilesToTransfer []FileInfo
@ -73,17 +74,8 @@ type Client struct {
CurrentFile *os.File
CurrentFileChunks []int64
sendSess *sender.Session
recvSess *receiver.Session
// channel data
incomingMessageChannel <-chan *redis.Message
nameOutChannel string
nameInChannel string
// webrtc connections
peerConnection [8]*webrtc.PeerConnection
dataChannel [8]*webrtc.DataChannel
// tcp connectios
conn [17]*comm.Comm
bar *progressbar.ProgressBar
spinner *spinner.Spinner
@ -131,15 +123,6 @@ func (m Message) String() string {
return string(b)
}
type Options struct {
IsSender bool
SharedSecret string
Debug bool
AddressRelay string
Stdout bool
NoPrompt bool
}
// New establishes a new connection for transfering files between two instances.
func New(ops Options) (c *Client, err error) {
c = new(Client)