@@ -30,16 +30,24 @@ import (
30
30
. "github.com/netsec-ethz/scion-apps/webapp/util"
31
31
)
32
32
33
+ // GOPATH is the root of the GOPATH environment.
34
+ var GOPATH = os .Getenv ("GOPATH" )
35
+
33
36
// browseRoot is browse-only, consider security (def: cwd)
34
37
var browseRoot = flag .String ("r" , "." ,
35
38
"Root path to browse from, CAUTION: read-access granted from -a and -p." )
36
39
37
- // staticRoot for serving/writing static data (def: cwd)
38
- var staticRoot = flag .String ("s" , "." ,
40
+ // staticRoot for serving/writing static data
41
+ var staticRoot = flag .String ("s" , path . Join ( GOPATH , "src/github.com/netsec-ethz/scion-apps/webapp" ) ,
39
42
"Static path of web server files (local repo scion-apps/webapp)." )
40
43
41
- // cwdPath - this is where images are going, this is runtime (record, no settings)
42
- var cwdPath = "."
44
+ // scionRoot is the root location of the scion infrastructure.
45
+ var scionRoot = flag .String ("i" , path .Join (GOPATH , "src/github.com/scionproto/scion" ),
46
+ "the root location of the scion infrastructure." )
47
+
48
+ // appsRoot is the root location of scionlab apps.
49
+ var appsRoot = flag .String ("l" , path .Join (GOPATH , "bin" ),
50
+ "the root location of scionlab apps." )
43
51
44
52
var addr = flag .String ("a" , "127.0.0.1" , "Address of server host." )
45
53
var port = flag .Int ("p" , 8000 , "Port of server host." )
@@ -154,7 +162,7 @@ func main() {
154
162
155
163
// load list of locally available IAs and determine user choices
156
164
func initLocalIaOptions () {
157
- localIAs = lib .ScanLocalIAs ()
165
+ localIAs = lib .ScanLocalIAs (* scionRoot )
158
166
settings = lib .ReadUserSetting (* staticRoot )
159
167
160
168
// if read myia not in list, pick default
@@ -188,7 +196,7 @@ func initServeHandlers() {
188
196
189
197
http .HandleFunc ("/command" , commandHandler )
190
198
http .HandleFunc ("/imglast" , findImageHandler )
191
- http .HandleFunc ("/txtlast" , lib . FindImageInfoHandler )
199
+ http .HandleFunc ("/txtlast" , findImageInfoHandler )
192
200
http .HandleFunc ("/getnodes" , getNodesHandler )
193
201
http .HandleFunc ("/getbwbytime" , getBwByTimeHandler )
194
202
http .HandleFunc ("/healthcheck" , healthCheckHandler )
@@ -203,10 +211,10 @@ func initServeHandlers() {
203
211
http .HandleFunc ("/labels" , lib .LabelsHandler )
204
212
http .HandleFunc ("/locations" , lib .LocationsHandler )
205
213
http .HandleFunc ("/geolocate" , lib .GeolocateHandler )
206
- http .HandleFunc ("/getpathtopo" , lib . PathTopoHandler )
214
+ http .HandleFunc ("/getpathtopo" , getPathInfoHandler )
207
215
http .HandleFunc ("/getastopo" , lib .AsTopoHandler )
208
- http .HandleFunc ("/getcrt" , lib . CrtHandler )
209
- http .HandleFunc ("/gettrc" , lib . TrcHandler )
216
+ http .HandleFunc ("/getcrt" , getCrtInfoHandler )
217
+ http .HandleFunc ("/gettrc" , getTrcInfoHandler )
210
218
}
211
219
212
220
func logRequestHandler (handler http.Handler ) http.Handler {
@@ -536,13 +544,13 @@ func getClientCwd(app string) string {
536
544
var cwd string
537
545
switch app {
538
546
case "sensorapp" :
539
- cwd = path .Join (lib . GOPATH , lib . LABROOT , "." )
547
+ cwd = path .Join (* staticRoot , "." )
540
548
case "camerapp" :
541
- cwd = path .Join (lib . GOPATH , lib . LABROOT , "webapp/ data/images" )
549
+ cwd = path .Join (* staticRoot , " data/images" )
542
550
case "bwtester" :
543
- cwd = path .Join (lib . GOPATH , lib . LABROOT , "." )
551
+ cwd = path .Join (* staticRoot , "." )
544
552
case "echo" , "traceroute" :
545
- cwd = path .Join (lib . GOPATH , lib . SCIONROOT , "bin" )
553
+ cwd = path .Join (* scionRoot , "bin" )
546
554
}
547
555
return cwd
548
556
}
@@ -552,13 +560,13 @@ func getClientLocationBin(app string) string {
552
560
var binname string
553
561
switch app {
554
562
case "sensorapp" :
555
- binname = path .Join (lib . GOPATH , "bin/ sensorfetcher" )
563
+ binname = path .Join (* appsRoot , "sensorfetcher" )
556
564
case "camerapp" :
557
- binname = path .Join (lib . GOPATH , "bin/ imagefetcher" )
565
+ binname = path .Join (* appsRoot , "imagefetcher" )
558
566
case "bwtester" :
559
- binname = path .Join (lib . GOPATH , "bin/ bwtestclient" )
567
+ binname = path .Join (* appsRoot , "bwtestclient" )
560
568
case "echo" , "traceroute" :
561
- binname = path .Join (lib . GOPATH , lib . SCIONROOT , "bin/scmp" )
569
+ binname = path .Join (* scionRoot , "bin/scmp" )
562
570
}
563
571
return binname
564
572
}
@@ -703,7 +711,23 @@ func getTracerouteByTimeHandler(w http.ResponseWriter, r *http.Request) {
703
711
704
712
// Handles locating most recent image formatting it for graphic display in response.
705
713
func findImageHandler (w http.ResponseWriter , r * http.Request ) {
706
- lib .FindImageHandler (w , r , browserAddr , * port )
714
+ lib .FindImageHandler (w , r , * staticRoot , browserAddr , * port )
715
+ }
716
+
717
+ func findImageInfoHandler (w http.ResponseWriter , r * http.Request ) {
718
+ lib .FindImageInfoHandler (w , r , * staticRoot )
719
+ }
720
+
721
+ func getTrcInfoHandler (w http.ResponseWriter , r * http.Request ) {
722
+ lib .TrcHandler (w , r , * scionRoot )
723
+ }
724
+
725
+ func getCrtInfoHandler (w http.ResponseWriter , r * http.Request ) {
726
+ lib .CrtHandler (w , r , * scionRoot )
727
+ }
728
+
729
+ func getPathInfoHandler (w http.ResponseWriter , r * http.Request ) {
730
+ lib .PathTopoHandler (w , r , * scionRoot )
707
731
}
708
732
709
733
func getNodesHandler (w http.ResponseWriter , r * http.Request ) {
0 commit comments