Skip to content

Commit

Permalink
Merge branch 'mainnet-milestone1' into feature/226-manaager-node-back…
Browse files Browse the repository at this point in the history
…end-additions
  • Loading branch information
ivcosla committed Sep 2, 2019
2 parents a3280a2 + f6e92d3 commit 36eac41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ func (app *App) serveConn(loop routing.Loop, conn io.ReadWriteCloser) {
if err != nil {
break
}
fmt.Println("READ:", buf)

packet := &Packet{Loop: loop, Payload: buf[:n]}
if err := app.proto.Send(FrameSend, packet, nil); err != nil {
Expand Down
11 changes: 5 additions & 6 deletions pkg/router/route_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import (
"net"
"time"

"github.com/skycoin/skywire/pkg/snet"

"github.com/google/uuid"
"github.com/skycoin/dmsg/cipher"

"github.com/skycoin/skywire/pkg/setup"

"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/pkg/routing"
"github.com/skycoin/skywire/pkg/setup"
"github.com/skycoin/skywire/pkg/snet"
)

type RMConfig struct {
Expand Down Expand Up @@ -308,7 +306,8 @@ func (rm *routeManager) loopClosed(data []byte) error {
}

func (rm *routeManager) occupyRouteID() ([]routing.RouteID, error) {
routeID, err := rm.rt.AddRule(nil)
rule := routing.ForwardRule(time.Now().Add(RouteTTL), 0, uuid.UUID{}, 0)
routeID, err := rm.rt.AddRule(rule)
if err != nil {
return nil, err
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/routing/rule.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package routing

import (
"bytes"
"encoding/binary"
"errors"
"fmt"
Expand Down Expand Up @@ -194,11 +195,11 @@ func AppRule(expireAt time.Time, respRoute RouteID, remotePK cipher.PubKey, remo
rule[8] = byte(RuleApp)
binary.BigEndian.PutUint32(rule[9:], uint32(respRoute))
rule = append(rule, remotePK[:]...)
rule = append(rule, 0, 0, 0, 0, 0, 0, 0, 0)
rule = append(rule, bytes.Repeat([]byte{0}, 8)...)
binary.BigEndian.PutUint16(rule[46:], uint16(remotePort))
binary.BigEndian.PutUint16(rule[48:], uint16(localPort))
binary.BigEndian.PutUint32(rule[50:], uint32(requestRouteID))
return Rule(rule)
return rule
}

// ForwardRule constructs a new forward RoutingRule.
Expand All @@ -213,7 +214,7 @@ func ForwardRule(expireAt time.Time, nextRoute RouteID, nextTrID uuid.UUID, requ
rule[8] = byte(RuleForward)
binary.BigEndian.PutUint32(rule[9:], uint32(nextRoute))
rule = append(rule, nextTrID[:]...)
rule = append(rule, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
rule = append(rule, bytes.Repeat([]byte{0}, 25)...)
binary.BigEndian.PutUint32(rule[50:], uint32(requestRouteID))
return Rule(rule)
return rule
}

0 comments on commit 36eac41

Please sign in to comment.