Skip to content

Commit

Permalink
Add local PK to the consume rule's descriptor. Therefore, modify `add…
Browse files Browse the repository at this point in the history
…-rule` cmd of visor-cli

`add-rule` command now has the following signature: add-rule (app <route-id> <local-pk> <local-port> <remote-pk> <remote-port> | fwd <next-route-id> <next-transport-id>)
  • Loading branch information
Darkren committed Nov 29, 2019
1 parent 1d57ce1 commit 547e0bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions cmd/skywire-cli/commands/node/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func init() {
}

var addRuleCmd = &cobra.Command{
Use: "add-rule (app <route-id> <remote-pk> <remote-port> <local-port> | fwd <next-route-id> <next-transport-id>)",
Use: "add-rule (app <route-id> <local-pk> <local-port> <remote-pk> <remote-port> | fwd <next-route-id> <next-transport-id>)",
Short: "Adds a new routing rule",
Args: func(_ *cobra.Command, args []string) error {
if len(args) > 0 {
Expand All @@ -95,11 +95,12 @@ var addRuleCmd = &cobra.Command{
case "app":
var (
routeID = routing.RouteID(parseUint("route-id", args[1], 32))
remotePK = internal.ParsePK("remote-pk", args[2])
remotePort = routing.Port(parseUint("remote-port", args[3], 16))
localPort = routing.Port(parseUint("local-port", args[4], 16))
localPK = internal.ParsePK("local-pk", args[2])
localPort = routing.Port(parseUint("local-port", args[3], 16))
remotePK = internal.ParsePK("remote-pk", args[4])
remotePort = routing.Port(parseUint("remote-port", args[5], 16))
)
rule = routing.ConsumeRule(keepAlive, routeID, remotePK, localPort, remotePort)
rule = routing.ConsumeRule(keepAlive, routeID, localPK, remotePK, localPort, remotePort)
case "fwd":
var (
nextRouteID = routing.RouteID(parseUint("next-route-id", args[1], 32))
Expand Down
3 changes: 2 additions & 1 deletion pkg/routing/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,14 @@ func (r Rule) Summary() *RuleSummary {
}

// ConsumeRule constructs a new Consume rule.
func ConsumeRule(keepAlive time.Duration, key RouteID, remotePK cipher.PubKey, localPort, remotePort Port) Rule {
func ConsumeRule(keepAlive time.Duration, key RouteID, localPK, remotePK cipher.PubKey, localPort, remotePort Port) Rule {
rule := Rule(make([]byte, RuleHeaderSize+routeDescriptorSize))

rule.setKeepAlive(keepAlive)
rule.setType(RuleConsume)
rule.SetKeyRouteID(key)

rule.setSrcPK(localPK)
rule.setDstPK(remotePK)
rule.setSrcPK(cipher.PubKey{})
rule.setDstPort(remotePort)
Expand Down

0 comments on commit 547e0bf

Please sign in to comment.