diff --git a/build.sh b/build.sh
index e72f075..d942aea 100755
--- a/build.sh
+++ b/build.sh
@@ -18,6 +18,7 @@ GitCommitLog=${GitCommitLog//\'/\"}
GitStatus=`git status -s`
BuildTime=`date +'%Y.%m.%d.%H%M%S'`
BuildGoVersion=`go version`
+WebUITpl=`cat lal.html`
LDFlags=" \
-X 'github.com/q191201771/naza/pkg/bininfo.GitTag=${GitTag}' \
@@ -25,6 +26,7 @@ LDFlags=" \
-X 'github.com/q191201771/naza/pkg/bininfo.GitStatus=${GitStatus}' \
-X 'github.com/q191201771/naza/pkg/bininfo.BuildTime=${BuildTime}' \
-X 'github.com/q191201771/naza/pkg/bininfo.BuildGoVersion=${BuildGoVersion}' \
+ -X 'github.com/q191201771/lal/pkg/logic.webUITpl=${WebUITpl}' \
"
echo "build" ${ROOT_DIR}/app/lalserver "..."
diff --git a/lal.html b/lal.html
new file mode 100644
index 0000000..c909d1d
--- /dev/null
+++ b/lal.html
@@ -0,0 +1,565 @@
+
+
+ lal
+
+
+
+
+ Server Info
+
+
+ Server ID |
+ {{.ServerID}} |
+
+
+ Git Tag |
+ {{.GitTag}} |
+
+
+ Git Commit Log |
+ {{.GitCommitLog}} |
+
+
+ Git Status |
+ {{.GitStatus}} |
+
+
+ Build Time |
+ {{.BuildTime}} |
+
+
+ Go Version |
+ {{.GoVersion}} |
+
+
+ Runtime |
+ {{.runtime}} |
+
+
+ lal Version |
+ {{.LalVersion}} |
+
+
+ API Version |
+ {{.ApiVersion}} |
+
+
+ Notify Version |
+ {{.NotifyVersion}} |
+
+
+ Start Time |
+ {{.StartTime}} |
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/logic/http_api.go b/pkg/logic/http_api.go
index f0a6b99..cc1a057 100644
--- a/pkg/logic/http_api.go
+++ b/pkg/logic/http_api.go
@@ -10,10 +10,13 @@ package logic
import (
"encoding/json"
- "github.com/q191201771/naza/pkg/nazajson"
+ "html/template"
"io/ioutil"
"net"
"net/http"
+ "strings"
+
+ "github.com/q191201771/naza/pkg/nazajson"
"github.com/q191201771/naza/pkg/nazahttp"
@@ -27,6 +30,8 @@ type HttpApiServer struct {
ln net.Listener
}
+var webUITpl string
+
func NewHttpApiServer(addr string, sm *ServerManager) *HttpApiServer {
return &HttpApiServer{
addr: addr,
@@ -53,7 +58,7 @@ func (h *HttpApiServer) RunLoop() error {
mux.HandleFunc("/api/ctrl/stop_relay_pull", h.ctrlStopRelayPullHandler)
mux.HandleFunc("/api/ctrl/kick_session", h.ctrlKickSessionHandler)
mux.HandleFunc("/api/ctrl/start_rtp_pub", h.ctrlStartRtpPubHandler)
- mux.HandleFunc("/", h.notFoundHandler)
+ mux.HandleFunc("/", h.webUIHandler)
var srv http.Server
srv.Handler = mux
@@ -213,6 +218,36 @@ func (h *HttpApiServer) ctrlStartRtpPubHandler(w http.ResponseWriter, req *http.
// ---------------------------------------------------------------------------------------------------------------------
+func (h *HttpApiServer) webUIHandler(w http.ResponseWriter, req *http.Request) {
+ if req.URL.Path != "/" {
+ h.notFoundHandler(w, req)
+ return
+ }
+
+ t, err := template.New("webUI").Parse(webUITpl)
+ if err != nil {
+ Log.Errorf("invaild html template: %v", err)
+ return
+ }
+
+ lalInfo := h.sm.StatLalInfo()
+ data := map[string]interface{}{
+ "ServerID": lalInfo.ServerId,
+ "LalVersion": lalInfo.LalVersion,
+ "ApiVersion": lalInfo.ApiVersion,
+ "NotifyVersion": lalInfo.NotifyVersion,
+ "StartTime": lalInfo.StartTime,
+ }
+ for _, item := range strings.Split(lalInfo.BinInfo, ". ") {
+ if index := strings.Index(item, "="); index != -1 {
+ k := item[:index]
+ v := strings.TrimPrefix(strings.TrimSuffix(item[index:], "."), "=")
+ data[k] = v
+ }
+ }
+ t.Execute(w, data)
+}
+
func (h *HttpApiServer) notFoundHandler(w http.ResponseWriter, req *http.Request) {
Log.Warnf("invalid http-api request. uri=%s, raddr=%s", req.RequestURI, req.RemoteAddr)
}