Skip to content

Commit 5d48942

Browse files
authored
HTTP client to communicate with TFServing (#10)
This patch modifies HTTP client to work with Tensorflow serving.
1 parent a8dd0b9 commit 5d48942

File tree

11 files changed

+222
-194
lines changed

11 files changed

+222
-194
lines changed

.travis.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
language: go
44

55
env:
6-
global:
7-
- GO111MODULE=on
8-
- TENSORFLOW_SRC=https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.15.0.tar.gz
9-
10-
before_install:
11-
- curl -fsSL $TENSORFLOW_SRC | sudo tar -C /usr/ -xzf -
12-
- sudo ldconfig
6+
- GO111MODULE=on
137

148
go:
159
- "1.12.x"

Corefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
. {
22
dnstun {
3-
graph /var/dnstun/dnscnn.pb
3+
runtime 127.0.0.1:8501
4+
detector reverse dnscnn:1
45
}
56
forward . 8.8.8.8
67

Dockerfile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
1-
ARG GOVERSION=1.14
1+
ARG GOVERSION=1.12
22

33
FROM golang:${GOVERSION}-buster
44

55
# All args after each FROM command are no longer available.
66
ARG COREDNSVERSION=v1.6.4
7-
ARG TENSORFLOWVERSION=1.15.0
87

98
RUN apt-get update && apt-get -uy upgrade
109
RUN apt-get -y install ca-certificates && update-ca-certificates
1110

1211
ENV COREDNSPATH github.com/coredns/coredns
1312
ENV DNSTUNPATH github.com/netrack/dnstun
14-
ENV TENSORFLOWPATH storage.googleapis.com/tensorflow/libtensorflow
1513
ENV GO111MODULE on
14+
ENV CGO_ENABLED 0
1615

1716
RUN curl -fsSL https://${COREDNSPATH}/archive/${COREDNSVERSION}.tar.gz -o coredns.tar.gz \
1817
&& mkdir -p coredns \
1918
&& tar -xzf coredns.tar.gz --strip-components=1 -C coredns \
2019
&& rm -rf coredns.tar.gz
2120

22-
23-
RUN curl -fsSL https://${TENSORFLOWPATH}/libtensorflow-cpu-linux-x86_64-${TENSORFLOWVERSION}.tar.gz -o tensorflow.tar.gz \
24-
&& tar -xzf tensorflow.tar.gz -C /usr/ \
25-
&& rm -rf tensorflow.tar.gz \
26-
&& ldconfig
27-
2821
COPY . ${GOPATH}/src/${DNSTUNPATH}
2922
COPY plugin.cfg coredns/plugin.cfg
3023

@@ -36,9 +29,8 @@ RUN go mod edit -replace ${DNSTUNPATH}@v0.0.0=${GOPATH}/src/${DNSTUNPATH}
3629
RUN go generate && go build -o /bin/coredns
3730

3831

39-
FROM debian:buster-slim
32+
FROM scratch
4033
COPY --from=0 /etc/ssl/certs /etc/ssl/certs
41-
COPY --from=0 /usr/lib/libtensorflow* /usr/lib/
4234
COPY --from=0 /bin/coredns /bin/coredns
4335
COPY Corefile /etc/coredns/Corefile
4436
VOLUME /etc/coredns

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,33 @@ tunnels.
1313

1414
```txt
1515
dnstun {
16-
graph PATH
16+
runtime HOST:PORT
17+
detector forward|reverse DETECTOR:VERSION
1718
}
1819
```
1920

20-
* `graph` is a directive to configure detector. It is a path to the `.pb` file
21-
with constant graph used to classify DNS traffic.
21+
* `runtime` specifies the endpoint in `HOST:PORT` format to the remote model
22+
runtime. This runtime should comply with e.g. `tensorcraft` HTTP interface.
23+
24+
* `detector` is a directive to configure detector. Option `forward` instructs
25+
the plugin to treat higher probability in the second element of prediction tuple
26+
as DNS tunnel, while `reverse` tells that first element in the prediction tuple
27+
identifies DNS tunnel.
2228

2329
## Examples
2430

2531
Here are the few basic examples of how to enable DNS tunnelling detection.
2632
Usually DNS tunneling detection is turned only for all DNS queries.
2733

34+
Analyze all DNS queries through remote resolver listening on TCP socket.
2835
```txt
2936
. {
3037
dnstun {
31-
graph /var/dnstun/dnscnn.pb
38+
# Connect to the runtime that stores model and executes it.
39+
runtime 10.240.0.1:5678
40+
41+
# Choose detector and it's version.
42+
detector reverse dns_cnn:latest
3243
}
3344
}
3445
```

0 commit comments

Comments
 (0)