mirror of https://github.com/schollz/croc.git
update
This commit is contained in:
parent
0f72e35268
commit
166b1cf6cc
2
go.mod
2
go.mod
|
@ -26,7 +26,7 @@ require (
|
|||
github.com/urfave/cli v1.22.1
|
||||
golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f
|
||||
golang.org/x/net v0.0.0-20191116160921-f9c825593386 // indirect
|
||||
golang.org/x/sys v0.0.0-20191115151921-52ab43148777 // indirect
|
||||
golang.org/x/sys v0.0.0-20191118133127-cf1e2d577169 // indirect
|
||||
golang.org/x/text v0.3.2 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -87,6 +87,8 @@ golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191115151921-52ab43148777 h1:wejkGHRTr38uaKRqECZlsCsJ1/TGxIyFbH32x5zUdu4=
|
||||
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191118133127-cf1e2d577169 h1:LPLFLulk2vyM7yI3CwNW64O6e8AxBmr9opfv14yI7HI=
|
||||
golang.org/x/sys v0.0.0-20191118133127-cf1e2d577169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
|
|
38
html/main.go
38
html/main.go
|
@ -25,12 +25,37 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/schollz/croc/v6/src/compress"
|
||||
"github.com/schollz/croc/v6/src/croc"
|
||||
"github.com/schollz/croc/v6/src/crypt"
|
||||
"github.com/schollz/croc/v6/src/message"
|
||||
log "github.com/schollz/logger"
|
||||
"github.com/schollz/pake/v2"
|
||||
)
|
||||
|
||||
func marshal(a interface{}) string {
|
||||
b, err := json.Marshal(a)
|
||||
if err != nil {
|
||||
log.Errorf("could not marshal: %+v, because '%s'", a, err.Error())
|
||||
}
|
||||
return base64.StdEncoding.EncodeToString(b)
|
||||
}
|
||||
|
||||
// crocInit(weakPassphrase,issender)
|
||||
func crocInit(this js.Value, inputs []js.Value) interface{} {
|
||||
if len(inputs) != 2 {
|
||||
return js.Global().Get("Error").New("need weakPassphrase,issender")
|
||||
}
|
||||
c := new(croc.Client)
|
||||
c.FilesHasFinished = make(map[int]struct{})
|
||||
c.Options = croc.Options{
|
||||
IsSender: inputs[1].String() == "1",
|
||||
SharedSecret: inputs[0].String(),
|
||||
RelayAddress: "localhost:9009",
|
||||
Debug: true,
|
||||
}
|
||||
return marshal(c)
|
||||
}
|
||||
|
||||
// messageEncode(key, Message)
|
||||
// returns base64 encoded, encrypts if key != nil
|
||||
func messageEncode(this js.Value, inputs []js.Value) interface{} {
|
||||
|
@ -233,12 +258,13 @@ func pakeSessionKey(this js.Value, inputs []js.Value) interface{} {
|
|||
func main() {
|
||||
c := make(chan bool)
|
||||
// fmt.Println("starting")
|
||||
js.Global().Set("pakeInit", js.FuncOf(pakeInit))
|
||||
js.Global().Set("pakePublic", js.FuncOf(pakePublic))
|
||||
js.Global().Set("pakeUpdate", js.FuncOf(pakeUpdate))
|
||||
js.Global().Set("pakeSessionKey", js.FuncOf(pakeSessionKey))
|
||||
js.Global().Set("messageEncode", js.FuncOf(messageEncode))
|
||||
js.Global().Set("messageDecode", js.FuncOf(messageDecode))
|
||||
js.Global().Set("crocInit", js.FuncOf(crocInit))
|
||||
// js.Global().Set("pakeInit", js.FuncOf(pakeInit))
|
||||
// js.Global().Set("pakePublic", js.FuncOf(pakePublic))
|
||||
// js.Global().Set("pakeUpdate", js.FuncOf(pakeUpdate))
|
||||
// js.Global().Set("pakeSessionKey", js.FuncOf(pakeSessionKey))
|
||||
// js.Global().Set("messageEncode", js.FuncOf(messageEncode))
|
||||
// js.Global().Set("messageDecode", js.FuncOf(messageDecode))
|
||||
fmt.Println("Initiated")
|
||||
<-c
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/denisbrodbeck/machineid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/schollz/croc/v6/src/comm"
|
||||
"github.com/schollz/croc/v6/src/compress"
|
||||
|
@ -308,7 +307,7 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
|||
}
|
||||
fmt.Fprintf(os.Stderr, "Code is: %s\nOn the other computer run\n\ncroc %s%s\n", c.Options.SharedSecret, otherRelay, c.Options.SharedSecret)
|
||||
if c.Options.Ask {
|
||||
machid, _ := machineid.ID()
|
||||
machid := "machineid.ID()"
|
||||
fmt.Fprintf(os.Stderr, "\rYour machine ID is '%s'\n", machid)
|
||||
}
|
||||
// // c.spinner.Suffix = " waiting for recipient..."
|
||||
|
@ -558,7 +557,7 @@ func (c *Client) processMessageFileInfo(m message.Message) (done bool, err error
|
|||
// c.spinner.Stop()
|
||||
if !c.Options.NoPrompt || c.Options.Ask || senderInfo.Ask {
|
||||
if c.Options.Ask || senderInfo.Ask {
|
||||
machID, _ := machineid.ID()
|
||||
machID := "machineid.ID()"
|
||||
fmt.Fprintf(os.Stderr, "\rYour machine id is '%s'.\nAccept %s (%s) from '%s'? (y/n) ", machID, fname, utils.ByteCountDecimal(totalSize), senderInfo.MachineID)
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "\rAccept %s (%s)? (y/n) ", fname, utils.ByteCountDecimal(totalSize))
|
||||
|
@ -750,7 +749,7 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
|
|||
func (c *Client) updateIfSenderChannelSecured() (err error) {
|
||||
if c.Options.IsSender && c.Step1ChannelSecured && !c.Step2FileInfoTransfered {
|
||||
var b []byte
|
||||
machID, _ := machineid.ID()
|
||||
machID := "machineid.ID()"
|
||||
b, err = json.Marshal(SenderInfo{
|
||||
FilesToTransfer: c.FilesToTransfer,
|
||||
MachineID: machID,
|
||||
|
@ -843,7 +842,7 @@ func (c *Client) recipientGetFileReady(finished bool) (err error) {
|
|||
}
|
||||
|
||||
c.TotalSent = 0
|
||||
machID, _ := machineid.ID()
|
||||
machID := "machineid.ID()"
|
||||
bRequest, _ := json.Marshal(RemoteFileRequest{
|
||||
CurrentFileChunkRanges: c.CurrentFileChunkRanges,
|
||||
FilesToTransferCurrentNum: c.FilesToTransferCurrentNum,
|
||||
|
|
|
@ -72,7 +72,9 @@ func receive(conn *websocket.Conn) (err error) {
|
|||
errBundle := json.Unmarshal(message, &bu)
|
||||
if errBundle == nil {
|
||||
if bu.Message == "room" {
|
||||
com, banner, externalIP, err = tcp.ConnectToTCPServer(models.DEFAULT_RELAY, bu.PayloadString)
|
||||
relayAddress := models.DEFAULT_RELAY
|
||||
relayAddress = "localhost:9009"
|
||||
com, banner, externalIP, err = tcp.ConnectToTCPServer(relayAddress, bu.PayloadString)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue