remove domain only access, that can be done in the reverse proxy side
This commit is contained in:
parent
94edee02d1
commit
c50e482085
1 changed files with 4 additions and 24 deletions
|
@ -24,12 +24,6 @@ import (
|
|||
"github.com/quic-go/quic-go/http3"
|
||||
)
|
||||
|
||||
var h3s bool
|
||||
|
||||
var domain_only_access bool = false
|
||||
|
||||
var version string
|
||||
|
||||
type ConnectionWatcher struct {
|
||||
totalEstablished int64
|
||||
established int64
|
||||
|
@ -37,6 +31,10 @@ type ConnectionWatcher struct {
|
|||
idle int64
|
||||
}
|
||||
|
||||
var h3s bool
|
||||
var version string
|
||||
var cw ConnectionWatcher
|
||||
|
||||
// https://stackoverflow.com/questions/51317122/how-to-get-number-of-idle-and-active-connections-in-go
|
||||
// OnStateChange records open connections in response to connection
|
||||
// state changes. Set net/http Server.ConnState to this method
|
||||
|
@ -53,8 +51,6 @@ func (cw *ConnectionWatcher) OnStateChange(conn net.Conn, state http.ConnState)
|
|||
}
|
||||
}
|
||||
|
||||
var cw ConnectionWatcher
|
||||
|
||||
var tx uint64
|
||||
|
||||
func blockCheckerCalc(p *procfs.Proc) {
|
||||
|
@ -109,13 +105,6 @@ func blockChecker(gh string, cooldown int) {
|
|||
func beforeMisc(next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, req *http.Request) {
|
||||
defer utils.PanicHandler(w)
|
||||
|
||||
// To prevent accessing from the bare IP address
|
||||
if domain_only_access && (req.Host == "" || net.ParseIP(strings.Split(req.Host, ":")[0]) != nil) {
|
||||
w.WriteHeader(444)
|
||||
return
|
||||
}
|
||||
|
||||
next(w, req)
|
||||
}
|
||||
}
|
||||
|
@ -124,12 +113,6 @@ func beforeProxy(next http.HandlerFunc) http.HandlerFunc {
|
|||
return func(w http.ResponseWriter, req *http.Request) {
|
||||
defer utils.PanicHandler(w)
|
||||
|
||||
// To prevent accessing from the bare IP address
|
||||
if domain_only_access && (req.Host == "" || net.ParseIP(strings.Split(req.Host, ":")[0]) != nil) {
|
||||
w.WriteHeader(444)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "*")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS")
|
||||
|
@ -194,9 +177,6 @@ func main() {
|
|||
if strings.ToLower(getenv("BLOCK_CHECKER")) == "false" {
|
||||
bc = false
|
||||
}
|
||||
if strings.ToLower(getenv("DOMAIN_ONLY_ACCESS")) == "true" {
|
||||
domain_only_access = true
|
||||
}
|
||||
|
||||
tls_cert := getenv("TLS_CERT")
|
||||
if tls_cert == "" {
|
||||
|
|
Loading…
Add table
Reference in a new issue