Browse Source

Inherit base path, add many cmdline flags, tidy up log output

master
Tyler Sommer 4 months ago
parent
commit
477c563542
Signed by: tyler-sommer GPG Key ID: C09C010500DBD008
16 changed files with 395 additions and 62 deletions
  1. +1
    -0
      .gitignore
  2. +9
    -8
      Makefile
  3. +22
    -15
      cli/manager.go
  4. +36
    -0
      cmd/squircy/defconf/config.toml
  5. +16
    -0
      cmd/squircy/defconf/package.json
  6. +74
    -12
      cmd/squircy/main.go
  7. +3
    -2
      config.toml.dist
  8. +1
    -2
      go.mod
  9. +151
    -0
      go.sum
  10. +3
    -2
      plugins/babel/plugin.go
  11. +22
    -10
      plugins/node_compat/plugin.go
  12. +15
    -5
      plugins/script/plugin.go
  13. +3
    -4
      plugins/squircy2_compat/data/tiedot_shim.go
  14. +22
    -0
      plugins/squircy2_compat/helper.go
  15. +2
    -1
      plugins/squircy2_compat/plugin.go
  16. +15
    -1
      vm/plugin.go

+ 1
- 0
.gitignore View File

@ -8,3 +8,4 @@ testdata/yarn-error.log
testdata/yarn.lock
yarn.lock
package-lock.json
*-packr.go

+ 9
- 8
Makefile View File

@ -1,12 +1,12 @@
# Makefile for squircy, a proper IRC bot.
# https://code.dopame.me/veonik/squircy3
SUBPACKAGES := config event irc plugin script vm
SUBPACKAGES := cli config event irc plugin vm
PLUGINS := $(patsubst plugins/%,%,$(wildcard plugins/*))
SOURCES := $(wildcard cmd/*/*.go) $(wildcard $(patsubst %,%/*.go,$(SUBPACKAGES)))
GENERATOR_SOURCES := $(wildcard web/views/*.twig) $(wildcard web/views/*/*.twig) $(wildcard web/public/css/*.css)
GENERATOR_SOURCES := $(wildcard cmd/squircy/defconf/*)
OUTPUT_BASE := out
@ -18,19 +18,19 @@ TEST_ARGS ?= -count 1
TESTDATA_NODEMODS_TARGET := testdata/node_modules
.PHONY: all build generate run squircy plugins clean
.PHONY: all build generate run plugins clean test
all: build
all: build plugins
clean:
cd cmd/squircy && \
packr2 clean
rm -rf $(OUTPUT_BASE)
build: plugins squircy
build: generate $(SQUIRCY_TARGET)
generate: $(OUTPUT_BASE)/.generated
squircy: $(SQUIRCY_TARGET)
plugins: $(PLUGIN_TARGETS)
run: build
@ -51,7 +51,8 @@ $(SQUIRCY_TARGET): $(SOURCES)
go build -tags netgo $(RACE) -o $@ cmd/squircy/*.go
$(OUTPUT_BASE)/.generated: $(GENERATOR_SOURCES)
go generate
cd cmd/squircy && \
packr2
touch $@
$(OUTPUT_BASE):

+ 22
- 15
cli/manager.go View File

@ -2,7 +2,7 @@
package cli
import (
"fmt"
"flag"
"os"
"os/signal"
"path/filepath"
@ -20,10 +20,14 @@ import (
)
type Config struct {
RootDir string `toml:"root_path"`
RootDir string `toml:"root_path",flag:"root"`
PluginDir string `toml:"plugin_path"`
ExtraPlugins []string `toml:"extra_plugins"`
PluginOptions map[string]interface{}
LogLevel string `toml:"log_level"`
// Specify additional plugins that are a part of the main executable.
LinkedPlugins []plugin.Initializer
}
@ -36,7 +40,7 @@ type Manager struct {
stop chan os.Signal
}
func NewManager(rootDir string, extraPlugins ...string) (*Manager, error) {
func NewManager(rootDir string, pluginOptions map[string]interface{}, extraPlugins ...string) (*Manager, error) {
m := plugin.NewManager()
// initialize only the config plugin so that it can be configured before
// other plugins are initialized
@ -45,15 +49,18 @@ func NewManager(rootDir string, extraPlugins ...string) (*Manager, error) {
return nil, err
}
conf := Config{
RootDir: rootDir,
PluginDir: filepath.Join(rootDir, "plugins"),
ExtraPlugins: extraPlugins,
RootDir: rootDir,
PluginDir: filepath.Join(rootDir, "plugins"),
ExtraPlugins: extraPlugins,
PluginOptions: pluginOptions,
}
// configure the config plugin!
cf := filepath.Join(rootDir, "config.toml")
err := config.ConfigurePlugin(m,
config.WithInitValue(&conf),
config.WithValuesFromTOMLFile(cf))
config.WithValuesFromTOMLFile(cf),
config.WithValuesFromFlagSet(flag.CommandLine),
config.WithValuesFromMap(conf.PluginOptions))
if err != nil {
return nil, err
}
@ -128,9 +135,9 @@ func (manager *Manager) Loop() error {
for {
select {
case <-manager.stop:
logrus.Infoln("shutting down")
logrus.Infoln("Shutting down...")
if err := manager.Shutdown(); err != nil {
logrus.Warnln("error shutting down:", err)
logrus.Warnln("core: error shutting down:", err)
}
return nil
case s := <-st:
@ -138,16 +145,16 @@ func (manager *Manager) Loop() error {
case syscall.SIGHUP:
myVM, err := vm.FromPlugins(manager.plugins)
if err != nil {
logrus.Warnln("unable to reload js vm:", err)
logrus.Warnln("core: unable to reload js vm:", err)
continue
}
logrus.Infoln("reloading javascript vm")
logrus.Infoln("Reloading javascript vm")
if err := myVM.Shutdown(); err != nil {
logrus.Warnln("unable to reload js vm:", err)
logrus.Warnln("core: unable to reload js vm:", err)
continue
}
if err := myVM.Start(); err != nil {
logrus.Warnln("unable to restart js vm:", err)
logrus.Warnln("core: unable to restart js vm:", err)
continue
}
case os.Interrupt:
@ -155,7 +162,7 @@ func (manager *Manager) Loop() error {
case syscall.SIGTERM:
manager.Stop()
default:
logrus.Infoln("received signal", s, "but not doing anything with it")
logrus.Debugln("Received signal", s, "but not doing anything with it")
}
}
}
@ -171,7 +178,7 @@ func configure(m *plugin.Manager) error {
errs := m.Configure()
if errs != nil && len(errs) > 0 {
if len(errs) > 1 {
return errors.WithMessage(errs[0], fmt.Sprintf("(and %d more...)", len(errs)-1))
return errors.Wrapf(errs[0], "(and %d more...)", len(errs)-1)
}
return errs[0]
}

+ 36
- 0
cmd/squircy/defconf/config.toml View File

@ -0,0 +1,36 @@
plugin_path="out"
extra_plugins=[
"babel.so",
"node_compat.so",
"squircy2_compat.so",
"script.so",
]
[irc]
nick="squishyjones"
user="mrjones"
network="chat.freenode.net:6697"
tls=true
sasl=false
#sasl_username=""
#sasl_password=""
#server_password=""
[vm]
modules_path="node_modules"
[babel]
enable=true
[script]
scripts_path="scripts"
[squircy2_compat]
enable_file_api=false
file_api_root="files"
#owner_nick=""
#owner_host=""
data_path="data"
[node_compat]
enable_exec=false

+ 16
- 0
cmd/squircy/defconf/package.json View File

@ -0,0 +1,16 @@
{
"private": true,
"dependencies": {
"@babel/standalone": "7.5.5",
"assert": "2.0.0",
"assert-polyfill": "0.0.0",
"buffer": "5.2.1",
"core-js-bundle": "3.1.4",
"process": "0.11.10",
"regenerator-runtime": "0.13.3",
"regenerator-transform": "0.14.1"
},
"resolutions": {
"util": "0.12.1"
}
}

+ 74
- 12
cmd/squircy/main.go View File

@ -3,9 +3,13 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/gobuffalo/packr/v2"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
tilde "gopkg.in/mattes/go-expand-tilde.v1"
@ -22,6 +26,33 @@ func (s *stringsFlag) Set(str string) error {
return nil
}
type pluginOptsFlag map[string]interface{}
func (s pluginOptsFlag) String() string {
var res []string
for k, v := range s {
res = append(res, fmt.Sprintf("%s=%s", k, v))
}
return strings.Join(res, " ")
}
func (s pluginOptsFlag) Set(str string) error {
p := strings.SplitN(str, "=", 2)
if len(p) == 1 {
p = append(p, "true")
}
var v interface{}
if p[1] == "true" {
v = true
} else if p[1] == "false" {
v = false
} else {
v = p[1]
}
s[p[0]] = v
return nil
}
type stringLevel logrus.Level
func (s stringLevel) String() string {
@ -38,14 +69,47 @@ func (s *stringLevel) Set(str string) error {
var rootDir string
var extraPlugins stringsFlag
var logLevel = stringLevel(logrus.DebugLevel)
var pluginOptions = make(pluginOptsFlag)
var logLevel = stringLevel(logrus.InfoLevel)
var interactive bool
func unboxAll(rootDir string) error {
box := packr.New("defconf", "./defconf")
if err := os.MkdirAll(rootDir, 0755); err != nil {
return errors.Wrap(err, "failed to create root directory")
}
for _, f := range box.List() {
dst := filepath.Join(rootDir, f)
if _, err := os.Stat(dst); os.IsNotExist(err) {
logrus.Infof("Creating default %s as %s", f, dst)
d, err := box.Find(f)
if err != nil {
return errors.Wrapf(err, "failed to get contents of boxed %s", f)
}
if err := ioutil.WriteFile(dst, d, 0644); err != nil {
return errors.Wrapf(err, "failed to write unboxed file %s", f)
}
}
}
return nil
}
func init() {
flag.StringVar(&rootDir, "root", "~/.squircy", "path to folder containing squircy data")
flag.Var(&logLevel, "log-level", "controls verbosity of logging output")
flag.Var(&extraPlugins, "plugin", "path to shared plugin .so file, multiple plugins may be given")
flag.BoolVar(&interactive, "interactive", false, "start interactive-read-evaluate-print (REPL) session")
flag.Var(&pluginOptions, "plugin-option", "specify extra plugin configuration option, format: key=value")
flag.Bool("irc-auto", false, "automatically connect to irc")
flag.String("irc-nick", "squishyjones", "specify irc nickname")
flag.String("irc-user", "mrjones", "specify irc user")
flag.String("irc-network", "chat.freenode.net:6697", "specify irc network")
flag.Bool("irc-tls", true, "use tls encryption when connecting to irc")
flag.Bool("irc-sasl", false, "use sasl authentication")
flag.String("irc-sasl-username", "", "specify sasl username")
flag.String("irc-sasl-password", "", "specify sasl password")
flag.String("irc-server-password", "", "specify server password")
flag.String("vm-modules-path", "node_modules", "specify javascript modules path")
flag.Usage = func() {
fmt.Println("Usage: ", os.Args[0], "[options]")
@ -56,25 +120,23 @@ func init() {
flag.PrintDefaults()
}
flag.Parse()
bp, err := tilde.Expand(rootDir)
if err != nil {
logrus.Fatalln(err)
var err error
if rootDir, err = tilde.Expand(rootDir); err != nil {
logrus.Fatalln("core: failed determine root directory:", err)
}
err = os.MkdirAll(bp, os.FileMode(0644))
if err != nil {
logrus.Fatalln(err)
if err := unboxAll(rootDir); err != nil {
logrus.Fatalln("core: failed to unbox defaults:", err)
}
rootDir = bp
}
func main() {
logrus.SetLevel(logrus.Level(logLevel))
m, err := cli.NewManager(rootDir, extraPlugins...)
m, err := cli.NewManager(rootDir, pluginOptions, extraPlugins...)
if err != nil {
logrus.Fatalln("error initializing squircy:", err)
logrus.Fatalln("core: error initializing squircy:", err)
}
if err := m.Start(); err != nil {
logrus.Fatalln("error starting squircy:", err)
logrus.Fatalln("core: error starting squircy:", err)
}
if interactive {
go func() {
@ -82,6 +144,6 @@ func main() {
}()
}
if err = m.Loop(); err != nil {
logrus.Fatalln("exiting main loop with error:", err)
logrus.Fatalln("core: exiting main loop with error:", err)
}
}

+ 3
- 2
config.toml.dist View File

@ -1,9 +1,9 @@
plugin_path="/squircy/plugins"
extra_plugins=[
"babel.so",
"script.so",
#"squircy2_compat.so",
"node_compat.so",
"squircy2_compat.so",
"script.so",
]
[irc]
@ -14,6 +14,7 @@ tls=true
sasl=false
#sasl_username=""
#sasl_password=""
#server_password=""
[vm]
modules_path="/home/squircy/.squircy/scripts/node_modules"

+ 1
- 2
go.mod View File

@ -8,11 +8,10 @@ require (
github.com/dop251/goja v0.0.0-20200526165454-f1752421c432
github.com/fatih/structtag v1.0.0
github.com/go-sourcemap/sourcemap v2.1.2+incompatible // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/gobuffalo/packr/v2 v2.8.0
github.com/peterh/liner v1.1.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.4.0 // indirect
github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb
golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect

+ 151
- 0
go.sum View File

@ -1,52 +1,203 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk=
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dop251/goja v0.0.0-20200526165454-f1752421c432 h1:EIY1hqp9O08saJ41t7aQy0o1hhq3ByOy61AACthST5M=
github.com/dop251/goja v0.0.0-20200526165454-f1752421c432/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA=
github.com/fatih/structtag v1.0.0 h1:pTHj65+u3RKWYPSGaU290FpI/dXxTaHdVwVwbcPKmEc=
github.com/fatih/structtag v1.0.0/go.mod h1:IKitwq45uXL/yqi5mYghiD3w9H6eTOvI9vnk8tXMphA=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-sourcemap/sourcemap v2.1.2+incompatible h1:0b/xya7BKGhXuqFESKM4oIiRo9WOt2ebz7KxfreD6ug=
github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gobuffalo/logger v1.0.3 h1:YaXOTHNPCvkqqA7w05A4v0k2tCdpr+sgFlgINbQ6gqc=
github.com/gobuffalo/logger v1.0.3/go.mod h1:SoeejUwldiS7ZsyCBphOGURmWdwUFXs0J7TCjEhjKxM=
github.com/gobuffalo/packd v1.0.0 h1:6ERZvJHfe24rfFmA9OaoKBdC7+c9sydrytMg8SdFGBM=
github.com/gobuffalo/packd v1.0.0/go.mod h1:6VTc4htmJRFB7u1m/4LeMTWjFoYrUiBkU9Fdec9hrhI=
github.com/gobuffalo/packr/v2 v2.8.0 h1:IULGd15bQL59ijXLxEvA5wlMxsmx/ZkQv9T282zNVIY=
github.com/gobuffalo/packr/v2 v2.8.0/go.mod h1:PDk2k3vGevNE3SwVyVRgQCCXETC9SaONCNSXT1Q8M1g=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/karrick/godirwalk v1.15.3 h1:0a2pXOgtB16CqIqXTiT7+K9L73f74n/aNQUnH6Ortew=
github.com/karrick/godirwalk v1.15.3/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI=
github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc=
github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY=
github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI=
github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/peterh/liner v1.1.0 h1:f+aAedNJA6uk7+6rXsYBnhdo4Xux7ESLe+kcuVUF5os=
github.com/peterh/liner v1.1.0/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.5.2 h1:qLvObTrvO/XRCqmkKxUlOBc48bI3efyDuAZe25QiF0w=
github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb h1:EavwSqheIJl3nb91HhkL73DwnT2Fk8W3yM7T7TuLZvA=
github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb/go.mod h1:I0ZT9x8wStY6VOxtNOrLpnDURFs7HS0z1e1vhuKUEVc=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c h1:/nJuwDLoL/zrqY6gf57vxC+Pi+pZ8bfhpPkicO5H7W4=
golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/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-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 h1:wYqz/tQaWUgGKyx+B/rssSE6wkIKdY5Ee6ryOmzarIg=
golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/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-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/mattes/go-expand-tilde.v1 v1.0.0-20150330173918-cb884138e64c h1:/Onz8dZtKBCmB8P0JU7+WSCfMekXry7BflVO0SQQrCU=
gopkg.in/mattes/go-expand-tilde.v1 v1.0.0-20150330173918-cb884138e64c/go.mod h1:j6QavCO5cYWud1+2/PFTXL1y6tjjkhSs+qcWgibOIc0=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

+ 3
- 2
plugins/babel/plugin.go View File

@ -50,15 +50,16 @@ func (p *babelPlugin) PrependRuntimeInitHandler() bool {
}
func (p *babelPlugin) HandleRuntimeInit(gr *goja.Runtime) {
p.vm.SetTransformer(nil)
if !p.enable {
logrus.Debugf("babel: disabled, not initializing")
return
}
p.vm.SetTransformer(nil)
logrus.Infoln("Initializing babel.js transformer...")
st := time.Now()
b, err := babel.New(gr)
if err != nil {
logrus.Warnln("Failed to initialize babel.js:", err)
logrus.Warnln("babel: failed to initialize babel.js:", err)
return
}
logrus.Infof("Initialized babel.js transformer (took %s)", time.Now().Sub(st))

+ 22
- 10
plugins/node_compat/plugin.go View File

@ -25,6 +25,9 @@ func Initialize(m *plugin.Manager) (plugin.Plugin, error) {
if err != nil {
return nil, errors.Wrapf(err, "%s: required dependency missing (vm)", PluginName)
}
if _, err := m.Lookup("babel"); err != nil {
return nil, errors.Wrapf(err, "%s: required dependency missing (babel)", PluginName)
}
vmp.SetModule(EventEmitter)
vmp.SetModule(ChildProcess)
vmp.SetModule(Crypto)
@ -39,28 +42,37 @@ type nodeCompatPlugin struct {
}
func (p *nodeCompatPlugin) HandleRuntimeInit(r *goja.Runtime) {
if !p.EnableExec {
if r.Get("Babel") == nil {
logrus.Warnf("%s: babel is required but not enabled, disabling node_compat", PluginName)
return
}
v := r.NewObject()
if err := v.Set("Command", NewProcess); err != nil {
logrus.Warnf("%s: error initializing runtime: %s", PluginName, err)
if p.EnableExec {
logrus.Debugf("%s: subprocess execution is enabled", PluginName)
v := r.NewObject()
if err := v.Set("Command", NewProcess); err != nil {
logrus.Warnf("%s: error initializing exec.Command: %s", PluginName, err)
} else {
r.Set("exec", v)
}
} else {
logrus.Debugf("%s: subprocess execution is disabled", PluginName)
}
r.Set("exec", v)
v = r.NewObject()
v := r.NewObject()
if err := v.Set("Sum", func(b []byte) (string, error) {
return fmt.Sprintf("%x", sha1.Sum(b)), nil
}); err != nil {
logrus.Warnf("%s: error initializing runtime: %s", PluginName, err)
logrus.Warnf("%s: error initializing sha1.Sum: %s", PluginName, err)
} else {
r.Set("sha1", v)
}
r.Set("sha1", v)
v = r.NewObject()
if err := v.Set("Dial", native.Dial); err != nil {
logrus.Warnf("%s: error initializing runtime: %s", PluginName, err)
logrus.Warnf("%s: error initializing native.Dial: %s", PluginName, err)
} else {
r.Set("native", v)
}
r.Set("native", v)
_, err := r.RunString(`this.global = this.global || this;
require('core-js-bundle');

+ 15
- 5
plugins/script/plugin.go View File

@ -1,6 +1,8 @@
package main
import (
"path/filepath"
"code.dopame.me/veonik/squircy3/config"
"code.dopame.me/veonik/squircy3/plugin"
"code.dopame.me/veonik/squircy3/vm"
@ -58,31 +60,39 @@ func (p *scriptPlugin) HandleRuntimeInit(r *goja.Runtime) {
logrus.Infoln("Loading scripts from", p.manager.rootDir)
ss, err := p.manager.LoadAll()
if err != nil {
logrus.Warnln("Error loading scripts at runtime init:", err)
logrus.Warnf("script: failed to list directory contents of '%s': %s", p.manager.rootDir, err)
return
}
for _, s := range ss {
logrus.Infoln("Running script", s.Name)
pr, err := p.vm.Compile(s.Name, s.Body)
if err != nil {
logrus.Warnln("Error compiling script", s.Name, err)
logrus.Warnf("script: failed to compile script (%s): %s", s.Name, err)
return
}
_, err = r.RunProgram(pr)
if err != nil {
logrus.Warnln("Error running script", s.Name, err)
logrus.Warnf("script: error while running script (%s): %s", s.Name, err)
}
}
}
func (p *scriptPlugin) Options() []config.SetupOption {
return []config.SetupOption{config.WithRequiredOption("scripts_path")}
return []config.SetupOption{
config.WithRequiredOption("scripts_path"),
config.WithInheritedOption("root_path")}
}
func (p *scriptPlugin) Configure(conf config.Config) error {
r, ok := conf.String("scripts_path")
if !ok {
return errors.Errorf("%s: scripts_path cannot be empty", pluginName)
r = "scripts"
}
if !filepath.IsAbs(r) {
rr, ok := conf.String("root_path")
if ok {
r = filepath.Join(rr, r)
}
}
p.manager = &Manager{rootDir: r}
return nil

+ 3
- 4
plugins/squircy2_compat/data/tiedot_shim.go View File

@ -32,10 +32,9 @@ func (d *DB) Use(name string) *Collection {
defer d.mu.Unlock()
if _, ok := d.open[name]; !ok {
dir := filepath.Join(d.rootPath, name)
_, err := os.Stat(dir)
if os.IsNotExist(err) {
if _, err := os.Stat(dir); os.IsNotExist(err) {
if err := os.MkdirAll(dir, 0755); err != nil {
d.logger.Warnln("failed to create directory for collection:", err)
d.logger.Warnf("squircy2_compat: failed to create directory (%s) for collection: %s", dir, err)
return nil
}
}
@ -127,7 +126,7 @@ func EvalQuery(q interface{}, src *Collection, result *map[int]struct{}) (err er
func (c *Collection) ForEachDoc(fn func(id int, doc []byte) (moveOn bool)) {
fs, err := ioutil.ReadDir(c.basePath)
if err != nil {
c.logger.Warnln("failed to read data directory:", err)
c.logger.Warnf("squircy2_compat: failed to read data directory (%s): %s", c.basePath, err)
return
}
for _, f := range fs {

+ 22
- 0
plugins/squircy2_compat/helper.go View File

@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
@ -24,6 +25,8 @@ type Config struct {
OwnerNick string `toml:"owner_nick"`
OwnerHost string `toml:"owner_host"`
DataPath string `toml:"data_path"`
RootDir string `flag:"root_path"`
}
type HelperSet struct {
@ -54,6 +57,25 @@ func NewHelperSet(e *event.Dispatcher, v *vm.VM, i *irc.Manager) *HelperSet {
}
func (p *HelperSet) Configure(c Config) error {
if !filepath.IsAbs(c.FileAPIPath) {
c.FileAPIPath = filepath.Join(c.RootDir, c.FileAPIPath)
}
if c.EnableFileAPI {
// only need to bother with this check if it is indeed enabled
if _, err := os.Stat(c.FileAPIPath); os.IsNotExist(err) {
logrus.Warnf("squircy2_compat: file_api_path '%s' does not exist, disabling file api", c.FileAPIPath)
c.EnableFileAPI = false
}
}
if !filepath.IsAbs(c.DataPath) {
c.DataPath = filepath.Join(c.RootDir, c.DataPath)
}
if _, err := os.Stat(c.DataPath); os.IsNotExist(err) {
logrus.Warnf("squircy2_compat: data_path '%s' does not exist, creating", c.DataPath)
if err := os.MkdirAll(c.DataPath, 0755); err != nil {
logrus.Warnf("squircy2_compat: db functions may not work, failed to create data_path '%s': %s", c.DataPath, err)
}
}
p.Config = &c
p.file = fileHelper{c.EnableFileAPI, c.FileAPIPath}
p.conf = configHelper{c.OwnerNick, c.OwnerHost}

+ 2
- 1
plugins/squircy2_compat/plugin.go View File

@ -47,11 +47,12 @@ func (p *shimPlugin) Configure(c config.Config) error {
cf.OwnerNick, _ = c.String("owner_nick")
cf.OwnerHost, _ = c.String("owner_host")
cf.DataPath, _ = c.String("data_path")
cf.RootDir, _ = c.String("root_path")
return p.HelperSet.Configure(cf)
}
func (p *shimPlugin) Options() []config.SetupOption {
return []config.SetupOption{config.WithInitValue(&Config{})}
return []config.SetupOption{config.WithInitValue(&Config{}), config.WithInheritedOption("root_path")}
}
func (p *shimPlugin) Name() string {

+ 15
- 1
vm/plugin.go View File

@ -1,6 +1,9 @@
package vm
import (
"os"
"path/filepath"
"code.dopame.me/veonik/squircy3/config"
"code.dopame.me/veonik/squircy3/plugin"
@ -48,6 +51,15 @@ func (p *vmPlugin) Configure(conf config.Config) error {
if !ok {
return errors.New("vm: modules_path cannot be empty")
}
if !filepath.IsAbs(r) {
if rr, ok := conf.String("root_path"); ok {
r = filepath.Join(rr, r)
}
}
logrus.Debugf("vm: configured with modules_path: %s", r)
if _, err := os.Stat(r); os.IsNotExist(err) {
logrus.Warnf("vm: modules_path '%s' does not exist, perhaps you need to run `yarn install`?", r)
}
vm, err := New(NewRegistry(r))
if err != nil {
return err
@ -57,7 +69,9 @@ func (p *vmPlugin) Configure(conf config.Config) error {
}
func (p *vmPlugin) Options() []config.SetupOption {
return []config.SetupOption{config.WithRequiredOption("modules_path")}
return []config.SetupOption{
config.WithRequiredOption("modules_path"),
config.WithInheritedOption("root_path")}
}
func (p *vmPlugin) Name() string {

Loading…
Cancel
Save