Merge branch 'dev'
This commit is contained in:
commit
5df75815b5
|
|
@ -71,7 +71,7 @@ This repository aims to promote the development of a multi-vendor management pla
|
|||
Run app using <u><b>Docker Compose</b></u>:
|
||||
<pre>
|
||||
user@user-laptop:~$ cd oktopus/deploy/compose
|
||||
user@user-laptop:~/oktopus/deploy/compose$ COMPOSE_PROFILES=nats,controller,mqtt,stomp,ws,adapter,frontend,portainer docker compose up -d
|
||||
user@user-laptop:~/oktopus/deploy/compose$ COMPOSE_PROFILES=nats,controller,cwmp,mqtt,stomp,ws,adapter,frontend,portainer docker compose up -d
|
||||
</pre>
|
||||
Oktopus deployment in <u><b>Kubernetes</b></u> still is in beta phase: <a href="https://github.com/OktopUSP/oktopus/blob/main/deploy/kubernetes/README.md"> Instructions for Kubernetes deployment</a><p></p>
|
||||
UI will open at port 3000:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ func main() {
|
|||
|
||||
natsActions := nats.StartNatsClient(c.Nats)
|
||||
|
||||
h := handler.NewHandler(natsActions.Publish, natsActions.Subscribe)
|
||||
h := handler.NewHandler(natsActions.Publish, natsActions.Subscribe, c.Acs)
|
||||
|
||||
b := bridge.NewBridge(
|
||||
natsActions.Publish,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
|
@ -24,9 +25,11 @@ type Acs struct {
|
|||
Tls bool
|
||||
TlsPort bool
|
||||
NoTls bool
|
||||
KeepAliveInterval time.Duration
|
||||
Username string
|
||||
Password string
|
||||
Route string
|
||||
DebugMode bool
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
|
@ -44,6 +47,8 @@ func NewConfig() *Config {
|
|||
natsVerifyCertificates := flag.Bool("nats_verify_certificates", lookupEnvOrBool("NATS_VERIFY_CERTIFICATES", false), "verify validity of certificates from nats server")
|
||||
acsPort := flag.String("acs_port", lookupEnvOrString("ACS_PORT", ":9292"), "port for acs server")
|
||||
acsRoute := flag.String("acs_route", lookupEnvOrString("ACS_ROUTE", "/acs"), "route for acs server")
|
||||
acsKeepAliveInterval := flag.Int("acs_keep_alive_interval", lookupEnvOrInt("KEEP_ALIVE_INTERVAL", 300), "keep alive interval in seconds for acs server")
|
||||
cwmpDebugMode := flag.Bool("debug_mode", lookupEnvOrBool("CWMP_DEBUG", false), "enable or disable cwmp logs in debug mode")
|
||||
flHelp := flag.Bool("help", false, "Help")
|
||||
|
||||
/*
|
||||
|
|
@ -72,6 +77,8 @@ func NewConfig() *Config {
|
|||
Acs: Acs{
|
||||
Port: *acsPort,
|
||||
Route: *acsRoute,
|
||||
KeepAliveInterval: time.Duration(*acsKeepAliveInterval),
|
||||
DebugMode: *cwmpDebugMode,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -99,6 +106,17 @@ func lookupEnvOrString(key string, defaultVal string) string {
|
|||
return defaultVal
|
||||
}
|
||||
|
||||
func lookupEnvOrInt(key string, defaultVal int) int {
|
||||
if val, _ := os.LookupEnv(key); val != "" {
|
||||
v, err := strconv.Atoi(val)
|
||||
if err != nil {
|
||||
log.Fatalf("LookupEnvOrInt[%s]: %v", key, err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
return defaultVal
|
||||
}
|
||||
|
||||
func lookupEnvOrBool(key string, defaultVal bool) bool {
|
||||
if val, _ := os.LookupEnv(key); val != "" {
|
||||
v, err := strconv.ParseBool(val)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ func (h *Handler) CwmpHandler(w http.ResponseWriter, r *http.Request) {
|
|||
tmp, _ := ioutil.ReadAll(r.Body)
|
||||
body := string(tmp)
|
||||
|
||||
if h.acsConfig.DebugMode {
|
||||
log.Println("Received message: ", body)
|
||||
}
|
||||
|
||||
var envelope cwmp.SoapEnvelope
|
||||
xml.Unmarshal(tmp, &envelope)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package handler
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"oktopUSP/backend/services/acs/internal/config"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
|
|
@ -56,6 +57,7 @@ type Handler struct {
|
|||
pub func(string, []byte) error
|
||||
sub func(string, func(*nats.Msg)) error
|
||||
Cpes map[string]CPE
|
||||
acsConfig config.Acs
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
@ -64,10 +66,15 @@ const (
|
|||
NATS_ADAPTER_SUBJECT_PREFIX = "adapter.v1."
|
||||
)
|
||||
|
||||
func NewHandler(pub func(string, []byte) error, sub func(string, func(*nats.Msg)) error) *Handler {
|
||||
func NewHandler(
|
||||
pub func(string, []byte) error,
|
||||
sub func(string, func(*nats.Msg)) error,
|
||||
cAcs config.Acs,
|
||||
) *Handler {
|
||||
return &Handler{
|
||||
pub: pub,
|
||||
sub: sub,
|
||||
Cpes: make(map[string]CPE),
|
||||
acsConfig: cAcs,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,19 +5,13 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// TODO: make these consts dynamic via config
|
||||
const (
|
||||
CHECK_STATUS_INTERVAL = 10 * time.Second
|
||||
KEEP_ALIVE_INTERVAL = 600 * time.Second
|
||||
)
|
||||
|
||||
func (h *Handler) handleCpeStatus(cpe string) {
|
||||
for {
|
||||
if time.Since(h.Cpes[cpe].LastConnection) > KEEP_ALIVE_INTERVAL {
|
||||
if time.Since(h.Cpes[cpe].LastConnection) > h.acsConfig.KeepAliveInterval {
|
||||
delete(h.Cpes, cpe)
|
||||
break
|
||||
}
|
||||
time.Sleep(CHECK_STATUS_INTERVAL)
|
||||
time.Sleep(h.acsConfig.KeepAliveInterval)
|
||||
}
|
||||
log.Println("CPE", cpe, "is offline")
|
||||
h.pub("cwmp.v1."+cpe+".status", []byte("0"))
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ services:
|
|||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.16
|
||||
profiles: [cwmp]
|
||||
|
||||
networks:
|
||||
usp_network:
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ export const OverviewLatestOrders = (props) => {
|
|||
</SeverityPill>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<SvgIcon
|
||||
{ order.Status == 2 && (order.Mqtt == 0 && order.Websockets == 0 && order.Stomp == 0) ? <span></span>: <SvgIcon
|
||||
fontSize="small"
|
||||
sx={{cursor: order.Status == 2 && 'pointer'}}
|
||||
onClick={()=>{
|
||||
|
|
@ -108,7 +108,7 @@ export const OverviewLatestOrders = (props) => {
|
|||
}
|
||||
>
|
||||
<ArrowTopRightOnSquareIcon />
|
||||
</SvgIcon>
|
||||
</SvgIcon>}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user