示例#1
0
文件: host.go 项目: huhoo/vulcand
func (cmd *Command) deleteHostAction(c *cli.Context) {
	if err := cmd.client.DeleteHost(engine.HostKey{Name: c.String("name")}); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("host deleted")
}
示例#2
0
文件: backend.go 项目: huhoo/vulcand
func (cmd *Command) deleteBackendAction(c *cli.Context) {
	if err := cmd.client.DeleteBackend(engine.BackendKey{Id: c.String("id")}); err != nil {
		cmd.printError(err)
	} else {
		cmd.printOk("backend deleted")
	}
}
示例#3
0
文件: host.go 项目: huhoo/vulcand
func (cmd *Command) upsertHostAction(c *cli.Context) {
	host, err := engine.NewHost(c.String("name"), engine.HostSettings{})
	if err != nil {
		cmd.printError(err)
		return
	}
	if c.String("cert") != "" || c.String("privateKey") != "" {
		keyPair, err := readKeyPair(c.String("cert"), c.String("privateKey"))
		if err != nil {
			cmd.printError(fmt.Errorf("failed to read key pair: %s", err))
			return
		}
		host.Settings.KeyPair = keyPair
	}
	host.Settings.OCSP = engine.OCSPSettings{
		Enabled:            c.Bool("ocsp"),
		SkipSignatureCheck: c.Bool("ocspSkipCheck"),
		Period:             c.Duration("ocspPeriod").String(),
		Responders:         c.StringSlice("ocspResponder"),
	}
	if err := cmd.client.UpsertHost(*host); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("host added")
}
示例#4
0
文件: listener.go 项目: huhoo/vulcand
func (cmd *Command) printListenerAction(c *cli.Context) {
	l, err := cmd.client.GetListener(engine.ListenerKey{Id: c.String("id")})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printListener(l)
}
示例#5
0
文件: server.go 项目: huhoo/vulcand
func (cmd *Command) printServerAction(c *cli.Context) {
	s, err := cmd.client.GetServer(engine.ServerKey{Id: c.String("id"), BackendKey: engine.BackendKey{Id: c.String("backend")}})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printServer(s)
}
示例#6
0
文件: server.go 项目: huhoo/vulcand
func (cmd *Command) deleteServerAction(c *cli.Context) {
	sk := engine.ServerKey{BackendKey: engine.BackendKey{Id: c.String("backend")}, Id: c.String("id")}
	if err := cmd.client.DeleteServer(sk); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("Server %v deleted", sk.Id)
}
示例#7
0
文件: server.go 项目: huhoo/vulcand
func (cmd *Command) printServersAction(c *cli.Context) {
	srvs, err := cmd.client.GetServers(engine.BackendKey{Id: c.String("backend")})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printServers(srvs)
}
示例#8
0
文件: host.go 项目: huhoo/vulcand
func (cmd *Command) printHostAction(c *cli.Context) {
	host, err := cmd.client.GetHost(engine.HostKey{Name: c.String("name")})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printHost(host)
}
示例#9
0
文件: frontend.go 项目: huhoo/vulcand
func (cmd *Command) deleteFrontendAction(c *cli.Context) {
	err := cmd.client.DeleteFrontend(engine.FrontendKey{Id: c.String("id")})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("frontend deleted")
}
示例#10
0
// FromCli constructs a middleware instance from the command line parameters.
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	return FromOther(
		RateLimit{
			PeriodSeconds: int64(c.Int("period")),
			Requests:      int64(c.Int("requests")),
			Burst:         int64(c.Int("burst")),
			Variable:      c.String("var"),
			RateVar:       c.String("rateVar")})
}
示例#11
0
文件: log.go 项目: huhoo/vulcand
func (cmd *Command) updateLogSeverityAction(c *cli.Context) {
	sev, err := log.SeverityFromString(c.String("severity"))
	if err != nil {
		cmd.printError(err)
		return
	}
	if err := cmd.client.UpdateLogSeverity(sev); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("log severity updated")
}
示例#12
0
文件: backend.go 项目: huhoo/vulcand
func (cmd *Command) upsertBackendAction(c *cli.Context) {
	settings, err := getBackendSettings(c)
	if err != nil {
		cmd.printError(err)
		return
	}
	b, err := engine.NewHTTPBackend(c.String("id"), settings)
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printResult("%s upserted", b, cmd.client.UpsertBackend(*b))
}
示例#13
0
文件: frontend.go 项目: huhoo/vulcand
func getFrontendSettings(c *cli.Context) (engine.HTTPFrontendSettings, error) {
	s := engine.HTTPFrontendSettings{}

	s.Limits.MaxMemBodyBytes = int64(c.Int("maxMemBodyKB") * 1024)
	s.Limits.MaxBodyBytes = int64(c.Int("maxBodyKB") * 1024)

	s.FailoverPredicate = c.String("failoverPredicate")
	s.Hostname = c.String("forwardHost")
	s.TrustForwardHeader = c.Bool("trustForwardHeader")
	s.PassHostHeader = c.Bool("passHostHeader")

	return s, nil
}
示例#14
0
文件: backend.go 项目: huhoo/vulcand
func (cmd *Command) printBackendAction(c *cli.Context) {
	bk := engine.BackendKey{Id: c.String("id")}
	b, err := cmd.client.GetBackend(bk)
	if err != nil {
		cmd.printError(err)
		return
	}
	srvs, err := cmd.client.GetServers(bk)
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printBackend(b, srvs)
}
示例#15
0
文件: frontend.go 项目: huhoo/vulcand
func (cmd *Command) printFrontendAction(c *cli.Context) {
	fk := engine.FrontendKey{Id: c.String("id")}
	frontend, err := cmd.client.GetFrontend(fk)
	if err != nil {
		cmd.printError(err)
		return
	}

	ms, err := cmd.client.GetMiddlewares(fk)
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printFrontend(frontend, ms)
}
示例#16
0
// FromCli constructs the middleware from the command line.
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	var suppliedConfig map[string]*domain

	configFile := c.String(configFile)
	if configFile != "" {
		yamlFile, err := ioutil.ReadFile(configFile)
		if err != nil {
			fmt.Println(errorFileIO)
		}

		yaml.Unmarshal(yamlFile, &suppliedConfig)
	}

	return New(suppliedConfig)
}
示例#17
0
文件: tls.go 项目: huhoo/vulcand
func getTLSSettings(c *cli.Context) (*engine.TLSSettings, error) {
	s := &engine.TLSSettings{
		InsecureSkipVerify:       c.Bool("tlsSkipVerify"),
		PreferServerCipherSuites: c.Bool("tlsPreferServerCS"),
		SessionTicketsDisabled:   c.Bool("tlsSessionTicketsOff"),
		MinVersion:               c.String("tlsMinV"),
		MaxVersion:               c.String("tlsMaxV"),
		CipherSuites:             c.StringSlice("tlsCS"),
	}
	s.SessionCache.Type = c.String("tlsSessionCache")
	if s.SessionCache.Type == engine.LRUCacheType {
		s.SessionCache.Settings = &engine.LRUSessionCacheSettings{
			Capacity: c.Int("tlsSessionCacheCapacity"),
		}
	}
	if _, err := engine.NewTLSConfig(s); err != nil {
		return nil, err
	}
	return s, nil
}
示例#18
0
文件: secret.go 项目: huhoo/vulcand
func getStream(c *cli.Context) (io.Writer, io.Closer, error) {
	if c.String("file") != "" {
		file, err := os.OpenFile(c.String("file"), os.O_WRONLY|os.O_CREATE, 0600)
		if err != nil {
			return nil, nil, fmt.Errorf("failed to open file %s, error: %s", c.String("file"), err)
		}
		return file, file, nil
	}
	return os.Stdout, nil, nil
}
示例#19
0
文件: server.go 项目: huhoo/vulcand
func (cmd *Command) upsertServerAction(c *cli.Context) {
	s, err := engine.NewServer(c.String("id"), c.String("url"))
	if err != nil {
		cmd.printError(err)
		return
	}
	if err := cmd.client.UpsertServer(engine.BackendKey{Id: c.String("backend")}, *s, c.Duration("ttl")); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("server upserted")
}
示例#20
0
文件: listener.go 项目: huhoo/vulcand
func (cmd *Command) upsertListenerAction(c *cli.Context) {
	var settings *engine.HTTPSListenerSettings
	if c.String("proto") == engine.HTTPS {
		s, err := getTLSSettings(c)
		if err != nil {
			cmd.printError(err)
			return
		}
		settings = &engine.HTTPSListenerSettings{TLS: *s}
	}
	listener, err := engine.NewListener(c.String("id"), c.String("proto"), c.String("net"), c.String("addr"), c.String("scope"), settings)
	if err != nil {
		cmd.printError(err)
		return
	}
	if err := cmd.client.UpsertListener(*listener); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("listener upserted")
}
示例#21
0
文件: frontend.go 项目: huhoo/vulcand
func (cmd *Command) upsertFrontendAction(c *cli.Context) {
	settings, err := getFrontendSettings(c)
	if err != nil {
		cmd.printError(err)
		return
	}
	f, err := engine.NewHTTPFrontend(route.NewMux(), c.String("id"), c.String("b"), c.String("route"), settings)
	if err != nil {
		cmd.printError(err)
		return
	}
	if err := cmd.client.UpsertFrontend(*f, c.Duration("ttl")); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("frontend upserted")
}
示例#22
0
文件: secret.go 项目: huhoo/vulcand
func (cmd *Command) sealKeyPairAction(c *cli.Context) {
	// Read the key and get a box
	box, err := readBox(c.String("sealKey"))
	if err != nil {
		cmd.printError(err)
		return
	}

	// Read keyPairificate
	stream, closer, err := getStream(c)
	if err != nil {
		cmd.printError(err)
		return
	}
	if closer != nil {
		defer closer.Close()
	}

	keyPair, err := readKeyPair(c.String("cert"), c.String("privateKey"))
	if err != nil {
		cmd.printError(fmt.Errorf("failed to read key pair: %s", err))
		return
	}

	bytes, err := secret.SealKeyPairToJSON(box, keyPair)
	if err != nil {
		cmd.printError(fmt.Errorf("failed to seal key pair: %s", err))
		return
	}

	_, err = stream.Write(bytes)
	if err != nil {
		cmd.printError(fmt.Errorf("failed writing to output stream, error %s", err))
		return
	}
}
示例#23
0
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	return NewRewrite(c.String("regexp"), c.String("replacement"), c.Bool("rewriteBody"), c.Bool("redirect"))
}
示例#24
0
文件: status.go 项目: huhoo/vulcand
func (cmd *Command) topAction(c *cli.Context) {
	cmd.overviewAction(c.String("backend"), c.Int("refresh"), c.Int("limit"))
}
示例#25
0
// Constructs the middleware from the command line
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	return NewConnLimit(int64(c.Int("connections")), c.String("var"))
}
示例#26
0
文件: listener.go 项目: huhoo/vulcand
func (cmd *Command) deleteListenerAction(c *cli.Context) {
	if err := cmd.client.DeleteListener(engine.ListenerKey{Id: c.String("id")}); err != nil {
		cmd.printError(err)
	}
	cmd.printOk("listener deleted")
}
示例#27
0
文件: spec.go 项目: huhoo/vulcand
// FromCli constructs the middleware from the command line arguments
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	return NewSpec(c.String("condition"), c.String("fallback"), c.String("onTripped"), c.String("onStandby"), c.Duration("fallbackDuration"), c.Duration("recoveryDuration"), c.Duration("checkPeriod"))
}
示例#28
0
文件: trace.go 项目: huhoo/vulcand
// FromCli creates a Trace plugin object from command line
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	return New(c.String("addr"), c.StringSlice("reqHeader"), c.StringSlice("respHeader"))
}