diff --git a/src/croc/sending.go b/src/croc/sending.go index f044d68..ecf4e06 100644 --- a/src/croc/sending.go +++ b/src/croc/sending.go @@ -148,10 +148,9 @@ func (c *Croc) sendReceive(address, websocketPort, tcpPort, fname, codephrase st } if isSender { - // start peerdiscovery relay server - go sender.Send(isLocal, done, sock, fname, codephrase, c.UseCompression, c.UseEncryption) + go sender.Send(address, tcpPort, isLocal, done, sock, fname, codephrase, c.UseCompression, c.UseEncryption) } else { - go recipient.Receive(isLocal, done, sock, codephrase, c.NoRecipientPrompt, c.Stdout) + go recipient.Receive(address, tcpPort, isLocal, done, sock, codephrase, c.NoRecipientPrompt, c.Stdout) } for { diff --git a/src/recipient/recipient.go b/src/recipient/recipient.go index 5c97d86..120b400 100644 --- a/src/recipient/recipient.go +++ b/src/recipient/recipient.go @@ -31,9 +31,9 @@ import ( var DebugLevel string // Receive is the async operation to receive a file -func Receive(isLocal bool, done chan struct{}, c *websocket.Conn, codephrase string, noPrompt bool, useStdout bool) { +func Receive(serverAddress, serverTCP string, isLocal bool, done chan struct{}, c *websocket.Conn, codephrase string, noPrompt bool, useStdout bool) { logger.SetLogLevel(DebugLevel) - err := receive(isLocal, c, codephrase, noPrompt, useStdout) + err := receive(serverAddress, serverTCP, isLocal, c, codephrase, noPrompt, useStdout) if err != nil { if !strings.HasPrefix(err.Error(), "websocket: close 100") { fmt.Fprintf(os.Stderr, "\n"+err.Error()) @@ -42,7 +42,7 @@ func Receive(isLocal bool, done chan struct{}, c *websocket.Conn, codephrase str done <- struct{}{} } -func receive(isLocal bool, c *websocket.Conn, codephrase string, noPrompt bool, useStdout bool) (err error) { +func receive(serverAddress, serverTCP string, isLocal bool, c *websocket.Conn, codephrase string, noPrompt bool, useStdout bool) (err error) { var fstats models.FileStats var sessionKey []byte var transferTime time.Duration @@ -161,7 +161,7 @@ func receive(isLocal bool, c *websocket.Conn, codephrase string, noPrompt bool, // connect to TCP to receive file if !isLocal { - tcpConnection, err = connectToTCPServer(utils.SHA256(fmt.Sprintf("%x", sessionKey)), "localhost:8154") + tcpConnection, err = connectToTCPServer(utils.SHA256(fmt.Sprintf("%x", sessionKey)), serverAddress+":"+serverTCP) if err != nil { log.Error(err) return err diff --git a/src/sender/sender.go b/src/sender/sender.go index d54932c..8aa21db 100644 --- a/src/sender/sender.go +++ b/src/sender/sender.go @@ -30,10 +30,10 @@ import ( var DebugLevel string // Send is the async call to send data -func Send(isLocal bool, done chan struct{}, c *websocket.Conn, fname string, codephrase string, useCompression bool, useEncryption bool) { +func Send(serverAddress, serverTCP string, isLocal bool, done chan struct{}, c *websocket.Conn, fname string, codephrase string, useCompression bool, useEncryption bool) { logger.SetLogLevel(DebugLevel) log.Debugf("sending %s", fname) - err := send(isLocal, c, fname, codephrase, useCompression, useEncryption) + err := send(serverAddress, serverTCP, isLocal, c, fname, codephrase, useCompression, useEncryption) if err != nil { if !strings.HasPrefix(err.Error(), "websocket: close 100") { fmt.Fprintf(os.Stderr, "\n"+err.Error()) @@ -43,7 +43,7 @@ func Send(isLocal bool, done chan struct{}, c *websocket.Conn, fname string, cod done <- struct{}{} } -func send(isLocal bool, c *websocket.Conn, fname string, codephrase string, useCompression bool, useEncryption bool) (err error) { +func send(serverAddress, serverTCP string, isLocal bool, c *websocket.Conn, fname string, codephrase string, useCompression bool, useEncryption bool) (err error) { var f *os.File defer f.Close() // ignore the error if it wasn't opened :( var fstats models.FileStats @@ -197,7 +197,7 @@ func send(isLocal bool, c *websocket.Conn, fname string, codephrase string, useC if !isLocal { // connection to TCP - tcpConnection, err = connectToTCPServer(utils.SHA256(fmt.Sprintf("%x", sessionKey)), "localhost:8154") + tcpConnection, err = connectToTCPServer(utils.SHA256(fmt.Sprintf("%x", sessionKey)), serverAddress+":"+serverTCP) if err != nil { log.Error(err) return