0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

localhost -> 127.0.0.1 Fixes #513

This commit is contained in:
Zack Scholl 2023-03-20 09:16:07 -07:00
parent e1b49e6d1c
commit b3c0625659
7 changed files with 32 additions and 32 deletions

View file

@ -428,7 +428,7 @@ func (c *Client) sendCollectFiles(filesInfo []FileInfo) (err error) {
func (c *Client) setupLocalRelay() {
// setup the relay locally
firstPort, _ := strconv.Atoi(c.Options.RelayPorts[0])
openPorts := utils.FindOpenPorts("localhost", firstPort, len(c.Options.RelayPorts))
openPorts := utils.FindOpenPorts("127.0.0.1", firstPort, len(c.Options.RelayPorts))
if len(openPorts) < len(c.Options.RelayPorts) {
panic("not enough open ports to run local relay")
}
@ -441,7 +441,7 @@ func (c *Client) setupLocalRelay() {
if c.Options.Debug {
debugString = "debug"
}
err := tcp.Run(debugString, "localhost", portStr, c.Options.RelayPassword, strings.Join(c.Options.RelayPorts[1:], ","))
err := tcp.Run(debugString, "127.0.0.1", portStr, c.Options.RelayPassword, strings.Join(c.Options.RelayPorts[1:], ","))
if err != nil {
panic(err)
}
@ -480,10 +480,10 @@ func (c *Client) transferOverLocalRelay(errchan chan<- error) {
time.Sleep(500 * time.Millisecond)
log.Debug("establishing connection")
var banner string
conn, banner, ipaddr, err := tcp.ConnectToTCPServer("localhost:"+c.Options.RelayPorts[0], c.Options.RelayPassword, c.Options.SharedSecret[:3])
conn, banner, ipaddr, err := tcp.ConnectToTCPServer("127.0.0.1:"+c.Options.RelayPorts[0], c.Options.RelayPassword, c.Options.SharedSecret[:3])
log.Debugf("banner: %s", banner)
if err != nil {
err = fmt.Errorf("could not connect to localhost:%s: %w", c.Options.RelayPorts[0], err)
err = fmt.Errorf("could not connect to 127.0.0.1:%s: %w", c.Options.RelayPorts[0], err)
log.Debug(err)
// not really an error because it will try to connect over the actual relay
return
@ -501,7 +501,7 @@ func (c *Client) transferOverLocalRelay(errchan chan<- error) {
}
c.conn[0] = conn
log.Debug("exchanged header message")
c.Options.RelayAddress = "localhost"
c.Options.RelayAddress = "127.0.0.1"
c.Options.RelayPorts = strings.Split(banner, ",")
if c.Options.NoMultiplexing {
log.Debug("no multiplexing")
@ -1160,7 +1160,7 @@ func (c *Client) processMessagePake(m message.Message) (err error) {
go func(j int) {
defer wg.Done()
var host string
if c.Options.RelayAddress == "localhost" {
if c.Options.RelayAddress == "127.0.0.1" {
host = c.Options.RelayAddress
} else {
host, _, err = net.SplitHostPort(c.Options.RelayAddress)

View file

@ -17,11 +17,11 @@ import (
func init() {
log.SetLevel("trace")
go tcp.Run("debug", "localhost", "8281", "pass123", "8282,8283,8284,8285")
go tcp.Run("debug", "localhost", "8282", "pass123")
go tcp.Run("debug", "localhost", "8283", "pass123")
go tcp.Run("debug", "localhost", "8284", "pass123")
go tcp.Run("debug", "localhost", "8285", "pass123")
go tcp.Run("debug", "127.0.0.1", "8281", "pass123", "8282,8283,8284,8285")
go tcp.Run("debug", "127.0.0.1", "8282", "pass123")
go tcp.Run("debug", "127.0.0.1", "8283", "pass123")
go tcp.Run("debug", "127.0.0.1", "8284", "pass123")
go tcp.Run("debug", "127.0.0.1", "8285", "pass123")
time.Sleep(1 * time.Second)
}
@ -33,7 +33,7 @@ func TestCrocReadme(t *testing.T) {
IsSender: true,
SharedSecret: "8123-testingthecroc",
Debug: true,
RelayAddress: "localhost:8281",
RelayAddress: "127.0.0.1:8281",
RelayPorts: []string{"8281"},
RelayPassword: "pass123",
Stdout: false,
@ -51,7 +51,7 @@ func TestCrocReadme(t *testing.T) {
IsSender: false,
SharedSecret: "8123-testingthecroc",
Debug: true,
RelayAddress: "localhost:8281",
RelayAddress: "127.0.0.1:8281",
RelayPassword: "pass123",
Stdout: false,
NoPrompt: true,
@ -99,7 +99,7 @@ func TestCrocEmptyFolder(t *testing.T) {
IsSender: true,
SharedSecret: "8123-testingthecroc",
Debug: true,
RelayAddress: "localhost:8281",
RelayAddress: "127.0.0.1:8281",
RelayPorts: []string{"8281"},
RelayPassword: "pass123",
Stdout: false,
@ -117,7 +117,7 @@ func TestCrocEmptyFolder(t *testing.T) {
IsSender: false,
SharedSecret: "8123-testingthecroc",
Debug: true,
RelayAddress: "localhost:8281",
RelayAddress: "127.0.0.1:8281",
RelayPassword: "pass123",
Stdout: false,
NoPrompt: true,
@ -166,7 +166,7 @@ func TestCrocSymlink(t *testing.T) {
IsSender: true,
SharedSecret: "8124-testingthecroc",
Debug: true,
RelayAddress: "localhost:8281",
RelayAddress: "127.0.0.1:8281",
RelayPorts: []string{"8281"},
RelayPassword: "pass123",
Stdout: false,
@ -184,7 +184,7 @@ func TestCrocSymlink(t *testing.T) {
IsSender: false,
SharedSecret: "8124-testingthecroc",
Debug: true,
RelayAddress: "localhost:8281",
RelayAddress: "127.0.0.1:8281",
RelayPassword: "pass123",
Stdout: false,
NoPrompt: true,
@ -241,7 +241,7 @@ func TestCrocLocal(t *testing.T) {
IsSender: true,
SharedSecret: "8123-testingthecroc",
Debug: true,
RelayAddress: "localhost:8181",
RelayAddress: "127.0.0.1:8181",
RelayPorts: []string{"8181", "8182"},
RelayPassword: "pass123",
Stdout: true,
@ -260,7 +260,7 @@ func TestCrocLocal(t *testing.T) {
IsSender: false,
SharedSecret: "8123-testingthecroc",
Debug: true,
RelayAddress: "localhost:8181",
RelayAddress: "127.0.0.1:8181",
RelayPassword: "pass123",
Stdout: true,
NoPrompt: true,