-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Systematizing preparation for minor release candidate (#6)
* feat: example client & server functions * fix: default target TCP server IP * feat: sample MQTT demo with Go * feat: example TCP republisher via server * fix: message payload contents (topic + data) * fix: build location & dependency requirements * feat: first draft at continuous integration (CI) workflow * feat: meta-testing for AETB & static binary name * nit: upgrade transitive/direct dependencies https://go.dev/doc/modules/managing-dependencies
- Loading branch information
1 parent
9058f1d
commit 53d8c7f
Showing
9 changed files
with
202 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Go | ||
name: ARCTIC Energy Testbed | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
branches: ["main"] | ||
pull_request: | ||
branches: [ "main" ] | ||
branches: ["main"] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21.x" | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
# FIXME: match version format (actions/setup-go/pull/410). | ||
- name: Install dependencies | ||
run: go get . | ||
|
||
# - name: Build | ||
# run: go build -v ./... | ||
- name: Build | ||
run: go build -o diode . | ||
|
||
# - name: Test | ||
# run: go test -v ./... | ||
- name: Test with the Go CLI | ||
run: go test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
module acep-uaf/cli/diode | ||
module github.com/acep-uaf/data-diode | ||
|
||
go 1.21.4 | ||
go 1.21.6 | ||
|
||
require ( | ||
github.com/urfave/cli/v2 v2.25.7 | ||
github.com/eclipse/paho.mqtt.golang v1.4.3 | ||
github.com/urfave/cli/v2 v2.27.1 | ||
rsc.io/quote v1.5.2 | ||
) | ||
|
||
require ( | ||
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect | ||
github.com/gorilla/websocket v1.5.1 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect | ||
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect | ||
golang.org/x/net v0.20.0 // indirect | ||
golang.org/x/sync v0.6.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
rsc.io/sampler v1.99.99 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Data Diode TCP Stream Republisher | ||
|
||
import socket | ||
import paho.mqtt.client as mqtt | ||
import json | ||
from datetime import datetime | ||
|
||
# Configuration Settings | ||
|
||
targetTcpServerIP = "192.168.1.20" | ||
targetTcpServerPort = 503 | ||
|
||
mqttBrokerIP = "test.mosquitto.org" | ||
mqttBrokerPort = 1883 | ||
mqttTopic = "test/message" | ||
|
||
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
server.bind((targetTcpServerIP, targetTcpServerPort)) | ||
server.listen(1) | ||
|
||
mqtt_client = mqtt.Client() | ||
mqtt_client.connect(mqttBrokerIP, mqttBrokerPort) | ||
|
||
while True: | ||
print(">> Waiting for connection...") | ||
connection, client = server.accept() | ||
|
||
try: | ||
print(">> Connected to client IP: {}".format(client)) | ||
|
||
while True: | ||
data = connection.recv(10240) | ||
if not data: | ||
break | ||
|
||
# print(f">> Received data: {data.decode()}") | ||
|
||
message = { | ||
"timestamp": datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"), | ||
"topic": mqttTopic, | ||
"data": data.decode() | ||
} | ||
|
||
json_message = json.dumps(message) | ||
|
||
mqtt_client.publish(mqttTopic, json_message) | ||
|
||
finally: | ||
connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestNewClient(t *testing.T) { | ||
name := "Input" | ||
t.Run(name, func(t *testing.T) { | ||
t.Parallel() | ||
}) | ||
} | ||
|
||
func TestNewServer(t *testing.T) { | ||
name := "Output" | ||
t.Run(name, func(t *testing.T) { | ||
t.Parallel() | ||
}) | ||
} |