Skip to content

Commit

Permalink
Combine http api and dns registration servers (#140)
Browse files Browse the repository at this point in the history
* Add dns registrar

* Add debug prints

* Strip clientconf in response if present

* Add unidirectional mode

* Assign bd endpoint in forwarder ctor

* Update dependencies

Use DNS registrar packages in updated gotapdance repo. Remove old repo
dependency.

* Add more logs

* Update log

* Check and log error from forwarder.RecvAndForward

* Return RecvAndRespond error value

* Update dependency version

* Add Makefile rules for dns registrar

* Add ability to read config from config file

* Add systemd service unit file for dns registrar

* Change defualt dnds reg privkey path in conf

* Add dns registrar simulation environment config

* Use logrus library to use log levels

* Format log to show timestamp

* Return on unsuccessful API HTTP code

Return immediatly, otherwise it will try to unmarshal the payload
resulting in another error.

Also change log levels.

* Add log level flag option and config var

* Change .gitignore

* Clean up comments

* Log RegID in logs

* Read key as raw bytes instead of encoded string

For compatibility with Conjure keys.

* Remove genkey functionality and unused functions

No need for dns registrar to genkey as we can just use conjure keys.

* Add comments and add log level

* Update config to use Conjure privkey path

* Move process bd req to func

* Rename api server

* Create regprocessor interface in seperate pkg

Put functions that handle formating registration requests and publishing
to zmq into its own package for reuse by DNS registrar and future
registration servers.

* Add zmq auth in regprocessor ctor

* Add regprocessor to api reg server

* Add regprocessor tests

* Add regprocessor tests

* Change var names

* Refactor api reg server to use regprocessor

* Add tests for api reg server

* Refactor dns registrar to use regprocessor

* Fix logging in api and dns reg server

* Add registration server cli main

* Add waitgroup for reg processes

* Use os instead of ioutil to read file

* Read log client IP env var

* Rm old registration api

* Use log fomatting in bdapi

* Use io instead of ioutil

* Add more logging

* Add systemd service file for registration server

* Update .gitignore

* Update logrus version

* Update sim env with reg server

* Fix make rule

* Remove unused files

* Add auth type config

* Remove logClientIP var from config struct

* Fix linter errors

* Update gh action to build combined reg server

* Update config files and instructions

* Fix file path in gh action rule

* Add tests for registration source

* Fix nil addr in registration processing

* Use same enum for api and bdapi in payload to zmq

* Reduce log level of successful registration logs

* Add metrics

* Add metric logging interval to config file

* Revert uninteded edit in config file
  • Loading branch information
mingyech authored Oct 31, 2022
1 parent 833bb4f commit ed0d226
Show file tree
Hide file tree
Showing 36 changed files with 2,069 additions and 1,476 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ jobs:
cd $GITHUB_WORKSPACE/go/src/github.com/refraction-networking/conjure
make app
- name: Build registration-api
- name: Build registration-server
run: |
cd $GITHUB_WORKSPACE/go/src/github.com/refraction-networking/conjure
make registration-api
make registration-server
- name: Store build artifacts
run: |
mkdir -p $GITHUB_WORKSPACE/bin
cd $GITHUB_WORKSPACE/go/src/github.com/refraction-networking/conjure
cp conjure application/application registration-api/registration-api $GITHUB_WORKSPACE/bin
cp conjure application/application cmd/registration-server/registration-server $GITHUB_WORKSPACE/bin
cd $GITHUB_WORKSPACE && tar -czf conjure-station.tar.gz bin
- name: Save build artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ jobs:
cd $GITHUB_WORKSPACE/go/src/github.com/refraction-networking/conjure
make app
- name: Build registration-api
- name: Build registration-server
run: |
cd $GITHUB_WORKSPACE/go/src/github.com/refraction-networking/conjure
make registration-api
make registration-server
golangci-lint:
name: Format and Lint with golangci-lint
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
backup/
conjure
application/application
registration-api/registration-api
libtapdance/genkey
cmd/registration-dns/registration-dns
cmd/registration-dns/*.key
cmd/registration-server/registration-server
target
19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ CFLAGS = -Wall -DENABLE_BPF -DHAVE_PF_RING -DHAVE_PF_RING_ZC -DTAPDANCE_USE_PF_R
PROTO_RS_PATH=src/signalling.rs


all: rust libtd conjure app registration-api registration-dns ${PROTO_RS_PATH}
all: rust libtd conjure app registration-server ${PROTO_RS_PATH}

sim: rust libtd conjure-sim app registration-api registration-dns ${PROTO_RS_PATH}
sim: rust libtd conjure-sim app registration-server ${PROTO_RS_PATH}

rust: ./src/*.rs
cargo build --${DEBUG_OR_RELEASE}
Expand All @@ -33,11 +33,8 @@ conjure: detect.c loadkey.c rust_util.c rust libtapdance
conjure-sim: detect.c loadkey.c rust_util.c rust libtapdance
${CC} -Wall -O2 -o conjure detect.c loadkey.c rust_util.c ${LIBS}

registration-api:
cd ./registration-api/ && make

registration-dns:
cd ./cmd/registration-dns/ && make
registration-server:
cd ./cmd/registration-server/ && make

# Note this copies in the whole current directory as context and results in
# overly large context. should not be used to build release/production images.
Expand All @@ -49,7 +46,7 @@ backup-config:
mkdir -p backup
cp -rf sysconfig backup/
cp application/config.toml backup/application.config.toml
cp registration-api/config.toml backup/registration-api.config.toml
cp cmd/registration-server/config.toml backup/registration-server.config.toml

restore-config:
ifneq (,$(wildcard backup/sysconfig))
Expand All @@ -59,8 +56,8 @@ endif
ifneq (,$(wildcard backup/application.config.toml))
mv backup/application.config.toml application/config.toml
endif
ifneq (,$(wildcard backup/registration-api.config.toml))
mv backup/registration-api.config.toml registration-api/config.toml
ifneq (,$(wildcard backup/registration-server.config.toml))
mv backup/registration-server.config.toml cmd/registration-server/config.toml
endif
$(RM) -rf backup

Expand All @@ -71,4 +68,4 @@ clean:
${PROTO_RS_PATH}:
cd ./proto/ && make

.PHONY: registration-api zmq-proxy
.PHONY: registration-server zmq-proxy
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ sudo systemctl enable zbalance
sudo systemctl enable conjure-app
sudo systemctl enable conjure-det

# if enabling and supporting registration api or multi-station registration sharing
sudo systemctl enable conjure-registration-api
# if enabling and supporting registration server or multi-station registration sharing
sudo systemctl enable conjure-registration-server
```

Start the station.
Expand All @@ -162,8 +162,8 @@ systemctl start zbalance
systemctl start conjure-det
systemctl start conjure-app

# if enabling and supporting registration api or multi-station registration sharing
systemctl start conjure-registration-api
# if enabling and supporting registration server or multi-station registration sharing
systemctl start conjure-registration-server
```

## [FAQ](https://github.com/refraction-networking/conjure/wiki/FAQ) | [WIKI](https://github.com/refraction-networking/conjure/wiki)
2 changes: 0 additions & 2 deletions cmd/registration-dns/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions cmd/registration-dns/config.toml

This file was deleted.

121 changes: 0 additions & 121 deletions cmd/registration-dns/main.go

This file was deleted.

Loading

0 comments on commit ed0d226

Please sign in to comment.