Skip to content

Commit

Permalink
Merge pull request #101 from akakou/hotfix/bugs
Browse files Browse the repository at this point in the history
Hotfix/bugs
  • Loading branch information
akakou authored Sep 9, 2024
2 parents b7689d6 + 13102d3 commit 484c15d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
18 changes: 14 additions & 4 deletions compose.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ services:
- ./test:/test
- /dev:/dev
working_dir: /ta/example
command: bash -c 'mount -o remount,exec /dev && ego-go build -buildvcs=false -trimpath=true && ego sign example && source /test/issue_service.sh && sleep 10 && ego run example'
command: bash -c 'mount -o remount,exec /dev && ego-go build -buildvcs=false -trimpath=true && ego sign example && source /test/issue_service.sh && ego run example'
privileged: true
environment:
- OE_SIMULATION=0
env_file:
- test/env/ta.env
- test/env/common.env
restart: unless-stopped
profiles:
- ta

verifier:
build: ./docker
ports:
- "10.0.0.5:443:443"
volumes:
- ./verifier:/verifier
- ./core:/core
Expand All @@ -34,3 +33,14 @@ services:
- test/env/common.env
privileged: true
tty: true
profiles:
- verifier

tunnel:
restart: unless-stopped
image: cloudflare/cloudflared
command: tunnel --url http://verifier:8080
env_file:
- test/env/tunnel.env
profiles:
- verifier
4 changes: 3 additions & 1 deletion ta/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ func main() {
}

http.HandleFunc("/", handler)
server.ListenAndServeTLS("", "")

err = server.ListenAndServeTLS("", "")
panic(err)
}
26 changes: 2 additions & 24 deletions verifier/serv/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
package main

import (
"crypto/tls"
"embed"
"fmt"
"html/template"
"io"
"net/http"
"os"

"github.com/akakou/ra_webs/verifier"
"github.com/akakou/ra_webs/verifier/api"
"github.com/akakou/ra_webs/verifier/notifier"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"golang.org/x/crypto/acme"
"golang.org/x/crypto/acme/autocert"
)

//go:embed views/*/*.html
Expand All @@ -42,13 +37,6 @@ func InjectSWHeader(next echo.HandlerFunc) echo.HandlerFunc {
}

func main() {
verifierHost := os.Getenv("RA_WEBS_VERIFIER_HOST")

autoTLSManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
Cache: autocert.DirCache("/var/www/.cache"),
}

e := echo.New()
verifier, err := verifier.DefaultVerifier()
if err != nil {
Expand All @@ -74,19 +62,9 @@ func main() {

fmt.Printf("public: %v\nprivate: %v", verifier.Notifier.(*notifier.BrowserNotifier).VapidPublicKey, verifier.Notifier.(*notifier.BrowserNotifier).VapidPrivateKey)

s := http.Server{
Addr: verifierHost + ":443",
Handler: e,
TLSConfig: &tls.Config{
GetCertificate: autoTLSManager.GetCertificate,
NextProtos: []string{acme.ALPNProto},
},
}

go verifier.Monitor.Run(verifier)
// fmt.Printf("public: %v\nprivate: %v", verifier.Notifier.(*notifier.BrowserNotifier).VapidPublicKey, verifier.Notifier.(*notifier.BrowserNotifier).VapidPrivateKey)

if err := s.ListenAndServeTLS("", ""); err != http.ErrServerClosed {
e.Logger.Fatal(err)
}
e.Logger.Fatal(e.Start(":8080"))
}

0 comments on commit 484c15d

Please sign in to comment.