diff --git a/.version b/.version index 5f8379dc..96bfc52a 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -version=0.5.4 +version=0.5.5 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b4e79d8..25400c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,17 @@ # Changelog ## [unreleased]((https://github.com/NodeFactoryIo/vedran/tree/HEAD)) -[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.4...HEAD) +[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.5...HEAD) + +### Added + +### Fix +- Fix duplicated ports inside tunnel address pool [\#204](https://github.com/NodeFactoryIo/vedran/pull/204) ([mpetrun5](https://github.com/mpetrun5)) + +### Changed + +## [v0.5.5]((https://github.com/NodeFactoryIo/vedran/tree/v0.5.5)) +[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.4...v0.5.5) ### Added diff --git a/README.md b/README.md index 91b473cb..e88dbc50 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ Send metrics for node. Auth token should be in header as `X-Auth-Header`. Body s "peer_count": "int32", "best_block_height": "int64", "finalized_block_height": "int64", + "target_block_height": "int64", "ready_transaction_count": "int32" } ``` @@ -263,14 +264,29 @@ Returns statistics for all nodes (mapped on node payout address). ```json { - "node_1_payout_address": { - "total_pings": "float64", - "total_requests": "float64" - }, - "node_2_payout_address": { - "total_pings": "float64", - "total_requests": "float64" - }, + "stats": { + "node_1_payout_address": { + "total_pings": "float64", + "total_requests": "float64" + }, + "node_2_payout_address": { + "total_pings": "float64", + "total_requests": "float64" + } + } +} +``` + +--- + +`GET api/v1/stats/lb` + +Returns statistics on reward distribution between load balancer and nodes. + +```json +{ + "lb_fee": "string", + "nodes_fee": "string" } ``` diff --git a/assets/vedran-arch.png b/assets/vedran-arch.png index 91e26d31..af57f6ba 100644 Binary files a/assets/vedran-arch.png and b/assets/vedran-arch.png differ diff --git a/docker-compose.yml b/docker-compose.yml index dc1eb265..2cb30bde 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,7 @@ services: container_name: "vedran" vedran-daemon: - image: nodefactory/vedran-daemon:v0.3.4 + image: nodefactory/vedran-daemon:latest depends_on: - vedran - polkadot diff --git a/internal/loadbalancer/server.go b/internal/loadbalancer/server.go index 70da00f8..dd2d45d0 100644 --- a/internal/loadbalancer/server.go +++ b/internal/loadbalancer/server.go @@ -100,7 +100,7 @@ func StartLoadBalancerServer( r := router.CreateNewApiRouter(apiController, privateKey) prometheus.RecordMetrics(*repos) if props.CertFile != "" { - tlsConfig := &tls.Config{MinVersion: tls.VersionTLS10} + tlsConfig := &tls.Config{MinVersion: 0} server := &http.Server{ Addr: fmt.Sprintf(":%d", props.Port), Handler: handlers.CORS()(r), diff --git a/pkg/http-tunnel/integration_test.go b/pkg/http-tunnel/integration_test.go index 416e86d5..ff237488 100644 --- a/pkg/http-tunnel/integration_test.go +++ b/pkg/http-tunnel/integration_test.go @@ -67,7 +67,6 @@ func Test_IntegrationTest(t *testing.T) { assert.True(t, strings.Contains(logStr, "msg=\"try connect\"")) assert.True(t, strings.Contains(logStr, "msg=\"handshake for address 127.0.0.1:5223\"")) assert.True(t, strings.Contains(logStr, "msg=\"REGISTRY SUBSCRIBE\"")) - assert.True(t, strings.Contains(logStr, "msg=\"REGISTRY SET (OLD FOUND)\"")) assert.True(t, strings.Contains(logStr, "msg=\"REGISTRY SET (NEW SET)\"")) assert.True(t, strings.Contains(logStr, "msg=\"test-id connected\"")) diff --git a/pkg/http-tunnel/server/addrpool.go b/pkg/http-tunnel/server/addrpool.go index a9d8f06f..cfce3266 100644 --- a/pkg/http-tunnel/server/addrpool.go +++ b/pkg/http-tunnel/server/addrpool.go @@ -53,6 +53,18 @@ func (ap *AddrPool) Init(rang string) error { func (ap *AddrPool) Acquire(cname string, pname string) (int, error) { ap.mutex.Lock() defer ap.mutex.Unlock() + var existingPort int + + if pname == "http" { + existingPort, _ = ap.GetHTTPPort(cname) + } else { + existingPort, _ = ap.GetWSPort(cname) + } + + if existingPort != 0 { + return existingPort, nil + } + assignedPort := 0 // search for the first unnused port for i := ap.first; i < ap.last; i++ { diff --git a/pkg/http-tunnel/server/addrpool_test.go b/pkg/http-tunnel/server/addrpool_test.go index 3466ac17..c9c204b1 100644 --- a/pkg/http-tunnel/server/addrpool_test.go +++ b/pkg/http-tunnel/server/addrpool_test.go @@ -73,7 +73,29 @@ func TestAddrPool_Acquire(t *testing.T) { fields: fields{100, 100, 1, make(map[int]*RemoteID)}, }, { - name: "Returns port if available", + name: "Returns existing http port if exists", + args: args{cname: "test-id", pname: "http"}, + wantErr: false, + want: 100, + fields: fields{100, 102, 1, map[int]*RemoteID{100: { + ClientID: "test-id", + PortName: "http", + Port: 100, + }}}, + }, + { + name: "Returns existing ws port if exists", + args: args{cname: "test-id", pname: "ws"}, + wantErr: false, + want: 100, + fields: fields{100, 102, 1, map[int]*RemoteID{100: { + ClientID: "test-id", + PortName: "ws", + Port: 100, + }}}, + }, + { + name: "Acquires port if available", args: args{cname: "test-id", pname: "default"}, wantErr: false, want: 100, diff --git a/pkg/http-tunnel/server/registry.go b/pkg/http-tunnel/server/registry.go index f4a0c7a8..9c304421 100644 --- a/pkg/http-tunnel/server/registry.go +++ b/pkg/http-tunnel/server/registry.go @@ -6,9 +6,10 @@ package server import ( "fmt" - log "github.com/sirupsen/logrus" "net" "sync" + + log "github.com/sirupsen/logrus" ) // RegistryItem holds information about hosts and listeners associated with a @@ -149,12 +150,6 @@ func (r *registry) set(i *RegistryItem, identifier string) error { return errClientNotSubscribed } - r.logger.WithFields(log.Fields{ - "client-name": identifier, - "client-id": j.ClientID, - "data": j, - }).Debug("REGISTRY SET (OLD FOUND)") - i.ClientID = j.ClientID r.logger.WithFields(log.Fields{ diff --git a/pkg/http-tunnel/server/server.go b/pkg/http-tunnel/server/server.go index d6e59c58..41a7866a 100644 --- a/pkg/http-tunnel/server/server.go +++ b/pkg/http-tunnel/server/server.go @@ -223,13 +223,13 @@ func (s *Server) handleClient(conn net.Conn) { resp, err = s.httpClient.Do(req) if err != nil { - alogger.Error("handshake failed 1", err) + alogger.Error("handshake failed 1 ", err) goto reject } if resp.StatusCode != http.StatusOK { err = fmt.Errorf("Status %s", resp.Status) - alogger.Error("handshake failed 2", err) + alogger.Error("handshake failed 2 ", err) goto reject } @@ -238,7 +238,7 @@ func (s *Server) handleClient(conn net.Conn) { token = resp.Header.Get("X-Auth-Header") if token == "" { err = errors.New("Auth header missing") - alogger.Error("handshake failed", err) + alogger.Error("handshake failed ", err) goto reject }