You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50-8Lines changed: 50 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,23 @@ On downstream startup, a file glob is read from the configuration file. When a k
64
64
#### Performance
65
65
UDP receive is normally faster than Kafka writes. The downstream application tries to safeguard against lost packets by using a lightweight thread that receives events, decrypts them using AES256 (quite fast) and then adds the events to an array. Another thread consumes the array and writes to Kafka using the async protocol (that also returns immediately and processes the write in another thread). If the performance is not enough, first try to add nodes to the Kafka cluster and add the nodes to the bootstrapServers configuration in the downstream process. You can also try to add several events together before writing them to the upstream Kafka, since there is some overhead for each Kafka event, especially for writing. As a last resort, the upstream sender can be set to throttle (no code for that yet), e.g., by adding a small time.Sleep after each sent event. You should be able to securely transmit tens of thousand events every second using one transmission chain, but for large installations you might have to add more sender/receiver chains, as well as upgrade the Kafka instances.
66
66
67
+
### Automatic resend
68
+
Since UDP is an unreliable protocol, you can set up air-gap to automatically resend logs at specific time intervals. In the upstream property file, add the following property:
For each name-dealy, a thread will be created in upstream. Each thread connects to Kafka with a group name that consists of the groupID from the property file, a "-" character, and the name from the sendingThreads property. In the example above, two threads will be created. One named "now" with 0 seconds delay and one named "3minutes-ago" with 180 seconds delay.
77
+
78
+
The thread with name "now" will connecto to Kafka with a group id of "testGroup-now" and the other thread "testGroup-3minutes-ago".
79
+
80
+
When a thread reads a message in Kafka, it will check if the Kafka timestamp - the delay (delay is a negative number) is at least equal to, or greater than, the current time. If not, it will sleep until the time is right to send.
81
+
82
+
If a message is read but not delivered (because the thread is sleeping) and the application terminates, then the
83
+
67
84
### Gap Detection
68
85
Since UDP diodes only allow traffic in one direction, we need to invent a new feedback loop in case any events are not successfully delivered over the connection. We do this by enumerating all events we get from the upstream Kafka, send them over the UDP connection and use the enumeration as a key for the events in the downstream Kafka.
69
86
@@ -92,22 +109,22 @@ When set-timestamp has updated the configuration file, just restart the upstream
92
109
93
110
## Keys
94
111
Generate keystore with certificate or obtain otherwise.
All configuration can be overridden by environment variables. In the case a file is parsed that will be parsed first and may result in configuration errors. After that, any environment variables are checked and, if found, will overwrite the file configuration.
169
+
170
+
The environment variables are named as:
171
+
```bash
172
+
AIRGAP_UPSTREAM_{variable name in upper case}
173
+
```
174
+
Example:
175
+
```bash
176
+
export AIRGAP_UPSTREAM_ID=NEW-ID
177
+
export AIRGAP_UPSTREAM_NIC=ens0
178
+
export AIRGAP_UPSTREAM_TARGET_IP=255.255.255.255
179
+
...
180
+
```
181
+
182
+
183
+
Resend will receive a major overhaul so this section is now deprecated:
184
+
151
185
The same configuration file is used for set-timestamp. set-timestamp uses the bootstrapServers to query for timestamps for each topic partition and position in the set-timestamp arguments. When the earlierst timestamp has been retrieved, the configuration files's from parameter is set to that timestamp. When upstream restarts, it will read all Kafka events from the beginning and discard those before the from timestamp. During the start phase, set-timestamp will revert the from parameter to an empty string so the next startup will use Kafka's stored pointer for where to read from in the future.
152
186
153
187
### Downstream
@@ -196,10 +230,18 @@ The applications responds to os signals and can be installed as a service in, e.
196
230
See https://fabianlee.org/2022/10/29/golang-running-a-go-binary-as-a-systemd-service-on-ubuntu-22-04/
197
231
198
232
## Compile
199
-
Change directory to the application you would like to build (./src/upstream, ...).
200
-
Compile the applications with `go build`.
201
-
233
+
There is a Makefile that will get the latest tag from git and save in version.go, then build upstream and downstream.
234
+
```bash
235
+
make # builds both upstream and downstream
236
+
make upstream # builds only upstream
237
+
make downstream # builds only downstream
238
+
make clean # removes binaries and version.go
202
239
```
240
+
To build manually, change directory to the application you would like to build (./src/upstream, ...).
241
+
Compile the applications with `go build {filename}`.
242
+
243
+
Example:
244
+
```bash
203
245
cd src/upstream
204
246
go build upstream.go
205
247
```
@@ -248,5 +290,5 @@ sudo systemctl start upstream
248
290
## Dependencies
249
291
air-gap uses IBM/sarama for the Kafka read/write. For other dependencies, check the go.mod file.
0 commit comments