@@ -16,47 +16,16 @@ package fabrid
16
16
17
17
import (
18
18
"context"
19
- "net/netip"
20
- "strings"
21
- "time"
22
-
19
+ "fmt"
23
20
"github.com/scionproto/scion/pkg/addr"
24
21
"github.com/scionproto/scion/pkg/daemon"
25
- "github.com/scionproto/scion/pkg/private/common"
26
22
"github.com/scionproto/scion/pkg/private/serrors"
27
- "github.com/scionproto/scion/pkg/snet"
28
- "github.com/scionproto/scion/private/app/path"
29
- "github.com/scionproto/scion/private/app/path/pathprobe"
30
- "github.com/scionproto/scion/private/path/pathpol"
31
23
)
32
24
33
25
// Result contains all the discovered paths.
34
26
type Result struct {
35
- LocalIA addr.IA `json:"local_isd_as" yaml:"local_isd_as"`
36
27
Destination addr.IA `json:"destination" yaml:"destination"`
37
- Policies []Path `json:"paths,omitempty" yaml:"paths,omitempty"`
38
- }
39
-
40
- // Policy holds information about the available policy.
41
- type Path struct {
42
- FullPath snet.Path `json:"-" yaml:"-"`
43
- Fingerprint string `json:"fingerprint" yaml:"fingerprint"`
44
- Hops []Hop `json:"hops" yaml:"hops"`
45
- Sequence string `json:"sequence" yaml:"sequence"`
46
- NextHop string `json:"next_hop" yaml:"next_hop"`
47
- Expiry time.Time `json:"expiry" yaml:"expiry"`
48
- MTU uint16 `json:"mtu" yaml:"mtu"`
49
- Latency []time.Duration `json:"latency" yaml:"latency"`
50
- CarbonIntensity []int64 `json:"carbon_intensity"`
51
- Status string `json:"status,omitempty" yaml:"status,omitempty"`
52
- StatusInfo string `json:"status_info,omitempty" yaml:"status_info,omitempty"`
53
- Local netip.Addr `json:"local_ip,omitempty" yaml:"local_ip,omitempty"`
54
- }
55
-
56
- // Hop represents an hop on the path.
57
- type Hop struct {
58
- IfID common.IFIDType `json:"ifid"`
59
- IA addr.IA `json:"isd_as"`
28
+ Description string `json:"description,omitempty" yaml:"description,omitempty"`
60
29
}
61
30
62
31
// Run lists information for FABRID policies to stdout.
@@ -66,89 +35,11 @@ func Run(ctx context.Context, dst addr.IA, cfg Config) (*Result, error) {
66
35
return nil , serrors .WrapStr ("connecting to the SCION Daemon" , err , "addr" , cfg .Daemon )
67
36
}
68
37
defer sdConn .Close ()
69
- localIA , err := sdConn .LocalIA (ctx )
70
- if err != nil {
71
- return nil , serrors .WrapStr ("determining local ISD-AS" , err )
72
- }
73
38
74
- allPaths , err := sdConn .RemotePolicyDescription ()
75
- if err != nil {
76
- return nil , serrors .WrapStr ("retrieving paths from the SCION Daemon" , err )
77
- }
78
- paths , err := path .Filter (cfg .Sequence , allPaths )
39
+ description , err := sdConn .RemotePolicyDescription (ctx , 10 , dst )
79
40
if err != nil {
80
- return nil , err
81
- }
82
- if cfg .MaxPaths != 0 && len (paths ) > cfg .MaxPaths {
83
- paths = paths [:cfg .MaxPaths ]
84
- }
85
-
86
- // If the epic flag is set, filter all paths that do not have
87
- // the necessary epic authenticators.
88
- if cfg .Epic {
89
- epicPaths := []snet.Path {}
90
- for _ , p := range paths {
91
- if p .Metadata ().EpicAuths .SupportsEpic () {
92
- epicPaths = append (epicPaths , p )
93
- }
94
- }
95
- paths = epicPaths
96
- }
97
-
98
- var statuses map [string ]pathprobe.Status
99
- if ! cfg .NoProbe {
100
- p := pathprobe .FilterEmptyPaths (paths )
101
- statuses , err = pathprobe.Prober {
102
- DstIA : dst ,
103
- LocalIA : localIA ,
104
- LocalIP : cfg .Local ,
105
- Topology : sdConn ,
106
- }.GetStatuses (ctx , p , pathprobe .WithEPIC (cfg .Epic ))
107
- if err != nil {
108
- return nil , serrors .WrapStr ("getting statuses" , err )
109
- }
110
- }
111
- path .Sort (paths )
112
- res := & Result {
113
- LocalIA : localIA ,
114
- Destination : dst ,
115
- Paths : []Path {},
116
- }
117
- for _ , path := range paths {
118
- fingerprint := "local"
119
- if len (path .Metadata ().Interfaces ) > 0 {
120
- fp := snet .Fingerprint (path ).String ()
121
- fingerprint = fp [:16 ]
122
- }
123
- var nextHop string
124
- if nh := path .UnderlayNextHop (); nh != nil {
125
- nextHop = path .UnderlayNextHop ().String ()
126
- }
127
- pathMeta := path .Metadata ()
128
- rpath := Path {
129
- FullPath : path ,
130
- Fingerprint : fingerprint ,
131
- NextHop : nextHop ,
132
- Expiry : pathMeta .Expiry ,
133
- MTU : pathMeta .MTU ,
134
- Latency : pathMeta .Latency ,
135
- CarbonIntensity : pathMeta .CarbonIntensity ,
136
- Hops : []Hop {},
137
- }
138
- for _ , hop := range path .Metadata ().Interfaces {
139
- rpath .Hops = append (rpath .Hops , Hop {IA : hop .IA , IfID : hop .ID })
140
- }
141
- if status , ok := statuses [pathprobe .PathKey (path )]; ok {
142
- rpath .Status = strings .ToLower (string (status .Status ))
143
- rpath .StatusInfo = status .AdditionalInfo
144
- rpath .Local = status .LocalIP
145
- }
146
- seq , err := pathpol .GetSequence (path )
147
- rpath .Sequence = seq
148
- if err != nil {
149
- rpath .Sequence = "invalid"
150
- }
151
- res .Paths = append (res .Paths , rpath )
41
+ return nil , serrors .WrapStr ("retrieving description from the SCION Daemon" , err )
152
42
}
153
- return res , nil
43
+ fmt .Println (description )
44
+ return & Result {Destination : dst , Description : description }, nil
154
45
}
0 commit comments