mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
update croc
This commit is contained in:
parent
1f49966bb1
commit
1045bd17b5
2 changed files with 24 additions and 41 deletions
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module github.com/schollz/croc
|
module github.com/schollz/croc/v6
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
|
|
|
@ -15,15 +15,16 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
"github.com/denisbrodbeck/machineid"
|
"github.com/denisbrodbeck/machineid"
|
||||||
"github.com/go-redis/redis"
|
"github.com/go-redis/redis"
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/schollz/croc/v6/src/comm"
|
||||||
"github.com/pions/webrtc"
|
"github.com/schollz/croc/v6/src/crypt"
|
||||||
"github.com/schollz/croc/v5/src/crypt"
|
"github.com/schollz/croc/v6/src/logger"
|
||||||
"github.com/schollz/croc/v5/src/utils"
|
"github.com/schollz/croc/v6/src/utils"
|
||||||
"github.com/schollz/croc/v5/src/webrtc/pkg/session/common"
|
"github.com/schollz/croc/v6/src/webrtc/pkg/session/common"
|
||||||
"github.com/schollz/croc/v5/src/webrtc/pkg/session/receiver"
|
"github.com/schollz/croc/v6/src/webrtc/pkg/session/receiver"
|
||||||
"github.com/schollz/croc/v5/src/webrtc/pkg/session/sender"
|
"github.com/schollz/croc/v6/src/webrtc/pkg/session/sender"
|
||||||
"github.com/schollz/pake"
|
"github.com/schollz/pake"
|
||||||
"github.com/schollz/progressbar/v2"
|
"github.com/schollz/progressbar/v2"
|
||||||
"github.com/schollz/spinner"
|
"github.com/schollz/spinner"
|
||||||
|
@ -33,29 +34,29 @@ import (
|
||||||
const BufferSize = 4096 * 10
|
const BufferSize = 4096 * 10
|
||||||
const Channels = 1
|
const Channels = 1
|
||||||
|
|
||||||
var log = logrus.New()
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.SetFormatter(&logrus.TextFormatter{ForceColors: true})
|
logger.SetLogLevel("debug")
|
||||||
log.SetOutput(colorable.NewColorableStdout())
|
|
||||||
Debug(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Debug(debug bool) {
|
func Debug(debug bool) {
|
||||||
receiver.Debug(debug)
|
|
||||||
sender.Debug(debug)
|
|
||||||
if debug {
|
if debug {
|
||||||
log.SetLevel(logrus.DebugLevel)
|
logger.SetLogLevel("debug")
|
||||||
} else {
|
} 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 {
|
type Client struct {
|
||||||
Options Options
|
Options Options
|
||||||
// basic setup
|
|
||||||
redisdb *redis.Client
|
|
||||||
log *logrus.Entry
|
|
||||||
Pake *pake.Pake
|
Pake *pake.Pake
|
||||||
|
|
||||||
// steps involved in forming relationship
|
// steps involved in forming relationship
|
||||||
|
@ -63,7 +64,7 @@ type Client struct {
|
||||||
Step2FileInfoTransfered bool
|
Step2FileInfoTransfered bool
|
||||||
Step3RecipientRequestFile bool
|
Step3RecipientRequestFile bool
|
||||||
Step4FileTransfer bool
|
Step4FileTransfer bool
|
||||||
Step5CloseChannels bool // TODO: Step5 should close files and reset things
|
Step5CloseChannels bool
|
||||||
|
|
||||||
// send / receive information of all files
|
// send / receive information of all files
|
||||||
FilesToTransfer []FileInfo
|
FilesToTransfer []FileInfo
|
||||||
|
@ -73,17 +74,8 @@ type Client struct {
|
||||||
CurrentFile *os.File
|
CurrentFile *os.File
|
||||||
CurrentFileChunks []int64
|
CurrentFileChunks []int64
|
||||||
|
|
||||||
sendSess *sender.Session
|
// tcp connectios
|
||||||
recvSess *receiver.Session
|
conn [17]*comm.Comm
|
||||||
|
|
||||||
// channel data
|
|
||||||
incomingMessageChannel <-chan *redis.Message
|
|
||||||
nameOutChannel string
|
|
||||||
nameInChannel string
|
|
||||||
|
|
||||||
// webrtc connections
|
|
||||||
peerConnection [8]*webrtc.PeerConnection
|
|
||||||
dataChannel [8]*webrtc.DataChannel
|
|
||||||
|
|
||||||
bar *progressbar.ProgressBar
|
bar *progressbar.ProgressBar
|
||||||
spinner *spinner.Spinner
|
spinner *spinner.Spinner
|
||||||
|
@ -131,15 +123,6 @@ func (m Message) String() string {
|
||||||
return string(b)
|
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.
|
// New establishes a new connection for transfering files between two instances.
|
||||||
func New(ops Options) (c *Client, err error) {
|
func New(ops Options) (c *Client, err error) {
|
||||||
c = new(Client)
|
c = new(Client)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue