replace interface{} by any

This commit is contained in:
imorte 2025-05-17 10:18:34 +02:00
commit d5edfeb6cb
39 changed files with 247 additions and 254 deletions

1
go.mod
View file

@ -23,7 +23,6 @@ require (
github.com/google/gousb v1.1.3 github.com/google/gousb v1.1.3
github.com/gorilla/mux v1.8.1 github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.3 github.com/gorilla/websocket v1.5.3
github.com/grandcat/zeroconf v1.0.0
github.com/hashicorp/go-bexpr v0.1.14 github.com/hashicorp/go-bexpr v0.1.14
github.com/inconshreveable/go-vhost v1.0.0 github.com/inconshreveable/go-vhost v1.0.0
github.com/jpillora/go-tld v1.2.1 github.com/jpillora/go-tld v1.2.1

7
go.sum
View file

@ -55,8 +55,6 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grandcat/zeroconf v1.0.0 h1:uHhahLBKqwWBV6WZUDAT71044vwOTL+McW0mBJvo6kE=
github.com/grandcat/zeroconf v1.0.0/go.mod h1:lTKmG1zh86XyCoUeIHSA4FJMBwCJiQmGfcP2PdzytEs=
github.com/hashicorp/go-bexpr v0.1.14 h1:uKDeyuOhWhT1r5CiMTjdVY4Aoxdxs6EtwgTGnlosyp4= github.com/hashicorp/go-bexpr v0.1.14 h1:uKDeyuOhWhT1r5CiMTjdVY4Aoxdxs6EtwgTGnlosyp4=
github.com/hashicorp/go-bexpr v0.1.14/go.mod h1:gN7hRKB3s7yT+YvTdnhZVLTENejvhlkZ8UE4YVBS+Q8= github.com/hashicorp/go-bexpr v0.1.14/go.mod h1:gN7hRKB3s7yT+YvTdnhZVLTENejvhlkZ8UE4YVBS+Q8=
github.com/inconshreveable/go-vhost v1.0.0 h1:IK4VZTlXL4l9vz2IZoiSFbYaaqUW7dXJAiPriUN5Ur8= github.com/inconshreveable/go-vhost v1.0.0 h1:IK4VZTlXL4l9vz2IZoiSFbYaaqUW7dXJAiPriUN5Ur8=
@ -92,7 +90,6 @@ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQ
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab h1:n8cgpHzJ5+EDyDri2s/GC7a9+qK3/YEGnBsd0uS/8PY= github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab h1:n8cgpHzJ5+EDyDri2s/GC7a9+qK3/YEGnBsd0uS/8PY=
github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab/go.mod h1:y1pL58r5z2VvAjeG1VLGc8zOQgSOzbKN7kMHPvFXJ+8= github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab/go.mod h1:y1pL58r5z2VvAjeG1VLGc8zOQgSOzbKN7kMHPvFXJ+8=
github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs= github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs=
github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ= github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
@ -140,8 +137,6 @@ golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190310074541-c10a0554eabf/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190310074541-c10a0554eabf/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
@ -153,7 +148,6 @@ golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -177,7 +171,6 @@ golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=

View file

@ -20,7 +20,7 @@ type httpResponse struct {
Response *http.Response Response *http.Response
Raw []byte Raw []byte
Body string Body string
JSON interface{} JSON any
} }
func (c httpPackage) Encode(s string) string { func (c httpPackage) Encode(s string) string {

View file

@ -8,7 +8,7 @@ import (
var NullValue = otto.Value{} var NullValue = otto.Value{}
func ReportError(format string, args ...interface{}) otto.Value { func ReportError(format string, args ...any) otto.Value {
log.Error(format, args...) log.Error(format, args...)
return NullValue return NullValue
} }

View file

@ -4,35 +4,35 @@ import (
"github.com/evilsocket/islazy/log" "github.com/evilsocket/islazy/log"
) )
type logFunction func(level log.Verbosity, format string, args ...interface{}) type logFunction func(level log.Verbosity, format string, args ...any)
var Logger = (logFunction)(nil) var Logger = (logFunction)(nil)
func Debug(format string, args ...interface{}) { func Debug(format string, args ...any) {
if Logger != nil { if Logger != nil {
Logger(log.DEBUG, format, args...) Logger(log.DEBUG, format, args...)
} }
} }
func Info(format string, args ...interface{}) { func Info(format string, args ...any) {
if Logger != nil { if Logger != nil {
Logger(log.INFO, format, args...) Logger(log.INFO, format, args...)
} }
} }
func Warning(format string, args ...interface{}) { func Warning(format string, args ...any) {
if Logger != nil { if Logger != nil {
Logger(log.WARNING, format, args...) Logger(log.WARNING, format, args...)
} }
} }
func Error(format string, args ...interface{}) { func Error(format string, args ...any) {
if Logger != nil { if Logger != nil {
Logger(log.ERROR, format, args...) Logger(log.ERROR, format, args...)
} }
} }
func Fatal(format string, args ...interface{}) { func Fatal(format string, args ...any) {
if Logger != nil { if Logger != nil {
Logger(log.FATAL, format, args...) Logger(log.FATAL, format, args...)
} }

View file

@ -39,7 +39,7 @@ func (mod *RestAPI) setAuthFailed(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Unauthorized")) w.Write([]byte("Unauthorized"))
} }
func (mod *RestAPI) toJSON(w http.ResponseWriter, o interface{}) { func (mod *RestAPI) toJSON(w http.ResponseWriter, o any) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(o); err != nil { if err := json.NewEncoder(w).Encode(o); err != nil {
mod.Debug("error while encoding object to JSON: %v", err) mod.Debug("error while encoding object to JSON: %v", err)
@ -70,24 +70,24 @@ func (mod *RestAPI) checkAuth(r *http.Request) bool {
return true return true
} }
func (mod *RestAPI) patchFrame(buf []byte) (frame map[string]interface{}, err error) { func (mod *RestAPI) patchFrame(buf []byte) (frame map[string]any, err error) {
// this is ugly but necessary: since we're replaying, the // this is ugly but necessary: since we're replaying, the
// api.rest state object is filled with *old* values (the // api.rest state object is filled with *old* values (the
// recorded ones), but the UI needs updated values at least // recorded ones), but the UI needs updated values at least
// of that in order to understand that a replay is going on // of that in order to understand that a replay is going on
// and where we are at it. So we need to parse the record // and where we are at it. So we need to parse the record
// back into a session object and update only the api.rest.state // back into a session object and update only the api.rest.state
frame = make(map[string]interface{}) frame = make(map[string]any)
if err = json.Unmarshal(buf, &frame); err != nil { if err = json.Unmarshal(buf, &frame); err != nil {
return return
} }
for _, i := range frame["modules"].([]interface{}) { for _, i := range frame["modules"].([]any) {
m := i.(map[string]interface{}) m := i.(map[string]any)
if m["name"] == "api.rest" { if m["name"] == "api.rest" {
state := m["state"].(map[string]interface{}) state := m["state"].(map[string]any)
mod.State.Range(func(key interface{}, value interface{}) bool { mod.State.Range(func(key any, value any) bool {
state[key.(string)] = value state[key.(string)] = value
return true return true
}) })

View file

@ -311,7 +311,7 @@ func (mod *C2) Configure() (err error) {
return mod.client.Connect(mod.settings.server) return mod.client.Connect(mod.settings.server)
} }
func (mod *C2) onPrint(format string, args ...interface{}) { func (mod *C2) onPrint(format string, args ...any) {
if !mod.Running() { if !mod.Running() {
return return
} }

View file

@ -59,7 +59,7 @@ func (mod *CANModule) Configure() error {
func (mod *CANModule) isFilteredOut(frame can.Frame, msg Message) bool { func (mod *CANModule) isFilteredOut(frame can.Frame, msg Message) bool {
// if we have an active filter // if we have an active filter
if mod.filter != "" { if mod.filter != "" {
if res, err := mod.filterExpr.Evaluate(map[string]interface{}{ if res, err := mod.filterExpr.Evaluate(map[string]any{
"message": msg, "message": msg,
"frame": frame, "frame": frame,
}); err != nil { }); err != nil {

View file

@ -182,23 +182,23 @@ func (p *DNSProxy) dnsWorker() error {
return p.Server.ListenAndServe() return p.Server.ListenAndServe()
} }
func (p *DNSProxy) Debug(format string, args ...interface{}) { func (p *DNSProxy) Debug(format string, args ...any) {
p.Sess.Events.Log(log.DEBUG, p.tag+format, args...) p.Sess.Events.Log(log.DEBUG, p.tag+format, args...)
} }
func (p *DNSProxy) Info(format string, args ...interface{}) { func (p *DNSProxy) Info(format string, args ...any) {
p.Sess.Events.Log(log.INFO, p.tag+format, args...) p.Sess.Events.Log(log.INFO, p.tag+format, args...)
} }
func (p *DNSProxy) Warning(format string, args ...interface{}) { func (p *DNSProxy) Warning(format string, args ...any) {
p.Sess.Events.Log(log.WARNING, p.tag+format, args...) p.Sess.Events.Log(log.WARNING, p.tag+format, args...)
} }
func (p *DNSProxy) Error(format string, args ...interface{}) { func (p *DNSProxy) Error(format string, args ...any) {
p.Sess.Events.Log(log.ERROR, p.tag+format, args...) p.Sess.Events.Log(log.ERROR, p.tag+format, args...)
} }
func (p *DNSProxy) Fatal(format string, args ...interface{}) { func (p *DNSProxy) Fatal(format string, args ...any) {
p.Sess.Events.Log(log.FATAL, p.tag+format, args...) p.Sess.Events.Log(log.FATAL, p.tag+format, args...)
} }

View file

@ -14,13 +14,13 @@ import (
) )
type JSQuery struct { type JSQuery struct {
Answers []map[string]interface{} Answers []map[string]any
Client map[string]string Client map[string]string
Compress bool Compress bool
Extras []map[string]interface{} Extras []map[string]any
Header JSQueryHeader Header JSQueryHeader
Nameservers []map[string]interface{} Nameservers []map[string]any
Questions []map[string]interface{} Questions []map[string]any
refHash string refHash string
} }
@ -39,23 +39,23 @@ type JSQueryHeader struct {
Zero bool Zero bool
} }
func jsPropToMap(obj map[string]interface{}, key string) map[string]interface{} { func jsPropToMap(obj map[string]any, key string) map[string]any {
if v, ok := obj[key].(map[string]interface{}); ok { if v, ok := obj[key].(map[string]any); ok {
return v return v
} }
log.Error("error converting JS property to map[string]interface{} where key is: %s", key) log.Error("error converting JS property to map[string]any where key is: %s", key)
return map[string]interface{}{} return map[string]any{}
} }
func jsPropToMapArray(obj map[string]interface{}, key string) []map[string]interface{} { func jsPropToMapArray(obj map[string]any, key string) []map[string]any {
if v, ok := obj[key].([]map[string]interface{}); ok { if v, ok := obj[key].([]map[string]any); ok {
return v return v
} }
log.Error("error converting JS property to []map[string]interface{} where key is: %s", key) log.Error("error converting JS property to []map[string]any where key is: %s", key)
return []map[string]interface{}{} return []map[string]any{}
} }
func jsPropToString(obj map[string]interface{}, key string) string { func jsPropToString(obj map[string]any, key string) string {
if v, ok := obj[key].(string); ok { if v, ok := obj[key].(string); ok {
return v return v
} }
@ -63,7 +63,7 @@ func jsPropToString(obj map[string]interface{}, key string) string {
return "" return ""
} }
func jsPropToStringArray(obj map[string]interface{}, key string) []string { func jsPropToStringArray(obj map[string]any, key string) []string {
if v, ok := obj[key].([]string); ok { if v, ok := obj[key].([]string); ok {
return v return v
} }
@ -71,7 +71,7 @@ func jsPropToStringArray(obj map[string]interface{}, key string) []string {
return []string{} return []string{}
} }
func jsPropToUint8(obj map[string]interface{}, key string) uint8 { func jsPropToUint8(obj map[string]any, key string) uint8 {
if v, ok := obj[key].(int64); ok { if v, ok := obj[key].(int64); ok {
if v >= 0 && v <= math.MaxUint8 { if v >= 0 && v <= math.MaxUint8 {
return uint8(v) return uint8(v)
@ -81,8 +81,8 @@ func jsPropToUint8(obj map[string]interface{}, key string) uint8 {
return uint8(0) return uint8(0)
} }
func jsPropToUint8Array(obj map[string]interface{}, key string) []uint8 { func jsPropToUint8Array(obj map[string]any, key string) []uint8 {
if arr, ok := obj[key].([]interface{}); ok { if arr, ok := obj[key].([]any); ok {
vArr := make([]uint8, 0, len(arr)) vArr := make([]uint8, 0, len(arr))
for _, item := range arr { for _, item := range arr {
if v, ok := item.(int64); ok { if v, ok := item.(int64); ok {
@ -100,7 +100,7 @@ func jsPropToUint8Array(obj map[string]interface{}, key string) []uint8 {
return []uint8{} return []uint8{}
} }
func jsPropToUint16(obj map[string]interface{}, key string) uint16 { func jsPropToUint16(obj map[string]any, key string) uint16 {
if v, ok := obj[key].(int64); ok { if v, ok := obj[key].(int64); ok {
if v >= 0 && v <= math.MaxUint16 { if v >= 0 && v <= math.MaxUint16 {
return uint16(v) return uint16(v)
@ -110,8 +110,8 @@ func jsPropToUint16(obj map[string]interface{}, key string) uint16 {
return uint16(0) return uint16(0)
} }
func jsPropToUint16Array(obj map[string]interface{}, key string) []uint16 { func jsPropToUint16Array(obj map[string]any, key string) []uint16 {
if arr, ok := obj[key].([]interface{}); ok { if arr, ok := obj[key].([]any); ok {
vArr := make([]uint16, 0, len(arr)) vArr := make([]uint16, 0, len(arr))
for _, item := range arr { for _, item := range arr {
if v, ok := item.(int64); ok { if v, ok := item.(int64); ok {
@ -129,7 +129,7 @@ func jsPropToUint16Array(obj map[string]interface{}, key string) []uint16 {
return []uint16{} return []uint16{}
} }
func jsPropToUint32(obj map[string]interface{}, key string) uint32 { func jsPropToUint32(obj map[string]any, key string) uint32 {
if v, ok := obj[key].(int64); ok { if v, ok := obj[key].(int64); ok {
if v >= 0 && v <= math.MaxUint32 { if v >= 0 && v <= math.MaxUint32 {
return uint32(v) return uint32(v)
@ -139,7 +139,7 @@ func jsPropToUint32(obj map[string]interface{}, key string) uint32 {
return uint32(0) return uint32(0)
} }
func jsPropToUint64(obj map[string]interface{}, key string) uint64 { func jsPropToUint64(obj map[string]any, key string) uint64 {
prop, found := obj[key] prop, found := obj[key]
if found { if found {
switch reflect.TypeOf(prop).String() { switch reflect.TypeOf(prop).String() {
@ -210,10 +210,10 @@ func (j *JSQuery) NewHash() string {
} }
func NewJSQuery(query *dns.Msg, clientIP string) (jsQuery *JSQuery) { func NewJSQuery(query *dns.Msg, clientIP string) (jsQuery *JSQuery) {
answers := make([]map[string]interface{}, len(query.Answer)) answers := make([]map[string]any, len(query.Answer))
extras := make([]map[string]interface{}, len(query.Extra)) extras := make([]map[string]any, len(query.Extra))
nameservers := make([]map[string]interface{}, len(query.Ns)) nameservers := make([]map[string]any, len(query.Ns))
questions := make([]map[string]interface{}, len(query.Question)) questions := make([]map[string]any, len(query.Question))
for i, rr := range query.Answer { for i, rr := range query.Answer {
jsRecord, err := NewJSResourceRecord(rr) jsRecord, err := NewJSResourceRecord(rr)
@ -243,7 +243,7 @@ func NewJSQuery(query *dns.Msg, clientIP string) (jsQuery *JSQuery) {
} }
for i, question := range query.Question { for i, question := range query.Question {
questions[i] = map[string]interface{}{ questions[i] = map[string]any{
"Name": question.Name, "Name": question.Name,
"Qtype": int64(question.Qtype), "Qtype": int64(question.Qtype),
"Qclass": int64(question.Qclass), "Qclass": int64(question.Qclass),

View file

@ -8,11 +8,11 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
) )
func NewJSResourceRecord(rr dns.RR) (jsRecord map[string]interface{}, err error) { func NewJSResourceRecord(rr dns.RR) (jsRecord map[string]any, err error) {
header := rr.Header() header := rr.Header()
jsRecord = map[string]interface{}{ jsRecord = map[string]any{
"Header": map[string]interface{}{ "Header": map[string]any{
"Class": int64(header.Class), "Class": int64(header.Class),
"Name": header.Name, "Name": header.Name,
"Rrtype": int64(header.Rrtype), "Rrtype": int64(header.Rrtype),
@ -26,9 +26,9 @@ func NewJSResourceRecord(rr dns.RR) (jsRecord map[string]interface{}, err error)
case *dns.AAAA: case *dns.AAAA:
jsRecord["AAAA"] = rr.AAAA.String() jsRecord["AAAA"] = rr.AAAA.String()
case *dns.APL: case *dns.APL:
jsPrefixes := make([]map[string]interface{}, len(rr.Prefixes)) jsPrefixes := make([]map[string]any, len(rr.Prefixes))
for i, v := range rr.Prefixes { for i, v := range rr.Prefixes {
jsPrefixes[i] = map[string]interface{}{ jsPrefixes[i] = map[string]any{
"Negation": v.Negation, "Negation": v.Negation,
"Network": v.Network.String(), "Network": v.Network.String(),
} }
@ -251,7 +251,7 @@ func NewJSResourceRecord(rr dns.RR) (jsRecord map[string]interface{}, err error)
jsRecord["Priority"] = int64(rr.Priority) jsRecord["Priority"] = int64(rr.Priority)
jsRecord["Target"] = rr.Target jsRecord["Target"] = rr.Target
kvs := rr.Value kvs := rr.Value
var jsKvs []map[string]interface{} var jsKvs []map[string]any
for _, kv := range kvs { for _, kv := range kvs {
jsKv, err := NewJSSVCBKeyValue(kv) jsKv, err := NewJSSVCBKeyValue(kv)
if err != nil { if err != nil {
@ -265,7 +265,7 @@ func NewJSResourceRecord(rr dns.RR) (jsRecord map[string]interface{}, err error)
jsRecord["Priority"] = int64(rr.Priority) jsRecord["Priority"] = int64(rr.Priority)
jsRecord["Target"] = rr.Target jsRecord["Target"] = rr.Target
kvs := rr.Value kvs := rr.Value
jsKvs := make([]map[string]interface{}, len(kvs)) jsKvs := make([]map[string]any, len(kvs))
for i, kv := range kvs { for i, kv := range kvs {
jsKv, err := NewJSSVCBKeyValue(kv) jsKv, err := NewJSSVCBKeyValue(kv)
if err != nil { if err != nil {
@ -307,7 +307,7 @@ func NewJSResourceRecord(rr dns.RR) (jsRecord map[string]interface{}, err error)
jsRecord["RendezvousServers"] = rr.RendezvousServers jsRecord["RendezvousServers"] = rr.RendezvousServers
case *dns.OPT: case *dns.OPT:
options := rr.Option options := rr.Option
jsOptions := make([]map[string]interface{}, len(options)) jsOptions := make([]map[string]any, len(options))
for i, option := range options { for i, option := range options {
jsOption, err := NewJSEDNS0(option) jsOption, err := NewJSEDNS0(option)
if err != nil { if err != nil {
@ -361,7 +361,7 @@ func NewJSResourceRecord(rr dns.RR) (jsRecord map[string]interface{}, err error)
return jsRecord, nil return jsRecord, nil
} }
func ToRR(jsRecord map[string]interface{}) (rr dns.RR, err error) { func ToRR(jsRecord map[string]any) (rr dns.RR, err error) {
jsHeader := jsPropToMap(jsRecord, "Header") jsHeader := jsPropToMap(jsRecord, "Header")
header := dns.RR_Header{ header := dns.RR_Header{
@ -385,7 +385,7 @@ func ToRR(jsRecord map[string]interface{}) (rr dns.RR, err error) {
AAAA: net.ParseIP(jsPropToString(jsRecord, "AAAA")), AAAA: net.ParseIP(jsPropToString(jsRecord, "AAAA")),
} }
case dns.TypeAPL: case dns.TypeAPL:
jsPrefixes := jsRecord["Prefixes"].([]map[string]interface{}) jsPrefixes := jsRecord["Prefixes"].([]map[string]any)
prefixes := make([]dns.APLPrefix, len(jsPrefixes)) prefixes := make([]dns.APLPrefix, len(jsPrefixes))
for i, jsPrefix := range jsPrefixes { for i, jsPrefix := range jsPrefixes {
jsNetwork := jsPrefix["Network"].(string) jsNetwork := jsPrefix["Network"].(string)

View file

@ -8,18 +8,18 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
) )
func NewJSEDNS0(e dns.EDNS0) (jsEDNS0 map[string]interface{}, err error) { func NewJSEDNS0(e dns.EDNS0) (jsEDNS0 map[string]any, err error) {
option := e.Option() option := e.Option()
jsEDNS0 = map[string]interface{}{ jsEDNS0 = map[string]any{
"Option": option, "Option": option,
} }
var jsVal map[string]interface{} var jsVal map[string]any
switch opt := e.(type) { switch opt := e.(type) {
case *dns.EDNS0_LLQ: case *dns.EDNS0_LLQ:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Code": opt.Code, "Code": opt.Code,
"Error": opt.Error, "Error": opt.Error,
"Id": opt.Id, "Id": opt.Id,
@ -28,38 +28,38 @@ func NewJSEDNS0(e dns.EDNS0) (jsEDNS0 map[string]interface{}, err error) {
"Version": opt.Version, "Version": opt.Version,
} }
case *dns.EDNS0_UL: case *dns.EDNS0_UL:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Code": opt.Code, "Code": opt.Code,
"Lease": opt.Lease, "Lease": opt.Lease,
"KeyLease": opt.KeyLease, "KeyLease": opt.KeyLease,
} }
case *dns.EDNS0_NSID: case *dns.EDNS0_NSID:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Code": opt.Code, "Code": opt.Code,
"Nsid": opt.Nsid, "Nsid": opt.Nsid,
} }
case *dns.EDNS0_ESU: case *dns.EDNS0_ESU:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Code": opt.Code, "Code": opt.Code,
"Uri": opt.Uri, "Uri": opt.Uri,
} }
case *dns.EDNS0_DAU: case *dns.EDNS0_DAU:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"AlgCode": opt.AlgCode, "AlgCode": opt.AlgCode,
"Code": opt.Code, "Code": opt.Code,
} }
case *dns.EDNS0_DHU: case *dns.EDNS0_DHU:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"AlgCode": opt.AlgCode, "AlgCode": opt.AlgCode,
"Code": opt.Code, "Code": opt.Code,
} }
case *dns.EDNS0_N3U: case *dns.EDNS0_N3U:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"AlgCode": opt.AlgCode, "AlgCode": opt.AlgCode,
"Code": opt.Code, "Code": opt.Code,
} }
case *dns.EDNS0_SUBNET: case *dns.EDNS0_SUBNET:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Address": opt.Address.String(), "Address": opt.Address.String(),
"Code": opt.Code, "Code": opt.Code,
"Family": opt.Family, "Family": opt.Family,
@ -67,33 +67,33 @@ func NewJSEDNS0(e dns.EDNS0) (jsEDNS0 map[string]interface{}, err error) {
"SourceScope": opt.SourceScope, "SourceScope": opt.SourceScope,
} }
case *dns.EDNS0_EXPIRE: case *dns.EDNS0_EXPIRE:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Code": opt.Code, "Code": opt.Code,
"Empty": opt.Empty, "Empty": opt.Empty,
"Expire": opt.Expire, "Expire": opt.Expire,
} }
case *dns.EDNS0_COOKIE: case *dns.EDNS0_COOKIE:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Code": opt.Code, "Code": opt.Code,
"Cookie": opt.Cookie, "Cookie": opt.Cookie,
} }
case *dns.EDNS0_TCP_KEEPALIVE: case *dns.EDNS0_TCP_KEEPALIVE:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Code": opt.Code, "Code": opt.Code,
"Length": opt.Length, "Length": opt.Length,
"Timeout": opt.Timeout, "Timeout": opt.Timeout,
} }
case *dns.EDNS0_PADDING: case *dns.EDNS0_PADDING:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Padding": string(opt.Padding), "Padding": string(opt.Padding),
} }
case *dns.EDNS0_EDE: case *dns.EDNS0_EDE:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"ExtraText": opt.ExtraText, "ExtraText": opt.ExtraText,
"InfoCode": opt.InfoCode, "InfoCode": opt.InfoCode,
} }
case *dns.EDNS0_LOCAL: case *dns.EDNS0_LOCAL:
jsVal = map[string]interface{}{ jsVal = map[string]any{
"Code": opt.Code, "Code": opt.Code,
"Data": string(opt.Data), "Data": string(opt.Data),
} }
@ -106,7 +106,7 @@ func NewJSEDNS0(e dns.EDNS0) (jsEDNS0 map[string]interface{}, err error) {
return jsEDNS0, nil return jsEDNS0, nil
} }
func ToEDNS0(jsEDNS0 map[string]interface{}) (e dns.EDNS0, err error) { func ToEDNS0(jsEDNS0 map[string]any) (e dns.EDNS0, err error) {
option := jsPropToUint16(jsEDNS0, "Option") option := jsPropToUint16(jsEDNS0, "Option")
jsVal := jsPropToMap(jsEDNS0, "Value") jsVal := jsPropToMap(jsEDNS0, "Value")

View file

@ -8,10 +8,10 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
) )
func NewJSSVCBKeyValue(kv dns.SVCBKeyValue) (map[string]interface{}, error) { func NewJSSVCBKeyValue(kv dns.SVCBKeyValue) (map[string]any, error) {
key := kv.Key() key := kv.Key()
jsKv := map[string]interface{}{ jsKv := map[string]any{
"Key": uint16(key), "Key": uint16(key),
} }
@ -56,7 +56,7 @@ func NewJSSVCBKeyValue(kv dns.SVCBKeyValue) (map[string]interface{}, error) {
return jsKv, nil return jsKv, nil
} }
func ToSVCBKeyValue(jsKv map[string]interface{}) (dns.SVCBKeyValue, error) { func ToSVCBKeyValue(jsKv map[string]any) (dns.SVCBKeyValue, error) {
var kv dns.SVCBKeyValue var kv dns.SVCBKeyValue
key := dns.SVCBKey(jsPropToUint16(jsKv, "Key")) key := dns.SVCBKey(jsPropToUint16(jsKv, "Key"))

View file

@ -178,7 +178,7 @@ func (mod *GPS) readFromSerial() {
} }
func (mod *GPS) runFromGPSD() { func (mod *GPS) runFromGPSD() {
mod.gpsd.AddFilter("TPV", func(r interface{}) { mod.gpsd.AddFilter("TPV", func(r any) {
report := r.(*gpsd.TPVReport) report := r.(*gpsd.TPVReport)
mod.Session.GPS.Updated = report.Time mod.Session.GPS.Updated = report.Time
mod.Session.GPS.Latitude = report.Lat mod.Session.GPS.Latitude = report.Lat
@ -189,7 +189,7 @@ func (mod *GPS) runFromGPSD() {
mod.Session.Events.Add("gps.new", mod.Session.GPS) mod.Session.Events.Add("gps.new", mod.Session.GPS)
}) })
mod.gpsd.AddFilter("SKY", func(r interface{}) { mod.gpsd.AddFilter("SKY", func(r any) {
report := r.(*gpsd.SKYReport) report := r.(*gpsd.SKYReport)
mod.Session.GPS.NumSatellites = int64(len(report.Satellites)) mod.Session.GPS.NumSatellites = int64(len(report.Satellites))
mod.Session.GPS.HDOP = report.Hdop mod.Session.GPS.HDOP = report.Hdop

View file

@ -249,18 +249,18 @@ func (g *Graph) JSON(filter string, disconnected bool) (string, int, int, error)
discarded := 0 discarded := 0
type link struct { type link struct {
Source string `json:"source"` Source string `json:"source"`
Target string `json:"target"` Target string `json:"target"`
Edge interface{} `json:"edge"` Edge any `json:"edge"`
} }
type data struct { type data struct {
Nodes []map[string]interface{} `json:"nodes"` Nodes []map[string]any `json:"nodes"`
Links []link `json:"links"` Links []link `json:"links"`
} }
jsData := data{ jsData := data{
Nodes: make([]map[string]interface{}, 0), Nodes: make([]map[string]any, 0),
Links: make([]link, 0), Links: make([]link, 0),
} }
@ -337,7 +337,7 @@ func (g *Graph) FindOtherTypes(t NodeType, id string) ([]*Node, error) {
return otherNodes, nil return otherNodes, nil
} }
func (g *Graph) CreateNode(t NodeType, id string, entity interface{}, annotations string) (*Node, error) { func (g *Graph) CreateNode(t NodeType, id string, entity any, annotations string) (*Node, error) {
g.Lock() g.Lock()
defer g.Unlock() defer g.Unlock()

View file

@ -49,13 +49,13 @@ var nodeDotStyles = map[NodeType]string{
} }
type Node struct { type Node struct {
Type NodeType `json:"type"` Type NodeType `json:"type"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`
ID string `json:"id"` ID string `json:"id"`
Annotations string `json:"annotations"` Annotations string `json:"annotations"`
Entity interface{} `json:"entity"` Entity any `json:"entity"`
Dummy bool `json:"-"` Dummy bool `json:"-"`
} }
func ReadNode(fileName string) (*Node, error) { func ReadNode(fileName string) (*Node, error) {
@ -121,27 +121,27 @@ func (n Node) Label() string {
return s return s
case BLEServer: case BLEServer:
return fmt.Sprintf("%s\\n(%s)", return fmt.Sprintf("%s\\n(%s)",
n.Entity.(map[string]interface{})["mac"].(string), n.Entity.(map[string]any)["mac"].(string),
n.Entity.(map[string]interface{})["vendor"].(string)) n.Entity.(map[string]any)["vendor"].(string))
case Station: case Station:
return fmt.Sprintf("%s\\n(%s)", return fmt.Sprintf("%s\\n(%s)",
n.Entity.(map[string]interface{})["mac"].(string), n.Entity.(map[string]any)["mac"].(string),
n.Entity.(map[string]interface{})["vendor"].(string)) n.Entity.(map[string]any)["vendor"].(string))
case AccessPoint: case AccessPoint:
return fmt.Sprintf("%s\\n%s\\n(%s)", return fmt.Sprintf("%s\\n%s\\n(%s)",
n.Entity.(map[string]interface{})["hostname"].(string), n.Entity.(map[string]any)["hostname"].(string),
n.Entity.(map[string]interface{})["mac"].(string), n.Entity.(map[string]any)["mac"].(string),
n.Entity.(map[string]interface{})["vendor"].(string)) n.Entity.(map[string]any)["vendor"].(string))
case Endpoint: case Endpoint:
return fmt.Sprintf("%s\\n(%s %s)", return fmt.Sprintf("%s\\n(%s %s)",
n.Entity.(map[string]interface{})["ipv4"].(string), n.Entity.(map[string]any)["ipv4"].(string),
n.Entity.(map[string]interface{})["mac"].(string), n.Entity.(map[string]any)["mac"].(string),
n.Entity.(map[string]interface{})["vendor"].(string)) n.Entity.(map[string]any)["vendor"].(string))
case Gateway: case Gateway:
return fmt.Sprintf("%s\\n(%s %s)", return fmt.Sprintf("%s\\n(%s %s)",
n.Entity.(map[string]interface{})["ipv4"].(string), n.Entity.(map[string]any)["ipv4"].(string),
n.Entity.(map[string]interface{})["mac"].(string), n.Entity.(map[string]any)["mac"].(string),
n.Entity.(map[string]interface{})["vendor"].(string)) n.Entity.(map[string]any)["vendor"].(string))
} }
return "?" return "?"
} }
@ -157,8 +157,8 @@ func (n Node) Dot(isTarget bool) string {
strings.ReplaceAll(n.Label(), "\"", "\\\"")) strings.ReplaceAll(n.Label(), "\"", "\\\""))
} }
func (n Node) ToMap() (map[string]interface{}, error) { func (n Node) ToMap() (map[string]any, error) {
var m map[string]interface{} var m map[string]any
if raw, err := json.Marshal(n); err != nil { if raw, err := json.Marshal(n); err != nil {
return nil, err return nil, err

View file

@ -3,7 +3,7 @@ package graph
import "sync" import "sync"
type entry struct { type entry struct {
data interface{} data any
next *entry next *entry
} }
@ -13,7 +13,7 @@ type Stack struct {
Size int Size int
} }
func (stk *Stack) Push(data interface{}) { func (stk *Stack) Push(data any) {
stk.lock.Lock() stk.lock.Lock()
element := new(entry) element := new(entry)
@ -26,7 +26,7 @@ func (stk *Stack) Push(data interface{}) {
stk.lock.Unlock() stk.lock.Unlock()
} }
func (stk *Stack) Pop() interface{} { func (stk *Stack) Pop() any {
if stk.head == nil { if stk.head == nil {
return nil return nil
} }

View file

@ -70,7 +70,7 @@ type dummyLogger struct {
p *HTTPProxy p *HTTPProxy
} }
func (l dummyLogger) Printf(format string, v ...interface{}) { func (l dummyLogger) Printf(format string, v ...any) {
l.p.Debug("[goproxy.log] %s", str.Trim(fmt.Sprintf(format, v...))) l.p.Debug("[goproxy.log] %s", str.Trim(fmt.Sprintf(format, v...)))
} }
@ -108,23 +108,23 @@ func NewHTTPProxy(s *session.Session, tag string) *HTTPProxy {
return p return p
} }
func (p *HTTPProxy) Debug(format string, args ...interface{}) { func (p *HTTPProxy) Debug(format string, args ...any) {
p.Sess.Events.Log(log.DEBUG, p.tag+format, args...) p.Sess.Events.Log(log.DEBUG, p.tag+format, args...)
} }
func (p *HTTPProxy) Info(format string, args ...interface{}) { func (p *HTTPProxy) Info(format string, args ...any) {
p.Sess.Events.Log(log.INFO, p.tag+format, args...) p.Sess.Events.Log(log.INFO, p.tag+format, args...)
} }
func (p *HTTPProxy) Warning(format string, args ...interface{}) { func (p *HTTPProxy) Warning(format string, args ...any) {
p.Sess.Events.Log(log.WARNING, p.tag+format, args...) p.Sess.Events.Log(log.WARNING, p.tag+format, args...)
} }
func (p *HTTPProxy) Error(format string, args ...interface{}) { func (p *HTTPProxy) Error(format string, args ...any) {
p.Sess.Events.Log(log.ERROR, p.tag+format, args...) p.Sess.Events.Log(log.ERROR, p.tag+format, args...)
} }
func (p *HTTPProxy) Fatal(format string, args ...interface{}) { func (p *HTTPProxy) Fatal(format string, args ...any) {
p.Sess.Events.Log(log.FATAL, p.tag+format, args...) p.Sess.Events.Log(log.FATAL, p.tag+format, args...)
} }
@ -180,10 +180,10 @@ func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, doRed
for _, mname := range []string{"http.proxy", "https.proxy"} { for _, mname := range []string{"http.proxy", "https.proxy"} {
err, m := p.Sess.Module(mname) err, m := p.Sess.Module(mname)
if err == nil && m.Running() { if err == nil && m.Running() {
var mextra interface{} var mextra any
var mstripper *SSLStripper var mstripper *SSLStripper
mextra = m.Extra() mextra = m.Extra()
mextramap := mextra.(map[string]interface{}) mextramap := mextra.(map[string]any)
mstripper = mextramap["stripper"].(*SSLStripper) mstripper = mextramap["stripper"].(*SSLStripper)
if mstripper != nil && mstripper.Enabled() { if mstripper != nil && mstripper.Enabled() {
p.Info("found another proxy using sslstrip -> merging strippers...") p.Info("found another proxy using sslstrip -> merging strippers...")

View file

@ -63,7 +63,7 @@ func (mod *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
var traffic *packets.Traffic var traffic *packets.Traffic
var found bool var found bool
var v interface{} var v any
if v, found = mod.Session.Queue.Traffic.Load(e.IpAddress); !found { if v, found = mod.Session.Queue.Traffic.Load(e.IpAddress); !found {
traffic = &packets.Traffic{} traffic = &packets.Traffic{}
} else { } else {
@ -99,7 +99,7 @@ func (mod *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
} }
metas := []string{} metas := []string{}
e.Meta.Each(func(name string, value interface{}) { e.Meta.Each(func(name string, value any) {
s := "" s := ""
if sv, ok := value.(string); ok { if sv, ok := value.(string); ok {
s = sv s = sv
@ -286,7 +286,7 @@ func (mod *Discovery) showMeta(arg string) (err error) {
for _, t := range targets { for _, t := range targets {
keys := []string{} keys := []string{}
t.Meta.Each(func(name string, value interface{}) { t.Meta.Each(func(name string, value any) {
keys = append(keys, name) keys = append(keys, name)
}) })

View file

@ -7,18 +7,18 @@ import (
"github.com/bettercap/bettercap/v2/session" "github.com/bettercap/bettercap/v2/session"
) )
type SniffData map[string]interface{} type SniffData map[string]any
type SnifferEvent struct { type SnifferEvent struct {
PacketTime time.Time `json:"time"` PacketTime time.Time `json:"time"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
Source string `json:"from"` Source string `json:"from"`
Destination string `json:"to"` Destination string `json:"to"`
Message string `json:"message"` Message string `json:"message"`
Data interface{} `json:"data"` Data any `json:"data"`
} }
func NewSnifferEvent(t time.Time, proto string, src string, dst string, data interface{}, format string, args ...interface{}) SnifferEvent { func NewSnifferEvent(t time.Time, proto string, src string, dst string, data any, format string, args ...any) SnifferEvent {
return SnifferEvent{ return SnifferEvent{
PacketTime: t, PacketTime: t,
Protocol: proto, Protocol: proto,

View file

@ -28,7 +28,7 @@ func vIP(ip net.IP) string {
return address return address
} }
func vPort(p interface{}) string { func vPort(p any) string {
sp := fmt.Sprintf("%d", p) sp := fmt.Sprintf("%d", p)
if tcp, ok := p.(layers.TCPPort); ok { if tcp, ok := p.(layers.TCPPort); ok {
if name, found := layers.TCPPortNames[tcp]; found { if name, found := layers.TCPPortNames[tcp]; found {

View file

@ -27,7 +27,7 @@ func wifiBruteforce(mod *WiFiModule, job bruteforceJob) (bool, error) {
err error err error
} }
if res, err := async.WithTimeout(job.timeout, func() interface{} { if res, err := async.WithTimeout(job.timeout, func() any {
start := time.Now() start := time.Now()
if output, err := core.Exec(networksetup, args); err != nil { if output, err := core.Exec(networksetup, args); err != nil {
return result{auth: false, err: err} return result{auth: false, err: err}

View file

@ -317,7 +317,7 @@ func (c *client) shutdown() {
// Data receiving routine reads from connection, unpacks packets into dns.Msg // Data receiving routine reads from connection, unpacks packets into dns.Msg
// structures and sends them to a given msgCh channel // structures and sends them to a given msgCh channel
func (c *client) recv(ctx context.Context, l interface{}, msgCh chan *dns.Msg) { func (c *client) recv(ctx context.Context, l any, msgCh chan *dns.Msg) {
var readFrom func([]byte) (n int, src net.Addr, err error) var readFrom func([]byte) (n int, src net.Addr, err error)
switch pConn := l.(type) { switch pConn := l.(type) {

View file

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
package network package network
@ -10,11 +11,11 @@ import (
) )
type BLECharacteristic struct { type BLECharacteristic struct {
UUID string `json:"uuid"` UUID string `json:"uuid"`
Name string `json:"name"` Name string `json:"name"`
Handle uint16 `json:"handle"` Handle uint16 `json:"handle"`
Properties []string `json:"properties"` Properties []string `json:"properties"`
Data interface{} `json:"data"` Data any `json:"data"`
} }
type BLEService struct { type BLEService struct {

View file

@ -1,7 +1,7 @@
package network package network
type DebugFunc func(format string, args ...interface{}) type DebugFunc func(format string, args ...any)
var Debug = func(format string, args ...interface{}) { var Debug = func(format string, args ...any) {
} }

View file

@ -12,19 +12,19 @@ import (
type Meta struct { type Meta struct {
sync.Mutex sync.Mutex
m map[string]interface{} m map[string]any
} }
// we want to protect concurrent access to the Meta // we want to protect concurrent access to the Meta
// object so the m field needs to be unexported, this // object so the m field needs to be unexported, this
// is to have it in JSON regardless. // is to have it in JSON regardless.
type metaJSON struct { type metaJSON struct {
Values map[string]interface{} `json:"values"` Values map[string]any `json:"values"`
} }
func NewMeta() *Meta { func NewMeta() *Meta {
return &Meta{ return &Meta{
m: make(map[string]interface{}), m: make(map[string]any),
} }
} }
@ -34,13 +34,13 @@ func (m *Meta) MarshalJSON() ([]byte, error) {
return json.Marshal(metaJSON{Values: m.m}) return json.Marshal(metaJSON{Values: m.m})
} }
func (m *Meta) Set(name string, value interface{}) { func (m *Meta) Set(name string, value any) {
m.Lock() m.Lock()
defer m.Unlock() defer m.Unlock()
m.m[name] = value m.m[name] = value
} }
func (m *Meta) Get(name string) interface{} { func (m *Meta) Get(name string) any {
m.Lock() m.Lock()
defer m.Unlock() defer m.Unlock()
@ -73,7 +73,7 @@ func (m *Meta) SetInts(name string, ints []int) {
m.Set(name, strings.Join(list, ",")) m.Set(name, strings.Join(list, ","))
} }
func (m *Meta) GetOr(name string, dflt interface{}) interface{} { func (m *Meta) GetOr(name string, dflt any) any {
m.Lock() m.Lock()
defer m.Unlock() defer m.Unlock()
@ -83,7 +83,7 @@ func (m *Meta) GetOr(name string, dflt interface{}) interface{} {
return dflt return dflt
} }
func (m *Meta) Each(cb func(name string, value interface{})) { func (m *Meta) Each(cb func(name string, value any)) {
m.Lock() m.Lock()
defer m.Unlock() defer m.Unlock()

View file

@ -74,7 +74,7 @@ func TestMetaEach(t *testing.T) {
example.m["evilsocket"] = true example.m["evilsocket"] = true
count := 0 count := 0
exampleCB := func(name string, value interface{}) { exampleCB := func(name string, value any) {
count++ count++
} }
example.Each(exampleCB) example.Each(exampleCB)

View file

@ -10,8 +10,8 @@ import (
func TestDot11Vars(t *testing.T) { func TestDot11Vars(t *testing.T) {
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{openFlags, 1057}, {openFlags, 1057},
{wpaFlags, 1041}, {wpaFlags, 1041},
@ -65,8 +65,8 @@ func TestDot11ApConfig(t *testing.T) {
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{config.SSID, ssid}, {config.SSID, ssid},
{config.BSSID, bssid}, {config.BSSID, bssid},
@ -88,8 +88,8 @@ func TestDot11Info(t *testing.T) {
dot11InfoElement := Dot11Info(id, info) dot11InfoElement := Dot11Info(id, info)
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{dot11InfoElement.ID, id}, {dot11InfoElement.ID, id},
{dot11InfoElement.Length, uint8(len(info))}, {dot11InfoElement.Length, uint8(len(info))},
@ -159,8 +159,8 @@ func TestDot11Parse(t *testing.T) {
ok, radiotap, dot11 := Dot11Parse(packet) ok, radiotap, dot11 := Dot11Parse(packet)
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
// testing for the known bad cases // testing for the known bad cases
{ok, false}, {ok, false},
@ -190,8 +190,8 @@ func TestDot11ParseIDSSID(t *testing.T) {
ok, id := Dot11ParseIDSSID(packet) ok, id := Dot11ParseIDSSID(packet)
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{ok, true}, {ok, true},
{id, "I still love Ruby, don't worry!"}, {id, "I still love Ruby, don't worry!"},
@ -231,8 +231,8 @@ func TestDot11ParseEncryption(t *testing.T) {
found, enc, cipher, auth := Dot11ParseEncryption(packet, dot11) found, enc, cipher, auth := Dot11ParseEncryption(packet, dot11)
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{found, true}, {found, true},
{enc, "WPA2"}, {enc, "WPA2"},

View file

@ -13,8 +13,8 @@ func TestDot11CipherSuite(t *testing.T) {
OUI: bytes, OUI: bytes,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{cs.OUI, bytes}, {cs.OUI, bytes},
} }
@ -33,8 +33,8 @@ func TestDot11AuthSuite(t *testing.T) {
OUI: bytes, OUI: bytes,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{cs.OUI, bytes}, {cs.OUI, bytes},
} }
@ -51,8 +51,8 @@ func TestDot11CipherSuiteSelector(t *testing.T) {
Count: count, Count: count,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{cs.Count, count}, {cs.Count, count},
} }
@ -69,8 +69,8 @@ func TestDot11AuthSuiteSelector(t *testing.T) {
Count: count, Count: count,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{cs.Count, count}, {cs.Count, count},
} }
@ -87,8 +87,8 @@ func TestDot11RSNInfo(t *testing.T) {
Version: version, Version: version,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{rsn.Version, version}, {rsn.Version, version},
{rsn.Group, CipherSuite{}}, {rsn.Group, CipherSuite{}},
@ -108,8 +108,8 @@ func TestDot11VendorInfo(t *testing.T) {
WPAVersion: version, WPAVersion: version,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{vendor.WPAVersion, version}, {vendor.WPAVersion, version},
{vendor.Multicast, CipherSuite{}}, {vendor.Multicast, CipherSuite{}},
@ -134,8 +134,8 @@ func TestDot11parsePairwiseSuite(t *testing.T) {
buf := []byte{0, 0, 1, 1} buf := []byte{0, 0, 1, 1}
suite, err := parsePairwiseSuite(buf) suite, err := parsePairwiseSuite(buf)
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{suite.OUI, buf[0:3]}, {suite.OUI, buf[0:3]},
{suite.Type, Dot11CipherType(buf[3])}, {suite.Type, Dot11CipherType(buf[3])},
@ -152,8 +152,8 @@ func TestDot11parseAuthkeySuite(t *testing.T) {
buf := []byte{0, 0, 1, 1} buf := []byte{0, 0, 1, 1}
suite, err := parseAuthkeySuite(buf) suite, err := parseAuthkeySuite(buf)
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{suite.OUI, buf[0:3]}, {suite.OUI, buf[0:3]},
{suite.Type, Dot11AuthType(buf[3])}, {suite.Type, Dot11AuthType(buf[3])},

View file

@ -10,8 +10,8 @@ import (
func TestKrb5Contants(t *testing.T) { func TestKrb5Contants(t *testing.T) {
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{Krb5AsRequestType, 10}, {Krb5AsRequestType, 10},
{Krb5Krb5PrincipalNameType, 1}, {Krb5Krb5PrincipalNameType, 1},
@ -28,8 +28,8 @@ func TestKrb5Contants(t *testing.T) {
func TestKrb5Vars(t *testing.T) { func TestKrb5Vars(t *testing.T) {
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{ErrNoCrypt, errors.New("No crypt alg found")}, {ErrNoCrypt, errors.New("No crypt alg found")},
{ErrReqData, errors.New("Failed to extract pnData from as-req")}, {ErrReqData, errors.New("Failed to extract pnData from as-req")},
@ -47,8 +47,8 @@ func TestKrb5PrincipalName(t *testing.T) {
str := []string{"example"} str := []string{"example"}
name := Krb5PrincipalName{NameString: str} name := Krb5PrincipalName{NameString: str}
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{name.NameType, 0}, {name.NameType, 0},
{name.NameString, str}, {name.NameString, str},
@ -64,8 +64,8 @@ func TestKrb5EncryptedData(t *testing.T) {
cipher := []byte{} cipher := []byte{}
data := Krb5EncryptedData{Cipher: cipher} data := Krb5EncryptedData{Cipher: cipher}
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{data.Cipher, cipher}, {data.Cipher, cipher},
{data.Etype, 0}, {data.Etype, 0},
@ -91,8 +91,8 @@ func TestKrb5Ticket(t *testing.T) {
EncPart: e, EncPart: e,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{ticket.TktVno, v}, {ticket.TktVno, v},
{ticket.Realm, r}, {ticket.Realm, r},
@ -114,8 +114,8 @@ func TestKrb5Address(t *testing.T) {
Krb5Address: y, Krb5Address: y,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{addr.AddrType, x}, {addr.AddrType, x},
{addr.Krb5Address, y}, {addr.Krb5Address, y},
@ -135,8 +135,8 @@ func TestKrb5PnData(t *testing.T) {
Krb5PnDataValue: y, Krb5PnDataValue: y,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{addr.Krb5PnDataType, x}, {addr.Krb5PnDataType, x},
{addr.Krb5PnDataValue, y}, {addr.Krb5PnDataValue, y},
@ -158,8 +158,8 @@ func TestKrb5ReqBody(t *testing.T) {
AdditionalKrb5Tickets: k, AdditionalKrb5Tickets: k,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{req.KDCOptions, asn1.BitString{}}, {req.KDCOptions, asn1.BitString{}},
{req.Cname, Krb5PrincipalName{}}, {req.Cname, Krb5PrincipalName{}},
@ -188,8 +188,8 @@ func TestKrb5Request(t *testing.T) {
Krb5PnData: p, Krb5PnData: p,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{req.Pvno, 0}, {req.Pvno, 0},
{req.MsgType, 0}, {req.MsgType, 0},

View file

@ -7,8 +7,8 @@ import (
func TestNTLMConstants(t *testing.T) { func TestNTLMConstants(t *testing.T) {
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{NTLM_SIG_OFFSET, 0}, {NTLM_SIG_OFFSET, 0},
{NTLM_TYPE_OFFSET, 8}, {NTLM_TYPE_OFFSET, 8},
@ -50,8 +50,8 @@ func TestNTLMConstants(t *testing.T) {
func TestNTLMChallengeResponse(t *testing.T) { func TestNTLMChallengeResponse(t *testing.T) {
r := NTLMChallengeResponse{} r := NTLMChallengeResponse{}
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{r.Challenge, ""}, {r.Challenge, ""},
{r.Response, ""}, {r.Response, ""},
@ -66,8 +66,8 @@ func TestNTLMChallengeResponse(t *testing.T) {
func TestNTLMChallengeResponseParsed(t *testing.T) { func TestNTLMChallengeResponseParsed(t *testing.T) {
r := NTLMChallengeResponseParsed{} r := NTLMChallengeResponseParsed{}
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{r.Type, 0}, {r.Type, 0},
{r.ServerChallenge, ""}, {r.ServerChallenge, ""},
@ -87,8 +87,8 @@ func TestNTLMChallengeResponseParsed(t *testing.T) {
func TestNTLMResponseHeader(t *testing.T) { func TestNTLMResponseHeader(t *testing.T) {
r := NTLMResponseHeader{} r := NTLMResponseHeader{}
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{r.Sig, ""}, {r.Sig, ""},
{r.Type, uint32(0)}, {r.Type, uint32(0)},
@ -123,8 +123,8 @@ func TestNTLMState(t *testing.T) {
Pairs: p, Pairs: p,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{s.Responses, r}, {s.Responses, r},
{s.Pairs, p}, {s.Pairs, p},
@ -149,8 +149,8 @@ func TestNTLMStateAddServerResponse(t *testing.T) {
s.AddServerResponse(uint32(0), "picat") s.AddServerResponse(uint32(0), "picat")
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{s.Responses[uint32(0)], "picat"}, {s.Responses[uint32(0)], "picat"},
} }

View file

@ -90,12 +90,12 @@ func (q *Queue) MarshalJSON() ([]byte, error) {
Traffic: make(map[string]*Traffic), Traffic: make(map[string]*Traffic),
} }
q.Protos.Range(func(k, v interface{}) bool { q.Protos.Range(func(k, v any) bool {
doc.Protos[k.(string)] = v.(int) doc.Protos[k.(string)] = v.(int)
return true return true
}) })
q.Traffic.Range(func(k, v interface{}) bool { q.Traffic.Range(func(k, v any) bool {
doc.Traffic[k.(string)] = v.(*Traffic) doc.Traffic[k.(string)] = v.(*Traffic)
return true return true
}) })

View file

@ -14,8 +14,8 @@ func TestQueueActivity(t *testing.T) {
MAC: h, MAC: h,
} }
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{a.IP, i}, {a.IP, i},
{a.MAC, h}, {a.MAC, h},
@ -31,8 +31,8 @@ func TestQueueActivity(t *testing.T) {
func TestQueueTraffic(t *testing.T) { func TestQueueTraffic(t *testing.T) {
tr := Traffic{} tr := Traffic{}
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{tr.Sent, uint64(0)}, {tr.Sent, uint64(0)},
{tr.Received, uint64(0)}, {tr.Received, uint64(0)},
@ -47,8 +47,8 @@ func TestQueueTraffic(t *testing.T) {
func TestQueueStats(t *testing.T) { func TestQueueStats(t *testing.T) {
s := Stats{} s := Stats{}
var units = []struct { var units = []struct {
got interface{} got any
exp interface{} exp any
}{ }{
{s.Sent, uint64(0)}, {s.Sent, uint64(0)},
{s.Received, uint64(0)}, {s.Received, uint64(0)},

View file

@ -12,9 +12,9 @@ import (
) )
type Event struct { type Event struct {
Tag string `json:"tag"` Tag string `json:"tag"`
Time time.Time `json:"time"` Time time.Time `json:"time"`
Data interface{} `json:"data"` Data any `json:"data"`
} }
type LogMessage struct { type LogMessage struct {
@ -22,7 +22,7 @@ type LogMessage struct {
Message string Message string
} }
func NewEvent(tag string, data interface{}) Event { func NewEvent(tag string, data any) Event {
return Event{ return Event{
Tag: tag, Tag: tag,
Time: time.Now(), Time: time.Now(),
@ -39,7 +39,7 @@ func (e Event) Label() string {
type EventBus <-chan Event type EventBus <-chan Event
type PrintCallback func(format string, args ...interface{}) type PrintCallback func(format string, args ...any)
type PrintWriter struct { type PrintWriter struct {
pool *EventPool pool *EventPool
@ -130,7 +130,7 @@ func (p *EventPool) SetDebug(d bool) {
p.debug = d p.debug = d
} }
func (p *EventPool) Add(tag string, data interface{}) { func (p *EventPool) Add(tag string, data any) {
p.Lock() p.Lock()
defer p.Unlock() defer p.Unlock()
@ -152,7 +152,7 @@ func (p *EventPool) Add(tag string, data interface{}) {
} }
} }
func (p *EventPool) Printf(format string, a ...interface{}) { func (p *EventPool) Printf(format string, a ...any) {
p.printLock.Lock() p.printLock.Lock()
defer p.printLock.Unlock() defer p.printLock.Unlock()
@ -162,7 +162,7 @@ func (p *EventPool) Printf(format string, a ...interface{}) {
fmt.Printf(format, a...) fmt.Printf(format, a...)
} }
func (p *EventPool) Log(level log.Verbosity, format string, args ...interface{}) { func (p *EventPool) Log(level log.Verbosity, format string, args ...any) {
if level == log.DEBUG && !p.debug { if level == log.DEBUG && !p.debug {
return return
} else if level < log.ERROR && p.silent { } else if level < log.ERROR && p.silent {

View file

@ -10,7 +10,7 @@ func TestNewEvent(t *testing.T) {
type args struct { type args struct {
tag string tag string
data interface{} data any
} }
tests := []struct { tests := []struct {
name string name string
@ -259,7 +259,7 @@ func TestEventPool_Add(t *testing.T) {
} }
type args struct { type args struct {
tag string tag string
data interface{} data any
} }
tests := []struct { tests := []struct {
name string name string

View file

@ -21,7 +21,7 @@ type Module interface {
Handlers() []ModuleHandler Handlers() []ModuleHandler
Parameters() map[string]*ModuleParam Parameters() map[string]*ModuleParam
Extra() map[string]interface{} Extra() map[string]any
Required() []string Required() []string
Running() bool Running() bool
Start() error Start() error
@ -65,9 +65,9 @@ func NewSessionModule(name string, s *Session) SessionModule {
return m return m
} }
func (m *SessionModule) Extra() map[string]interface{} { func (m *SessionModule) Extra() map[string]any {
extra := make(map[string]interface{}) extra := make(map[string]any)
m.State.Range(func(k, v interface{}) bool { m.State.Range(func(k, v any) bool {
extra[k.(string)] = v extra[k.(string)] = v
return true return true
}) })
@ -81,33 +81,33 @@ func (m *SessionModule) InitState(keys ...string) {
} }
func (m *SessionModule) ResetState() { func (m *SessionModule) ResetState() {
m.State.Range(func(k, v interface{}) bool { m.State.Range(func(k, v any) bool {
m.State.Store(k, nil) m.State.Store(k, nil)
return true return true
}) })
} }
func (m *SessionModule) Debug(format string, args ...interface{}) { func (m *SessionModule) Debug(format string, args ...any) {
m.Session.Events.Log(log.DEBUG, m.tag+format, args...) m.Session.Events.Log(log.DEBUG, m.tag+format, args...)
} }
func (m *SessionModule) Info(format string, args ...interface{}) { func (m *SessionModule) Info(format string, args ...any) {
m.Session.Events.Log(log.INFO, m.tag+format, args...) m.Session.Events.Log(log.INFO, m.tag+format, args...)
} }
func (m *SessionModule) Warning(format string, args ...interface{}) { func (m *SessionModule) Warning(format string, args ...any) {
m.Session.Events.Log(log.WARNING, m.tag+format, args...) m.Session.Events.Log(log.WARNING, m.tag+format, args...)
} }
func (m *SessionModule) Error(format string, args ...interface{}) { func (m *SessionModule) Error(format string, args ...any) {
m.Session.Events.Log(log.ERROR, m.tag+format, args...) m.Session.Events.Log(log.ERROR, m.tag+format, args...)
} }
func (m *SessionModule) Fatal(format string, args ...interface{}) { func (m *SessionModule) Fatal(format string, args ...any) {
m.Session.Events.Log(log.FATAL, m.tag+format, args...) m.Session.Events.Log(log.FATAL, m.tag+format, args...)
} }
func (m *SessionModule) Printf(format string, a ...interface{}) { func (m *SessionModule) Printf(format string, a ...any) {
m.Session.Events.Printf(format, a...) m.Session.Events.Printf(format, a...)
} }
@ -293,7 +293,7 @@ type moduleJSON struct {
Parameters map[string]*ModuleParam `json:"parameters"` Parameters map[string]*ModuleParam `json:"parameters"`
Handlers []ModuleHandler `json:"handlers"` Handlers []ModuleHandler `json:"handlers"`
Running bool `json:"running"` Running bool `json:"running"`
State map[string]interface{} `json:"state"` State map[string]any `json:"state"`
} }
func (mm ModuleList) MarshalJSON() ([]byte, error) { func (mm ModuleList) MarshalJSON() ([]byte, error) {

View file

@ -62,7 +62,7 @@ func NewDecimalParameter(name string, def_value string, desc string) *ModulePara
return NewModuleParameter(name, def_value, FLOAT, `^[\-\+]?[\d]+(\.\d+)?$`, desc) return NewModuleParameter(name, def_value, FLOAT, `^[\-\+]?[\d]+(\.\d+)?$`, desc)
} }
func (p ModuleParam) validate(value string) (error, interface{}) { func (p ModuleParam) validate(value string) (error, any) {
if p.Validator != nil { if p.Validator != nil {
if !p.Validator.MatchString(value) { if !p.Validator.MatchString(value) {
return fmt.Errorf("Parameter %s not valid: '%s' does not match rule '%s'.", tui.Bold(p.Name), value, p.Validator.String()), nil return fmt.Errorf("Parameter %s not valid: '%s' does not match rule '%s'.", tui.Bold(p.Name), value, p.Validator.String()), nil
@ -119,8 +119,8 @@ func (p ModuleParam) parse(s *Session, v string) string {
v = net.HardwareAddr(hw).String() v = net.HardwareAddr(hw).String()
default: default:
// check the <iface> case // check the <iface> case
if m := ParamIfaceNameParser.FindStringSubmatch(v); len(m) == 2 { if m := ParamIfaceNameParser.FindStringSubmatch(v); len(m) == 2 {
// does it match any interface? // does it match any interface?
name := m[1] name := m[1]
if iface, err := net.InterfaceByName(name); err == nil { if iface, err := net.InterfaceByName(name); err == nil {
if addrs, err := iface.Addrs(); err == nil { if addrs, err := iface.Addrs(); err == nil {
@ -159,7 +159,7 @@ func (p ModuleParam) getUnlocked(s *Session) string {
return p.parse(s, v) return p.parse(s, v)
} }
func (p ModuleParam) Get(s *Session) (error, interface{}) { func (p ModuleParam) Get(s *Session) (error, any) {
_, v := s.Env.Get(p.Name) _, v := s.Env.Get(p.Name)
v = p.parse(s, v) v = p.parse(s, v)
return p.validate(v) return p.validate(v)

View file

@ -83,7 +83,7 @@ func jsOnEventFunc(call otto.FunctionCall) otto.Value {
if expr == "" || event.Tag == expr { if expr == "" || event.Tag == expr {
// some objects don't do well with js, so convert them to a generic map // some objects don't do well with js, so convert them to a generic map
// before passing them to the callback // before passing them to the callback
var opaque interface{} var opaque any
if raw, err := json.Marshal(event); err != nil { if raw, err := json.Marshal(event); err != nil {
I.Events.Log(log.ERROR, "error serializing event %s: %v", event.Tag, err) I.Events.Log(log.ERROR, "error serializing event %s: %v", event.Tag, err)
} else if err = json.Unmarshal(raw, &opaque); err != nil { } else if err = json.Unmarshal(raw, &opaque); err != nil {
@ -208,7 +208,7 @@ func jsLoadJSONFunc(call otto.FunctionCall) otto.Value {
return js.ReportError("loadJSON accepts one string argument") return js.ReportError("loadJSON accepts one string argument")
} }
var obj interface{} var obj any
if fileName, err := fs.Expand(argv[0].String()); err != nil { if fileName, err := fs.Expand(argv[0].String()); err != nil {
return js.ReportError("can't expand '%s': %v", fileName, err) return js.ReportError("can't expand '%s': %v", fileName, err)

View file

@ -231,7 +231,7 @@ func (s *Session) Register(mod Module) error {
func (s *Session) Start() error { func (s *Session) Start() error {
var err error var err error
network.Debug = func(format string, args ...interface{}) { network.Debug = func(format string, args ...any) {
s.Events.Log(log.DEBUG, format, args...) s.Events.Log(log.DEBUG, format, args...)
} }