Skip to content

Commit

Permalink
ui+ios updates #patch (#283)
Browse files Browse the repository at this point in the history
ui:
- alerts view fixes
- default icon and color for new devices
- disable edit of pending devices
- catch auth:failure events by default
- remove autoFocus for some input elements
api:
- Add device names as .lan domains
- For local mappings allow multiple names for one I
build:
- base image now uses 23.10 mantic for pi5 support and 6.5 kernel


* [build] move codeql scans to the dev branch

* [wifid] Address #279 by resetting wlan0 down/up on startup

* [ui] fix #271

* gluestack + iOS updates (#280)

* [ui] fix for ios build
* [ui] bump gluestack

---------

Co-authored-by: lts-po <po@longterm.io>

* [ui] qrcode for device component

* [ui] get device, with psk if otp

* [ui] show otp in modal

* [ui] show login info & qrcode for device

* [api] /device route to include psk if otp auth

* [ui] menu order

* [ui] validate ip for iOS

* [ui] send JSONPath query to api

* [ui] skip otp modal for auth page

* [ui] fix width for new gluestack, desktop

* [ui] only set endpoint if default endpoint is set

* [ui] useRNModal for web for menu/popup inside of modal

* [ui] input is wider now

* [ui] use actionsheet if more items

* empty out template device

* [ui] react-native - same as gstack

* [build] [ios] Attempt verion updates

* [ui] bump gluestack

* [ui] ios build

* [ui] remove autoFocus to avoid keyboard popup

* [ui] skip autoFocus

* [ui] skip autoFocus

* [ui] Select component for alert state

* [ui] fix eventTemplate for ios, only build template strings

* [api] Update error codes to 400

* [ui] Move New item to the top of the Item Menu

* [build] Move back from self hosted due to caching annoyances

* [api] Add device names as .lan domains

* [api] For local mappings allow multiple names for one IP

* [ui] auth:failure to catch event

* [ui] auth events

* [ui] change default notificationType to warning/error in sample alerts

* [ui] skip autoFocus

* [ui] use Textarea for body

* [ui] list alerts for mobile

* [ui] set default icon and color

* [ui] no edit of pending devices, #282

* [ui] no edit of pending devices, #282

* [ui] fix alert position on mobile

* [ui] use Select component. Fix #285

* [ui] show items on new line

* [packet_logs] remove old ulogd2 code and docs

* [plugin-lookup] update docs

* [installer] Update installer for 23.10

* [build] Update go packages for moby fixes

* [dyndns] Update golang to 1.21.5

* [build] [dyndns] Fix golang package name

* [build] [clearfog] Update to mantic base image & kernel

* [build] [dyndns] Fix to 3.0.7, don't need webserver backend

---------

Co-authored-by: Alex Radocea <alex@supernetworks.org>
Co-authored-by: lts-po <po@longterm.io>
  • Loading branch information
3 people authored Feb 22, 2024
1 parent 20fcc6c commit e1a1f2c
Show file tree
Hide file tree
Showing 71 changed files with 1,296 additions and 1,270 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
branches: [ "dev" ]
pull_request:
branches: [ "main" ]
branches: [ "dev" ]
schedule:
- cron: '31 21 * * 2'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
build-images:
name: Build images
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
-
name: Checkout
Expand Down
48 changes: 39 additions & 9 deletions api/code/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func ipAddr(w http.ResponseWriter, r *http.Request) {

if err != nil {
log.Println("ipAddr failed", err)
http.Error(w, "Not found", 404)
http.Error(w, "Not found", 400)
return
}

Expand Down Expand Up @@ -272,13 +272,13 @@ func getInfo(w http.ResponseWriter, r *http.Request) {

req, err := http.NewRequest(http.MethodGet, "http://localhost/v1.41/networks", nil)
if err != nil {
http.Error(w, err.Error(), 404)
http.Error(w, err.Error(), 400)
return
}

resp, err := c.Do(req)
if err != nil {
http.Error(w, err.Error(), 404)
http.Error(w, err.Error(), 400)
return
}

Expand All @@ -295,13 +295,13 @@ func getInfo(w http.ResponseWriter, r *http.Request) {

req, err := http.NewRequest(http.MethodGet, "http://localhost/v1.41/containers/json?all=1", nil)
if err != nil {
http.Error(w, err.Error(), 404)
http.Error(w, err.Error(), 400)
return
}

resp, err := c.Do(req)
if err != nil {
http.Error(w, err.Error(), 404)
http.Error(w, err.Error(), 400)
return
}

Expand All @@ -318,7 +318,7 @@ func getInfo(w http.ResponseWriter, r *http.Request) {
} else if name == "ss" {
data, err = exec.Command("jc", "-p", "ss", "-4", "-n").Output()
} else {
http.Error(w, "Invalid info", 404)
http.Error(w, "Invalid info", 400)
return
}

Expand Down Expand Up @@ -1156,6 +1156,35 @@ func getDevices(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(devices)
}

func getDevice(w http.ResponseWriter, r *http.Request) {
identity := r.URL.Query().Get("identity")
if strings.Contains(identity, ":") {
identity = trimLower(identity)
}

//nomask := r.URL.Query().Get("nomask")
//if nomask != "" {}

if identity == "" {
http.Error(w, "Invalid device identity", 400)
return
}

Devicesmtx.Lock()
defer Devicesmtx.Unlock()

devices := getDevicesJson()

dev, exists := devices[identity]
if !exists {
http.Error(w, "Invalid device identity", 400)
return
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(dev)
}

func handleUpdateDevice(w http.ResponseWriter, r *http.Request) {
identity := r.URL.Query().Get("identity")

Expand Down Expand Up @@ -1837,7 +1866,7 @@ func updateLocalMappings(IP string, Name string) {
}
ip := pieces[0]
hostname := pieces[1]
if ip == IP || entryName == hostname {
if entryName == hostname {
continue
}
new_data += ip + " " + hostname + "\n"
Expand Down Expand Up @@ -2685,6 +2714,7 @@ func main() {
external_router_authenticated.HandleFunc("/groups", getGroups).Methods("GET")
external_router_authenticated.HandleFunc("/groups", updateGroups).Methods("PUT", "DELETE")
external_router_authenticated.HandleFunc("/devices", getDevices).Methods("GET")
external_router_authenticated.HandleFunc("/device", applyJwtOtpCheck(getDevice)).Methods("GET")
external_router_authenticated.HandleFunc("/device", handleUpdateDevice).Methods("PUT", "DELETE")
external_router_authenticated.HandleFunc("/devices", syncDevices).Methods("PUT")

Expand Down Expand Up @@ -2746,15 +2776,15 @@ func main() {
// Auth api
external_router_authenticated.HandleFunc("/tokens", applyJwtOtpCheck(getAuthTokens)).Methods("GET")
external_router_authenticated.HandleFunc("/tokens", applyJwtOtpCheck(updateAuthTokens)).Methods("PUT", "DELETE")
//TBD: API Docs OTP

external_router_authenticated.HandleFunc("/otp_register", otpRegister).Methods("PUT", "DELETE")
external_router_authenticated.HandleFunc("/otp_validate", generateOTPToken).Methods("PUT")
external_router_authenticated.HandleFunc("/otp_status", otpStatus).Methods("GET")
external_router_authenticated.HandleFunc("/otp_jwt_test", applyJwtOtpCheck(testJWTOTP)).Methods("PUT")

// alerts
external_router_authenticated.HandleFunc("/alerts", getAlertSettings).Methods("GET")
external_router_authenticated.HandleFunc("/alerts", modifyAlertSettings).Methods("DELETE", "PUT")
external_router_authenticated.HandleFunc("/alerts", modifyAlertSettings).Methods("PUT")
external_router_authenticated.HandleFunc("/alerts/{index:[0-9]+}", modifyAlertSettings).Methods("DELETE", "PUT")

// allow leaf nodes to report PSK events also
Expand Down
1 change: 0 additions & 1 deletion api/code/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
var AuthUsersFile = TEST_PREFIX + "/configs/auth/auth_users.json"
var AuthTokensFile = TEST_PREFIX + "/configs/auth/auth_tokens.json"

var gOtpPeriod = 30
var OTPSettingsFile = TEST_PREFIX + "/configs/auth/otp_settings.json"

var WebAuthnOtpFile = TEST_PREFIX + "/state/api/webauthn_otp"
Expand Down
7 changes: 7 additions & 0 deletions api/code/dhcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ func getSetDhcpConfig(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(gDhcpConfig)
}

func normalizeName(Name string) string {
re := regexp.MustCompile("[^a-zA-Z0-9]")
return trimLower(re.ReplaceAllString(Name, "-"))
}

func handleDHCPResult(MAC string, IP string, Name string, Iface string) {
devices := getDevicesJson()
val, exists := devices[MAC]
Expand Down Expand Up @@ -289,6 +294,8 @@ func handleDHCPResult(MAC string, IP string, Name string, Iface string) {

if Name != "" {
// update local mappings file for DNS
updateLocalMappings(IP, normalizeName(val.Name))
// and the DHCP name also
updateLocalMappings(IP, Name)
}
}
Expand Down
10 changes: 5 additions & 5 deletions api/code/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/PaesslerAG/gval v1.2.2
github.com/PaesslerAG/jsonpath v0.1.1
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/uuid v1.5.0
github.com/google/uuid v1.6.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.1
Expand All @@ -28,10 +28,10 @@ require (
github.com/oapi-codegen/runtime v1.1.1 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/grpc v1.61.1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
)
10 changes: 10 additions & 0 deletions api/code/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
Expand Down Expand Up @@ -65,20 +67,28 @@ golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 h1:hZB7eLIaYlW9qXRfCq/qDaPdbeY3757uARz5Vvfv+cY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:YUWgXUFRPfoYK1IHMuxH5K6nPEXSCzIMljnQ59lLRCk=
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY=
google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
4 changes: 2 additions & 2 deletions base/template_configs/devices/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"VLANMatch": "",
"RecentIP": "",
"PSKEntry": {
"Type": "sae",
"Psk": "secure passphrase"
"Type": "",
"Psk": ""
},
"Groups": [
"dns",
Expand Down
6 changes: 3 additions & 3 deletions dyndns/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ RUN apt-get install -y --no-install-recommends nftables iproute2 netcat-traditio
RUN mkdir /code/
WORKDIR /code/
ARG TARGETARCH
RUN curl -O https://dl.google.com/go/go1.20.linux-${TARGETARCH}.tar.gz
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.linux-${TARGETARCH}.tar.gz
RUN curl -O https://dl.google.com/go/go1.21.5.linux-${TARGETARCH}.tar.gz
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.5.linux-${TARGETARCH}.tar.gz
ENV PATH="/usr/local/go/bin:$PATH"
RUN git clone https://github.com/TimothyYe/godns.git
RUN git clone --branch v3.0.7 https://github.com/TimothyYe/godns.git
WORKDIR godns/cmd/godns
ARG USE_TMPFS=true
RUN --mount=type=tmpfs,target=/tmpfs \
Expand Down
2 changes: 1 addition & 1 deletion dyndns/code/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module dyndns_plugin

go 1.17

require github.com/gorilla/mux v1.8.0
require github.com/gorilla/mux v1.8.1
2 changes: 2 additions & 0 deletions dyndns/code/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
Loading

0 comments on commit e1a1f2c

Please sign in to comment.