Skip to content

Commit 86f7e11

Browse files
authored
Maintain MQTT topic prefix + suffix structure (#61)
* Released data diode system information (#53) * docs: build requirements for `make` * fix: match MQTT client ID * Fix: Add a 'min' function to work with go1.18.1, the default on Ubuntu 22.04. (#54) * refactor: continuous outbound MQTT topic structure * bump: project requirements * docs: resolve formatting issues with markdownlint
1 parent 0b67fa1 commit 86f7e11

File tree

6 files changed

+48
-32
lines changed

6 files changed

+48
-32
lines changed

README.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@ Scripts for verifying TCP passthrough functionality.
66

77
> [!TIP]
88
> This project utilizes [`go`](https://go.dev/) for module management.
9-
> You can find installation instructions via https://go.dev/doc/install.
9+
> You can find installation instructions via [relevant operating system](https://go.dev/doc/install) documentation.
1010
1111
- Clone repository: `gh repo clone acep-uaf/data-diode`
1212
- Source navigation: `cd data-diode`
13-
- Build binary: `make`
14-
- [`build-essential`](https://packages.ubuntu.com/focal/build-essential)
13+
- Build binary: [`make`](https://www.gnu.org/software/make/)
1514
- CLI: `./diode [options...]`
1615

17-
#### Branch Management
16+
### Branch Management
1817

1918
- `main` → production ready environment.
2019
- `dev` → testing changes to be merged into `main`.
2120

22-
#### Directory Structure
21+
### Directory Structure
2322

2423
```zsh
2524
.
@@ -39,7 +38,7 @@ Scripts for verifying TCP passthrough functionality.
3938
5 directories, 7 files
4039
```
4140

42-
#### Architecture Diagram
41+
### Architecture Diagram
4342

4443
```mermaid
4544
graph LR
@@ -52,23 +51,23 @@ graph LR
5251
5352
## User Stories
5453

55-
#### Scenario Planning
54+
### Scenario Planning
5655

5756
1. Power Plant Operator
5857
1. Information Security Auditor
5958
1. Energy Awareness Application Developer
6059
1. Community Member
6160

62-
#### Threat Model[^1]
61+
### Threat Model[^1]
6362

6463
- [ ] Tactics
6564
- [ ] Techniques
6665
- [ ] Procedures
6766

68-
## System Benchmarking
67+
### System Benchmarking
6968

70-
#### Experimental Design
69+
### Experimental Design
7170

72-
###### [Device Configuration](docs/SOP.md)
71+
#### [Device Configuration](docs/SOP.md)
7372

74-
[^1]: https://csrc.nist.gov/glossary/term/tactics_techniques_and_procedures
73+
[^1]: <https://csrc.nist.gov/glossary/term/tactics_techniques_and_procedures>

docs/SOP.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
88
## Research Question
99

10-
#### State Synchronization
10+
### State Synchronization
1111

12-
#### System Replication
12+
### System Replication
1313

1414
## System Analysis
1515

16-
#### Latency
16+
### Latency
1717

18-
#### Bandwidth
18+
### Bandwidth
1919

20-
#### Throughput
20+
### Throughput
2121

2222
## Data Integrity

go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ go 1.22
44

55
require (
66
github.com/eclipse/paho.mqtt.golang v1.4.3
7-
github.com/urfave/cli/v2 v2.27.1
7+
github.com/urfave/cli/v2 v2.27.2
88
gopkg.in/yaml.v2 v2.4.0
99
)
1010

1111
require (
1212
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
13-
github.com/gorilla/websocket v1.5.1 // indirect
13+
github.com/gorilla/websocket v1.5.3 // indirect
1414
github.com/russross/blackfriday/v2 v2.1.0 // indirect
15-
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
16-
golang.org/x/net v0.24.0 // indirect
15+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
16+
golang.org/x/net v0.26.0 // indirect
1717
golang.org/x/sync v0.7.0 // indirect
1818
)

go.sum

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lV
22
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
33
github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik=
44
github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE=
5-
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
6-
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
5+
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
6+
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
77
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
88
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
9-
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
10-
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
11-
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
12-
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
13-
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
14-
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
9+
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
10+
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
11+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
12+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
13+
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
14+
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
1515
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
1616
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
1717
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

utility/application.go

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ const (
1313
SAMPLE = 10240
1414
)
1515

16+
func min(a, b int) int {
17+
if a < b {
18+
return a
19+
}
20+
return b
21+
}
22+
1623
func SendMessage(input string, client string) {
1724
conn, err := net.Dial(CONN_TYPE, client)
1825
if err != nil {

utility/republisher.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func InboundMessageFlow(server string, port int, topic string, arrival string) {
5555
<-c
5656
}
5757

58-
func OutboundMessageFlow(server string, port int, topic string, destination string) {
58+
func OutboundMessageFlow(server string, port int, prefix string, destination string) {
5959
messages := make(chan string)
6060
go func() {
6161
err := RecieveMessage(destination, messages)
@@ -66,8 +66,18 @@ func OutboundMessageFlow(server string, port int, topic string, destination stri
6666
}()
6767

6868
for message := range messages {
69-
repackaged := RepackageContents(message, topic)
70-
PublishPayload(server, port, topic, repackaged)
69+
var msg InputDiodeMessage
70+
err := json.Unmarshal([]byte(message), &msg)
71+
if err != nil {
72+
fmt.Println(">> [!] Error parsing JSON message: ", err)
73+
continue
74+
}
75+
76+
// TODO: Bounds checking for extracted top-level message intent.
77+
78+
prepend := prefix + "/" + msg.Topic
79+
repackaged := RepackageContents(message, prepend)
80+
PublishPayload(server, port, prepend, repackaged)
7181
}
7282
}
7383

0 commit comments

Comments
 (0)