Skip to content

Commit

Permalink
A lot of logger.InfoFs are added. Some tweaks in configs
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuryshev committed Jun 11, 2019
1 parent 777e756 commit 959a837
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 18 deletions.
1 change: 1 addition & 0 deletions integration/intermediary-nodeB.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
],
"route_finder": "https://routefinder.skywire.skycoin.net/",
"route_finder_timeout": "60s",
"table": {
"type": "boltdb",
"location": "./local/nodeB/routing.db"
Expand Down
16 changes: 10 additions & 6 deletions integration/messaging/env-vars.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# This script needs to be `source`d from bash-compatible shell
# E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/generic/env-vars.sh`
export PK_A=$(jq -r ".node.static_public_key" ./integration/generic/nodeA.json)
export RPC_A=$(jq -r ".interfaces.rpc" ./integration/generic/nodeA.json)
# E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/messaging/env-vars.sh`
export PK_A=$(jq -r ".node.static_public_key" ./integration/messaging/nodeA.json)
export RPC_A=$(jq -r ".interfaces.rpc" ./integration/messaging/nodeA.json)
export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json)
export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json)
export PK_C=$(jq -r ".node.static_public_key" ./integration/generic/nodeC.json)
export RPC_C=$(jq -r ".interfaces.rpc" ./integration/generic/nodeC.json)
export PK_C=$(jq -r ".node.static_public_key" ./integration/messaging/nodeC.json)
export RPC_C=$(jq -r ".interfaces.rpc" ./integration/messaging/nodeC.json)

export CHAT_A=http://localhost:8000/message
export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/generic/nodeC.json)/message
export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/messaging/nodeC.json)/message

alias CLI_A='./skywire-cli --rpc $RPC_A'
alias CLI_B='./skywire-cli --rpc $RPC_B'
alias CLI_C='./skywire-cli --rpc $RPC_C'

alias RUN_A='go run ./cmd/skywire-node ./integration/messaging/nodeA.json --tag NodeA'
alias RUN_B='go run ./cmd/skywire-node ./integration/intermediary-nodeB.json --tag NodeB'
alias RUN_C='go run ./cmd/skywire-node ./integration/messaging/nodeC.json --tag NodeC'

echo PK_A: $PK_A
echo PK_B: $PK_B
echo PK_C: $PK_C
Expand Down
2 changes: 2 additions & 0 deletions integration/messaging/nodeA.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
],
"route_finder": "https://routefinder.skywire.skycoin.net/",
"route_finder_timeout": "60s",
"table": {
"type": "boltdb",
"location": "./local/nodeA/routing.db"
Expand All @@ -37,6 +38,7 @@
"trusted_nodes": [],
"manager_nodes": [],
"apps_path": "./apps",
"shutdown_timeout": "30s",
"local_path": "./local/nodeA",
"log_level": "info",
"interfaces": {
Expand Down
2 changes: 2 additions & 0 deletions integration/messaging/nodeC.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
],
"route_finder": "https://routefinder.skywire.skycoin.net/",
"route_finder_timeout": "60s",
"table": {
"type": "boltdb",
"location": "./local/nodeC/routing.db"
Expand All @@ -37,6 +38,7 @@
"trusted_nodes": [],
"manager_nodes": [],
"apps_path": "./apps",
"shutdown_timeout": "30s",
"local_path": "./local/nodeC",
"log_level": "info",
"interfaces": {
Expand Down
4 changes: 4 additions & 0 deletions integration/proxy/env-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ alias CLI_A='./skywire-cli --rpc $RPC_A'
alias CLI_B='./skywire-cli --rpc $RPC_B'
alias CLI_C='./skywire-cli --rpc $RPC_C'

alias RUN_A='go run ./cmd/skywire-node ./integration/messaging/nodeA.json --tag NodeA'
alias RUN_B='go run ./cmd/skywire-node ./integration/intermediary-nodeB.json --tag NodeB'
alias RUN_C='go run ./cmd/skywire-node ./integration/messaging/nodeC.json --tag NodeC'

echo PK_A: $PK_A
echo PK_B: $PK_B
echo PK_C: $PK_C
4 changes: 4 additions & 0 deletions integration/ssh/env-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ alias CLI_A='./skywire-cli --rpc $RPC_A'
alias CLI_B='./skywire-cli --rpc $RPC_B'
alias CLI_C='./skywire-cli --rpc $RPC_C'

alias RUN_A='go run ./cmd/skywire-node ./integration/messaging/nodeA.json --tag NodeA'
alias RUN_B='go run ./cmd/skywire-node ./integration/intermediary-nodeB.json --tag NodeB'
alias RUN_C='go run ./cmd/skywire-node ./integration/messaging/nodeC.json --tag NodeC'

echo PK_A: $PK_A
echo PK_B: $PK_B
echo PK_C: $PK_C
2 changes: 1 addition & 1 deletion integration/test-messaging.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
source ./integration/generic/env-vars.sh
curl --data {'"recipient":"'$PK_A'", "message":"Hello Joe!"}' -X POST $CHAT_C
# curl --data {'"recipient":"'$PK_A'", "message":"Hello Joe!"}' -X POST $CHAT_C
curl --data {'"recipient":"'$PK_C'", "message":"Hello Mike!"}' -X POST $CHAT_A
1 change: 1 addition & 0 deletions pkg/messaging/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func newChannel(initiator bool, secKey cipher.SecKey, remote cipher.PubKey, link
readChan: make(chan []byte),
doneChan: make(chan struct{}),
noise: noiseInstance,
deadline: time.Time{},
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/messaging/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ var (
// ErrRejected indicates that ChannelOpen frame was rejected by remote server.
ErrRejected = errors.New("rejected")
// ErrChannelClosed indicates that underlying channel is being closed and writes are prohibited.
ErrChannelClosed = errors.New("channel closed")
ErrChannelClosed = errors.New("messaging channel closed")
// ErrDeadlineExceeded indicates that read/write operation failed due to timeout.
ErrDeadlineExceeded = errors.New("deadline exceeded")
ErrDeadlineExceeded = errors.New("deadline exceeded in messaging")
// ErrClientClosed indicates that client is closed and not accepting new connections.
ErrClientClosed = errors.New("client closed")
)
Expand Down
29 changes: 20 additions & 9 deletions pkg/transport/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,64 @@ func (handshake settlementHandshake) Do(tm *Manager, tr Transport, timeout time.
case <-done:
return entry, err
case <-time.After(timeout):
return nil, errors.New("deadline exceeded")
tm.Logger.Infof("handshake.Do timeout exceeded for value: %v", timeout)
return nil, errors.New("deadline exceeded on handshake")
}
}

func settlementInitiatorHandshake(public bool) settlementHandshake {
return func(tm *Manager, tr Transport) (*Entry, error) {
tm.Logger.Info("Entering settlementInitiatorHandshake")
entry := &Entry{
ID: MakeTransportID(tr.Edges()[0], tr.Edges()[1], tr.Type(), public),
EdgeKeys: tr.Edges(),
Type: tr.Type(),
Public: public,
}

remote, ok := tm.Remote(tr.Edges())
if !ok {
return nil, errors.New("configured PubKey not found in edges")
}

tm.Logger.Infof("settlementInitiatorHandshake: NewSignedEntry with %v", remote)
sEntry, ok := NewSignedEntry(entry, tm.config.PubKey, tm.config.SecKey)
if !ok {
return nil, errors.New("error creating signed entry")
}
tm.Logger.Info("settlementInitiatorHandshake: validateSignedEntry")
if err := validateSignedEntry(sEntry, tr, tm.config.PubKey); err != nil {
return nil, fmt.Errorf("settlementInitiatorHandshake NewSignedEntry: %s\n sEntry: %v", err, sEntry)
}

tm.Logger.Info("settlementInitiatorHandshake: json.NewEncoder.Encode")
if err := json.NewEncoder(tr).Encode(sEntry); err != nil {
return nil, fmt.Errorf("write: %s", err)
}

tm.Logger.Info("settlementInitiatorHandshake: json.NewDecoder")
respSEntry := &SignedEntry{}
if err := json.NewDecoder(tr).Decode(respSEntry); err != nil {
return nil, fmt.Errorf("read: %s", err)
}

// Verifying remote signature
remote, ok := tm.Remote(tr.Edges())
if !ok {
return nil, errors.New("configured PubKey not found in edges")
}

tm.Logger.Info("settlementInitiatorHandshake: verifySig")
if err := verifySig(respSEntry, remote); err != nil {
return nil, err
}

tm.Logger.Info("settlementInitiatorHandshake: tm.walkEntries")
newEntry := tm.walkEntries(func(e *Entry) bool { return *e == *respSEntry.Entry }) == nil
if newEntry {
tm.addEntry(entry)
}

tm.Logger.Info("Exiting settlementInitiatorHandshake")
return respSEntry.Entry, nil
}
}

func settlementResponderHandshake(tm *Manager, tr Transport) (*Entry, error) {
tm.Logger.Info("Entering settlementResponderHandshake")
sEntry := &SignedEntry{}
if err := json.NewDecoder(tr).Decode(sEntry); err != nil {
return nil, fmt.Errorf("read: %s", err)
Expand All @@ -91,6 +100,7 @@ func settlementResponderHandshake(tm *Manager, tr Transport) (*Entry, error) {

newEntry := tm.walkEntries(func(e *Entry) bool { return *e == *sEntry.Entry }) == nil

tm.Logger.Info("Entering settlementResponderHandshake: DiscoveryClient.UpdateStatuses/RegisterTransports")
var err error
if sEntry.Entry.Public {
if !newEntry {
Expand All @@ -104,14 +114,15 @@ func settlementResponderHandshake(tm *Manager, tr Transport) (*Entry, error) {
return nil, fmt.Errorf("entry set: %s", err)
}

tm.Logger.Info("Entering settlementResponderHandshake: json.NewEncoder(tr).Encode")
if err := json.NewEncoder(tr).Encode(sEntry); err != nil {
return nil, fmt.Errorf("write: %s", err)
}

if newEntry {
tm.addEntry(sEntry.Entry)
}

tm.Logger.Info("Exiting settlementResponderHandshake")
return sEntry.Entry, nil
}

Expand Down

0 comments on commit 959a837

Please sign in to comment.