Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "*" as acceptable origin #1252

Closed
wants to merge 1 commit into from
Closed

add "*" as acceptable origin #1252

wants to merge 1 commit into from

Conversation

geoknee
Copy link
Contributor

@geoknee geoknee commented May 4, 2023

Today I tried to connect to go-nitro using the TS rpc client CLI tool https://github.com/statechannels/nitro-gui/tree/main/packages/nitro-rpc-client#cli-tool .

I got the error:

~/s/go-nitro ❯❯❯ go run . --usenats=false                                                                                                                                                                                                     ✘ 1 remove-panic ⬆ ✭
{"level":"debug","engine":"0xAAA662","time":1683203643997,"caller":"engine.go:115","message":"Constructed Engine"}
Nitro as a Service listening on port 4005
2023/05/04 13:34:10 http: panic serving 127.0.0.1:61722: failed to accept WebSocket connection: request Origin "*" is not authorized for Host "127.0.0.1:4005"
goroutine 73 [running]:
net/http.(*conn).serve.func1()
	/usr/local/go/src/net/http/server.go:1854 +0xb0
panic({0x101df5380, 0x14000bda240})
	/usr/local/go/src/runtime/panic.go:890 +0x258
github.com/statechannels/go-nitro/rpc/transport/ws.(*serverWebSocketTransport).subscribe(0x1400065a000, {0x1020059c0?, 0x14000204000?}, 0x140005a0100)
	/Users/georgeknee/statechannels/go-nitro/rpc/transport/ws/server.go:112 +0x468
net/http.HandlerFunc.ServeHTTP(0x14000595ad8?, {0x1020059c0?, 0x14000204000?}, 0x10?)
	/usr/local/go/src/net/http/server.go:2122 +0x38
net/http.(*ServeMux).ServeHTTP(0x0?, {0x1020059c0, 0x14000204000}, 0x140005a0100)
	/usr/local/go/src/net/http/server.go:2500 +0x140
net/http.serverHandler.ServeHTTP({0x140001de540?}, {0x1020059c0, 0x14000204000}, 0x140005a0100)
	/usr/local/go/src/net/http/server.go:2936 +0x2d8
net/http.(*conn).serve(0x1400022f8c0, {0x1020071b8, 0x140005b80c0})
	/usr/local/go/src/net/http/server.go:1995 +0x560
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:3089 +0x520
{"level":"debug","txSigner":"0xdF3e18","time":1683203794020,"caller":"eth_chainservice.go:242","message":"resubscribed to filtered logs"}
^CReceived signal interrupt, exiting..%

It seems that by trying to lock down connections to localhost, we have actually ended up excluding connections from our CLI tool. This change fixes the error, although I am not sure it is the correct place to do so. An alternative would be to have the CLI tool set a more meaningful Origin: header and have go-nitro add that to its whitelist.

Related to #1221 and also statechannels/nitro-gui#5

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for nitrodocs canceled.

Name Link
🔨 Latest commit 82fa26f
🔍 Latest deploy log https://app.netlify.com/sites/nitrodocs/deploys/6453a93bd88c0c0008d61ae6

@lalexgap
Copy link
Contributor

lalexgap commented May 4, 2023

I think this may actually be a nitro-rpc-client issue. We were hardcoding an Origin of * in our websocket connection. Here's a PR to address this

@geoknee
Copy link
Contributor Author

geoknee commented May 4, 2023

I think this may actually be a nitro-rpc-client issue. We were hardcoding an Origin of * in our websocket connection. Here's a PR to address this

Thanks @lalexgap, I guess we don't need this change then.

@geoknee geoknee closed this May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants