Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Commit 5d460d3

Browse files
committed
Smart Edge Open Release 22.04
0 parents  commit 5d460d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+7515
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```text
2+
INTEL CONFIDENTIAL
3+
4+
Copyright 2021-2021 Intel Corporation.
5+
6+
This software and the related documents are Intel copyrighted materials, and your use of
7+
them is governed by the express license under which they were provided to you ("License").
8+
Unless the License provides otherwise, you may not use, modify, copy, publish, distribute,
9+
disclose or transmit this software or the related documents without Intel's prior written permission.
10+
11+
This software and the related documents are provided as is, with no express or implied warranties,
12+
other than those that are expressly stated in the License.
13+
```
14+
# Smart Edge Open Edge Agents
15+
This repository contains the source code for the Smart Edge Open Edge Agents.

edgedns/Makefile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# INTEL CONFIDENTIAL
2+
#
3+
# Copyright 2021-2021 Intel Corporation.
4+
#
5+
# This software and the related documents are Intel copyrighted materials, and your use of
6+
# them is governed by the express license under which they were provided to you ("License").
7+
# Unless the License provides otherwise, you may not use, modify, copy, publish, distribute,
8+
# disclose or transmit this software or the related documents without Intel's prior written permission.
9+
#
10+
# This software and the related documents are provided as is, with no express or implied warranties,
11+
# other than those that are expressly stated in the License.
12+
13+
export GO111MODULE = on
14+
export GOPRIVATE="github.com/smart-edge-open/*"
15+
export ACK_GINKGO_DEPRECATIONS=1.16.4
16+
17+
.PHONY: \
18+
clean \
19+
build \
20+
edgednssvr \
21+
edgednscli \
22+
lint test help
23+
COPY_DOCKERFILES := $(shell /usr/bin/cp -rfT ./build/ ./dist/)
24+
VER ?= 1.0
25+
26+
help:
27+
@echo "Please use \`make <target>\` where <target> is one of"
28+
@echo ""
29+
@echo "Helper targets:"
30+
@echo " clean to clean build artifacts"
31+
@echo " build to build both edgedns executables without images"
32+
@echo " lint to run linter on Go code"
33+
@echo " test to run tests on Go code"
34+
@echo " test-cov to run coverage tests on Go code"
35+
@echo " help to show this message"
36+
@echo ""
37+
@echo "Single targets:"
38+
@echo " edgednssvr to build only docker image of the Edge DNS Service"
39+
@echo " edgednscli to build edgednscli to the ./dist/ folder"
40+
41+
clean:
42+
rm -rf ./dist
43+
44+
test:
45+
http_proxy= https_proxy= HTTP_PROXY= HTTPS_PROXY= ginkgo -v -r -gcflags=-l --randomizeSuites --failOnPending --skipPackage=vendor,k8s
46+
47+
test-cov:
48+
rm -rf coverage.out*
49+
http_proxy= https_proxy= HTTP_PROXY= HTTPS_PROXY= ginkgo -v -r --randomizeSuites --failOnPending --skipPackage=vendor,k8s \
50+
-gcflags=-l -cover -coverprofile=coverage.out -outputdir=.
51+
sed '1!{/^mode/d;}' coverage.out > coverage.out.fix
52+
go tool cover -html=coverage.out.fix
53+
54+
edgednssvr:
55+
GOOS=linux go build -a --ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo -o ./dist/$@ ./cmd/$@
56+
docker build ./dist/ --build-arg username=edgednssvr -f ./build/Dockerfile -t $@:${VER}
57+
58+
edgednscli:
59+
go build -o dist/edgednscli ./cmd/edgednscli
60+
61+
build:
62+
GOPRIVATE="github.com/smart-edge-open/*" go get github.com/smart-edge-open/edge-services/common/log
63+
GOOS=linux go build -a --ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo -o ./dist/edgednssvr ./cmd/edgednssvr
64+
go build -o dist/edgednscli ./cmd/edgednscli
65+
66+
lint:
67+
golangci-lint run

edgedns/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
```text
2+
INTEL CONFIDENTIAL
3+
4+
Copyright 2021-2021 Intel Corporation.
5+
6+
This software and the related documents are Intel copyrighted materials, and your use of
7+
them is governed by the express license under which they were provided to you ("License").
8+
Unless the License provides otherwise, you may not use, modify, copy, publish, distribute,
9+
disclose or transmit this software or the related documents without Intel's prior written permission.
10+
11+
This software and the related documents are provided as is, with no express or implied warranties,
12+
other than those that are expressly stated in the License.
13+
```
14+
15+
# Edge DNS Responder
16+
17+
This project provides a standards compliant DNS server that exposes gRPC interfaces for the realtime creation of records.
18+
19+
Feature|Community Edition|Enterprise Edition|
20+
|---|:---:|:---:|
21+
|gRPC Control API|||
22+
|Embedded database|||
23+
|Embedded Forwarder Cache|||
24+
|Nested dynamic Forwarder chains||✅
25+
|IPv6 Listeners|||
26+
|IPv6 Record Types|||
27+
|Authoritative TXT Record|||
28+
|Authoritative SRV Record|||
29+
|Dynamic logging levels|||
30+
|Logging to syslog|||
31+
32+
This Community Edition server implements:
33+
34+
* DNS Authoritative server
35+
* Control via gRPC API
36+
37+
## Usage
38+
39+
All queries are processed in the following order:
40+
41+
1. Authoritative lookup (default TTL of 10 seconds)
42+
2. Forwarder lookup
43+
44+
The Enterprise Edition allows the dynamic definition of forwarders on a per FQDN basis with hierarchical traversal of forwarders if a given forwarder does not return an answer for the query.
45+
46+
### API Client
47+
48+
See the test [API client](pkg/edgednssvr/test/control_client.go) for example usage of the control API.
49+
50+
### Logging
51+
52+
By default only major events related to the listeners or databases, as well as control API requests, are sent to `STDERR`.
53+
54+
### CLI
55+
56+
You can specify the following options:
57+
58+
|flag|required|default|description|
59+
|---|---|---|---|
60+
|4|NO|anyhost|IPv4 Listen address|
61+
|port|NO|5053|UDP Listen port|
62+
|sock|NO|`/run/edgedns.sock`|Filesystem path for the UNIX gRPC socket|
63+
|address|NO|``|API IP address. If defined, socket parameter is not used|
64+
|db|NO|`/var/lib/edgedns/rrsets.db`|Filesystem path for persistent database file|
65+
|statsdip|NO|``|IP address of external statsd service. By default mock statsd service gets initiated|
66+
|statsdport|NO|0|Port of external statsd service|
67+
|hb|NO|60|Heartbeat interval. Heartbeats sent to the stats service at the specified interval in s|
68+
|log|NO|`info`|Log level. Supported values: debug, info, notice, warning, error, critical, alert, emergency|
69+
|syslog|NO|``|Syslog address|
70+
|cert|NO|`certs/cert.pem`|PKI Cert Path|
71+
|key|NO|`certs/key.pem`|PKI Key Path|
72+
|ca|NO|`certs/root.pem`|PKI CA Path|
73+
74+
## Configuration
75+
76+
The following operations are available via the gRPC inteface:
77+
78+
* Add(Create/Update), Delete and Get operations for A records
79+
* Add/Delete operations for forwarders
80+

edgedns/build/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# INTEL CONFIDENTIAL
2+
#
3+
# Copyright 2021-2021 Intel Corporation.
4+
#
5+
# This software and the related documents are Intel copyrighted materials, and your use of
6+
# them is governed by the express license under which they were provided to you ("License").
7+
# Unless the License provides otherwise, you may not use, modify, copy, publish, distribute,
8+
# disclose or transmit this software or the related documents without Intel's prior written permission.
9+
#
10+
# This software and the related documents are provided as is, with no express or implied warranties,
11+
# other than those that are expressly stated in the License.
12+
13+
FROM alpine:3.12.0 AS edgedns-deps-image
14+
15+
RUN printf "http://nl.alpinelinux.org/alpine/v3.12/main\nhttp://nl.alpinelinux.org/alpine/v3.12/community" >> /etc/apk/repositories
16+
RUN apk add --no-cache sudo
17+
18+
FROM edgedns-deps-image
19+
20+
ENV DNS_FWDR=""
21+
22+
ARG username=edgednssvr
23+
ARG user_dir=/home/$username
24+
25+
RUN addgroup -S sudo && adduser -S $username -G sudo
26+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
27+
# Workaround for sudo error: https://gitlab.alpinelinux.org/alpine/aports/issues/11122
28+
RUN echo 'Set disable_coredump false' >> /etc/sudo.conf
29+
30+
USER $username
31+
WORKDIR $user_dir
32+
33+
COPY ./edgednssvr ./
34+
ENTRYPOINT ["sudo", "./edgednssvr"]
35+
CMD ["-port=53"]

edgedns/cmd/edgednscli/main.go

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
// INTEL CONFIDENTIAL
2+
//
3+
// Copyright 2021-2021 Intel Corporation.
4+
//
5+
// This software and the related documents are Intel copyrighted materials, and your use of
6+
// them is governed by the express license under which they were provided to you ("License").
7+
// Unless the License provides otherwise, you may not use, modify, copy, publish, distribute,
8+
// disclose or transmit this software or the related documents without Intel's prior written permission.
9+
//
10+
// This software and the related documents are provided as is, with no express or implied warranties,
11+
// other than those that are expressly stated in the License.
12+
package main
13+
14+
import (
15+
"flag"
16+
"fmt"
17+
"os"
18+
"strings"
19+
20+
"github.com/smart-edge-open/edge-agents/edgedns/pkg/edgednscli"
21+
"github.com/smart-edge-open/edge-agents/edgedns/pkg/edgednscli/pb"
22+
)
23+
24+
const name = "edgedns-client"
25+
26+
var (
27+
code int
28+
fwdrs string
29+
addr string
30+
pkiCrtPath string
31+
pkiKeyPath string
32+
pkiCAPath string
33+
serverNameOverride string
34+
35+
addFS *flag.FlagSet
36+
delFS *flag.FlagSet
37+
getAllFS *flag.FlagSet
38+
getPlatFS *flag.FlagSet
39+
getClientFS *flag.FlagSet
40+
)
41+
42+
func main() {
43+
44+
defer func() {
45+
os.Exit(code)
46+
}()
47+
48+
flag.StringVar(&edgednscli.SvcOpts.DNSSocketPath, "socket-path", "/run/edgedns.sock", "Unix domain socket path")
49+
flag.StringVar(&addr, "address", ":4204", "EdgeDNS API address")
50+
flag.StringVar(&pkiCrtPath, "cert", "certs/cert.pem", "PKI Cert Path")
51+
flag.StringVar(&pkiKeyPath, "key", "certs/key.pem", "PKI Key Path")
52+
flag.StringVar(&pkiCAPath, "ca", "certs/root.pem", "PKI CA Path")
53+
flag.StringVar(&serverNameOverride, "name", "", "PKI Server Name to override while grpc connection")
54+
flag.StringVar(&fwdrs, "set-forwarders", "", "set DNS forwarders")
55+
56+
flag.Parse()
57+
58+
addFS = flag.NewFlagSet("add", flag.ContinueOnError)
59+
addFS.StringVar(&edgednscli.RecordOpts.Rec, "A", "", "domain:ip1,ip2,ip3")
60+
61+
delFS = flag.NewFlagSet("del", flag.ContinueOnError)
62+
delFS.StringVar(&edgednscli.RecordOpts.Rec, "A", "", "domain")
63+
64+
getAllFS = flag.NewFlagSet("get-all-records", flag.ContinueOnError)
65+
getPlatFS = flag.NewFlagSet("get-platform-records", flag.ContinueOnError)
66+
getClientFS = flag.NewFlagSet("get-client-records", flag.ContinueOnError)
67+
68+
pki := &edgednscli.PKIPaths{
69+
CrtPath: pkiCrtPath,
70+
KeyPath: pkiKeyPath,
71+
CAPath: pkiCAPath,
72+
ServerNameOverride: serverNameOverride,
73+
}
74+
cfg := edgednscli.AppFlags{
75+
Sock: edgednscli.SvcOpts.DNSSocketPath,
76+
Address: addr,
77+
PKI: pki}
78+
79+
cli, err := edgednscli.PbDNSClient(&cfg)
80+
if err != nil {
81+
fmt.Printf("Unable to create Edge DNS client: %v\n", err)
82+
code = 1
83+
return
84+
}
85+
// If the set-forwarders flag is set without a value, clear the forwarders in Edge DNS.
86+
if strings.Contains(strings.Join(os.Args, " "), "set-forwarders") {
87+
if err := edgednscli.SetForwarders(fwdrs, cli); err != nil {
88+
fmt.Printf("Unable to set DNS forwarders: %v\n", err)
89+
code = 1
90+
return
91+
}
92+
return
93+
}
94+
options(flag.Args(), cli)
95+
}
96+
97+
//options list the main functions of EDNS
98+
func options(arg []string, cli pb.ControlClient) {
99+
switch arg[0] {
100+
case "add":
101+
if err := addFS.Parse(arg[1:]); err == nil {
102+
if err := edgednscli.AddRecord(edgednscli.RecordOpts.Rec, pb.RType_A, cli); err != nil {
103+
fmt.Println(err)
104+
code = 1
105+
}
106+
}
107+
case "del":
108+
if err := delFS.Parse(arg[1:]); err == nil {
109+
if err := edgednscli.DelRecord(edgednscli.RecordOpts.Rec, pb.RType_A, cli); err != nil {
110+
fmt.Println(err)
111+
code = 1
112+
}
113+
}
114+
case "help":
115+
usage()
116+
case "get-all-records":
117+
filter(cli, true)
118+
default:
119+
extraoptions(arg[0], cli)
120+
}
121+
}
122+
123+
//extraoptions lists some extra functions of EDNS
124+
func extraoptions(arg string, cli pb.ControlClient) {
125+
switch arg {
126+
case "get-platform-records":
127+
filter(cli, false)
128+
case "get-client-records":
129+
filter(cli, false)
130+
default:
131+
_, _ = fmt.Fprintf(os.Stderr, "Unknown command: %s\n", arg)
132+
usage()
133+
code = 1
134+
}
135+
}
136+
func filter(cli pb.ControlClient, getall bool) {
137+
recs, err := edgednscli.FilterRecords(cli, func(fqdn string) bool {
138+
if getall {
139+
return true
140+
}
141+
return !strings.HasSuffix(fqdn, ".mec.")
142+
})
143+
if err != nil {
144+
fmt.Println(err)
145+
code = 1
146+
return
147+
}
148+
edgednscli.PrintRecs(recs)
149+
}
150+
func usage() {
151+
fmt.Printf("usage %s [GLOBAL_OPTION] CMD [OPTION]\n", name)
152+
fmt.Println("global options:")
153+
flag.PrintDefaults()
154+
fmt.Println(addFS.Name())
155+
addFS.PrintDefaults()
156+
fmt.Println(delFS.Name())
157+
delFS.PrintDefaults()
158+
fmt.Println(getAllFS.Name())
159+
getAllFS.PrintDefaults()
160+
fmt.Println(getPlatFS.Name())
161+
getPlatFS.PrintDefaults()
162+
fmt.Println(getClientFS.Name())
163+
getClientFS.PrintDefaults()
164+
}

0 commit comments

Comments
 (0)