Skip to content

Commit af13021

Browse files
authored
Simplify and extend hostname resolution (#155)
Make the hostname resolution more "pluggable", using separate Resolvers for reading from /etc/hosts and RAINS. Resolving from the /etc/hosts file (by hostsfileResolver) now reads the file on every request instead of parsing on startup. This is more aligned with what e.g. gethostbyname does, making modifications to the file visible to running applications. Because it's easy, add an additional resolver that loads /etc/scion/hosts, in the same format as /etc/hosts. The idea is that by having a separate file, we can now easily distribute a simple hosts file from the coordinator. Remove the fixed hosts table with `AddHost` and the only half-implemented reverse lookup `GetHostnamesByAddress`. Add explicit build tag `norains` to build without RAINS support. Building with `make 'TAGS=!norains'` will build without rains. This is handy e.g. when updating the SCION dependency with API breaking changes here in scion-apps but RAINS has not yet been updated.
1 parent 36820ac commit af13021

File tree

12 files changed

+454
-349
lines changed

12 files changed

+454
-349
lines changed

Makefile

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ BIN = bin
88
# $GOBIN, else $GOPATH/bin, else $HOME/go/bin
99
DESTDIR = $(shell set -a; eval $$( go env ); echo $${GOBIN:-$${GOPATH:-$${HOME}/go}/bin})
1010

11+
# HINT: build with TAGS=norains to build without rains support
12+
TAGS =
13+
1114
all: lint build
1215

1316
build: scion-bat \
@@ -24,84 +27,84 @@ clean:
2427
rm -f bin/*
2528

2629
test: lint
27-
go test -v ./...
30+
go test -v -tags=$(TAGS) ./...
2831

2932
setup_lint:
3033
@# Install golangci-lint (as dumb as this looks, this is the recommended way to install)
3134
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $$(go env GOPATH)/bin v1.26.0
3235

3336
lint:
3437
@type golangci-lint > /dev/null || ( echo "golangci-lint not found. Install it manually or by running 'make setup_lint'."; exit 1 )
35-
golangci-lint run
38+
golangci-lint run --build-tags=$(TAGS)
3639

3740
install: all
3841
# Note: install everything but the examples
3942
mkdir -p $(DESTDIR)
4043
cp -t $(DESTDIR) $(BIN)/scion-*
4144

4245
integration: all
43-
go test -v -tags=integration ./... ./_examples/helloworld/
46+
go test -v -tags=integration,$(TAGS) ./... ./_examples/helloworld/
4447

4548
.PHONY: scion-bat
4649
scion-bat:
47-
go build -o $(BIN)/$@ ./bat/
50+
go build -tags=$(TAGS) -o $(BIN)/$@ ./bat/
4851

4952
.PHONY: scion-bwtestclient
5053
scion-bwtestclient:
51-
go build -o $(BIN)/$@ ./bwtester/bwtestclient/
54+
go build -tags=$(TAGS) -o $(BIN)/$@ ./bwtester/bwtestclient/
5255

5356
.PHONY: scion-bwtestserver
5457
scion-bwtestserver:
55-
go build -o $(BIN)/$@ ./bwtester/bwtestserver/
58+
go build -tags=$(TAGS) -o $(BIN)/$@ ./bwtester/bwtestserver/
5659

5760
.PHONY: scion-imagefetcher
5861
scion-imagefetcher:
59-
go build -o $(BIN)/$@ ./camerapp/imagefetcher/
62+
go build -tags=$(TAGS) -o $(BIN)/$@ ./camerapp/imagefetcher/
6063

6164
.PHONY: scion-imageserver
6265
scion-imageserver:
63-
go build -o $(BIN)/$@ ./camerapp/imageserver/
66+
go build -tags=$(TAGS) -o $(BIN)/$@ ./camerapp/imageserver/
6467

6568
.PHONY: scion-netcat
6669
scion-netcat:
67-
go build -o $(BIN)/$@ ./netcat/
70+
go build -tags=$(TAGS) -o $(BIN)/$@ ./netcat/
6871

6972
.PHONY: scion-sensorfetcher
7073
scion-sensorfetcher:
71-
go build -o $(BIN)/$@ ./sensorapp/sensorfetcher/
74+
go build -tags=$(TAGS) -o $(BIN)/$@ ./sensorapp/sensorfetcher/
7275

7376
.PHONY: scion-sensorserver
7477
scion-sensorserver:
75-
go build -o $(BIN)/$@ ./sensorapp/sensorserver/
78+
go build -tags=$(TAGS) -o $(BIN)/$@ ./sensorapp/sensorserver/
7679

7780
.PHONY: scion-ssh
7881
scion-ssh:
79-
go build -o $(BIN)/$@ ./ssh/client/
82+
go build -tags=$(TAGS) -o $(BIN)/$@ ./ssh/client/
8083

8184
.PHONY: scion-sshd
8285
scion-sshd:
83-
go build -o $(BIN)/$@ ./ssh/server/
86+
go build -tags=$(TAGS) -o $(BIN)/$@ ./ssh/server/
8487

8588
.PHONY: scion-webapp
8689
scion-webapp:
87-
go build -o $(BIN)/$@ ./webapp/
90+
go build -tags=$(TAGS) -o $(BIN)/$@ ./webapp/
8891

8992
.PHONY: example-helloworld
9093
example-helloworld:
91-
go build -o $(BIN)/$@ ./_examples/helloworld/
94+
go build -tags=$(TAGS) -o $(BIN)/$@ ./_examples/helloworld/
9295

9396
.PHONY: example-shttp-client
9497
example-shttp-client:
95-
go build -o $(BIN)/$@ ./_examples/shttp/client
98+
go build -tags=$(TAGS) -o $(BIN)/$@ ./_examples/shttp/client
9699

97100
.PHONY: example-shttp-server
98101
example-shttp-server:
99-
go build -o $(BIN)/$@ ./_examples/shttp/server
102+
go build -tags=$(TAGS) -o $(BIN)/$@ ./_examples/shttp/server
100103

101104
.PHONY: example-shttp-fileserver
102105
example-shttp-fileserver:
103-
go build -o $(BIN)/$@ ./_examples/shttp/fileserver
106+
go build -tags=$(TAGS) -o $(BIN)/$@ ./_examples/shttp/fileserver
104107

105108
.PHONY: example-shttp-proxy
106109
example-shttp-proxy:
107-
go build -o $(BIN)/$@ ./_examples/shttp/proxy
110+
go build -tags=$(TAGS) -o $(BIN)/$@ ./_examples/shttp/proxy

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ directory, or summarized in the file `gen/sciond_addresses.json`.
7575

7676

7777
#### Hostnames
78-
Hostnames are resolved by scanning the `/etc/hosts` file and by a RAINS lookup.
78+
Hostnames are resolved by scanning `/etc/hosts`, `/etc/scion/hosts` and by a RAINS lookup.
7979

80-
Hosts can be added to `/etc/hosts` by adding lines like this:
80+
Hosts can be added to `/etc/hosts`, or `/etc/scion/hosts` by adding lines like this:
8181

8282
```
8383
# The following lines are SCION hosts
84-
17-ffaa:1:10,[10.0.8.100] server1
85-
18-ffaa:0:11,[10.0.8.120] server2
84+
17-ffaa:1:10,[10.0.8.100] server1
85+
18-ffaa:0:11,[10.0.8.120] server2
8686
```
8787

8888
The RAINS resolver address can be configured in `/etc/scion/rains.cfg`.

bwtester/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ The packet contents are filled with a Pseudo-Random Generator (PRG) based on AES
2929

3030
The wireline protocol is as follows:
3131
* 'N' new bwtest request
32-
> Request: 'N', encoded bwtest parameters client->server, encoded bwtest parameters server->client
33-
>
34-
> Success response: 'N', 0
35-
>
36-
> Failure response: 'N', number of seconds to wait until next request is sent
32+
> Request: 'N', encoded bwtest parameters client->server, encoded bwtest parameters server->client
33+
>
34+
> Success response: 'N', 0
35+
>
36+
> Failure response: 'N', number of seconds to wait until next request is sent
3737
* 'R' result request
38-
> Request: 'R', encoded client sending PRG key
39-
>
40-
> Success response: 'R', 0, encoded result data
41-
>
42-
> Not ready response: 'R', number of seconds to wait until result should be ready by
43-
>
44-
> Not found response: 'R', 127
38+
> Request: 'R', encoded client sending PRG key
39+
>
40+
> Success response: 'R', 0, encoded result data
41+
>
42+
> Not ready response: 'R', number of seconds to wait until result should be ready by
43+
>
44+
> Not found response: 'R', 127
4545
4646
## bwtestclient
4747

0 commit comments

Comments
 (0)