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

cmd: Adds check for invalid inferred IP #1859

Merged
merged 1 commit into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
#### Orchestrator

- \#1860 Discard low gas prices to prevent insufficient ticket faceValue errors (@kyriediculous)
- \#1859 Handle error for invalid inferred orchestrator public IP on node startup (@reubenr0d)

#### Transcoder
12 changes: 8 additions & 4 deletions cmd/livepeer/livepeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,17 +1012,21 @@ func getServiceURI(n *core.LivepeerNode, serviceAddr string) (*url.URL, error) {
// TODO probably should put this (along w wizard GETs) into common code
resp, err := http.Get("https://api.ipify.org?format=text")
if err != nil {
glog.Error("Could not look up public IP address")
glog.Errorf("Could not look up public IP err=%v", err)
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
glog.Error("Could not look up public IP address")
glog.Errorf("Could not look up public IP err=%v", err)
return nil, err
}
addr := "https://" + strings.TrimSpace(string(body)) + ":" + RpcPort
inferredUri, err := url.ParseRequestURI(addr)
if err != nil {
glog.Errorf("Could not look up public IP err=%v", err)
return nil, err
}
if n.Eth == nil {
// we won't be looking up onchain sURI so use the inferred one
return inferredUri, err
Expand All @@ -1031,12 +1035,12 @@ func getServiceURI(n *core.LivepeerNode, serviceAddr string) (*url.URL, error) {
// On-chain lookup and matching with inferred public address
addr, err = n.Eth.GetServiceURI(n.Eth.Account().Address)
if err != nil {
glog.Error("Could not get service URI; orchestrator may be unreachable")
glog.Errorf("Could not get service URI; orchestrator may be unreachable err=%v", err)
return nil, err
}
ethUri, err := url.ParseRequestURI(addr)
if err != nil {
glog.Error("Could not parse service URI; orchestrator may be unreachable")
glog.Errorf("Could not parse service URI; orchestrator may be unreachable err=%v", err)
ethUri, _ = url.ParseRequestURI("http://127.0.0.1:" + RpcPort)
}
if ethUri.Hostname() != inferredUri.Hostname() || ethUri.Port() != inferredUri.Port() {
Expand Down