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

Release v0.5.5 #202

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.5.4
version=0.5.5
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
```
Expand All @@ -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"
}
```

Expand Down
Binary file modified assets/vedran-arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/loadbalancer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion pkg/http-tunnel/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\""))

Expand Down
12 changes: 12 additions & 0 deletions pkg/http-tunnel/server/addrpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand Down
24 changes: 23 additions & 1 deletion pkg/http-tunnel/server/addrpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 2 additions & 7 deletions pkg/http-tunnel/server/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down
6 changes: 3 additions & 3 deletions pkg/http-tunnel/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down