diff -Nru golang-github-evilsocket-islazy-1.10.6/async/queue.go golang-github-evilsocket-islazy-1.11.0/async/queue.go --- golang-github-evilsocket-islazy-1.10.6/async/queue.go 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/async/queue.go 2022-12-22 13:46:11.000000000 +0000 @@ -28,12 +28,20 @@ // scaled to the number of logical CPUs usable by the current // process. func NewQueue(workers int, logic Logic) *WorkQueue { + return createQueue(workers, logic, 0) +} + +func NewBufferedQueue(workers int, logic Logic, size int) *WorkQueue { + return createQueue(workers, logic, size) +} + +func createQueue(workers int, logic Logic, bufferSize int) *WorkQueue { if workers <= 0 { workers = runtime.NumCPU() } wq := &WorkQueue{ workers: workers, - jobChan: make(chan Job), + jobChan: make(chan Job, bufferSize), stopChan: make(chan struct{}), jobs: sync.WaitGroup{}, done: sync.WaitGroup{}, diff -Nru golang-github-evilsocket-islazy-1.10.6/compile.go golang-github-evilsocket-islazy-1.11.0/compile.go --- golang-github-evilsocket-islazy-1.10.6/compile.go 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/compile.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -package plugin - -import ( - // "unicode" - "github.com/robertkrimen/otto" -) - -func (p *Plugin) compile() (err error) { - // create a new vm - p.vm = otto.New() - // track objects already defined by Otto - predefined := map[string]bool{} - for name := range p.vm.Context().Symbols { - predefined[name] = true - } - - // define symbols - for name, val := range Defines { - if err := p.vm.Set(name, val); err != nil { - return err - } - } - - // run the code once in order to define all the functions - // and validate the syntax, then get the callbacks - if _, err = p.vm.Run(p.Code); err != nil { - return - } - // every uppercase object is considered exported - for name, sym := range p.vm.Context().Symbols { - // ignore predefined objects - if _, found := predefined[name]; !found { - // ignore lowercase global objects - // if unicode.IsUpper(rune(name[0])) { - if sym.IsFunction() { - p.callbacks[name] = sym - } else { - p.objects[name] = sym - } - // } - } - } - return nil -} diff -Nru golang-github-evilsocket-islazy-1.10.6/data/unsortedkv.go golang-github-evilsocket-islazy-1.11.0/data/unsortedkv.go --- golang-github-evilsocket-islazy-1.10.6/data/unsortedkv.go 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/data/unsortedkv.go 2022-12-22 13:46:11.000000000 +0000 @@ -14,7 +14,7 @@ // UnsortedKV is a thread safe and unsorted key-value // storage with optional persistency on disk. type UnsortedKV struct { - sync.Mutex + sync.RWMutex fileName string m map[string]string policy FlushPolicy @@ -65,15 +65,15 @@ // MarshalJSON is used to serialize the UnsortedKV data structure to // JSON correctly. func (u *UnsortedKV) MarshalJSON() ([]byte, error) { - u.Lock() - defer u.Unlock() + u.RLock() + defer u.RUnlock() return json.Marshal(u.m) } // Has return true if name exists in the store. func (u *UnsortedKV) Has(name string) bool { - u.Lock() - defer u.Unlock() + u.RLock() + defer u.RUnlock() _, found := u.m[name] return found } @@ -81,8 +81,8 @@ // Get return the value of the named object if present, or returns // found as false otherwise. func (u *UnsortedKV) Get(name string) (v string, found bool) { - u.Lock() - defer u.Unlock() + u.RLock() + defer u.RUnlock() v, found = u.m[name] return } @@ -108,8 +108,8 @@ // Flush flushes the store to disk if the flush policy // is different than FlushNone func (u *UnsortedKV) Flush() error { - u.Lock() - defer u.Unlock() + u.RLock() + defer u.RUnlock() if u.policy != FlushNone { return u.flushUnlocked() } @@ -162,7 +162,7 @@ // Empty returns bool if the store is empty. func (u *UnsortedKV) Empty() bool { - u.Lock() - defer u.Unlock() + u.RLock() + defer u.RUnlock() return len(u.m) == 0 } diff -Nru golang-github-evilsocket-islazy-1.10.6/debian/changelog golang-github-evilsocket-islazy-1.11.0/debian/changelog --- golang-github-evilsocket-islazy-1.10.6/debian/changelog 2023-06-21 18:06:31.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/debian/changelog 2023-07-25 22:36:16.000000000 +0000 @@ -1,3 +1,9 @@ +golang-github-evilsocket-islazy (1.11.0-1) unstable; urgency=medium + + * New upstream version 1.11.0. + + -- Francisco Vilmar Cardoso Ruviaro Tue, 25 Jul 2023 22:36:16 +0000 + golang-github-evilsocket-islazy (1.10.6-5) unstable; urgency=medium * Bump Standards-Version to 4.6.2. diff -Nru golang-github-evilsocket-islazy-1.10.6/examples/log.go golang-github-evilsocket-islazy-1.11.0/examples/log.go --- golang-github-evilsocket-islazy-1.10.6/examples/log.go 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/examples/log.go 2022-12-22 13:46:11.000000000 +0000 @@ -13,6 +13,9 @@ log.TimeFormat = "15:04:05" log.DateTimeFormat = "2006-01-02 15:04:05" log.Format = "{datetime} {level:color}{level:name}{reset} {message}" + log.Callback = func(verbosity log.Verbosity, message string) { + // fmt.Printf("got message '%s'\n", message) + } if err := log.Open(); err != nil { panic(err) diff -Nru golang-github-evilsocket-islazy-1.10.6/go.mod golang-github-evilsocket-islazy-1.11.0/go.mod --- golang-github-evilsocket-islazy-1.10.6/go.mod 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/go.mod 2022-12-22 13:46:11.000000000 +0000 @@ -0,0 +1,10 @@ +module github.com/evilsocket/islazy + +go 1.19 + +require github.com/robertkrimen/otto v0.2.1 + +require ( + golang.org/x/text v0.4.0 // indirect + gopkg.in/sourcemap.v1 v1.0.5 // indirect +) diff -Nru golang-github-evilsocket-islazy-1.10.6/go.sum golang-github-evilsocket-islazy-1.11.0/go.sum --- golang-github-evilsocket-islazy-1.10.6/go.sum 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/go.sum 2022-12-22 13:46:11.000000000 +0000 @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/robertkrimen/otto v0.2.1 h1:FVP0PJ0AHIjC+N4pKCG9yCDz6LHNPCwi/GKID5pGGF0= +github.com/robertkrimen/otto v0.2.1/go.mod h1:UPwtJ1Xu7JrLcZjNWN8orJaM5n5YEtqL//farB5FlRY= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI= +gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff -Nru golang-github-evilsocket-islazy-1.10.6/log/log.go golang-github-evilsocket-islazy-1.11.0/log/log.go --- golang-github-evilsocket-islazy-1.10.6/log/log.go 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/log/log.go 2022-12-22 13:46:11.000000000 +0000 @@ -10,6 +10,8 @@ "github.com/evilsocket/islazy/tui" ) +type MessageCallback = func(verbosity Verbosity, message string) + var ( // Level represents the current verbosity level of the logging system. Level = INFO @@ -19,6 +21,8 @@ NoEffects = false // OnFatal represents the callback/action to execute on Fatal messages. OnFatal = ExitOnFatal + // A custom callback to execute for every log message. + Callback = dummyCallback lock = &sync.Mutex{} currMessage = "" @@ -47,17 +51,27 @@ } } -func emit(s string) { +func dummyCallback(verbosity Verbosity, message string) { + +} + +func removeEffects(s string) string { + for _, re := range reEffects { + s = re.ReplaceAllString(s, "") + } + return s +} + +func emit(v Verbosity, s string) { // remove all effects if found + plain := removeEffects(s) + + Callback(v, plain) + if NoEffects { - for _, re := range reEffects { - s = re.ReplaceAllString(s, "") - } + s = plain } - - s = strings.Replace(s, "%", "%%", -1) - fmt.Fprintf(writer, s) - fmt.Fprintf(writer, "\n") + fmt.Fprintf(writer, "%s\n", s) } func do(v Verbosity, format string, args ...interface{}) { @@ -87,7 +101,7 @@ logLine += tui.RESET } - emit(logLine) + emit(v, logLine) } // Raw emits a message without format to the logs. @@ -96,7 +110,7 @@ defer lock.Unlock() currMessage = fmt.Sprintf(format, args...) - emit(currMessage) + emit(INFO, currMessage) } // Debug emits a debug message. diff -Nru golang-github-evilsocket-islazy-1.10.6/plugin/compile.go golang-github-evilsocket-islazy-1.11.0/plugin/compile.go --- golang-github-evilsocket-islazy-1.10.6/plugin/compile.go 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/plugin/compile.go 2022-12-22 13:46:11.000000000 +0000 @@ -14,7 +14,7 @@ predefined[name] = true } - // defines + // define symbols for name, val := range Defines { if err := p.vm.Set(name, val); err != nil { return err diff -Nru golang-github-evilsocket-islazy-1.10.6/plugin.go golang-github-evilsocket-islazy-1.11.0/plugin.go --- golang-github-evilsocket-islazy-1.10.6/plugin.go 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/plugin.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ -package plugin - -import ( - "fmt" - "io/ioutil" - "path/filepath" - "strings" - "sync" - - "github.com/robertkrimen/otto" -) - -// Defines is a map containing the predefined objects -// and functions for each vm of each plugin. -var Defines = map[string]interface{}{} - -// Plugin is an object representing a javascript -// file exporting functions and variables that -// your project can use to extend its functionalities. -type Plugin struct { - sync.Mutex - // The basename of the plugin. - Name string - // The actual javascript code. - Code string - // The full path of the plugin. - Path string - - vm *otto.Otto - callbacks map[string]otto.Value - objects map[string]otto.Value -} - -// Parse parsesand compiles a plugin given its source code. -func Parse(code string) (*Plugin, error) { - plugin := &Plugin{ - Code: code, - callbacks: make(map[string]otto.Value), - objects: make(map[string]otto.Value), - } - - if err := plugin.compile(); err != nil { - return nil, err - } - - return plugin, nil -} - -// Load loads and compiles a plugin given its path. -func Load(path string) (plug *Plugin, err error) { - if raw, err := ioutil.ReadFile(path); err != nil { - return nil, err - } else if plug, err = Parse(string(raw)); err != nil { - return nil, err - } else { - plug.Path = path - plug.Name = strings.Replace(filepath.Base(path), ".js", "", -1) - } - return plug, nil -} - -// Clone returns a new instance identical to the plugin. -func (p *Plugin) Clone() (clone *Plugin) { - var err error - if p.Path == "" { - clone, err = Parse(p.Code) - } else { - clone, err = Load(p.Path) - } - if err != nil { - panic(err) // this should never happen - } - return clone -} - -// HasFunc returns true if the function with `name` -// has been declared in the plugin code. -func (p *Plugin) HasFunc(name string) bool { - _, found := p.callbacks[name] - return found -} - -// Set sets a variable into the VM of this plugin instance. -func (p *Plugin) Set(name string, v interface{}) error { - p.Lock() - defer p.Unlock() - return p.vm.Set(name, v) -} - -// Call executes one of the declared callbacks of the plugin by its name. -func (p *Plugin) Call(name string, args ...interface{}) (interface{}, error) { - p.Lock() - defer p.Unlock() - - if cb, found := p.callbacks[name]; !found { - return nil, fmt.Errorf("%s does not name a function", name) - } else if ret, err := cb.Call(otto.NullValue(), args...); err != nil { - return nil, err - } else if !ret.IsUndefined() { - exported, err := ret.Export() - if err != nil { - return nil, err - } - return exported, nil - } - return nil, nil -} - -// Methods returns a list of methods exported from the javascript -func (p *Plugin) Methods() []string { - methods := []string{} - for key, _ := range p.callbacks { - methods = append(methods, key) - } - return methods -} - -// Objects returns a list of object exported by the javascript -func (p *Plugin) Objects() []string { - objs := []string{} - for key, _ := range p.callbacks { - objs = append(objs, key) - } - return objs -} - -// GetTypeObject returns the type of the object by its name -func (p *Plugin) GetTypeObject(name string) string { - if obj, found := p.objects[name]; !found { - return "" - } else if obj.IsPrimitive() { - if obj.IsBoolean() { - return "BooleanPrimitive" - } else if obj.IsNumber() { - return "NumberPrimitive" - } else if obj.IsString() { - return "StringPrimitive" - } - } else if obj.IsObject() { - switch obj.Class() { - case "Array": - return "ArrayObject" - case "String": - return "StringObject" - case "Boolean": - return "BooleanObject" - case "Number": - return "NumberObject" - case "Date": - return "DateObject" - case "RegExp": - return "RegExpObject" - case "Error": - return "ErrorObject" - } - } - return "" -} - -// IsStringPrimitive returns true if the object with a -// given name is a javascript primitive string -func (p *Plugin) IsStringPrimitive(name string) bool { - return p.GetTypeObject(name) == "StringPrimitive" -} - -// IsBooleanPrimitive returns true if the object with a -// given name is a javascript primitive boolean, false otherwise -func (p *Plugin) IsBooleanPrimitive(name string) bool { - return p.GetTypeObject(name) == "BooleanPrimitive" -} - -// IsNumberPrimitive returns true if the object with a -// given name is a javascript primitive number, false otherwise -func (p *Plugin) IsNumberPrimitive(name string) bool { - return p.GetTypeObject(name) == "NumberPrimitive" -} - -// IsArrayObject returns true if the object with a -// given name is a javascript array object, false otherwise -func (p *Plugin) IsArrayObject(name string) bool { - return p.GetTypeObject(name) == "ArrayObject" -} - -// IsStringObject returns true if the object with a -// given name is a javascript string object, false otherwise -func (p *Plugin) IsStringObject(name string) bool { - return p.GetTypeObject(name) == "StringObject" -} - -// IsBooleanObject returns true if the object with a -// given name is a javascript boolean object, false otherwise -func (p *Plugin) IsBooleanObject(name string) bool { - return p.GetTypeObject(name) == "BooleanObject" -} - -// IsNumberObject returns true if the object with a -// given name is a javascript Number object, false otherwise -func (p *Plugin) IsNumberObject(name string) bool { - return p.GetTypeObject(name) == "NumberObject" -} - -// IsDateObject returns true if the object with a -// given name is a javascript Date object, false otherwise -func (p *Plugin) IsDateObject(name string) bool { - return p.GetTypeObject(name) == "DateObject" -} - -// IsRegExpObject returns true if the object with a -// given name is a javascript RegExp object, false otherwise -func (p *Plugin) IsRegExpObject(name string) bool { - return p.GetTypeObject(name) == "RegExpObject" -} - -// IsErrorObject returns true if the object with a -// given name is a javascript error object, false otherwise -func (p *Plugin) IsErrorObject(name string) bool { - return p.GetTypeObject(name) == "ErrorObject" -} - -// GetObject returns an interface containing the value of the object by its name -func (p *Plugin) GetObject(name string) (interface{}, error) { - if obj, found := p.objects[name]; !found { - return nil, fmt.Errorf("%s does not name an object", name) - } else { - return obj.Export() - } -} diff -Nru golang-github-evilsocket-islazy-1.10.6/release.sh golang-github-evilsocket-islazy-1.11.0/release.sh --- golang-github-evilsocket-islazy-1.10.6/release.sh 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/release.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -#!/bin/bash -# nothing to see here, just a utility i use to create new releases ^_^ - -CURRENT_VERSION=$(cat version/ver.go | grep "Version =" | cut -d '"' -f 2) -TO_UPDATE=( - version/ver.go -) - -echo -n "Current version is $CURRENT_VERSION, select new version: " -read NEW_VERSION -echo "Creating version $NEW_VERSION ...\n" - -for file in "${TO_UPDATE[@]}" -do - echo "Patching $file ..." - sed -i.bak "s/$CURRENT_VERSION/$NEW_VERSION/g" "$file" - rm -rf "$file.bak" - git add $file -done - -git commit -m "Releasing v$NEW_VERSION" -git push - -git tag -a v$NEW_VERSION -m "Release v$NEW_VERSION" -git push origin v$NEW_VERSION - -echo -echo "All done, v$NEW_VERSION released ^_^" diff -Nru golang-github-evilsocket-islazy-1.10.6/release.stork golang-github-evilsocket-islazy-1.11.0/release.stork --- golang-github-evilsocket-islazy-1.10.6/release.stork 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/release.stork 2022-12-22 13:46:11.000000000 +0000 @@ -0,0 +1,6 @@ +#!/usr/bin/env stork -f + +version:file "version/ver.go" +version:from_user + +git:create_tag $VERSION \ No newline at end of file diff -Nru golang-github-evilsocket-islazy-1.10.6/version/ver.go golang-github-evilsocket-islazy-1.11.0/version/ver.go --- golang-github-evilsocket-islazy-1.10.6/version/ver.go 2019-11-07 13:21:28.000000000 +0000 +++ golang-github-evilsocket-islazy-1.11.0/version/ver.go 2022-12-22 13:46:11.000000000 +0000 @@ -2,5 +2,5 @@ const ( // Version is the version of the library (semantic versioning applies). - Version = "1.10.6" + Version = "1.11.0" )