Skip to content

Exit sender when room matches but code doesn't#743

Closed
Ozoniuss wants to merge 2 commits intoschollz:mainfrom
Ozoniuss:notify-sender-if-roomname-wrong
Closed

Exit sender when room matches but code doesn't#743
Ozoniuss wants to merge 2 commits intoschollz:mainfrom
Ozoniuss:notify-sender-if-roomname-wrong

Conversation

@Ozoniuss
Copy link
Copy Markdown
Contributor

@Ozoniuss Ozoniuss commented Jun 24, 2024

So I've been working on this for a while now. From time to time I will have a test panic, and not sure why yet. I will make a draft PR, just to see how tests behave in the CI

edit: looks like workflow requires approval, you can give it a go if you'd like. I'll keep debugging

if interested, logs:

Details
servercluj@xxxxxx:~/github/crocfork$ go test -v -run=TestCrocLocal ./...
?       github.com/schollz/croc/v10     [no test files]
?       github.com/schollz/croc/v10/src/cli     [no test files]
testing: warning: no tests to run
PASS
ok      github.com/schollz/croc/v10/src/comm    0.003s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/schollz/croc/v10/src/compress        0.004s [no tests to run]
?       github.com/schollz/croc/v10/src/install [no test files]
?       github.com/schollz/croc/v10/src/models  [no test files]
[debug] 14:57:32 tcp.go:59: starting with password 'pass123'
[info]  2024/06/24 14:57:32 starting TCP server on 0.0.0.0:8282
[debug] 14:57:32 tcp.go:59: starting with password 'pass123'
[debug] 14:57:32 tcp.go:59: starting with password 'pass123'
[info]  2024/06/24 14:57:32 starting TCP server on 0.0.0.0:8283
[info]  2024/06/24 14:57:32 starting TCP server on 0.0.0.0:8285
[debug] 14:57:32 tcp.go:59: starting with password 'pass123'
[debug] 14:57:32 tcp.go:59: starting with password 'pass123'
[info]  2024/06/24 14:57:32 starting TCP server on 0.0.0.0:8284
[info]  2024/06/24 14:57:32 starting TCP server on 0.0.0.0:8281
=== RUN   TestCrocLocal
[debug] 14:57:33 croc_test.go:268: setting up sender
[debug] 14:57:34 croc_test.go:288: setting up receiver
[debug] 14:57:35 croc.go:511: hashed /home/servercluj/github/crocfork/LICENSE to 8a7abb1490f90afd using xxhash
[debug] 14:57:35 croc.go:516: file 0 info: {Name:LICENSE FolderRemote:./ FolderSource:/home/servercluj/github/crocfork Hash:[138 122 187 20 144 249 10 253] Size:1066 ModTime:2024-06-18 14:48:34.560506133 -0400 EDT IsCompressed:false IsEncrypted:false Symlink: Mode:-rw-r--r-- TempFile:false IsIgnored:false}
Sending 0 files (1.0 kB)[debug] 14:57:35 croc.go:511: hashed /home/servercluj/github/crocfork/src/croc/touched to ef46db3751d8e999 using xxhash
[debug] 14:57:35 croc.go:516: file 1 info: {Name:touched FolderRemote:./ FolderSource:/home/servercluj/github/crocfork/src/croc Hash:[239 70 219 55 81 216 233 153] Size:0 ModTime:2024-06-24 14:57:35.009874563 -0400 EDT IsCompressed:false IsEncrypted:false Symlink: Mode:-rw-r--r-- TempFile:false IsIgnored:false}
Sending 1 files (1.0 kB)[debug] 14:57:35 croc.go:520: longestFilename: 7
Sending 2 files (1.0 kB)
Code is: 8123-testingthecroc
On the other computer run

croc --relay 127.0.0.1:8181 8123-testingthecroc
[debug] 14:57:35 croc.go:676: host: '127.0.0.1', port: '8181'
[debug] 14:57:35 tcp.go:59: starting with password 'pass123'
[debug] 14:57:35 croc.go:682: got host '127.0.0.1' and port '8181'
[debug] 14:57:35 croc.go:684: trying connection to 127.0.0.1:8181
[info]  2024/06/24 14:57:35 starting TCP server on 0.0.0.0:8181
[debug] 14:57:35 tcp.go:59: starting with password 'pass123'
[debug] 14:57:35 comm.go:78: dialing to 127.0.0.1:8181 with timelimit 5s
[info]  2024/06/24 14:57:35 starting TCP server on 0.0.0.0:8182
[debug] 14:57:35 comm.go:87: connected to '127.0.0.1:8181'
[debug] 14:57:35 tcp.go:125: client 127.0.0.1:47442 connected
[debug] 14:57:35 tcp.go:188: Abytes: {"Role":0,"Uᵤ":793136080485469241208656611513609866400481671853,"Uᵥ":18458907634222644275952014841865282643645472623913459400556233196838128612339,"Vᵤ":1086685267857089638167386722555472967068468061489,"Vᵥ":19593504966619549205903364028255899745298716108914514072669075231742699650911,"Xᵤ":179775775857634493440447923060055803819186466075623906896213865962852143255,"Xᵥ":15427587444199907627213934414994199481618092588179793031970966668995161272678,"Yᵤ":null,"Yᵥ":null,"P":null,"Pw":null,"Vpwᵤ":null,"Vpwᵥ":null,"Upwᵤ":null,"Upwᵥ":null,"":null,"Aαᵤ":null,"Aαᵥ":null,"Zᵤ":null,"Zᵥ":null,"K":null}
[debug] 14:57:35 tcp.go:207: strongkey: ca8530fdc99859d786a6c35584937f17bac01fb54b69f3008b2b972ec10c8cad
[debug] 14:57:35 tcp.go:476: strong key: ca8530fdc99859d786a6c35584937f17bac01fb54b69f3008b2b972ec10c8cad
[debug] 14:57:35 tcp.go:490: sending password
[debug] 14:57:35 tcp.go:501: waiting for first ok
[debug] 14:57:35 tcp.go:219: waiting for password
[debug] 14:57:35 tcp.go:242: sending '8182'
[debug] 14:57:35 tcp.go:253: waiting for answer
[debug] 14:57:35 tcp.go:519: sending room; 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 tcp.go:530: waiting for room confirmation
[debug] 14:57:35 tcp.go:284: room 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355 has 1
[debug] 14:57:35 tcp.go:129: room: 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 tcp.go:130: err: <nil>
[debug] 14:57:35 tcp.go:546: all set
[debug] 14:57:35 croc.go:701: banner: 8182
[debug] 14:57:35 tcp.go:143: checking connection of room 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355 for &{connection:0xc00031a008}
[debug] 14:57:35 croc.go:702: connection established: &{connection:0xc0002b2030}
[debug] 14:57:35 tcp.go:151: room: {first:0xc000582010 second:<nil> opened:{wall:13949493334676263204 ext:2344705894 loc:0xa03300} full:false}
connecting...[debug]    14:57:35 croc.go:850: attempt to discover peers
[debug] 14:57:35 croc.go:915: discoveries: []
[debug] 14:57:35 croc.go:916: establishing connection
[debug] 14:57:35 croc.go:932: got host '127.0.0.1' and port '8181'
[debug] 14:57:35 croc.go:934: trying connection to 127.0.0.1:8181
[debug] 14:57:35 comm.go:78: dialing to 127.0.0.1:8181 with timelimit 5s
[debug] 14:57:35 comm.go:87: connected to '127.0.0.1:8181'
[debug] 14:57:35 tcp.go:125: client 127.0.0.1:47452 connected
[debug] 14:57:35 tcp.go:188: Abytes: {"Role":0,"Uᵤ":793136080485469241208656611513609866400481671853,"Uᵥ":18458907634222644275952014841865282643645472623913459400556233196838128612339,"Vᵤ":1086685267857089638167386722555472967068468061489,"Vᵥ":19593504966619549205903364028255899745298716108914514072669075231742699650911,"Xᵤ":18102734819343927058386106659317409246116877136654585952481879896885019132918,"Xᵥ":20613694207780063750051778806588241728208859277998310460962786773024391771465,"Yᵤ":null,"Yᵥ":null,"P":null,"Pw":null,"Vpwᵤ":null,"Vpwᵥ":null,"Upwᵤ":null,"Upwᵥ":null,"":null,"Aαᵤ":null,"Aαᵥ":null,"Zᵤ":null,"Zᵥ":null,"K":null}
[debug] 14:57:35 tcp.go:207: strongkey: c9a034c91139bcd145ce19755b86c87e51ffb26d62386227aeeb4f7d6f200015
[debug] 14:57:35 tcp.go:476: strong key: c9a034c91139bcd145ce19755b86c87e51ffb26d62386227aeeb4f7d6f200015
[debug] 14:57:35 tcp.go:490: sending password
[debug] 14:57:35 tcp.go:501: waiting for first ok
[debug] 14:57:35 tcp.go:219: waiting for password
[debug] 14:57:35 tcp.go:242: sending '8182'
[debug] 14:57:35 tcp.go:253: waiting for answer
[debug] 14:57:35 tcp.go:519: sending room; 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 tcp.go:530: waiting for room confirmation
[debug] 14:57:35 tcp.go:300: room 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355 has 2
[debug] 14:57:35 tcp.go:316: starting pipes
[debug] 14:57:35 tcp.go:546: all set
[debug] 14:57:35 croc.go:947: receiver connection established: &{connection:0xc00039c030}
[debug] 14:57:35 croc.go:948: banner: 8182
[debug] 14:57:35 croc.go:992: dataMessage kA: 7b4b1cbffa2c7ef1df9d9f0288746d0a2fc404d0ac2d35f6f8e59a01bcc6f568
[debug] 14:57:35 croc.go:999: sending ips?
[debug] 14:57:35 croc.go:1011: ips data: ["8181","192.168.0.40","10.1.124.192"]
[debug] 14:57:35 croc.go:1023: ipv4Add4: 192.168.0.40, ipv4Net: 192.168.0.0/24, err: <nil>
[debug] 14:57:35 croc.go:1028: localIP: 192.168.0.40, localIPparsed: 192.168.0.40
[debug] 14:57:35 croc.go:1031: ip: 192.168.0.40 is a local IP
[debug] 14:57:35 comm.go:78: dialing to 192.168.0.40:8181 with timelimit 500ms
[debug] 14:57:35 comm.go:87: connected to '192.168.0.40:8181'
[debug] 14:57:35 tcp.go:125: client 192.168.0.40:39092 connected
[debug] 14:57:35 tcp.go:188: Abytes: {"Role":0,"Uᵤ":793136080485469241208656611513609866400481671853,"Uᵥ":18458907634222644275952014841865282643645472623913459400556233196838128612339,"Vᵤ":1086685267857089638167386722555472967068468061489,"Vᵥ":19593504966619549205903364028255899745298716108914514072669075231742699650911,"Xᵤ":14192465908708358045697841510900867503376227754155761638798273735757167693264,"Xᵥ":16566607493494817400796979104735254563108080074412326565098824458137270115073,"Yᵤ":null,"Yᵥ":null,"P":null,"Pw":null,"Vpwᵤ":null,"Vpwᵥ":null,"Upwᵤ":null,"Upwᵥ":null,"":null,"Aαᵤ":null,"Aαᵥ":null,"Zᵤ":null,"Zᵥ":null,"K":null}
[debug] 14:57:35 tcp.go:207: strongkey: c6d6319719347d78de7767557288d5a5530657c09327de18f0e72f9df1700403
[debug] 14:57:35 tcp.go:476: strong key: c6d6319719347d78de7767557288d5a5530657c09327de18f0e72f9df1700403
[debug] 14:57:35 tcp.go:490: sending password
[debug] 14:57:35 tcp.go:501: waiting for first ok
[debug] 14:57:35 tcp.go:219: waiting for password
[debug] 14:57:35 tcp.go:242: sending '8182'
[debug] 14:57:35 tcp.go:253: waiting for answer
[debug] 14:57:35 tcp.go:519: sending room; 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 tcp.go:530: waiting for room confirmation
[debug] 14:57:35 tcp.go:129: room: 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 tcp.go:130: err: <nil>
[debug] 14:57:35 tcp.go:543: got bad response: room full
[debug] 14:57:35 tcp.go:143: checking connection of room 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355 for &{connection:0xc000116020}
[debug] 14:57:35 tcp.go:151: room: {first:0xc000582010 second:0xc000306330 opened:{wall:13949493334676263204 ext:2344705894 loc:0xa03300} full:true}
[debug] 14:57:35 tcp.go:153: rooms ready
[debug] 14:57:35 croc.go:1043: got bad response: room full
[debug] 14:57:35 croc.go:1044: could not connect to 192.168.0.40:8181
[debug] 14:57:35 croc.go:1023: ipv4Add4: 10.1.124.192, ipv4Net: 10.1.124.0/24, err: <nil>
[debug] 14:57:35 croc.go:1028: localIP: 192.168.0.40, localIPparsed: 192.168.0.40
[debug] 14:57:35 croc.go:1028: localIP: 10.1.124.192, localIPparsed: 10.1.124.192
[debug] 14:57:35 croc.go:1031: ip: 10.1.124.192 is a local IP
[debug] 14:57:35 comm.go:78: dialing to 10.1.124.192:8181 with timelimit 500ms
[debug] 14:57:35 comm.go:87: connected to '10.1.124.192:8181'
[debug] 14:57:35 tcp.go:125: client 10.1.124.192:51706 connected
[debug] 14:57:35 tcp.go:188: Abytes: {"Role":0,"Uᵤ":793136080485469241208656611513609866400481671853,"Uᵥ":18458907634222644275952014841865282643645472623913459400556233196838128612339,"Vᵤ":1086685267857089638167386722555472967068468061489,"Vᵥ":19593504966619549205903364028255899745298716108914514072669075231742699650911,"Xᵤ":4796593038701370884457929193183194033134706210724113152238742591806021198181,"Xᵥ":9214479472998085697274020812165219155590802513971162182943284166918702325214,"Yᵤ":null,"Yᵥ":null,"P":null,"Pw":null,"Vpwᵤ":null,"Vpwᵥ":null,"Upwᵤ":null,"Upwᵥ":null,"":null,"Aαᵤ":null,"Aαᵥ":null,"Zᵤ":null,"Zᵥ":null,"K":null}
[debug] 14:57:35 tcp.go:207: strongkey: ec3f391b1846120a3b923813ea0590523986ee8dfd55bd74870e4190308fab28
[debug] 14:57:35 tcp.go:476: strong key: ec3f391b1846120a3b923813ea0590523986ee8dfd55bd74870e4190308fab28
[debug] 14:57:35 tcp.go:490: sending password
[debug] 14:57:35 tcp.go:501: waiting for first ok
[debug] 14:57:35 tcp.go:219: waiting for password
[debug] 14:57:35 tcp.go:242: sending '8182'
[debug] 14:57:35 tcp.go:253: waiting for answer
[debug] 14:57:35 tcp.go:519: sending room; 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 tcp.go:530: waiting for room confirmation
[debug] 14:57:35 tcp.go:129: room: 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 tcp.go:130: err: <nil>
[debug] 14:57:35 tcp.go:143: checking connection of room 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355 for &{connection:0xc00039c028}
[debug] 14:57:35 tcp.go:543: got bad response: room full
[debug] 14:57:35 tcp.go:151: room: {first:0xc000582010 second:0xc000306330 opened:{wall:13949493334676263204 ext:2344705894 loc:0xa03300} full:true}
[debug] 14:57:35 croc.go:1043: got bad response: room full
[debug] 14:57:35 tcp.go:153: rooms ready
[debug] 14:57:35 croc.go:1044: could not connect to 10.1.124.192:8181
[debug] 14:57:35 croc.go:1069: exchanged header message
securing channel...[debug]      14:57:35 croc.go:1087: ready
[debug] 14:57:35 croc.go:808: error from errchan: invalid recipient password
    croc_test.go:315: send failed: invalid recipient password
[debug] 14:57:35 message.go:61: writing pake message (unencrypted)
[debug] 14:57:35 tcp.go:376: EOF
[debug] 14:57:35 tcp.go:381: exiting
[debug] 14:57:35 tcp.go:319: done piping
[debug] 14:57:35 tcp.go:345: deleting room: 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 comm.go:151: initial read error: EOF
[debug] 14:57:35 tcp.go:129: room: 1cdafe5c70a87f001f2f437fa6773c0ee726d10b7c3f86184dc68fa709c2f355
[debug] 14:57:35 croc.go:1105: got error receiving: EOF
[debug] 14:57:35 tcp.go:130: err: <nil>
panic: runtime error: index out of range [0] with length 0

goroutine 129 [running]:
github.com/schollz/croc/v10/src/croc.(*Client).transfer(0xc0002ae288)
        /home/servercluj/github/crocfork/src/croc/croc.go:1149 +0x8d3
github.com/schollz/croc/v10/src/croc.(*Client).Receive(0xc0002ae288)
        /home/servercluj/github/crocfork/src/croc/croc.go:1071 +0x149b
github.com/schollz/croc/v10/src/croc.TestCrocLocal.func2()
        /home/servercluj/github/crocfork/src/croc/croc_test.go:321 +0x29
created by github.com/schollz/croc/v10/src/croc.TestCrocLocal in goroutine 65
        /home/servercluj/github/crocfork/src/croc/croc_test.go:320 +0x36b
FAIL    github.com/schollz/croc/v10/src/croc    2.741s
testing: warning: no tests to run
PASS
ok      github.com/schollz/croc/v10/src/crypt   0.004s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/schollz/croc/v10/src/message 0.004s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/schollz/croc/v10/src/tcp     0.006s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/schollz/croc/v10/src/utils   0.004s [no tests to run]
FAIL

Tested on 2 different machines on local network, doesn't work yet. No need to run the pipeline

Previously if the receiver introduced a code that would hash to an open
room, but the code would be different from the code used to generate the
room, the receiver would fail. However, the sender would keep running,
in spite the fact that subsequent attempts to connect to the room would
fail even with the correct password. This change ensures the receiver
also stops.

- Some errors were also refactored to make the error checks easier.
@Ozoniuss Ozoniuss force-pushed the notify-sender-if-roomname-wrong branch from be6c40e to 5bd30fb Compare June 24, 2024 20:50
Adds a diagram that presents the communication steps between any client
and a local relay.
@Ozoniuss Ozoniuss force-pushed the notify-sender-if-roomname-wrong branch from 5bd30fb to 3eee9a1 Compare June 24, 2024 21:23
@Ozoniuss Ozoniuss mentioned this pull request Jul 3, 2024
@github-actions
Copy link
Copy Markdown

Stale pull request message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants