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