Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d515e2d9d7 | ||
|
|
5990e8ee11 | ||
|
|
48d05eec7e |
89
.gitea/workflows/build.yml
Normal file
89
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
name: Build DBM Service
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
APP_NAME: tecamino-dbm
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: windows
|
||||
arch: amd64
|
||||
ext: .exe
|
||||
- os: linux
|
||||
arch: amd64
|
||||
ext: ""
|
||||
- os: linux
|
||||
arch: arm64
|
||||
ext: ""
|
||||
- os: linux
|
||||
arch: arm
|
||||
arm_version: 6
|
||||
ext: ""
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Ensure latest Go is installed in /data/go
|
||||
run: |
|
||||
export GOROOT=/data/go/go
|
||||
export PATH=$GOROOT/bin:$PATH
|
||||
export GOCACHE=/data/gocache
|
||||
export GOMODCACHE=/data/gomodcache
|
||||
mkdir -p $GOCACHE $GOMODCACHE
|
||||
|
||||
if [ ! -x "$GOROOT/bin/go" ]; then
|
||||
echo "Go not found in $GOROOT, downloading latest stable..."
|
||||
|
||||
GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n1)
|
||||
echo "Latest version is $GO_VERSION"
|
||||
|
||||
mkdir -p /data/go
|
||||
curl -sSL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tar.gz
|
||||
tar -C /data/go -xzf /tmp/go.tar.gz
|
||||
else
|
||||
echo "Using cached Go from $GOROOT"
|
||||
fi
|
||||
|
||||
go version
|
||||
|
||||
- name: Download Go dependencies
|
||||
run: |
|
||||
export GOROOT=/data/go/go
|
||||
export PATH=$GOROOT/bin:$PATH
|
||||
export GOCACHE=/data/gocache
|
||||
export GOMODCACHE=/data/gomodcache
|
||||
mkdir -p $GOCACHE $GOMODCACHE
|
||||
go mod download
|
||||
|
||||
- name: Build binary
|
||||
run: |
|
||||
export GOROOT=/data/go/go
|
||||
export PATH=$GOROOT/bin:$PATH
|
||||
export GOCACHE=/data/gocache
|
||||
export GOMODCACHE=/data/gomodcache
|
||||
mkdir -p $GOCACHE $GOMODCACHE
|
||||
|
||||
OUTPUT="bin/${APP_NAME}-${{ matrix.os }}-${{ matrix.arch }}"
|
||||
if [ -n "${{ matrix.arm_version }}" ]; then
|
||||
OUTPUT="${OUTPUT}v${{ matrix.arm_version }}"
|
||||
export GOARM=${{ matrix.arm_version }}
|
||||
fi
|
||||
OUTPUT="${OUTPUT}${{ matrix.ext }}"
|
||||
echo "Building $OUTPUT"
|
||||
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT"
|
||||
shell: bash
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
|
||||
path: bin/
|
||||
48
.github/workflows/build.yml
vendored
48
.github/workflows/build.yml
vendored
@@ -1,48 +0,0 @@
|
||||
name: Build Go Binaries
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
goos: [linux, windows]
|
||||
goarch: [amd64, arm, arm64]
|
||||
exclude:
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
- goos: windows
|
||||
goarch: arm64
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.24.0'
|
||||
|
||||
- name: Set up Git credentials for private modules
|
||||
run: |
|
||||
git config --global url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"
|
||||
echo "GOPRIVATE=github.com/tecamino/*" >> $GITHUB_ENV
|
||||
|
||||
- name: Build binary
|
||||
run: |
|
||||
mkdir -p build
|
||||
if [ "${{ matrix.goos }}" == "windows" ]; then
|
||||
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -trimpath -o build/tecamino-dbm-${{ matrix.goos }}-${{ matrix.goarch }}.exe main.go
|
||||
else
|
||||
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -trimpath -o build/tecamino-dbm-${{ matrix.goos }}-${{ matrix.goarch }} main.go
|
||||
fi
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
path: build/
|
||||
@@ -3,8 +3,8 @@ package args
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/tecamino/tecamino-dbm/cert"
|
||||
"github.com/tecamino/tecamino-dbm/models"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/cert"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/models"
|
||||
)
|
||||
|
||||
// DBM cli arguments
|
||||
|
||||
162
cert/cert.go
162
cert/cert.go
@@ -7,6 +7,7 @@ import (
|
||||
"crypto/x509/pkix"
|
||||
"encoding/pem"
|
||||
"math/big"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
@@ -35,65 +36,142 @@ func (c *Cert) GenerateSelfSignedCert() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
priv, err := rsa.GenerateKey(rand.Reader, 2048)
|
||||
caCert, caKey, err := createCA()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
serialNumber, _ := rand.Int(rand.Reader, big.NewInt(1<<62))
|
||||
|
||||
template := x509.Certificate{
|
||||
SerialNumber: serialNumber,
|
||||
Subject: pkix.Name{
|
||||
CommonName: "localhost",
|
||||
Organization: []string{c.Organization},
|
||||
},
|
||||
NotBefore: time.Now(),
|
||||
NotAfter: time.Now().Add(365 * 24 * time.Hour),
|
||||
|
||||
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
|
||||
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
|
||||
BasicConstraintsValid: true,
|
||||
DNSNames: []string{"localhost"},
|
||||
}
|
||||
|
||||
certDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv)
|
||||
serverCert, serverKey, err := createServerCert(caCert, caKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path.Dir(c.CertFile)); os.IsNotExist(err) {
|
||||
os.MkdirAll(path.Dir(c.CertFile), 0700)
|
||||
}
|
||||
|
||||
certOut, err := os.Create(c.CertFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer certOut.Close()
|
||||
pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: certDER})
|
||||
|
||||
// Set permission to 0600 (read/write by owner only)
|
||||
if err := os.Chmod(c.CertFile, 0600); err != nil {
|
||||
if err := os.MkdirAll(path.Dir(c.CertFile), 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path.Dir(c.KeyFile)); os.IsNotExist(err) {
|
||||
os.MkdirAll(path.Dir(c.KeyFile), 0700)
|
||||
}
|
||||
|
||||
keyOut, err := os.Create(c.KeyFile)
|
||||
if err != nil {
|
||||
if err := os.MkdirAll(path.Dir(c.KeyFile), 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
defer keyOut.Close()
|
||||
|
||||
pem.Encode(keyOut, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)})
|
||||
if err := saveCert(c.CertFile, serverCert.Raw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set permission to 0600 (read/write by owner only)
|
||||
if err := os.Chmod(c.KeyFile, 0600); err != nil {
|
||||
if err := saveKey(c.KeyFile, serverKey); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createCA() (*x509.Certificate, *rsa.PrivateKey, error) {
|
||||
priv, _ := rsa.GenerateKey(rand.Reader, 2048)
|
||||
|
||||
serial, _ := rand.Int(rand.Reader, big.NewInt(1<<62))
|
||||
|
||||
template := x509.Certificate{
|
||||
SerialNumber: serial,
|
||||
Subject: pkix.Name{
|
||||
CommonName: "Local Dev CA",
|
||||
},
|
||||
|
||||
NotBefore: time.Now(),
|
||||
NotAfter: time.Now().AddDate(10, 0, 0),
|
||||
|
||||
KeyUsage: x509.KeyUsageCertSign | x509.KeyUsageCRLSign,
|
||||
BasicConstraintsValid: true,
|
||||
IsCA: true,
|
||||
}
|
||||
|
||||
certDER, _ := x509.CreateCertificate(
|
||||
rand.Reader,
|
||||
&template,
|
||||
&template,
|
||||
&priv.PublicKey,
|
||||
priv,
|
||||
)
|
||||
|
||||
cert, _ := x509.ParseCertificate(certDER)
|
||||
|
||||
return cert, priv, nil
|
||||
}
|
||||
|
||||
func createServerCert(
|
||||
ca *x509.Certificate,
|
||||
caKey *rsa.PrivateKey,
|
||||
) (*x509.Certificate, *rsa.PrivateKey, error) {
|
||||
|
||||
priv, _ := rsa.GenerateKey(rand.Reader, 2048)
|
||||
serial, _ := rand.Int(rand.Reader, big.NewInt(1<<62))
|
||||
|
||||
template := x509.Certificate{
|
||||
SerialNumber: serial,
|
||||
|
||||
Subject: pkix.Name{
|
||||
CommonName: "localhost",
|
||||
},
|
||||
|
||||
NotBefore: time.Now(),
|
||||
NotAfter: time.Now().AddDate(1, 0, 0),
|
||||
|
||||
KeyUsage: x509.KeyUsageDigitalSignature,
|
||||
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
|
||||
|
||||
DNSNames: []string{
|
||||
"localhost",
|
||||
"lvh.me",
|
||||
},
|
||||
|
||||
IPAddresses: []net.IP{
|
||||
net.ParseIP("127.0.0.1"),
|
||||
net.ParseIP("::1"),
|
||||
},
|
||||
}
|
||||
|
||||
certDER, _ := x509.CreateCertificate(
|
||||
rand.Reader,
|
||||
&template,
|
||||
ca,
|
||||
&priv.PublicKey,
|
||||
caKey,
|
||||
)
|
||||
|
||||
cert, _ := x509.ParseCertificate(certDER)
|
||||
|
||||
return cert, priv, nil
|
||||
}
|
||||
|
||||
func saveCert(path string, der []byte) error {
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if err := pem.Encode(file, &pem.Block{
|
||||
Type: "CERTIFICATE",
|
||||
Bytes: der,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.Chmod(path, 0600)
|
||||
}
|
||||
|
||||
func saveKey(path string, key *rsa.PrivateKey) error {
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if err := pem.Encode(file, &pem.Block{
|
||||
Type: "RSA PRIVATE KEY",
|
||||
Bytes: x509.MarshalPKCS1PrivateKey(key),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.Chmod(path, 0600)
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
func (d *DBMHandler) SaveData(c *gin.Context) {
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/tecamino/tecamino-dbm/args"
|
||||
"github.com/tecamino/tecamino-dbm/models"
|
||||
ws "github.com/tecamino/tecamino-dbm/websocket"
|
||||
"github.com/tecamino/tecamino-logger/logging"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/args"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/models"
|
||||
ws "gitea.tecamino.com/paadi/tecamino-dbm/websocket"
|
||||
"gitea.tecamino.com/paadi/tecamino-logger/logging"
|
||||
)
|
||||
|
||||
type DBMHandler struct {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dbm
|
||||
|
||||
import (
|
||||
json_data "github.com/tecamino/tecamino-json_data"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
json_data "gitea.tecamino.com/paadi/tecamino-json_data"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
func (d *DBMHandler) Get(req *json_dataModels.Request, id string) {
|
||||
|
||||
@@ -3,9 +3,9 @@ package dbm
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
json_data "gitea.tecamino.com/paadi/tecamino-json_data"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
json_data "github.com/tecamino/tecamino-json_data"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
func (d *DBMHandler) Json_Data(c *gin.Context) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package dbm
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
func (d *DBMHandler) Set(req *json_dataModels.Request, id string) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package dbm
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
func (d *DBMHandler) Subscribe(req *json_dataModels.Request, id string) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dbm
|
||||
|
||||
import (
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/models"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
"github.com/google/uuid"
|
||||
"github.com/tecamino/tecamino-dbm/models"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
func (d *DBMHandler) AddSystemDps() (err error) {
|
||||
|
||||
@@ -3,9 +3,9 @@ package dbm
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/auth"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tecamino/tecamino-dbm/auth"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
6
go.mod
6
go.mod
@@ -1,14 +1,14 @@
|
||||
module github.com/tecamino/tecamino-dbm
|
||||
module gitea.tecamino.com/paadi/tecamino-dbm
|
||||
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
gitea.tecamino.com/paadi/tecamino-json_data v0.1.0
|
||||
gitea.tecamino.com/paadi/tecamino-logger v0.2.1
|
||||
github.com/gin-contrib/cors v1.7.5
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/tecamino/tecamino-json_data v0.0.31
|
||||
github.com/tecamino/tecamino-logger v0.2.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
8
go.sum
8
go.sum
@@ -1,3 +1,7 @@
|
||||
gitea.tecamino.com/paadi/tecamino-json_data v0.1.0 h1:zp3L8qUvkVqzuesQdMh/SgZZZbX3pGD9NYa6jtz+JvA=
|
||||
gitea.tecamino.com/paadi/tecamino-json_data v0.1.0/go.mod h1:/FKhbVYuhiNlQp4552rJJQIhynjLarDzfrgXpupkwZU=
|
||||
gitea.tecamino.com/paadi/tecamino-logger v0.2.1 h1:sQTBKYPdzn9mmWX2JXZBtGBvNQH7cuXIwsl4TD0aMgE=
|
||||
gitea.tecamino.com/paadi/tecamino-logger v0.2.1/go.mod h1:FkzRTldUBBOd/iy2upycArDftSZ5trbsX5Ira5OzJgM=
|
||||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
@@ -71,10 +75,6 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tecamino/tecamino-json_data v0.0.31 h1:7zFbANj1Lihr64CCCh3O+9hxxsMcEPniRJZ5NgPrS5Y=
|
||||
github.com/tecamino/tecamino-json_data v0.0.31/go.mod h1:LLlyD7Wwqplb2BP4PeO86EokEcTRidlW5MwgPd1T2JY=
|
||||
github.com/tecamino/tecamino-logger v0.2.0 h1:NPH/Gg9qRhmVoW8b39i1eXu/LEftHc74nyISpcRG+XU=
|
||||
github.com/tecamino/tecamino-logger v0.2.0/go.mod h1:0M1E9Uei/qw3e3WA1x3lBo1eP3H5oeYE7GjYrMahnj8=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
|
||||
6
main.go
6
main.go
@@ -3,10 +3,10 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/args"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/dbm"
|
||||
ws "gitea.tecamino.com/paadi/tecamino-dbm/websocket"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tecamino/tecamino-dbm/args"
|
||||
"github.com/tecamino/tecamino-dbm/dbm"
|
||||
ws "github.com/tecamino/tecamino-dbm/websocket"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/utils"
|
||||
ws "gitea.tecamino.com/paadi/tecamino-dbm/websocket"
|
||||
wsModels "gitea.tecamino.com/paadi/tecamino-dbm/websocket/models"
|
||||
json_data "gitea.tecamino.com/paadi/tecamino-json_data"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
"github.com/google/uuid"
|
||||
"github.com/tecamino/tecamino-dbm/utils"
|
||||
ws "github.com/tecamino/tecamino-dbm/websocket"
|
||||
wsModels "github.com/tecamino/tecamino-dbm/websocket/models"
|
||||
json_data "github.com/tecamino/tecamino-json_data"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/utils"
|
||||
ws "gitea.tecamino.com/paadi/tecamino-dbm/websocket"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
"gitea.tecamino.com/paadi/tecamino-logger/logging"
|
||||
"github.com/google/uuid"
|
||||
"github.com/tecamino/tecamino-dbm/utils"
|
||||
ws "github.com/tecamino/tecamino-dbm/websocket"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
"github.com/tecamino/tecamino-logger/logging"
|
||||
)
|
||||
|
||||
type DBM struct {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package models
|
||||
|
||||
import wsModels "github.com/tecamino/tecamino-dbm/websocket/models"
|
||||
import wsModels "gitea.tecamino.com/paadi/tecamino-dbm/websocket/models"
|
||||
|
||||
type Subscriptions map[*wsModels.Client]*Subscription
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
"github.com/google/uuid"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
type Uuids map[uuid.UUID]*Datapoint
|
||||
|
||||
@@ -3,17 +3,18 @@ package test
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/args"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/cert"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/dbm"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/models"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/utils"
|
||||
ws "gitea.tecamino.com/paadi/tecamino-dbm/websocket"
|
||||
"github.com/google/uuid"
|
||||
"github.com/tecamino/tecamino-dbm/args"
|
||||
"github.com/tecamino/tecamino-dbm/cert"
|
||||
"github.com/tecamino/tecamino-dbm/dbm"
|
||||
"github.com/tecamino/tecamino-dbm/models"
|
||||
"github.com/tecamino/tecamino-dbm/utils"
|
||||
ws "github.com/tecamino/tecamino-dbm/websocket"
|
||||
)
|
||||
|
||||
func TestCreateDps(t *testing.T) {
|
||||
@@ -146,3 +147,30 @@ func TestServer(t *testing.T) {
|
||||
|
||||
t.Fatal(server.ServeHttp("http://localhost", 8100))
|
||||
}
|
||||
|
||||
func TestCreateCerts(t *testing.T) {
|
||||
certFile := "cert.pem"
|
||||
keyFile := "key.pem"
|
||||
|
||||
defer func() {
|
||||
err := os.Remove(certFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = os.Remove(keyFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
t.Log("test create certificates")
|
||||
cert := cert.Cert{
|
||||
Organization: "tecamino",
|
||||
CertFile: certFile,
|
||||
KeyFile: keyFile,
|
||||
}
|
||||
|
||||
if err := cert.GenerateSelfSignedCert(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/websocket/models"
|
||||
wsModels "gitea.tecamino.com/paadi/tecamino-dbm/websocket/models"
|
||||
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tecamino/tecamino-dbm/websocket/models"
|
||||
wsModels "github.com/tecamino/tecamino-dbm/websocket/models"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
// serves as connection handler of websocket
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/cert"
|
||||
"gitea.tecamino.com/paadi/tecamino-dbm/utils"
|
||||
"gitea.tecamino.com/paadi/tecamino-logger/logging"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tecamino/tecamino-dbm/cert"
|
||||
"github.com/tecamino/tecamino-dbm/utils"
|
||||
"github.com/tecamino/tecamino-logger/logging"
|
||||
)
|
||||
|
||||
// server model for database manager websocket
|
||||
|
||||
Reference in New Issue
Block a user