mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
interface{} to any.
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
var policiesJson string
|
||||
|
||||
func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
policiesTmpl := map[string]interface{}{}
|
||||
policiesTmpl := map[string]any{}
|
||||
if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
// Extensions
|
||||
//
|
||||
|
||||
ExtensionInstallForcelist := []interface{}{}
|
||||
ExtensionInstallForcelist := []any{}
|
||||
for _, e := range policies.Extensions {
|
||||
URL := e.URL
|
||||
if URL == "" {
|
||||
@@ -36,7 +36,7 @@ func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
)
|
||||
}
|
||||
|
||||
ExtensionInstallAllowlist := []interface{}{}
|
||||
ExtensionInstallAllowlist := []any{}
|
||||
for _, e := range policies.Extensions {
|
||||
ExtensionInstallAllowlist = append(
|
||||
ExtensionInstallAllowlist,
|
||||
@@ -46,7 +46,7 @@ func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
|
||||
policiesTmpl["ExtensionInstallForcelist"] = ExtensionInstallForcelist
|
||||
policiesTmpl["ExtensionInstallAllowlist"] = ExtensionInstallAllowlist
|
||||
policiesTmpl["ExtensionInstallBlocklist"] = []interface{}{"*"}
|
||||
policiesTmpl["ExtensionInstallBlocklist"] = []any{"*"}
|
||||
|
||||
//
|
||||
// Developer Tools
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func Parse(policiesJson string) (*types.BrowserPolicyContent, error) {
|
||||
policies := types.BrowserPolicyContent{}
|
||||
|
||||
policiesTmpl := map[string]interface{}{}
|
||||
policiesTmpl := map[string]any{}
|
||||
if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func Parse(policiesJson string) (*types.BrowserPolicyContent, error) {
|
||||
|
||||
if extensions, ok := policiesTmpl["ExtensionInstallForcelist"]; ok {
|
||||
policies.Extensions = []types.BrowserPolicyExtension{}
|
||||
for _, val := range extensions.([]interface{}) {
|
||||
for _, val := range extensions.([]any) {
|
||||
s := strings.Split(val.(string), ";")
|
||||
url := ""
|
||||
if len(s) > 1 {
|
||||
|
||||
@@ -14,7 +14,7 @@ var policiesJson string
|
||||
|
||||
func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
policiesTmpl := struct {
|
||||
Policies map[string]interface{} `json:"policies"`
|
||||
Policies map[string]any `json:"policies"`
|
||||
}{}
|
||||
if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil {
|
||||
return "", err
|
||||
@@ -24,13 +24,13 @@ func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
// Extensions
|
||||
//
|
||||
|
||||
ExtensionSettings := map[string]interface{}{}
|
||||
ExtensionSettings["*"] = map[string]interface{}{
|
||||
ExtensionSettings := map[string]any{}
|
||||
ExtensionSettings["*"] = map[string]any{
|
||||
"installation_mode": "blocked",
|
||||
}
|
||||
|
||||
for _, e := range policies.Extensions {
|
||||
ExtensionSettings[e.ID] = map[string]interface{}{
|
||||
ExtensionSettings[e.ID] = map[string]any{
|
||||
"install_url": e.URL,
|
||||
"installation_mode": "force_installed",
|
||||
}
|
||||
@@ -48,18 +48,18 @@ func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
// Persistent Data
|
||||
//
|
||||
|
||||
Preferences := policiesTmpl.Policies["Preferences"].(map[string]interface{})
|
||||
Preferences := policiesTmpl.Policies["Preferences"].(map[string]any)
|
||||
Preferences["browser.urlbar.suggest.history"] = policies.PersistentData
|
||||
Preferences["places.history.enabled"] = policies.PersistentData
|
||||
policiesTmpl.Policies["Preferences"] = Preferences
|
||||
policiesTmpl.Policies["SanitizeOnShutdown"] = !policies.PersistentData
|
||||
|
||||
if policies.PersistentData {
|
||||
policiesTmpl.Policies["Homepage"] = map[string]interface{}{
|
||||
policiesTmpl.Policies["Homepage"] = map[string]any{
|
||||
"StartPage": "previous-session",
|
||||
}
|
||||
} else {
|
||||
policiesTmpl.Policies["Homepage"] = map[string]interface{}{
|
||||
policiesTmpl.Policies["Homepage"] = map[string]any{
|
||||
"StartPage": "homepage",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ func Parse(policiesJson string) (*types.BrowserPolicyContent, error) {
|
||||
policies := types.BrowserPolicyContent{}
|
||||
|
||||
policiesTmpl := struct {
|
||||
Policies map[string]interface{} `json:"policies"`
|
||||
Policies map[string]any `json:"policies"`
|
||||
}{}
|
||||
if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil {
|
||||
return nil, err
|
||||
@@ -30,12 +30,12 @@ func Parse(policiesJson string) (*types.BrowserPolicyContent, error) {
|
||||
|
||||
if extensions, ok := policiesTmpl.Policies["ExtensionSettings"]; ok {
|
||||
policies.Extensions = []types.BrowserPolicyExtension{}
|
||||
for id, val := range extensions.(map[string]interface{}) {
|
||||
for id, val := range extensions.(map[string]any) {
|
||||
if id == "*" {
|
||||
continue
|
||||
}
|
||||
|
||||
data := val.(map[string]interface{})
|
||||
data := val.(map[string]any)
|
||||
url, _ := data["install_url"].(string)
|
||||
|
||||
policies.Extensions = append(
|
||||
|
||||
@@ -14,7 +14,7 @@ type logformatter struct {
|
||||
}
|
||||
|
||||
func (l *logformatter) NewLogEntry(r *http.Request) middleware.LogEntry {
|
||||
req := map[string]interface{}{}
|
||||
req := map[string]any{}
|
||||
|
||||
if reqID := middleware.GetReqID(r.Context()); reqID != "" {
|
||||
req["id"] = reqID
|
||||
@@ -32,7 +32,7 @@ func (l *logformatter) NewLogEntry(r *http.Request) middleware.LogEntry {
|
||||
req["agent"] = r.UserAgent()
|
||||
req["uri"] = fmt.Sprintf("%s://%s%s", scheme, r.Host, r.RequestURI)
|
||||
|
||||
fields := map[string]interface{}{}
|
||||
fields := map[string]any{}
|
||||
fields["req"] = req
|
||||
|
||||
return &logentry{
|
||||
@@ -43,12 +43,12 @@ func (l *logformatter) NewLogEntry(r *http.Request) middleware.LogEntry {
|
||||
|
||||
type logentry struct {
|
||||
logger zerolog.Logger
|
||||
fields map[string]interface{}
|
||||
errors []map[string]interface{}
|
||||
fields map[string]any
|
||||
errors []map[string]any
|
||||
}
|
||||
|
||||
func (e *logentry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{}) {
|
||||
res := map[string]interface{}{}
|
||||
func (e *logentry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra any) {
|
||||
res := map[string]any{}
|
||||
res["time"] = time.Now().UTC().Format(time.RFC1123)
|
||||
res["status"] = status
|
||||
res["bytes"] = bytes
|
||||
@@ -65,8 +65,8 @@ func (e *logentry) Write(status, bytes int, header http.Header, elapsed time.Dur
|
||||
}
|
||||
}
|
||||
|
||||
func (e *logentry) Panic(v interface{}, stack []byte) {
|
||||
err := map[string]interface{}{}
|
||||
func (e *logentry) Panic(v any, stack []byte) {
|
||||
err := map[string]any{}
|
||||
err["message"] = fmt.Sprintf("%+v", v)
|
||||
err["stack"] = string(stack)
|
||||
|
||||
|
||||
@@ -29,6 +29,6 @@ func Color(str string) string {
|
||||
return result + str[lastIndex:]
|
||||
}
|
||||
|
||||
func Colorf(format string, a ...interface{}) string {
|
||||
func Colorf(format string, a ...any) string {
|
||||
return fmt.Sprintf(Color(format), a...)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ func Swal2Response(w http.ResponseWriter, body string) {
|
||||
http.Error(w, err.Error(), 500)
|
||||
}
|
||||
|
||||
err = tmpl.Execute(w, map[string]interface{}{
|
||||
err = tmpl.Execute(w, map[string]any{
|
||||
"Body": template.HTML(body),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user