This commit is contained in:
parent
654610ecd3
commit
3b89ea41e7
2 changed files with 17 additions and 8 deletions
|
@ -20,11 +20,13 @@ func videoplayback(w http.ResponseWriter, req *http.Request) {
|
|||
mn := strings.Split(q.Get("mn"), ",")
|
||||
|
||||
if len(mvi) <= 0 {
|
||||
w.WriteHeader(400)
|
||||
io.WriteString(w, "No `mvi` in query parameters")
|
||||
return
|
||||
}
|
||||
|
||||
if len(mn) <= 0 {
|
||||
w.WriteHeader(400)
|
||||
io.WriteString(w, "No `mn` in query parameters")
|
||||
return
|
||||
}
|
||||
|
@ -35,6 +37,7 @@ func videoplayback(w http.ResponseWriter, req *http.Request) {
|
|||
parts := strings.Split(strings.ToLower(host), ".")
|
||||
|
||||
if len(parts) < 2 {
|
||||
w.WriteHeader(400)
|
||||
io.WriteString(w, "Invalid hostname.")
|
||||
return
|
||||
}
|
||||
|
@ -49,6 +52,7 @@ func videoplayback(w http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
|
||||
if disallowed {
|
||||
w.WriteHeader(401)
|
||||
io.WriteString(w, "Non YouTube domains are not supported.")
|
||||
return
|
||||
}
|
||||
|
|
21
main.go
21
main.go
|
@ -96,6 +96,8 @@ var version string
|
|||
|
||||
var h3s bool
|
||||
|
||||
var programInit = time.Now()
|
||||
|
||||
type ConnectionWatcher struct {
|
||||
totalEstablished int64
|
||||
established int64
|
||||
|
@ -134,14 +136,15 @@ func (cw *ConnectionWatcher) OnStateChange(conn net.Conn, state http.ConnState)
|
|||
var cw ConnectionWatcher
|
||||
|
||||
type statusJson struct {
|
||||
Version string `json:"version"`
|
||||
RequestCount int64 `json:"requestCount"`
|
||||
RequestPerSecond int64 `json:"requestPerSecond"`
|
||||
RequestPerMinute int64 `json:"requestPerMinute"`
|
||||
TotalEstablished int64 `json:"totalEstablished"`
|
||||
EstablishedConnections int64 `json:"establishedConnections"`
|
||||
ActiveConnections int64 `json:"activeConnections"`
|
||||
IdleConnections int64 `json:"idleConnections"`
|
||||
Version string `json:"version"`
|
||||
Uptime time.Duration `json:"uptime"`
|
||||
RequestCount int64 `json:"requestCount"`
|
||||
RequestPerSecond int64 `json:"requestPerSecond"`
|
||||
RequestPerMinute int64 `json:"requestPerMinute"`
|
||||
TotalEstablished int64 `json:"totalEstablished"`
|
||||
EstablishedConnections int64 `json:"establishedConnections"`
|
||||
ActiveConnections int64 `json:"activeConnections"`
|
||||
IdleConnections int64 `json:"idleConnections"`
|
||||
RequestsForbidden struct {
|
||||
Videoplayback int64 `json:"videoplayback"`
|
||||
Vi int64 `json:"vi"`
|
||||
|
@ -151,6 +154,7 @@ type statusJson struct {
|
|||
|
||||
var stats_ = statusJson{
|
||||
Version: version + "-" + runtime.GOARCH,
|
||||
Uptime: 0,
|
||||
RequestCount: 0,
|
||||
RequestPerSecond: 0,
|
||||
RequestPerMinute: 0,
|
||||
|
@ -182,6 +186,7 @@ func root(w http.ResponseWriter, req *http.Request) {
|
|||
|
||||
func stats(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
stats_.Uptime = time.Duration(time.Since(programInit).Seconds())
|
||||
stats_.TotalEstablished = int64(cw.totalEstablished)
|
||||
stats_.EstablishedConnections = int64(cw.established)
|
||||
// stats_.ActiveConnections = int64(cw.active)
|
||||
|
|
Loading…
Reference in a new issue