@@ -59,30 +59,33 @@ func main() {
59
59
// initialize SCION
60
60
err = snet .Init (clientCCAddr .IA , sciondPath , dispatcherPath )
61
61
Check (err )
62
- // query paths from here to there:
63
- pathMgr := snet .DefNetwork .PathResolver ()
64
- pathSet := pathMgr .Query (context .Background (), clientCCAddr .IA , serverCCAddr .IA )
65
- if len (pathSet ) == 0 {
66
- Check (fmt .Errorf ("No paths" ))
67
- }
68
- // print all paths. Also pick one path. Here we chose the path with least hops:
69
- i := 0
70
- minLength , argMinPath := 999 , (* sciond .PathReplyEntry )(nil )
71
- fmt .Println ("Available paths:" )
72
- for _ , path := range pathSet {
73
- fmt .Printf ("[%2d] %d %s\n " , i , len (path .Entry .Path .Interfaces )/ 2 , path .Entry .Path .String ())
74
- if len (path .Entry .Path .Interfaces ) < minLength {
75
- minLength = len (path .Entry .Path .Interfaces )
76
- argMinPath = path .Entry
62
+
63
+ if ! serverCCAddr .IA .Equal (clientCCAddr .IA ) {
64
+ // query paths from here to there:
65
+ pathMgr := snet .DefNetwork .PathResolver ()
66
+ pathSet := pathMgr .Query (context .Background (), clientCCAddr .IA , serverCCAddr .IA , sciond.PathReqFlags {})
67
+ if len (pathSet ) == 0 {
68
+ Check (fmt .Errorf ("No paths" ))
69
+ }
70
+ // print all paths. Also pick one path. Here we chose the path with least hops:
71
+ i := 0
72
+ minLength , argMinPath := 999 , (* sciond .PathReplyEntry )(nil )
73
+ fmt .Println ("Available paths:" )
74
+ for _ , path := range pathSet {
75
+ fmt .Printf ("[%2d] %d %s\n " , i , len (path .Entry .Path .Interfaces )/ 2 , path .Entry .Path .String ())
76
+ if len (path .Entry .Path .Interfaces ) < minLength {
77
+ minLength = len (path .Entry .Path .Interfaces )
78
+ argMinPath = path .Entry
79
+ }
80
+ i ++
77
81
}
78
- i ++
82
+ fmt .Println ("Chosen path:" , argMinPath .Path .String ())
83
+ // we need to copy the path to the destination (destination is the whole selected path)
84
+ serverCCAddr .Path = spath .New (argMinPath .Path .FwdPath )
85
+ serverCCAddr .Path .InitOffsets ()
86
+ serverCCAddr .NextHop , _ = argMinPath .HostInfo .Overlay ()
87
+ // get a connection object using that path:
79
88
}
80
- fmt .Println ("Chosen path:" , argMinPath .Path .String ())
81
- // we need to copy the path to the destination (destination is the whole selected path)
82
- serverCCAddr .Path = spath .New (argMinPath .Path .FwdPath )
83
- serverCCAddr .Path .InitOffsets ()
84
- serverCCAddr .NextHop , _ = argMinPath .HostInfo .Overlay ()
85
- // get a connection object using that path:
86
89
conn , err := snet .DialSCION ("udp4" , clientCCAddr , serverCCAddr )
87
90
Check (err )
88
91
defer conn .Close ()
0 commit comments