Skip to content

Commit

Permalink
removed certificates, updated docs, update run-self-signed command (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvovk authored Nov 16, 2023
1 parent 0b3f792 commit 782c604
Show file tree
Hide file tree
Showing 12 changed files with 716 additions and 769 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ run:
go run ./cmd/diagnostics

run-self-signed:
go run ./cmd/diagnostics --tls.cert _demo-tls/diagnostics.crt --tls.key _demo-tls/diagnostics-key.pem --tls.cacerts _demo-tls/CA-cert.pem

## In order to solw relod UI 404 issue first cd to folder and after run
cd ./cmd/diagnostics && go run .
clean:
rm -rf $(BUILD_DIR)

Expand Down
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ Run the application. This may take a while. Expect to see a TLS Handshake error
make run-self-signed
```

To view the application in your browser, go to the URL `https://localhost:8080/ui`. Your browser will likely ask to accept the risks (due to self-signed certificate), do that.

[Link to more information on this step](#how-to-build-and-run)

## Connect the Erigon Node to the Diagnostics System setup
Expand Down Expand Up @@ -167,20 +165,16 @@ If metrics are exposed, textual representation of metrics will be displayed in t
# How to connect Erigon node to the diagnostics system
![diagnostics system connection](/_images/diagnostics-connection-anim.gif)
#### Step 1:
The app's diagnostic user interface (UI) will automatically open at https://localhost:8080 after you run one of the following commands:
The app's diagnostic user interface (UI) will automatically open at http://< --metrics.addr --metrics.port> after you run one of the following commands:
```
./_bin/diagnostics --tls.cert demo-tls/diagnostics.crt --tls.key demo-tls/diagnostics-key.pem --tls.cacerts demo-tls/CA-cert.pem
cd ./cmd/diagnostics && go run .
```
or
```
make run-self-signed
```


#### Step 2:
Please note that you may need to accept the security risks associated with the self-signed certificate. This action is required only the first time you access this URL, as your browser will remember your choice for subsequent visits.

#### Step 3:
Follow these steps to create a session:

![create new operation session 1](/_images/create_session_1.png)
Expand All @@ -193,28 +187,26 @@ Enter session name which helps you helassociate session with erigon node user

![create new operation session 3](/_images/create_session_3.png)

#### Step 4:
#### Step 3:
Once the new session is successfully created, it will be allocated a unique 8-digit PIN number. You can find this PIN displayed alongside the session in the list of created sessions. Please note that currently, you can only create one session, but support for multiple sessions will be extended in the future.

#### Step 5:
#### Step 4:
Ensure that the Erigon node is already running on your system. Then, open a new console window and run the following command. Be sure to specify the session PIN at the end of the `--diagnostics.url` command line flag. Since the website uses a self-signed certificate without a properly allocated CName, you need to use the `--insecure` flag to establish a connection.

```
./build/bin/erigon support --debug.urls http://localhost:6060 --diagnostics.url https://localhost:8080 --diagnostics.sessions YOUR_SESSION_PIN --insecure
./build/bin/erigon support --debug.urls http://localhost:6060 --diagnostics.url http://< --metrics.addr --metrics.port> --diagnostics.sessions YOUR_SESSION_PIN --insecure
```

Replace `YOUR_SESSION_PIN` with the 8-digit PIN allocated to your session during the previous step. This command will attach the diagnostics tool erigon node using the provided PIN.

#### Step 6:
#### Step 5:
Once the diagnostics tool successfully connects to the Erigon node, return to your web browser and reload the page. This step is necessary to query data from the connected node.

#### Step 7:
Currently diagnostics UI support "Process", "Logs", "Data" tabs
# Architecture of diagnostics system

Following diagram shows schematically how the process of diagnostics works. Erigon nodes that can be diagnosed, need to be running with `--metrics` flag.
Diagnostics system (HTTP/2 website) needs to be running somewhere. For the public use, it can be a website managed by Erigon team, for example. For
personal and testing use, this can be locally run website with self-signed certificates.
personal and testing use, this can be locally run website.

In order to connect Erigon node to the Diagnostics system, user needs to start a process with a command `erigon support`, as described earlier.
The initiations of network connections are shown as solid single arrows. One can see that `erigon support` initiates connections to both Erigon node
Expand Down
11 changes: 0 additions & 11 deletions _demo-tls/CA-cert.pem

This file was deleted.

5 changes: 0 additions & 5 deletions _demo-tls/diagnostics-key.pem

This file was deleted.

11 changes: 0 additions & 11 deletions _demo-tls/diagnostics.crt

This file was deleted.

3 changes: 2 additions & 1 deletion api/main_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func NewHandler(services APIServices) http.Handler {

r.Mount("/", web.UI)
r.HandleFunc("/snapshot-sync", index)
r.HandleFunc("/network", index)
r.HandleFunc("/sentry-network", index)
r.HandleFunc("/sentinel-network", index)
r.HandleFunc("/logs", index)
r.HandleFunc("/chain", index)
r.HandleFunc("/data", index)
Expand Down
8 changes: 0 additions & 8 deletions cmd/diagnostics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ var (
listenAddr string
listenPort int
routerPort int
serverKeyFile string
serverCertFile string
caCertFiles []string
insecure bool
maxNodeSessions int
maxUISessions int
Expand Down Expand Up @@ -44,11 +41,6 @@ func init() {
rootCmd.Flags().StringVar(&listenAddr, "addr", "localhost", "network interface to listen on")
rootCmd.Flags().IntVar(&listenPort, "port", 8080, "port to listen on")
rootCmd.Flags().IntVar(&routerPort, "rest.port", 0, "port to listen on")
rootCmd.Flags().StringVar(&serverKeyFile, "tls.key", "", "path to server TLS key")
_ = rootCmd.MarkFlagRequired("tls.key")
rootCmd.Flags().StringVar(&serverCertFile, "tls.cert", "", "paths to server TLS certificates")
_ = rootCmd.MarkFlagRequired("tls.cert")
rootCmd.Flags().StringSliceVar(&caCertFiles, "tls.cacerts", []string{}, "comma-separated list of paths to and CAs TLS certificates")
rootCmd.Flags().BoolVar(&insecure, "insecure", false, "whether to use insecure PIN generation for testing purposes (default is false)")
rootCmd.Flags().IntVar(&maxNodeSessions, "node.sessions", 5000, "maximum number of node sessions to allow")
rootCmd.Flags().IntVar(&maxUISessions, "ui.sessions", 5000, "maximum number of UI sessions to allow")
Expand Down
11 changes: 0 additions & 11 deletions cmd/diagnostics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"crypto/x509"
"fmt"
"log"
"net/http"
Expand Down Expand Up @@ -39,16 +38,6 @@ func main() {
log.Fatalf("session cache creation failed: %v", err)
}

// Initializes and adds the provided certificate to the pool, to be used in TLS config
certPool := x509.NewCertPool()
for _, caCertFile := range caCertFiles {
caCert, err := os.ReadFile(caCertFile)
if err != nil {
log.Fatalf("reading server certificate: %v", err)
}
certPool.AppendCertsFromPEM(caCert)
}

// Passing in the services to REST layer
handlers := api.NewHandler(
api.APIServices{
Expand Down
Loading

0 comments on commit 782c604

Please sign in to comment.