Skip to content

Commit 107c48f

Browse files
authored
Layout Update (#179)
* add prelim changes for inf updates * README mistakes * build and test fixes * env var export in start_zbalance
1 parent 1f4ce57 commit 107c48f

File tree

14 files changed

+84
-44
lines changed

14 files changed

+84
-44
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ jobs:
5555
echo "Station successfully built"
5656
5757
- name: Set up Go
58-
uses: actions/setup-go@v3
58+
uses: actions/setup-go@v4
5959
with:
60-
go-version: 1.18.x
60+
go-version: 'stable'
6161

6262
- name: Build app
6363
run: |
@@ -71,9 +71,9 @@ jobs:
7171
7272
- name: Store build artifacts
7373
run: |
74-
mkdir -p $GITHUB_WORKSPACE/bin
74+
mkdir -p $GITHUB_WORKSPACE/
7575
cd $GITHUB_WORKSPACE/go/src/github.com/refraction-networking/conjure
76-
cp conjure application/application cmd/registration-server/registration-server $GITHUB_WORKSPACE/bin
76+
cp -r ./bin/ $GITHUB_WORKSPACE/
7777
cd $GITHUB_WORKSPACE && tar -czf conjure-station.tar.gz bin
7878
7979
- name: Save build artifacts

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ conjure
44
application/application
55
libtapdance/genkey
66
cmd/registration-server/registration-server
7-
target
7+
target
8+
bin/

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ TD_LIB=./libtapdance/libtapdance.a
88
LIBS=${RUST_LIB} ${TD_LIB} -L/usr/local/lib -lpcap -lpfring -lzmq -lcrypto -lpthread -lrt -lgmp -ldl -lm
99
CFLAGS = -Wall -DENABLE_BPF -DHAVE_PF_RING -DHAVE_PF_RING_ZC -DTAPDANCE_USE_PF_RING_ZERO_COPY -O2 # -g
1010
PROTO_RS_PATH=src/signalling.rs
11-
11+
EXE_DIR=./bin
1212

1313
all: rust libtd conjure app registration-server ${PROTO_RS_PATH}
1414

@@ -21,20 +21,24 @@ test:
2121
cargo test --${DEBUG_OR_RELEASE}
2222

2323
app:
24-
cd ./application/ && make
24+
[ -d $(EXE_DIR) ] || mkdir -p $(EXE_DIR)
25+
go build -o ${EXE_DIR}/application ./application
2526

2627
libtd:
2728
cd ./libtapdance/ && make libtapdance.a
2829

2930
conjure: detect.c loadkey.c rust_util.c rust libtapdance
30-
${CC} ${CFLAGS} -o $@ detect.c loadkey.c rust_util.c ${LIBS}
31-
# gcc -Wall -DENABLE_BPF -DHAVE_PF_RING -DHAVE_PF_RING_ZC -DTAPDANCE_USE_PF_RING_ZERO_COPY -O2 -o conjure detect.c loadkey.c rust_util.c ./target/release/librust_dark_decoy.a ./libtapdance/libtapdance.a -lpfring -lpcap -L/usr/local/lib -lzmq -lcrypto -lpthread -lrt -lgmp -ldl -lm
31+
[ -d $(EXE_DIR) ] || mkdir -p $(EXE_DIR)
32+
${CC} ${CFLAGS} -o ${EXE_DIR}/$@ detect.c loadkey.c rust_util.c ${LIBS}
33+
3234

3335
conjure-sim: detect.c loadkey.c rust_util.c rust libtapdance
34-
${CC} -Wall -O2 -o conjure detect.c loadkey.c rust_util.c ${LIBS}
36+
[ -d $(EXE_DIR) ] || mkdir -p $(EXE_DIR)
37+
${CC} -Wall -O2 -o ${EXE_DIR}/conjure detect.c loadkey.c rust_util.c ${LIBS}
3538

3639
registration-server:
37-
cd ./cmd/registration-server/ && make
40+
[ -d $(EXE_DIR) ] || mkdir -p $(EXE_DIR)
41+
go build -o ${EXE_DIR}/registration-server ./cmd/registration-server
3842

3943
PARAMS := det app reg zbalance sim
4044
target := unk
@@ -81,7 +85,7 @@ endif
8185

8286
clean:
8387
cargo clean
84-
rm -f ${TARGETS} *.o *~
88+
rm -f ${TARGETS} *.o *~ ${EXE_DIR}
8589

8690
${PROTO_RS_PATH}:
8791
cd ./proto/ && make

README.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<a href="https://goreportcard.com/report/github.com/refraction-networking/conjure"><img src="https://goreportcard.com/badge/github.com/refraction-networking/conjure"></a>
1010
</p>
1111

12-
### See also
12+
### See also
1313

1414
[Refraction Client Library](https://github.com/refraction-networking/gotapdance) -
1515
pure golang client library for connecting to refraction systems. Implements BOTH
@@ -23,14 +23,13 @@ station code implementing the previous iteration of refraction networking develo
2323
This is an abridged install and configuration process, for expanded install instructions,
2424
configuration options, or multi-station deployments see [the wiki](https://github.com/refraction-networking/conjure/wiki).
2525

26-
2726
### Requirements
2827

2928
Building the station requires both go and rust:
3029

3130
- [Install Golang](https://golang.org/doc/install)
3231

33-
- [Install Rust](https://www.rust-lang.org/tools/install)
32+
- [Install Rust](https://www.rust-lang.org/tools/install)
3433

3534
**Install packages and go libraries**
3635

@@ -39,12 +38,12 @@ sudo apt install wget git make gcc bison flex protobuf-compiler curl libssl-dev
3938
go get -d -u -t github.com/refraction-networking/gotapdance/...
4039
```
4140

42-
**Install PF_RING**
41+
**Install PF_RING**
4342

4443
1. [Install from Package](https://github.com/refraction-networking/conjure/wiki/PF_RING#from-packages)
4544

4645
2. [Install From Git / Source](https://github.com/refraction-networking/conjure/wiki/PF_RING#from-source)
47-
* if installing from git / source make the zbalance_ipc executable, and ensure that it is available through your `$PATH`.
46+
- if installing from git / source make the zbalance_ipc executable, and ensure that it is available through your `$PATH`.
4847

4948
### Build the station
5049

@@ -57,6 +56,38 @@ make
5756

5857
### Configure
5958

59+
The layout of configuration expected by the default layout of a production server is:
60+
61+
```sh
62+
## Station specific configuration and files go in /var/lib/conjure
63+
$ tree /var/lib/conjure/
64+
/var/lib/conjure/
65+
├── app_config.toml
66+
├── ClientConf # if running the registration server locally
67+
├── conjure.conf
68+
├── phantom_subnets.toml
69+
├── privkey
70+
├── pubkey
71+
└── reg_config.toml # if running the registration server locally
72+
73+
## Scripts, executables, and the default environment script (conjure.conf) go in /opt/conjure
74+
$ tree /opt/conjure/
75+
/opt/conjure/
76+
├── bin
77+
│   ├── application
78+
│   ├── conjure
79+
│   └── registration_server # if running the registration server locally
80+
├── on-reboot.sh
81+
├── scripts
82+
│   ├── install_pfring.sh
83+
│   ├── start_application.sh
84+
│   ├── start_detector.sh
85+
│   ├── start_registrar.sh
86+
│   └── start_zbalance_ipc.sh
87+
└── sysconfig
88+
└── conjure.conf # Expected by systemd services, applies overrides from /var/lib/conjure/conjure.conf
89+
```
90+
6091
To run a station configuration modifications are required. This section outlines
6192
some minimal changes, for more configuration options see the [wiki configuration page](https://github.com/refraction-networking/conjure/wiki/Configuration).
6293

@@ -67,24 +98,25 @@ some minimal changes, for more configuration options see the [wiki configuration
6798
# The interface(s) which PF_RING Zero Copy will tap.
6899
CJ_IFACE="zc:enp179s0f0,zc:enp179s0f1"
69100
70-
Public addresses that of non-tap interface - used for kernel DNAT
101+
Public addresses that of non-tap interface - used for kernel DNAT
71102
IP4_ADDR="<PUBLIC_STATION_V4_ADDRESS>"
72103
IP6_ADDR="<PUBLIC_STATION_V6_ADDRESS>"
73104
74105
```
75106
76107
Note: ipv6 in disabled by default. To enable IPv6 modify
77108
`application/config.toml`
109+
78110
```diff
79111
# Allow the station to opt out of either version of internet protocol to limit a
80112
# station to handling one or the other. For example, v6 on small station deployment
81-
# with only v6 phantom subnet, v4 only on station with no puvlic v6 address.
113+
# with only v6 phantom subnet, v4 only on station with no puvlic v6 address.
82114
enable_v4 = true
83115
-enable_v6 = false
84116
+enable_v6 = true
85117
```
86118
87-
2. Define application parameters in `application/congfig.toml`
119+
2. Define application parameters in `application/app_config.toml`
88120
89121
```toml
90122
# ============[ REQUIRED ]============
@@ -105,16 +137,16 @@ updated going forward with new generations) in `sysconfig/phantom_subnets.toml`
105137
Generation = 1
106138
[[Networks.1.WeightedSubnets]]
107139
Weight = 9
108-
Subnets = ["192.122.190.0/24", "2001:0123:4567:89ab::/64"]
140+
Subnets = ["192.122.190.0/24", "2001:0123:4567:89ab::/64"]
109141
110142
[Networks.2]
111143
Generation = 2
112144
[[Networks.2.WeightedSubnets]]
113145
Weight = 9
114-
Subnets = ["192.0.0.0/24", "2001:0123:4567:89ab::/64"]
146+
Subnets = ["192.0.0.0/24", "2001:0123:4567:89ab::/64"]
115147
[[Networks.2.WeightedSubnets]]
116148
Weight = 1
117-
Subnets = ["2001:0123:4567:89ab::/96"]
149+
Subnets = ["2001:0123:4567:89ab::/96"]
118150
```
119151
120152
### Setup
@@ -155,7 +187,7 @@ sudo systemctl enable conjure-registration-server
155187
Start the station.
156188

157189
```sh
158-
# zbalance has to be first or the detector will throw an error
190+
# zbalance has to be first or the detector will throw an error
159191
systemctl start zbalance
160192

161193
# Next start the detector and station application processes
@@ -166,4 +198,4 @@ systemctl start conjure-app
166198
systemctl start conjure-registration-server
167199
```
168200

169-
## [FAQ](https://github.com/refraction-networking/conjure/wiki/FAQ) | [WIKI](https://github.com/refraction-networking/conjure/wiki)
201+
## [FAQ](https://github.com/refraction-networking/conjure/wiki/FAQ) | [WIKI](https://github.com/refraction-networking/conjure/wiki)
File renamed without changes.

application/lib/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
// TestConfigParse double checks to ensure that the identity struct reflection
1212
// trick works and that the fields are accessible.
1313
func TestConfigParse(t *testing.T) {
14-
os.Setenv("CJ_STATION_CONFIG", "../config.toml")
14+
os.Setenv("CJ_STATION_CONFIG", "../app_config.toml")
1515

1616
var c Config
1717
_, err := toml.DecodeFile(os.Getenv("CJ_STATION_CONFIG"), &c)

cmd/registration-server/config.toml renamed to cmd/registration-server/reg_config.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dns_listen_addr = "[::]:53"
55
domain = "r.refraction.network"
66

77
# Path to Conjure private key file
8-
dns_private_key_path = "/opt/conjure/sysconfig/privkey"
8+
dns_private_key_path = "/var/lib/conjure/privkey"
99

1010
# Log level, one of the following: panic, fatal, error, warn, info, debug, trace
1111
log_level = "info"
@@ -21,7 +21,7 @@ zmq_port = 5591
2121
zmq_bind_addr = "*"
2222

2323
# The path on disk to the private key used for the ZMQ socket
24-
zmq_privkey_path = "/opt/conjure/sysconfig/privkey"
24+
zmq_privkey_path = "/var/lib/conjure/privkey"
2525

2626
# The type of authentication to use on the ZMQ socket.
2727
# Can be set to "NULL" which allows all connections, or "CURVE"
@@ -44,4 +44,4 @@ station_pubkeys = [
4444
bidirectional_api_generation = 957
4545

4646
# Path on disk to the latest ClientConfig file that the station should use
47-
clientconf_path = "/opt/conjure/sysconfig/ClientConf"
47+
clientconf_path = "/var/lib/conjure/ClientConf"

scripts/start_zbalance_ipc.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ check_ZC_driver() {
3434
echo ''
3535
sleep 10
3636
exit 1;
37-
fi
37+
fi
3838
}
3939

4040
# Run zbalance. Needed for zero-copy mode Conjure
4141
# See README.md
42+
# load config. will access config in /var/lib/conjure for overrides
43+
set -a
4244
source /opt/conjure/sysconfig/conjure.conf
45+
set +a
4346

4447
# CJ_IFACE could be a CSV list of interfaces.
4548
# Pull them apart to ensure each gets zc: prefix
@@ -53,7 +56,7 @@ do
5356
ifcelem=${ifc}
5457
fi
5558

56-
check_ZC_driver ${ifcelem}
59+
check_ZC_driver ${ifcelem}
5760

5861
if [ $didfirst -ne 0 ]; then
5962
ifcarg="$ifcarg,$ifcelem"

src/process_packet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ mod tests {
382382

383383
#[test]
384384
fn test_filter_station_traffic() {
385-
env::set_var("CJ_STATION_CONFIG", "./application/config.toml");
385+
env::set_var("CJ_STATION_CONFIG", "./application/app_config.toml");
386386

387387
// --
388388
let conf_path = env::var("CJ_STATION_CONFIG").unwrap();

sysconfig/conjure-app.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Type=simple
1010
WorkingDirectory=/opt/conjure/
1111

1212
SyslogIdentifier=conjure
13-
EnvironmentFile=/opt/conjure/sysconfig/conjure.conf
13+
# EnvironmentFile=/opt/conjure/sysconfig/conjure.conf
1414

1515
# # makes if binary doesn't exist
1616
# ExecStartPre=/bin/bash /opt/conjure/build.sh
1717
# Ensure zbalance finished starting (else pfring_zc_ipc_attach can give Invalid argument)
1818
ExecStartPre=/bin/sleep 10
19-
ExecStart=/opt/conjure/application/application
19+
ExecStart=/bin/bash /opt/conjure/scripts/start_application.sh
2020

2121
# send SIGHUP to the station process
2222
ExecReload=/bin/kill -HUP $MAINPID

0 commit comments

Comments
 (0)