mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Merge branch 'main' of github.com:schollz/croc
This commit is contained in:
commit
064f84ccd3
9 changed files with 66 additions and 113 deletions
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
|
@ -27,7 +27,7 @@ jobs:
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.22'
|
go-version: '1.21'
|
||||||
- name: Prepare source tarball
|
- name: Prepare source tarball
|
||||||
run: |
|
run: |
|
||||||
git clone -b ${{ github.event.release.name }} --depth 1 https://github.com/schollz/croc croc-${{ github.event.release.name }}
|
git clone -b ${{ github.event.release.name }} --depth 1 https://github.com/schollz/croc croc-${{ github.event.release.name }}
|
||||||
|
@ -39,6 +39,10 @@ jobs:
|
||||||
zip croc_${{ github.event.release.name }}_Windows-64bit.zip croc.exe
|
zip croc_${{ github.event.release.name }}_Windows-64bit.zip croc.exe
|
||||||
GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o croc.exe
|
GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o croc.exe
|
||||||
zip croc_${{ github.event.release.name }}_Windows-32bit.zip croc.exe
|
zip croc_${{ github.event.release.name }}_Windows-32bit.zip croc.exe
|
||||||
|
GOOS=windows GOARCH=arm go build -ldflags="-s -w" -o croc.exe
|
||||||
|
zip croc_${{ github.event.release.name }}_Windows-ARM.zip croc.exe
|
||||||
|
GOOS=windows GOARCH=arm64 go build -ldflags="-s -w" -o croc.exe
|
||||||
|
zip croc_${{ github.event.release.name }}_Windows-ARM64.zip croc.exe
|
||||||
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o croc
|
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o croc
|
||||||
upx --brute croc
|
upx --brute croc
|
||||||
tar -czvf croc_${{ github.event.release.name }}_Linux-64bit.tar.gz croc
|
tar -czvf croc_${{ github.event.release.name }}_Linux-64bit.tar.gz croc
|
||||||
|
@ -60,6 +64,8 @@ jobs:
|
||||||
sha256sum croc_${{ github.event.release.name }}_src.tar.gz >> croc_${{ github.event.release.name }}_checksums.txt
|
sha256sum croc_${{ github.event.release.name }}_src.tar.gz >> croc_${{ github.event.release.name }}_checksums.txt
|
||||||
sha256sum croc_${{ github.event.release.name }}_Windows-64bit.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
sha256sum croc_${{ github.event.release.name }}_Windows-64bit.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
||||||
sha256sum croc_${{ github.event.release.name }}_Windows-32bit.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
sha256sum croc_${{ github.event.release.name }}_Windows-32bit.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
||||||
|
sha256sum croc_${{ github.event.release.name }}_Windows-ARM.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
||||||
|
sha256sum croc_${{ github.event.release.name }}_Windows-ARM64.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
||||||
sha256sum croc_${{ github.event.release.name }}_Windows7-64bit.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
sha256sum croc_${{ github.event.release.name }}_Windows7-64bit.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
||||||
sha256sum croc_${{ github.event.release.name }}_Windows7-32bit.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
sha256sum croc_${{ github.event.release.name }}_Windows7-32bit.zip >> croc_${{ github.event.release.name }}_checksums.txt
|
||||||
sha256sum croc_${{ github.event.release.name }}_Linux-64bit.tar.gz >> croc_${{ github.event.release.name }}_checksums.txt
|
sha256sum croc_${{ github.event.release.name }}_Linux-64bit.tar.gz >> croc_${{ github.event.release.name }}_checksums.txt
|
||||||
|
@ -76,6 +82,8 @@ jobs:
|
||||||
croc_${{ github.event.release.name }}_src.tar.gz
|
croc_${{ github.event.release.name }}_src.tar.gz
|
||||||
croc_${{ github.event.release.name }}_Windows-64bit.zip
|
croc_${{ github.event.release.name }}_Windows-64bit.zip
|
||||||
croc_${{ github.event.release.name }}_Windows-32bit.zip
|
croc_${{ github.event.release.name }}_Windows-32bit.zip
|
||||||
|
croc_${{ github.event.release.name }}_Windows-ARM.zip
|
||||||
|
croc_${{ github.event.release.name }}_Windows-ARM64.zip
|
||||||
croc_${{ github.event.release.name }}_Windows7-64bit.zip
|
croc_${{ github.event.release.name }}_Windows7-64bit.zip
|
||||||
croc_${{ github.event.release.name }}_Windows7-32bit.zip
|
croc_${{ github.event.release.name }}_Windows7-32bit.zip
|
||||||
croc_${{ github.event.release.name }}_Linux-64bit.tar.gz
|
croc_${{ github.event.release.name }}_Linux-64bit.tar.gz
|
||||||
|
|
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v5
|
- uses: actions/stale@v9
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'Stale issue message'
|
stale-issue-message: 'Stale issue message'
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
src="https://user-images.githubusercontent.com/6550035/46709024-9b23ad00-cbf6-11e8-9fb2-ca8b20b7dbec.jpg"
|
src="https://user-images.githubusercontent.com/6550035/46709024-9b23ad00-cbf6-11e8-9fb2-ca8b20b7dbec.jpg"
|
||||||
width="408px" border="0" alt="croc">
|
width="408px" border="0" alt="croc">
|
||||||
<br>
|
<br>
|
||||||
<a href="https://github.com/schollz/croc/releases/latest"><img src="https://img.shields.io/badge/version-v9.6.9-brightgreen.svg?style=flat-square" alt="Version"></a>
|
<a href="https://github.com/schollz/croc/releases/latest"><img src="https://img.shields.io/badge/version-v9.6.11-brightgreen.svg?style=flat-square" alt="Version"></a>
|
||||||
<a href="https://coveralls.io/github/schollz/croc"><img src="https://img.shields.io/badge/coverage-81%25-green.svg?style=flat-square" alt="Coverage"></a>
|
<a href="https://coveralls.io/github/schollz/croc"><img src="https://img.shields.io/badge/coverage-81%25-green.svg?style=flat-square" alt="Coverage"></a>
|
||||||
<a href="https://travis-ci.org/schollz/croc"><img
|
<a href="https://travis-ci.org/schollz/croc"><img
|
||||||
src="https://img.shields.io/travis/schollz/croc.svg?style=flat-square" alt="Build
|
src="https://img.shields.io/travis/schollz/croc.svg?style=flat-square" alt="Build
|
||||||
|
|
4
go.mod
4
go.mod
|
@ -16,7 +16,7 @@ require (
|
||||||
github.com/schollz/progressbar/v3 v3.14.1
|
github.com/schollz/progressbar/v3 v3.14.1
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.8.2
|
||||||
golang.org/x/crypto v0.19.0
|
golang.org/x/crypto v0.19.0
|
||||||
golang.org/x/net v0.20.0
|
golang.org/x/net v0.21.0
|
||||||
golang.org/x/time v0.5.0
|
golang.org/x/time v0.5.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ require (
|
||||||
github.com/magisterquis/connectproxy v0.0.0-20200725203833-3582e84f0c9b
|
github.com/magisterquis/connectproxy v0.0.0-20200725203833-3582e84f0c9b
|
||||||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/rivo/uniseg v0.4.6 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
github.com/tscholl2/siec v0.0.0-20210707234609-9bdfc483d499 // indirect
|
github.com/tscholl2/siec v0.0.0-20210707234609-9bdfc483d499 // indirect
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -34,8 +34,8 @@ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
@ -85,8 +85,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
|
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
|
||||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
|
|
@ -36,7 +36,7 @@ func Run() (err error) {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "croc"
|
app.Name = "croc"
|
||||||
if Version == "" {
|
if Version == "" {
|
||||||
Version = "v9.6.9"
|
Version = "v9.6.11"
|
||||||
}
|
}
|
||||||
app.Version = Version
|
app.Version = Version
|
||||||
app.Compiled = time.Now()
|
app.Compiled = time.Now()
|
||||||
|
@ -86,8 +86,7 @@ func Run() (err error) {
|
||||||
Action: relay,
|
Action: relay,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{Name: "host", Usage: "host of the relay"},
|
&cli.StringFlag{Name: "host", Usage: "host of the relay"},
|
||||||
&cli.IntFlag{Name: "port", Value: 9009, Usage: "base port for the relay"},
|
&cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the relay"},
|
||||||
&cli.IntFlag{Name: "transfers", Value: 4, Usage: "number of ports to use for transfers"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -176,13 +175,19 @@ func send(c *cli.Context) (err error) {
|
||||||
setDebugLevel(c)
|
setDebugLevel(c)
|
||||||
comm.Socks5Proxy = c.String("socks5")
|
comm.Socks5Proxy = c.String("socks5")
|
||||||
comm.HttpProxy = c.String("connect")
|
comm.HttpProxy = c.String("connect")
|
||||||
portString := c.Int("port")
|
|
||||||
if portString == 0 {
|
portParam := c.Int("port")
|
||||||
portString = 9009
|
if portParam == 0 {
|
||||||
|
portParam = 9009
|
||||||
}
|
}
|
||||||
transfersString := c.Int("transfers")
|
transfersParam := c.Int("transfers")
|
||||||
if transfersString == 0 {
|
if transfersParam == 0 {
|
||||||
transfersString = 4
|
transfersParam = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
ports := make([]string, transfersParam+1)
|
||||||
|
for i := 0; i <= transfersParam; i++ {
|
||||||
|
ports[i] = strconv.Itoa(portParam + i)
|
||||||
}
|
}
|
||||||
|
|
||||||
crocOptions := croc.Options{
|
crocOptions := croc.Options{
|
||||||
|
@ -196,8 +201,7 @@ func send(c *cli.Context) (err error) {
|
||||||
DisableLocal: c.Bool("no-local"),
|
DisableLocal: c.Bool("no-local"),
|
||||||
OnlyLocal: c.Bool("local"),
|
OnlyLocal: c.Bool("local"),
|
||||||
IgnoreStdin: c.Bool("ignore-stdin"),
|
IgnoreStdin: c.Bool("ignore-stdin"),
|
||||||
BasePort: portString,
|
RelayPorts: ports,
|
||||||
TransferPorts: transfersString,
|
|
||||||
Ask: c.Bool("ask"),
|
Ask: c.Bool("ask"),
|
||||||
NoMultiplexing: c.Bool("no-multi"),
|
NoMultiplexing: c.Bool("no-multi"),
|
||||||
RelayPassword: determinePass(c),
|
RelayPassword: determinePass(c),
|
||||||
|
@ -230,11 +234,8 @@ func send(c *cli.Context) (err error) {
|
||||||
if !c.IsSet("no-local") {
|
if !c.IsSet("no-local") {
|
||||||
crocOptions.DisableLocal = rememberedOptions.DisableLocal
|
crocOptions.DisableLocal = rememberedOptions.DisableLocal
|
||||||
}
|
}
|
||||||
if !c.IsSet("port") && rememberedOptions.BasePort > 0 {
|
if !c.IsSet("ports") && len(rememberedOptions.RelayPorts) > 0 {
|
||||||
crocOptions.BasePort = rememberedOptions.BasePort
|
crocOptions.RelayPorts = rememberedOptions.RelayPorts
|
||||||
}
|
|
||||||
if !c.IsSet("transfers") && rememberedOptions.TransferPorts > 0 {
|
|
||||||
crocOptions.TransferPorts = rememberedOptions.TransferPorts
|
|
||||||
}
|
}
|
||||||
if !c.IsSet("code") {
|
if !c.IsSet("code") {
|
||||||
crocOptions.SharedSecret = rememberedOptions.SharedSecret
|
crocOptions.SharedSecret = rememberedOptions.SharedSecret
|
||||||
|
|
104
src/croc/croc.go
104
src/croc/croc.go
|
@ -60,8 +60,7 @@ type Options struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
RelayAddress string
|
RelayAddress string
|
||||||
RelayAddress6 string
|
RelayAddress6 string
|
||||||
BasePort int
|
RelayPorts []string
|
||||||
TransferPorts int
|
|
||||||
RelayPassword string
|
RelayPassword string
|
||||||
Stdout bool
|
Stdout bool
|
||||||
NoPrompt bool
|
NoPrompt bool
|
||||||
|
@ -530,26 +529,21 @@ func (c *Client) sendCollectFiles(filesInfo []FileInfo) (err error) {
|
||||||
|
|
||||||
func (c *Client) setupLocalRelay() {
|
func (c *Client) setupLocalRelay() {
|
||||||
// setup the relay locally
|
// setup the relay locally
|
||||||
basePort := c.Options.BasePort
|
firstPort, _ := strconv.Atoi(c.Options.RelayPorts[0])
|
||||||
transferPorts := c.Options.TransferPorts
|
openPorts := utils.FindOpenPorts("127.0.0.1", firstPort, len(c.Options.RelayPorts))
|
||||||
ports := make([]string, transferPorts+1)
|
if len(openPorts) < len(c.Options.RelayPorts) {
|
||||||
for i := range ports {
|
|
||||||
ports[i] = strconv.Itoa(basePort + i)
|
|
||||||
}
|
|
||||||
openPorts := utils.FindOpenPorts("127.0.0.1", basePort, transferPorts+1)
|
|
||||||
if len(openPorts) < len(ports) {
|
|
||||||
panic("not enough open ports to run local relay")
|
panic("not enough open ports to run local relay")
|
||||||
}
|
}
|
||||||
for i, port := range openPorts {
|
for i, port := range openPorts {
|
||||||
ports[i] = fmt.Sprint(port)
|
c.Options.RelayPorts[i] = fmt.Sprint(port)
|
||||||
}
|
}
|
||||||
for _, port := range ports {
|
for _, port := range c.Options.RelayPorts {
|
||||||
go func(portStr string) {
|
go func(portStr string) {
|
||||||
debugString := "warn"
|
debugString := "warn"
|
||||||
if c.Options.Debug {
|
if c.Options.Debug {
|
||||||
debugString = "debug"
|
debugString = "debug"
|
||||||
}
|
}
|
||||||
err := tcp.Run(debugString, "127.0.0.1", portStr, c.Options.RelayPassword, fmt.Sprintf(strconv.Itoa(basePort)+","+strconv.Itoa(transferPorts)))
|
err := tcp.Run(debugString, "127.0.0.1", portStr, c.Options.RelayPassword, strings.Join(c.Options.RelayPorts[1:], ","))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -568,7 +562,7 @@ func (c *Client) broadcastOnLocalNetwork(useipv6 bool) {
|
||||||
// look for peers first
|
// look for peers first
|
||||||
settings := peerdiscovery.Settings{
|
settings := peerdiscovery.Settings{
|
||||||
Limit: -1,
|
Limit: -1,
|
||||||
Payload: []byte("croc" + strconv.Itoa(c.Options.BasePort)),
|
Payload: []byte("croc" + c.Options.RelayPorts[0]),
|
||||||
Delay: 20 * time.Millisecond,
|
Delay: 20 * time.Millisecond,
|
||||||
TimeLimit: timeLimit,
|
TimeLimit: timeLimit,
|
||||||
}
|
}
|
||||||
|
@ -588,10 +582,10 @@ func (c *Client) transferOverLocalRelay(errchan chan<- error) {
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
log.Debug("establishing connection")
|
log.Debug("establishing connection")
|
||||||
var banner string
|
var banner string
|
||||||
conn, banner, ipaddr, err := tcp.ConnectToTCPServer("127.0.0.1:"+strconv.Itoa(c.Options.BasePort), 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)
|
log.Debugf("banner: %s", banner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("could not connect to 127.0.0.1:%s: %w", c.Options.BasePort, err)
|
err = fmt.Errorf("could not connect to 127.0.0.1:%s: %w", c.Options.RelayPorts[0], err)
|
||||||
log.Debug(err)
|
log.Debug(err)
|
||||||
// not really an error because it will try to connect over the actual relay
|
// not really an error because it will try to connect over the actual relay
|
||||||
return
|
return
|
||||||
|
@ -610,26 +604,10 @@ func (c *Client) transferOverLocalRelay(errchan chan<- error) {
|
||||||
c.conn[0] = conn
|
c.conn[0] = conn
|
||||||
log.Debug("exchanged header message")
|
log.Debug("exchanged header message")
|
||||||
c.Options.RelayAddress = "127.0.0.1"
|
c.Options.RelayAddress = "127.0.0.1"
|
||||||
var basePort, transferPorts int
|
c.Options.RelayPorts = strings.Split(banner, ",")
|
||||||
banner_split := strings.Split(banner, ",")
|
|
||||||
if len(banner_split) != 2 {
|
|
||||||
panic(fmt.Sprintf("Expected port and number of transfer ports in banner: %v", banner))
|
|
||||||
}
|
|
||||||
basePort, err = strconv.Atoi(banner_split[0])
|
|
||||||
if err == nil {
|
|
||||||
c.Options.BasePort = basePort
|
|
||||||
} else {
|
|
||||||
panic(fmt.Sprintf("could not get transfer ports: %v", err))
|
|
||||||
}
|
|
||||||
transferPorts, err = strconv.Atoi(banner_split[1])
|
|
||||||
if err == nil {
|
|
||||||
c.Options.TransferPorts = transferPorts
|
|
||||||
} else {
|
|
||||||
panic(fmt.Sprintf("could not get transfer ports: %v", err))
|
|
||||||
}
|
|
||||||
if c.Options.NoMultiplexing {
|
if c.Options.NoMultiplexing {
|
||||||
log.Debug("no multiplexing")
|
log.Debug("no multiplexing")
|
||||||
c.Options.TransferPorts = 1
|
c.Options.RelayPorts = []string{c.Options.RelayPorts[0]}
|
||||||
}
|
}
|
||||||
c.ExternalIP = ipaddr
|
c.ExternalIP = ipaddr
|
||||||
errchan <- c.transfer()
|
errchan <- c.transfer()
|
||||||
|
@ -727,7 +705,7 @@ func (c *Client) Send(filesInfo []FileInfo, emptyFoldersToTransfer []FileInfo, t
|
||||||
log.Debugf("error getting local ips: %v", err)
|
log.Debugf("error getting local ips: %v", err)
|
||||||
}
|
}
|
||||||
// prepend the port that is being listened to
|
// prepend the port that is being listened to
|
||||||
ips = append([]string{strconv.Itoa(c.Options.BasePort)}, ips...)
|
ips = append([]string{c.Options.RelayPorts[0]}, ips...)
|
||||||
}
|
}
|
||||||
bips, _ := json.Marshal(ips)
|
bips, _ := json.Marshal(ips)
|
||||||
if err = conn.Send(bips); err != nil {
|
if err = conn.Send(bips); err != nil {
|
||||||
|
@ -747,26 +725,10 @@ func (c *Client) Send(filesInfo []FileInfo, emptyFoldersToTransfer []FileInfo, t
|
||||||
}
|
}
|
||||||
|
|
||||||
c.conn[0] = conn
|
c.conn[0] = conn
|
||||||
var basePort, transferPorts int
|
c.Options.RelayPorts = strings.Split(banner, ",")
|
||||||
banner_split := strings.Split(banner, ",")
|
|
||||||
if len(banner_split) != 2 {
|
|
||||||
panic(fmt.Sprintf("Expected port and number of transfer ports in banner: %v", banner))
|
|
||||||
}
|
|
||||||
basePort, err = strconv.Atoi(banner_split[0])
|
|
||||||
if err == nil {
|
|
||||||
c.Options.BasePort = basePort
|
|
||||||
} else {
|
|
||||||
panic(fmt.Sprintf("could not get transfer ports: %v", err))
|
|
||||||
}
|
|
||||||
transferPorts, err = strconv.Atoi(banner_split[1])
|
|
||||||
if err == nil {
|
|
||||||
c.Options.TransferPorts = transferPorts
|
|
||||||
} else {
|
|
||||||
panic(fmt.Sprintf("could not get transfer ports: %v", err))
|
|
||||||
}
|
|
||||||
if c.Options.NoMultiplexing {
|
if c.Options.NoMultiplexing {
|
||||||
log.Debug("no multiplexing")
|
log.Debug("no multiplexing")
|
||||||
c.Options.TransferPorts = 1
|
c.Options.RelayPorts = []string{c.Options.RelayPorts[0]}
|
||||||
}
|
}
|
||||||
c.ExternalIP = ipaddr
|
c.ExternalIP = ipaddr
|
||||||
log.Debug("exchanged header message")
|
log.Debug("exchanged header message")
|
||||||
|
@ -986,26 +948,10 @@ func (c *Client) Receive() (err error) {
|
||||||
if err = c.conn[0].Send(handshakeRequest); err != nil {
|
if err = c.conn[0].Send(handshakeRequest); err != nil {
|
||||||
log.Errorf("handshake send error: %v", err)
|
log.Errorf("handshake send error: %v", err)
|
||||||
}
|
}
|
||||||
var basePort, transferPorts int
|
c.Options.RelayPorts = strings.Split(banner, ",")
|
||||||
banner_split := strings.Split(banner, ",")
|
|
||||||
if len(banner_split) != 2 {
|
|
||||||
panic(fmt.Sprintf("Expected port and number of transfer ports in banner: %v", banner))
|
|
||||||
}
|
|
||||||
basePort, err = strconv.Atoi(banner_split[0])
|
|
||||||
if err == nil {
|
|
||||||
c.Options.BasePort = basePort
|
|
||||||
} else {
|
|
||||||
panic(fmt.Sprintf("could not get transfer ports: %v", err))
|
|
||||||
}
|
|
||||||
transferPorts, err = strconv.Atoi(banner_split[1])
|
|
||||||
if err == nil {
|
|
||||||
c.Options.TransferPorts = transferPorts
|
|
||||||
} else {
|
|
||||||
panic(fmt.Sprintf("could not get transfer ports: %v", err))
|
|
||||||
}
|
|
||||||
if c.Options.NoMultiplexing {
|
if c.Options.NoMultiplexing {
|
||||||
log.Debug("no multiplexing")
|
log.Debug("no multiplexing")
|
||||||
c.Options.TransferPorts = 1
|
c.Options.RelayPorts = []string{c.Options.RelayPorts[0]}
|
||||||
}
|
}
|
||||||
log.Debug("exchanged header message")
|
log.Debug("exchanged header message")
|
||||||
fmt.Fprintf(os.Stderr, "\rsecuring channel...")
|
fmt.Fprintf(os.Stderr, "\rsecuring channel...")
|
||||||
|
@ -1098,7 +1044,7 @@ func (c *Client) transfer() (err error) {
|
||||||
if err = os.Remove(pathToFile); err != nil {
|
if err = os.Remove(pathToFile); err != nil {
|
||||||
log.Warnf("error removing %s: %v", pathToFile, err)
|
log.Warnf("error removing %s: %v", pathToFile, err)
|
||||||
}
|
}
|
||||||
fmt.Print("\n")
|
fmt.Fprint(os.Stderr, "\n")
|
||||||
}
|
}
|
||||||
if err != nil && strings.Contains(err.Error(), "pake not successful") {
|
if err != nil && strings.Contains(err.Error(), "pake not successful") {
|
||||||
log.Debugf("pake error: %s", err.Error())
|
log.Debugf("pake error: %s", err.Error())
|
||||||
|
@ -1309,9 +1255,9 @@ func (c *Client) processMessagePake(m message.Message) (err error) {
|
||||||
|
|
||||||
// connects to the other ports of the server for transfer
|
// connects to the other ports of the server for transfer
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(c.Options.TransferPorts + 1)
|
wg.Add(len(c.Options.RelayPorts))
|
||||||
for i := 0; i <= c.Options.TransferPorts; i++ {
|
for i := 0; i < len(c.Options.RelayPorts); i++ {
|
||||||
log.Debugf("port: [%d]", c.Options.BasePort+i)
|
log.Debugf("port: [%s]", c.Options.RelayPorts[i])
|
||||||
go func(j int) {
|
go func(j int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
var host string
|
var host string
|
||||||
|
@ -1324,7 +1270,7 @@ func (c *Client) processMessagePake(m message.Message) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server := net.JoinHostPort(host, strconv.Itoa(c.Options.BasePort+j))
|
server := net.JoinHostPort(host, c.Options.RelayPorts[j])
|
||||||
log.Debugf("connecting to %s", server)
|
log.Debugf("connecting to %s", server)
|
||||||
c.conn[j+1], _, _, err = tcp.ConnectToTCPServer(
|
c.conn[j+1], _, _, err = tcp.ConnectToTCPServer(
|
||||||
server,
|
server,
|
||||||
|
@ -1802,7 +1748,7 @@ func (c *Client) updateState() (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := 0; i <= c.Options.TransferPorts; i++ {
|
for i := 0; i < len(c.Options.RelayPorts); i++ {
|
||||||
log.Debugf("starting sending over comm %d", i)
|
log.Debugf("starting sending over comm %d", i)
|
||||||
go c.sendData(i)
|
go c.sendData(i)
|
||||||
}
|
}
|
||||||
|
@ -1915,7 +1861,7 @@ func (c *Client) sendData(i int) {
|
||||||
defer func() {
|
defer func() {
|
||||||
log.Debugf("finished with %d", i)
|
log.Debugf("finished with %d", i)
|
||||||
c.numfinished++
|
c.numfinished++
|
||||||
if c.numfinished == c.Options.TransferPorts+1 {
|
if c.numfinished == len(c.Options.RelayPorts) {
|
||||||
log.Debug("closing file")
|
log.Debug("closing file")
|
||||||
if err := c.fread.Close(); err != nil {
|
if err := c.fread.Close(); err != nil {
|
||||||
log.Errorf("error closing file: %v", err)
|
log.Errorf("error closing file: %v", err)
|
||||||
|
@ -1939,7 +1885,7 @@ func (c *Client) sendData(i int) {
|
||||||
time.Sleep(r.Delay())
|
time.Sleep(r.Delay())
|
||||||
}
|
}
|
||||||
|
|
||||||
if math.Mod(curi, float64(c.Options.TransferPorts+1)) == float64(i) {
|
if math.Mod(curi, float64(len(c.Options.RelayPorts))) == float64(i) {
|
||||||
// check to see if this is a chunk that the recipient wants
|
// check to see if this is a chunk that the recipient wants
|
||||||
usableChunk := true
|
usableChunk := true
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
func init() {
|
func init() {
|
||||||
log.SetLevel("trace")
|
log.SetLevel("trace")
|
||||||
|
|
||||||
go tcp.Run("debug", "127.0.0.1", "8281", "pass123", "8281,4")
|
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", "8282", "pass123")
|
||||||
go tcp.Run("debug", "127.0.0.1", "8283", "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", "8284", "pass123")
|
||||||
|
@ -35,7 +35,7 @@ func TestCrocReadme(t *testing.T) {
|
||||||
SharedSecret: "8123-testingthecroc",
|
SharedSecret: "8123-testingthecroc",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
RelayAddress: "127.0.0.1:8281",
|
RelayAddress: "127.0.0.1:8281",
|
||||||
BasePort: 8281,
|
RelayPorts: []string{"8281"},
|
||||||
RelayPassword: "pass123",
|
RelayPassword: "pass123",
|
||||||
Stdout: false,
|
Stdout: false,
|
||||||
NoPrompt: true,
|
NoPrompt: true,
|
||||||
|
@ -102,7 +102,7 @@ func TestCrocEmptyFolder(t *testing.T) {
|
||||||
SharedSecret: "8123-testingthecroc",
|
SharedSecret: "8123-testingthecroc",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
RelayAddress: "127.0.0.1:8281",
|
RelayAddress: "127.0.0.1:8281",
|
||||||
BasePort: 8281,
|
RelayPorts: []string{"8281"},
|
||||||
RelayPassword: "pass123",
|
RelayPassword: "pass123",
|
||||||
Stdout: false,
|
Stdout: false,
|
||||||
NoPrompt: true,
|
NoPrompt: true,
|
||||||
|
@ -169,7 +169,7 @@ func TestCrocSymlink(t *testing.T) {
|
||||||
SharedSecret: "8124-testingthecroc",
|
SharedSecret: "8124-testingthecroc",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
RelayAddress: "127.0.0.1:8281",
|
RelayAddress: "127.0.0.1:8281",
|
||||||
BasePort: 8281,
|
RelayPorts: []string{"8281"},
|
||||||
RelayPassword: "pass123",
|
RelayPassword: "pass123",
|
||||||
Stdout: false,
|
Stdout: false,
|
||||||
NoPrompt: true,
|
NoPrompt: true,
|
||||||
|
@ -271,8 +271,7 @@ func TestCrocLocal(t *testing.T) {
|
||||||
SharedSecret: "8123-testingthecroc",
|
SharedSecret: "8123-testingthecroc",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
RelayAddress: "127.0.0.1:8181",
|
RelayAddress: "127.0.0.1:8181",
|
||||||
BasePort: 8181,
|
RelayPorts: []string{"8181", "8182"},
|
||||||
TransferPorts: 1,
|
|
||||||
RelayPassword: "pass123",
|
RelayPassword: "pass123",
|
||||||
Stdout: true,
|
Stdout: true,
|
||||||
NoPrompt: true,
|
NoPrompt: true,
|
||||||
|
@ -352,8 +351,7 @@ func TestCrocError(t *testing.T) {
|
||||||
SharedSecret: "8123-testingthecroc2",
|
SharedSecret: "8123-testingthecroc2",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
RelayAddress: "doesntexistok.com:8381",
|
RelayAddress: "doesntexistok.com:8381",
|
||||||
BasePort: 8381,
|
RelayPorts: []string{"8381", "8382"},
|
||||||
TransferPorts: 1,
|
|
||||||
RelayPassword: "pass123",
|
RelayPassword: "pass123",
|
||||||
Stdout: true,
|
Stdout: true,
|
||||||
NoPrompt: true,
|
NoPrompt: true,
|
||||||
|
|
|
@ -528,7 +528,7 @@ main() {
|
||||||
local autocomplete_install_rcode
|
local autocomplete_install_rcode
|
||||||
|
|
||||||
croc_bin_name="croc"
|
croc_bin_name="croc"
|
||||||
croc_version="9.6.9"
|
croc_version="9.6.11"
|
||||||
croc_dl_ext="tar.gz"
|
croc_dl_ext="tar.gz"
|
||||||
croc_base_url="https://github.com/schollz/croc/releases/download"
|
croc_base_url="https://github.com/schollz/croc/releases/download"
|
||||||
prefix="${1}"
|
prefix="${1}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue