Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sundowndev
GitHub Repository: sundowndev/phoneinfoga
Path: blob/master/lib/remote/scanner.go
988 views
1
package remote
2
3
import (
4
"fmt"
5
"os"
6
"plugin"
7
8
"github.com/sundowndev/phoneinfoga/v2/lib/number"
9
)
10
11
type ScannerOptions map[string]interface{}
12
13
func (o ScannerOptions) GetStringEnv(k string) string {
14
if v, ok := o[k].(string); ok {
15
return v
16
}
17
return os.Getenv(k)
18
}
19
20
type Plugin interface {
21
Lookup(string) (plugin.Symbol, error)
22
}
23
24
type Scanner interface {
25
Name() string
26
Description() string
27
DryRun(number.Number, ScannerOptions) error
28
Run(number.Number, ScannerOptions) (interface{}, error)
29
}
30
31
func OpenPlugin(path string) error {
32
if _, err := os.Stat(path); os.IsNotExist(err) {
33
return fmt.Errorf("given path %s does not exist", path)
34
}
35
36
_, err := plugin.Open(path)
37
if err != nil {
38
return fmt.Errorf("given plugin %s is not valid: %v", path, err)
39
}
40
41
return nil
42
}
43
44