Merge branch 'develop' into feature/sources/openbgpd
This commit is contained in:
commit
38df30585d
@ -1,6 +1,10 @@
|
||||
|
||||
# Changelog
|
||||
|
||||
## 4.3.0 (2021-04-15)
|
||||
|
||||
* Added configurable main table
|
||||
|
||||
## 4.2.0 (2020-07-29)
|
||||
|
||||
* Added GoBGP processing_timeout source config option
|
||||
|
14
Dockerfile
14
Dockerfile
@ -31,22 +31,16 @@ ADD go.mod .
|
||||
ADD go.sum .
|
||||
RUN go mod download
|
||||
|
||||
ADD . .
|
||||
|
||||
# Add client
|
||||
COPY --from=frontend /src/alice-lg/client/build client/build
|
||||
|
||||
# Build backend
|
||||
WORKDIR /src/alice-lg
|
||||
ADD VERSION .
|
||||
ADD go.mod go.sum .
|
||||
|
||||
WORKDIR /src/alice-lg/backend
|
||||
ADD backend .
|
||||
|
||||
# RUN go build -o alice-lg-linux-amd64 -ldflags="-X main.version=4.0.3"
|
||||
WORKDIR /src/alice-lg/cmd/alice-lg
|
||||
RUN make alpine
|
||||
|
||||
FROM alpine:latest
|
||||
COPY --from=backend /src/alice-lg/backend/alice-lg-linux-amd64 /usr/bin/alice-lg
|
||||
COPY --from=backend /src/alice-lg/cmd/alice-lg/alice-lg-linux-amd64 /usr/bin/alice-lg
|
||||
RUN ls -lsha /usr/bin/alice-lg
|
||||
|
||||
EXPOSE 7340:7340
|
||||
|
5
Makefile
5
Makefile
@ -35,15 +35,14 @@ client_dev:
|
||||
client_prod:
|
||||
$(MAKE) -C client/ client_prod
|
||||
|
||||
|
||||
backend_prod: client_prod
|
||||
$(MAKE) -C cmd/alice-lg/ linux
|
||||
|
||||
backend:
|
||||
$(MAKE) -C cmd/alice-lg/ linux
|
||||
|
||||
alice: client_prod backend_prod
|
||||
mv backend/alice-lg-* bin/
|
||||
alice: backend_prod
|
||||
cp cmd/alice-lg/alice-lg-* bin/
|
||||
|
||||
|
||||
dist: clean alice
|
||||
|
16
Makefile.docker
Normal file
16
Makefile.docker
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
# Build a local alice binary using docker.
|
||||
|
||||
DOCKER := docker
|
||||
|
||||
all: alice
|
||||
cp cmd/alice-lg/alice-lg-* bin/
|
||||
|
||||
client:
|
||||
$(MAKE) -C client/ -f Makefile.docker client_prod
|
||||
|
||||
alice: client
|
||||
$(MAKE) -C cmd/alice-lg -f Makefile.docker
|
||||
|
||||
.PHONY: client alice
|
||||
|
@ -9,9 +9,9 @@ Take a look at an Alice-LG production examples at:
|
||||
And checkout the API at:
|
||||
- https://lg.de-cix.net/api/v1/config
|
||||
- https://lg.de-cix.net/api/v1/routeservers
|
||||
- https://lg.de-cix.net/api/v1/routeservers/0/status
|
||||
- https://lg.de-cix.net/api/v1/routeservers/0/neighbours
|
||||
- https://lg.de-cix.net/api/v1/routeservers/0/neighbours/ID109_AS31078/routes
|
||||
- https://lg.de-cix.net/api/v1/routeservers/rs1_fra_ipv4/status
|
||||
- https://lg.de-cix.net/api/v1/routeservers/rs1_fra_ipv4/neighbors
|
||||
- https://lg.de-cix.net/api/v1/routeservers/rs1_fra_ipv4/neighbors/R194_106/routes
|
||||
- https://lg.de-cix.net/api/v1/lookup/prefix?q=217.115.0.0
|
||||
|
||||
## Explanations
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
DOCKER := docker
|
||||
DOCKER_CONTAINER := alice-lg-node-build
|
||||
DOCKER_IMAGE := alice-lg-node:latest
|
||||
DOCKER_EXEC := docker run --rm -t -i \
|
||||
DOCKER_EXEC := $(DOCKER) run --rm -t -i \
|
||||
-a stdin -a stdout -a stderr \
|
||||
-v `pwd`:/client/ \
|
||||
--name $(DOCKER_CONTAINER) \
|
||||
@ -11,7 +12,7 @@ all: client
|
||||
@echo "Built alice-lg client"
|
||||
|
||||
image:
|
||||
docker build . -t $(DOCKER_IMAGE)
|
||||
$(DOCKER) build . -t $(DOCKER_IMAGE)
|
||||
|
||||
deps: image
|
||||
$(DOCKER_EXEC) "yarn install"
|
||||
@ -29,12 +30,12 @@ watch:
|
||||
|
||||
stop:
|
||||
@echo "Stopping docker container: $(DOCKER_CONTAINER)"
|
||||
-docker stop $(DOCKER_CONTAINER)
|
||||
-$(DOCKER) stop $(DOCKER_CONTAINER)
|
||||
@sleep 1
|
||||
|
||||
kill:
|
||||
@echo "Killing docker container: $(DOCKER_CONTAINER)"
|
||||
-docker kill $(DOCKER_CONTAINER)
|
||||
-$(DOCKER) kill $(DOCKER_CONTAINER)
|
||||
@sleep 1
|
||||
|
||||
|
||||
|
@ -9,7 +9,6 @@ ARCH=amd64
|
||||
APP_VERSION=$(shell cat ../../VERSION)
|
||||
VERSION=$(APP_VERSION)_$(shell git rev-parse --short HEAD)
|
||||
|
||||
LOCAL_RPMS=RPMS
|
||||
|
||||
# OS Detection
|
||||
UNAME=$(shell uname)
|
||||
@ -20,7 +19,9 @@ else
|
||||
endif
|
||||
|
||||
|
||||
LDFLAGS=-ldflags="-X main.version=$(APP_VERSION)"
|
||||
LDFLAGS=-ldflags="-X github.com/alice-lg/alice-lg/pkg/backend.Version=$(APP_VERSION)"
|
||||
LDFLAGS_STATIC=-ldflags="-X github.com/alice-lg/alice-lg/pkg/backend.Version=$(APP_VERSION) -extldflags '-static'"
|
||||
|
||||
FILES=$(shell find . -depth 1 ! -name "*_test.go" -name "*.go")
|
||||
|
||||
all: deps $(TARGET)
|
||||
@ -43,11 +44,18 @@ alpine:
|
||||
-a -installsuffix cgo \
|
||||
$(LDFLAGS) -o $(PROG)-linux-$(ARCH)
|
||||
|
||||
static:
|
||||
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) \
|
||||
go build $(CFLAGS) \
|
||||
-a $(LDFLAGS_STATIC) \
|
||||
-o $(PROG)-linux-$(ARCH)
|
||||
|
||||
|
||||
test:
|
||||
GO111MODULE=on go test -v
|
||||
cd api/ && GO111MODULE=on go test -v
|
||||
cd caches/ && GO111MODULE=on go test -v
|
||||
cd sources/birdwatcher && GO111MODULE=on go test -v
|
||||
cd ../../pkg/api/ && GO111MODULE=on go test -v
|
||||
cd ../../pkg/caches/ && GO111MODULE=on go test -v
|
||||
cd ../../pkg/sources/birdwatcher && GO111MODULE=on go test -v
|
||||
|
||||
|
||||
dev: clean all
|
||||
|
20
cmd/alice-lg/Makefile.docker
Normal file
20
cmd/alice-lg/Makefile.docker
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
#
|
||||
# Build alice using a dockerized go version
|
||||
#
|
||||
|
||||
DOCKER := docker
|
||||
|
||||
DOCKER_CONTAINER := alice-lg-build
|
||||
DOCKER_IMAGE := golang:1.16
|
||||
|
||||
DOCKER_EXEC := $(DOCKER) run --rm -t -i \
|
||||
-a stdin -a stdout -a stderr \
|
||||
-v `pwd`/../../:/src/alice-lg \
|
||||
--name $(DOCKER_CONTAINER) \
|
||||
--workdir /src/alice-lg/cmd/alice-lg \
|
||||
$(DOCKER_IMAGE)
|
||||
|
||||
all:
|
||||
$(DOCKER_EXEC) make static
|
||||
|
@ -150,6 +150,8 @@ blackholes = 10.23.6.666, 10.23.6.665
|
||||
api = http://rs1.example.com:29184/
|
||||
# single_table / multi_table
|
||||
type = multi_table
|
||||
|
||||
main_table = master4 # default is master in bird1x
|
||||
peer_table_prefix = T
|
||||
pipe_protocol_prefix = M
|
||||
# Timeout in seconds to wait for the status data (only required if enable_neighbors_status_refresh is true)
|
||||
|
@ -29,7 +29,7 @@ func apiNeighborsList(
|
||||
// Make response
|
||||
neighborsResponse = &api.NeighboursResponse{
|
||||
Api: api.ApiStatus{
|
||||
Version: version,
|
||||
Version: Version,
|
||||
CacheStatus: api.CacheStatus{
|
||||
OrigTtl: 0,
|
||||
CachedAt: sourceStatus.LastRefresh,
|
||||
|
@ -631,6 +631,7 @@ func getSources(config *ini.File) ([]*SourceConfig, error) {
|
||||
switch backendType {
|
||||
case SOURCE_BIRDWATCHER:
|
||||
sourceType := backendConfig.Key("type").MustString("")
|
||||
mainTable := backendConfig.Key("main_table").MustString("master")
|
||||
peerTablePrefix := backendConfig.Key("peer_table_prefix").MustString("T")
|
||||
pipeProtocolPrefix := backendConfig.Key("pipe_protocol_prefix").MustString("M")
|
||||
|
||||
@ -653,6 +654,7 @@ func getSources(config *ini.File) ([]*SourceConfig, error) {
|
||||
ServerTimeExt: "Mon, 02 Jan 2006 15:04:05 -0700",
|
||||
|
||||
Type: sourceType,
|
||||
MainTable: mainTable,
|
||||
PeerTablePrefix: peerTablePrefix,
|
||||
PipeProtocolPrefix: pipeProtocolPrefix,
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package backend
|
||||
|
||||
var version = "unknown"
|
||||
// Version Alice (set during the build)
|
||||
var Version = "unknown"
|
||||
|
||||
// Build is the current revision pointing at HEAD
|
||||
var Build = "unknown"
|
||||
|
||||
// AppStatus contains application status information
|
||||
type AppStatus struct {
|
||||
@ -25,7 +29,7 @@ func NewAppStatus() (*AppStatus, error) {
|
||||
}
|
||||
|
||||
status := &AppStatus{
|
||||
Version: version,
|
||||
Version: Version,
|
||||
Routes: routesStatus,
|
||||
Neighbours: neighboursStatus,
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package caches
|
||||
|
||||
import (
|
||||
"github.com/alice-lg/alice-lg/backend/api"
|
||||
"github.com/alice-lg/alice-lg/pkg/api"
|
||||
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package caches
|
||||
|
||||
import (
|
||||
"github.com/alice-lg/alice-lg/backend/api"
|
||||
"github.com/alice-lg/alice-lg/pkg/api"
|
||||
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -50,7 +50,7 @@ func (self *Client) Get(client *http.Client, url string) (ClientResponse, error)
|
||||
func (self *Client) GetJson(endpoint string) (ClientResponse, error) {
|
||||
client := &http.Client{}
|
||||
|
||||
return self.Get(client, self.Api + endpoint)
|
||||
return self.Get(client, self.Api+endpoint)
|
||||
}
|
||||
|
||||
// Make API request, parse response and return map or error
|
||||
@ -59,5 +59,5 @@ func (self *Client) GetJsonTimeout(timeout time.Duration, endpoint string) (Clie
|
||||
Timeout: timeout,
|
||||
}
|
||||
|
||||
return self.Get(client, self.Api + endpoint)
|
||||
return self.Get(client, self.Api+endpoint)
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ type Config struct {
|
||||
ShowLastReboot bool `ini:"show_last_reboot"`
|
||||
|
||||
Type string `ini:"type"`
|
||||
MainTable string `ini:"main_table"`
|
||||
PeerTablePrefix string `ini:"peer_table_prefix"`
|
||||
PipeProtocolPrefix string `ini:"pipe_protocol_prefix"`
|
||||
NeighborsRefreshTimeout int `ini:"neighbors_refresh_timeout"`
|
||||
|
@ -480,9 +480,10 @@ func (self *MultiTableBirdwatcher) AllRoutes() (*api.RoutesResponse, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mainTable := self.GenericBirdwatcher.config.MainTable
|
||||
|
||||
// Fetch received routes first
|
||||
birdImported, err := self.client.GetJson("/routes/table/master")
|
||||
birdImported, err := self.client.GetJson("/routes/table/" + mainTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -276,13 +276,14 @@ func (self *SingleTableBirdwatcher) RoutesNotExported(neighborId string) (*api.R
|
||||
|
||||
func (self *SingleTableBirdwatcher) AllRoutes() (*api.RoutesResponse, error) {
|
||||
// First fetch all routes from the master table
|
||||
birdImported, err := self.client.GetJson("/routes/table/master")
|
||||
mainTable := self.GenericBirdwatcher.config.MainTable
|
||||
birdImported, err := self.client.GetJson("/routes/table/" + mainTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Then fetch all filtered routes from the master table
|
||||
birdFiltered, err := self.client.GetJson("/routes/table/master/filtered")
|
||||
birdFiltered, err := self.client.GetJson("/routes/table/" + mainTable + "/filtered")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user