mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 15:29:26 +00:00
WIP: Update to the go api.
This commit is contained in:
parent
03181cf6a4
commit
3b38372b4b
16 changed files with 317 additions and 30 deletions
|
|
@ -10,8 +10,6 @@ import (
|
|||
)
|
||||
|
||||
func EndpointAccess(w http.ResponseWriter, r *http.Request) bool {
|
||||
log.Println("endpoint access")
|
||||
|
||||
ip, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
@ -19,13 +17,13 @@ func EndpointAccess(w http.ResponseWriter, r *http.Request) bool {
|
|||
|
||||
if (isLocal(ip) && isEndpointAllowed("Local", r.URL.Path)) ||
|
||||
(isLanRemote(ip) && isEndpointAllowed("Remote", r.URL.Path)) {
|
||||
log.Println("accessible")
|
||||
log.Println(r.URL.Path, "endpoint access: accessible")
|
||||
return true
|
||||
} else if isLanRemote(ip) && isEndpointAllowed("auth", r.URL.Path) && isDeviceAuthorized() {
|
||||
log.Println("authorized")
|
||||
log.Println(r.URL.Path, "endpoint access: authorized")
|
||||
}
|
||||
|
||||
log.Println(r.URL.Path, "not authorized or accessible")
|
||||
log.Println(r.URL.Path, "endpoint access: not authorized or accessible")
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
27
be/app/helper/device-helper.go
Normal file
27
be/app/helper/device-helper.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package helper
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TempPinFile(Uuid string, pin string) bool {
|
||||
log.Println("temp pin file", Uuid, pin)
|
||||
err := os.WriteFile("devices/"+Uuid+".tmp", []byte(pin), 0644)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return false
|
||||
}
|
||||
|
||||
time.AfterFunc(1*time.Minute, func() {
|
||||
log.Println("deleting", Uuid, pin)
|
||||
os.Remove("devices/" + Uuid + ".tmp")
|
||||
})
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func CheckPinFile(encryptedData []byte) bool {
|
||||
return false
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue