Skip to content

Commit da762fd

Browse files
chaehnijuagargi
authored andcommitted
Update apps to new SCION version (#102)
* Update apps to new version * Remove non existing reference and update commit for upgraded scionlab * remove binary files * update vendor.json * update vendor.json * use updated RAINS in vendor * Update vendor file * Install govendor if not there * fix for helloworld * Add mrproper and vendor to Makefile * Check go version is at least 1.11
1 parent bd9bdc2 commit da762fd

File tree

14 files changed

+2630
-495
lines changed

14 files changed

+2630
-495
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ all: $(TARGETS)
99
deps:
1010
./deps.sh
1111

12+
vendor: deps
13+
1214
clean:
1315
@$(foreach d,$(SRCDIRS),cd $(ROOT_DIR)/$(d) && go clean;)
1416

17+
mrproper: clean
18+
rm -rf vendor/*/
19+
1520
install: all
1621
@$(foreach d,$(SRCDIRS), cd $(ROOT_DIR)/$(d); cp $(shell basename $(d)) ~/go/bin;)
1722

bat/bat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func init() {
121121
}
122122

123123
// redirect SCION log to a log file
124-
slog.SetupLogFile("scion", "log", "debug", 10, 10, 0)
124+
slog.SetupLogFile("scion", "log", "debug", 10, 10, 0, 0)
125125
}
126126

127127
func parsePrintOption(s string) {

bwtester/bwtestclient/bwtestclient.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func main() {
336336
}
337337

338338
var pathEntry *sciond.PathReplyEntry
339-
if !serverCCAddr.IA.Eq(clientCCAddr.IA) {
339+
if !serverCCAddr.IA.Equal(clientCCAddr.IA) {
340340
if interactive {
341341
pathEntry = scionutil.ChoosePathInteractive(clientCCAddr, serverCCAddr)
342342
} else {
@@ -373,7 +373,7 @@ func main() {
373373
L3: serverCCAddr.Host.L3, L4: addr.NewL4UDPInfo(uint16(serverPort) + 1)}}
374374

375375
// Set path on data connection
376-
if !serverDCAddr.IA.Eq(clientDCAddr.IA) {
376+
if !serverDCAddr.IA.Equal(clientDCAddr.IA) {
377377
serverDCAddr.Path = spath.New(pathEntry.Path.FwdPath)
378378
serverDCAddr.Path.InitOffsets()
379379
serverDCAddr.NextHop, _ = pathEntry.HostInfo.Overlay()

bwtester/bwtestserver/bwtestserver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/scionproto/scion/go/lib/addr"
2323
"github.com/scionproto/scion/go/lib/sciond"
2424
"github.com/scionproto/scion/go/lib/snet"
25+
"github.com/scionproto/scion/go/lib/sock/reliable"
2526
)
2627

2728
func printUsage() {
@@ -149,7 +150,7 @@ func runServer() {
149150
*sciondPath = sciond.GetDefaultSCIONDPath(nil)
150151
}
151152
log.Info("Starting server")
152-
snet.Init(serverCCAddr.IA, *sciondPath, *dispatcherPath)
153+
snet.Init(serverCCAddr.IA, *sciondPath, reliable.NewDispatcherService(*dispatcherPath))
153154

154155
serverISDASIP := fmt.Sprintf("%s,[%s]", serverCCAddr.IA, serverCCAddr.Host.L3)
155156

camerapp/imagefetcher/imagefetcher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/netsec-ethz/scion-apps/lib/scionutil"
1616
"github.com/scionproto/scion/go/lib/sciond"
1717
"github.com/scionproto/scion/go/lib/snet"
18+
"github.com/scionproto/scion/go/lib/sock/reliable"
1819
)
1920

2021
const (
@@ -207,7 +208,7 @@ func main() {
207208
} else if sciondPath == "" {
208209
sciondPath = sciond.GetDefaultSCIONDPath(nil)
209210
}
210-
snet.Init(local.IA, sciondPath, dispatcherPath)
211+
snet.Init(local.IA, sciondPath, reliable.NewDispatcherService(dispatcherPath))
211212
udpConnection, err = snet.DialSCION("udp4", local, remote)
212213
check(err)
213214

camerapp/imageserver/imageserver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/scionproto/scion/go/lib/addr"
2020
"github.com/scionproto/scion/go/lib/sciond"
2121
"github.com/scionproto/scion/go/lib/snet"
22+
"github.com/scionproto/scion/go/lib/sock/reliable"
2223
)
2324

2425
const (
@@ -167,7 +168,7 @@ func main() {
167168
} else if sciondPath == "" {
168169
sciondPath = sciond.GetDefaultSCIONDPath(nil)
169170
}
170-
snet.Init(server.IA, sciondPath, dispatcherPath)
171+
snet.Init(server.IA, sciondPath, reliable.NewDispatcherService(dispatcherPath))
171172
udpConnection, err = snet.ListenSCION("udp4", server)
172173
check(err)
173174

deps.sh

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
#!/bin/bash
2-
set -x
2+
set -e
33

4-
printf "\n### Getting govendor ###\n"
5-
if ! govendor -version 2>&1 | grep v1.0.8 >& /dev/null; then
6-
GOVENDORDIR="$HOME/go/src/github.com/kardianos/govendor"
7-
[ -d "$GOVENDORDIR" ] || git clone "https://github.com/kardianos/govendor" "$GOVENDORDIR"
8-
cd "$GOVENDORDIR" && git checkout fbbc78e8d1b533dfcf81c2a4be2cec2617a926f7 && go install -v
9-
fi
10-
11-
printf "\n### Getting vendor libraries\n"
12-
govendor sync -v
4+
# version less or equal. E.g. verleq 1.9 2.0.8 == true (1.9 <= 2.0.8)
5+
verleq() {
6+
[ ! -z "$1" ] && [ ! -z "$2" ] && [ "$1" = `echo -e "$1\n$2" | sort -V | head -n1` ]
7+
}
138

14-
printf "\n### Getting dependencies\n"
15-
sudo apt-get install -y capnproto libpam0g-dev
16-
if ! command -v capnpc-go >&/dev/null; then
17-
cd vendor/zombiezen.com/go/capnproto2/capnpc-go && go install -v
9+
V=$(go version | sed 's/^go version go\(.*\) .*$/\1/')
10+
if ! verleq 1.11.0 "$V"; then
11+
echo "Go version 1.11 or newer required"
12+
exit 1
1813
fi
19-
20-
printf "\n### Compiling capnp ###\n"
21-
cp vendor/zombiezen.com/go/capnproto2/std/go.capnp vendor/github.com/scionproto/scion/proto/go.capnp
22-
cd vendor/github.com/scionproto/scion/go/proto && make
14+
command -v govendor >/dev/null || go get github.com/kardianos/govendor
15+
govendor sync -v

helloworld/helloworld.go

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,33 @@ func main() {
5959
// initialize SCION
6060
err = snet.Init(clientCCAddr.IA, sciondPath, dispatcherPath)
6161
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++
7781
}
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:
7988
}
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:
8689
conn, err := snet.DialSCION("udp4", clientCCAddr, serverCCAddr)
8790
Check(err)
8891
defer conn.Close()

lib/scionutil/initialization.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/scionproto/scion/go/lib/addr"
2424
"github.com/scionproto/scion/go/lib/sciond"
2525
"github.com/scionproto/scion/go/lib/snet"
26+
"github.com/scionproto/scion/go/lib/sock/reliable"
2627
)
2728

2829
const localhost = "localhost"
@@ -60,8 +61,8 @@ func GetSCIONDPath(ia *addr.IA) string {
6061
}
6162

6263
// GetDefaultDispatcher returns the path to the default SCION dispatcher
63-
func GetDefaultDispatcher() string {
64-
return "/run/shm/dispatcher/default.sock"
64+
func GetDefaultDispatcher() reliable.DispatcherService {
65+
return reliable.NewDispatcherService("")
6566
}
6667

6768
// GetLocalhost returns a local SCION address an application can bind to

lib/scionutil/path_selection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func ChoosePathInteractive(local, remote *snet.Addr) *sciond.PathReplyEntry {
4545
}
4646

4747
pathMgr := snet.DefNetwork.PathResolver()
48-
pathSet := pathMgr.Query(context.Background(), local.IA, remote.IA)
48+
pathSet := pathMgr.Query(context.Background(), local.IA, remote.IA, sciond.PathReqFlags{})
4949
var appPaths []*spathmeta.AppPath
5050
var selectedPath *spathmeta.AppPath
5151

@@ -86,7 +86,7 @@ func ChoosePathByMetric(pathAlgo int, local, remote *snet.Addr) *sciond.PathRepl
8686
}
8787

8888
pathMgr := snet.DefNetwork.PathResolver()
89-
pathSet := pathMgr.Query(context.Background(), local.IA, remote.IA)
89+
pathSet := pathMgr.Query(context.Background(), local.IA, remote.IA, sciond.PathReqFlags{})
9090
var appPaths []*spathmeta.AppPath
9191

9292
i := 0

0 commit comments

Comments
 (0)