Exemplo n.º 1
0
func main() {
	//Parse command line flags
	var (
		_host    = kingpin.Flag("host", "Hostname").Short('h').Required().String()
		_port    = kingpin.Flag("port", "Port number").Short('p').Required().Int()
		_threads = kingpin.Flag("threads", "Thread count").Short('t').Default("1").Int()
		_size    = kingpin.Flag("size", "Packet Size").Short('s').Default("65507").Int()
	)
	kingpin.Parse()

	fullAddr := fmt.Sprintf("%s:%v", *_host, *_port)
	//Create send buffer
	var buf []byte = make([]byte, *_size)

	//Establish udp
	conn, err := net.Dial("udp", fullAddr)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("Flooding %s\n", fullAddr)
		for i := 0; i < *_threads; i++ {
			go func() {
				for {
					conn.Write(buf)
				}
			}()
		}
	}

	//Sleep forever
	<-make(chan bool, 1)
}
Exemplo n.º 2
0
func init() {
	m = macaron.Classic()
	m.Use(modules.Public)

	if _, err := os.Stat("templates"); err == nil {
		m.Use(macaron.Renderer())
	} else {
		m.Use(modules.Renderer)
	}

	kingpin.HelpFlag.Short('h')
	kingpin.Version(VERSION)
	kingpin.Flag("port", "Port to listen").Default("8000").IntVar(&gcfg.port)
	kingpin.Flag("root", "File root directory").Default(".").StringVar(&gcfg.root)
	kingpin.Flag("private", "Only listen on loopback address").BoolVar(&gcfg.private)
	kingpin.Flag("httpauth", "HTTP basic auth (ex: user:pass)").Default("").StringVar(&gcfg.httpauth)
	kingpin.Flag("cert", "TLS cert.pem").StringVar(&gcfg.cert)
	kingpin.Flag("key", "TLS key.pem").StringVar(&gcfg.key)
	kingpin.Flag("gzip", "Enable Gzip support").BoolVar(&gcfg.gzip)
	//kingpin.Flag("ftp", "Enable FTP support").BoolVar(&gcfg.ftp)
	//kingpin.Flag("ftp-port", "FTP listen port").Default("2121").IntVar(&gcfg.ftpPort)
	//kingpin.Flag("ftp-auth", "FTP auth (ex: user:pass)").Default("admin:123456").StringVar(&gcfg.ftpAuth)
	kingpin.Flag("upload", "Enable upload support").BoolVar(&gcfg.upload)
	kingpin.Flag("zipable", "Enable archieve folder into zip").BoolVar(&gcfg.zipable)
}
Exemplo n.º 3
0
func init() {
	m = macaron.Classic()
	m.Use(modules.Public)
	m.Use(modules.Renderer)

	kingpin.HelpFlag.Short('h')
	kingpin.Flag("port", "Port to listen").Default("8000").IntVar(&gcfg.port)
	kingpin.Flag("root", "File root directory").Default(".").StringVar(&gcfg.root)
	kingpin.Flag("private", "Only listen on loopback address").BoolVar(&gcfg.private)
	kingpin.Flag("httpauth", "HTTP basic auth (ex: user:pass)").Default("").StringVar(&gcfg.httpauth)
	kingpin.Flag("cert", "TLS cert.pem").StringVar(&gcfg.cert)
	kingpin.Flag("key", "TLS key.pem").StringVar(&gcfg.key)
	kingpin.Flag("gzip", "Enable Gzip support").BoolVar(&gcfg.gzip)
	kingpin.Flag("ftp", "Enable FTP support").BoolVar(&gcfg.ftp)
	kingpin.Flag("ftp-port", "FTP listen port").Default("2121").IntVar(&gcfg.ftpPort)
	kingpin.Flag("ftp-auth", "FTP auth (ex: user:pass)").Default("admin:123456").StringVar(&gcfg.ftpAuth)
}
Exemplo n.º 4
0
func main() {
	// Setup context
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	// Define a CLI
	dcConfig := &DCConfig{ServiceIdentifier: "omnivore"}

	kingpin.Flag("n", "The index of this node in the pool, if IPFS_POOL_PATH is set").Default("-1").Short('n').IntVar(&dcConfig.PoolIndex)

	var args []string
	kingpin.Arg("args", "arguments").StringsVar(&args)
	kingpin.Parse()

	// Build a node
	ipfsNode, err := BuildNode(ctx, dcConfig)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	fmt.Printf("I am node %s\n", ipfsNode.Identity.Pretty())

	// Respond to incoming providerIDs and streams
	// providerIDsIn, err := StartServiceDiscovery(ctx, ipfsNode, dcConfig)
	// if err != nil {
	// 	fmt.Println(err)
	// 	os.Exit(1)
	// }
	//
	// streamIn, err := StartListening(ipfsNode, dcConfig)
	// if err != nil {
	// 	fmt.Println(err)
	// 	os.Exit(1)
	// }
	//
	// for {
	// 	select {
	// 	case providerIDs := <-providerIDsIn:
	// 		for _, providerID := range providerIDs {
	// 			fmt.Printf("Provider: %s\n", providerID.Pretty())
	//
	// 			stream, err := corenet.Dial(ipfsNode, providerID, dcConfig.ServiceIdentifier)
	// 			if err != nil {
	// 				fmt.Printf("Failed to dial provider %s (%s)\n", providerID.Pretty(), err)
	// 				continue
	// 			}
	//
	// 			fmt.Fprintf(stream, "Hello! I'm peer %s\n", ipfsNode.Identity.Pretty())
	// 			stream.Close()
	// 		}
	//
	// 	case stream := <-streamIn:
	// 		fmt.Printf("Peer %s called!\n", stream.Conn().RemotePeer().Pretty())
	// 	}
	// }
}
Exemplo n.º 5
0
func main() {
	bsize := kingpin.Flag("blocksize", "blocksize to test with").Default("262144").Int64()
	kingpin.Parse()

	ipfsdir := getIpfsDir()
	r, err := fsrepo.Open(ipfsdir)
	if err != nil {
		fmt.Printf("Failed to open ipfs repo at: %s: %s\n", ipfsdir, err)
		fmt.Println("Please ensure ipfs has been initialized and that no daemon is running")
		return
	}

	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	nd, err := core.NewNode(ctx, &core.BuildCfg{
		Repo: r,
	})
	if err != nil {
		fmt.Printf("failed to create node: %s\n", err)
		return
	}

	cfg := &BenchCfg{
		Blocksize: *bsize,
	}

	fmt.Println(cfg)
	err = BenchmarkBlockRewrites(nd, cfg)
	if err != nil {
		panic(err)
	}

	err = BenchmarkRandomBlockWrites(nd, cfg)
	if err != nil {
		panic(err)
	}

	err = BenchmarkAdd(nd, cfg)
	if err != nil {
		panic(err)
	}

	err = BenchmarkDiskWrites(ipfsdir)
	if err != nil {
		panic(err)
	}
}
Exemplo n.º 6
0
	"encoding/binary"
	"errors"
	"fmt"
	"io/ioutil"
	"net"
	"os"
	"strings"

	"github.com/alecthomas/kingpin"
	"github.com/chzyer/readline"
	"github.com/joushou/qp"
	"github.com/joushou/qptools/client"
)

var (
	service = kingpin.Flag("service", "service name to use when connecting (aname)").Short('s').String()
	user    = kingpin.Flag("user", "username to use when connecting (uname)").Short('u').String()
	address = kingpin.Arg("address", "address to connect to").Required().String()
	command = stringList(kingpin.Arg("command", "command to execute (disables interactive mode)"))
	rawtls  = kingpin.Flag("rawtls", "wrap connection in TLS").Short('t').Bool()
)

type slist []string

func (i *slist) Set(value string) error {
	*i = append(*i, value)
	return nil
}

func (i *slist) String() string {
	return ""
Exemplo n.º 7
0
 */

import (
	"fmt"
	"github.com/alecthomas/kingpin"
	"github.com/cathalgarvey/go-minilock"
	"github.com/cathalgarvey/go-minilock/taber"
	"github.com/howeyc/gopass"
	"io/ioutil"
)

var (
	encrypt = kingpin.Command("encrypt", "Encrypt a file.")
	decrypt = kingpin.Command("decrypt", "Decrypt a file.")

	PassPhrase = kingpin.Flag("passphrase", "Full passphrase for this miniLock key. If not given through this flag, it will be asked for interactively").
			Short('p').String()
	OutputFileName = kingpin.Flag("output", "Name of output file. By default for encryption, this is input filename + '.minilock', and for decryption this is the indicated filename in the ciphertext. Warning: Right now this presents potential security hazards!").
			Short('o').Default("NOTGIVEN").String()

	efile = encrypt.Arg("file", "File to encrypt or decrypt.").Required().String()
	dfile = decrypt.Arg("file", "File to encrypt or decrypt.").Required().String()

	eUserEmail = encrypt.
			Arg("user-email", "Your email address. This need not be secret, but if this isn't *accurate* it must be *globally unique*, it is used for generating security.").
			Required().String()
	dUserEmail = decrypt.
			Arg("user-email", "Your email address. This need not be secret, but if this isn't *accurate* it must be *globally unique*, it is used for generating security.").
			Required().String()

	recipients      = encrypt.Arg("recipients", "One or more miniLock IDs to add to encrypted file.").Strings()
Exemplo n.º 8
0
func Flag(name string, helpOptional ...string) *kingpin.FlagClause {
	help := strings.Join(helpOptional, " ")
	return kingpin.Flag(name, help)
}
Exemplo n.º 9
0
func parseFlags() {
	kingpin.HelpFlag.Short('h')
	kingpin.Version(versionMessage())
	kingpin.Flag("root", "root directory").Short('r').Default("./").StringVar(&gcfg.Root)
	kingpin.Flag("addr", "listen address").Short('a').Default(":8000").StringVar(&gcfg.Addr)
	kingpin.Flag("cert", "tls cert.pem path").StringVar(&gcfg.Cert)
	kingpin.Flag("key", "tls key.pem path").StringVar(&gcfg.Key)
	kingpin.Flag("httpauth", "HTTP basic auth (ex: user:pass)").Default("").StringVar(&gcfg.HttpAuth)
	kingpin.Flag("theme", "web theme, one of <black|green>").Default("black").StringVar(&gcfg.Theme)
	kingpin.Flag("upload", "enable upload support").BoolVar(&gcfg.Upload)
	kingpin.Flag("xheaders", "used when behide nginx").BoolVar(&gcfg.XHeaders)
	kingpin.Flag("cors", "enable cross-site HTTP request").BoolVar(&gcfg.Cors)
	kingpin.Flag("plistproxy", "plist proxy when server is not https").Default(defaultPlistProxy).Short('p').URLVar(&gcfg.PlistProxy)
	kingpin.Flag("title", "server title").Default("Go HTTP File Server").StringVar(&gcfg.Title)

	kingpin.Parse()
}
Exemplo n.º 10
0
import (
	"log"
	"os"
	"os/user"
	"path/filepath"
	"strconv"
	"syscall"

	"github.com/alecthomas/kingpin"
	"github.com/go-fsnotify/fsnotify"
)

var (
	cliDir        = kingpin.Arg("dir", "The directory to enforce permissions.").Required().String()
	cliChownUser  = kingpin.Flag("chown-user", "Name of the user to Chown the directory with.").Required().String()
	cliChownGroup = kingpin.Flag("chown-group", "Name of group to Chown the directory with.").Required().String()
	cliChmodDir   = kingpin.Flag("chmod-dir", "The mode to be assigned to directories.").Default("0775").Int64()
	cliChmodFile  = kingpin.Flag("chmod-file", "The mode to be assigned to files.").Default("0664").Int64()

	uid int
	gid int
)

func main() {
	kingpin.Parse()

	u, err := user.Lookup(*cliChownUser)
	if err != nil {
		panic(err)
	}
Exemplo n.º 11
0
import (
	"os"

	log "github.com/Sirupsen/logrus"
	"github.com/alecthomas/kingpin"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/autoscaling"
	"github.com/lox/lifecycled"
)

const (
	simulateQueue = "simulate"
)

var (
	verbose    = kingpin.Flag("verbose", "Verbose mode.").Short('v').Bool()
	instanceID = kingpin.Flag("instanceid", "An instanceid to use to filter messages").String()
	sqsQueue   = kingpin.Flag("queue", "The sqs queue identifier to consume").Required().String()
	handler    = kingpin.Flag("handler", "The script to invoke to handle events").Required().File()
	debug      = kingpin.Flag("debug", "Show debugging info").Bool()
)

func main() {
	log.SetFormatter(&log.TextFormatter{})

	kingpin.CommandLine.DefaultEnvars()
	kingpin.Parse()

	var queue lifecycled.Queue

	// provide a simulated queue for testing
Exemplo n.º 12
0
	"os"
	"os/signal"
	"strings"
	"syscall"
	"time"

	"github.com/alecthomas/kingpin"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/ec2"
	"github.com/bluele/slack"
)

const filename = "notified.json"

var token = kingpin.Flag("token", "The slack API token").OverrideDefaultFromEnvar("TOKEN").Required().String()
var timeout = kingpin.Arg("wait", "Wait in minutes before checking for changes").Default("10").Int()
var expireTime = kingpin.Arg("expire", "Age in hours before notifing about the instance").Default("48").Int()
var region = kingpin.Arg("region", "Amazon EC2 region to scan for instances").Default("eu-west-1").String()
var prod = kingpin.Flag("prod", "Running for real?").OverrideDefaultFromEnvar("PROD").Default("false").Bool()

func findUser(list []*slack.User, searchid string) string {
	for _, u := range list {
		if u.Id == searchid {
			return u.Id
		}

		if u.Profile.Email != "" {
			data := strings.Split(u.Profile.Email, "@")
			if data[0] == searchid {
				return u.Id
Exemplo n.º 13
0
	//"github.com/davecgh/go-spew/spew" // For neatly outputting stuff
	//"strconv" // For String construction
	//"time" // Used as part of "setInterval" and for pausing code to allow for data to come back
	//"fmt" //Output stuff to the screen

	"github.com/alecthomas/kingpin"
	"github.com/juju/loggo"
	//"github.com/rcrowley/go-metrics"
)

//const statsTopic = "$device/stats"
const wbTopic = "$device/wb"

var (
	debug   = kingpin.Flag("debug", "Enable debug mode.").OverrideDefaultFromEnvar("DEBUG").Bool()
	daemon  = kingpin.Flag("daemon", "Run in daemon mode.").Short('d').Bool()
	mqttURL = kingpin.Flag("mqttUrl", "The MQTT url to publish too.").Short('u').Default("tcp://localhost:1883").String()
	logName = kingpin.Flag("logName", "The Log Name.").Short('u').Default("webbrick-mqtt").String()
	//port     = kingpin.Flag("port", "HTTP Port.").Short('i').OverrideDefaultFromEnvar("PORT").Default("9980").Int()
	//path     = kingpin.Flag("path", "Path to static content.").Short('p').OverrideDefaultFromEnvar("CONTENT_PATH").Default("./public").String()
	interval = kingpin.Flag("interval", "Publish interval.").Short('i').Default("30").Int()

	//log = loggo.GetLogger("mqtt_webbrick")
)

func main() {
	kingpin.Version(Version)
	kingpin.Parse()

	setupLoggo(*debug)
Exemplo n.º 14
0
Arquivo: kaifa.go Projeto: kaifali/cli
import (
	"fmt"
	"os"

	"github.com/alecthomas/kingpin"
	"github.com/parnurzeal/gorequest"
	"github.com/toqueteos/webbrowser"
)

const htmlURL string = "http://kaifa.at/services/"
const jsonURL string = "http://kaifa.at/api/services/"

var (
	keyword = kingpin.Arg("keyword", "Keyword of service").Required().String()
	format  = kingpin.Flag("format", "Format: html,json").Default("html").String()
)

func main() {
	kingpin.Version("0.2.1")
	kingpin.Parse()

	switch *format {
	case "html":
		openBrowser()
	case "json":
		fetchJSON()
	default:
		openBrowser()
	}
}
Exemplo n.º 15
0
// Program gcm-logger logs and echoes as a GCM "server".
package main

import (
	"github.com/alecthomas/kingpin"
	"github.com/aliafshar/toylog"
	"github.com/google/go-gcm"
)

var (
	serverKey = kingpin.Flag("server_key", "The server key to use for GCM.").Short('k').Required().String()
	senderId  = kingpin.Flag("sender_id", "The sender ID to use for GCM.").Short('s').Required().String()
)

// onMessage receives messages, logs them, and echoes a response.
func onMessage(cm gcm.CcsMessage) error {
	toylog.Infoln("Message, from:", cm.From, "with:", cm.Data)
	// Echo the message with a tag.
	cm.Data["echoed"] = true
	m := gcm.HttpMessage{To: cm.From, Data: cm.Data}
	r, err := gcm.SendHttp(*serverKey, m)
	if err != nil {
		toylog.Errorln("Error sending message.", err)
		return err
	}
	toylog.Infof("Sent message. %+v -> %+v", m, r)
	return nil
}

func main() {
	toylog.Infoln("GCM Logger, starting.")
Exemplo n.º 16
0
Arquivo: main.go Projeto: xrstf/raziel
	"github.com/alecthomas/kingpin"
	"github.com/go-martini/martini"
	"github.com/jmoiron/sqlx"
	"github.com/martini-contrib/gzip"
	"github.com/martini-contrib/method"
)

const TestString = "Umse ♪"

var templateManager *TemplateManager
var restrictionHandlers map[string]RestrictionHandler
var config *configuration
var sessions *SessionMiddleware

var (
	password   = kingpin.Flag("password", "Encryption key in plain text (discouraged)").String()
	configFile = kingpin.Flag("config", "Configuration file to use").ExistingFile()
)

func main() {
	kingpin.UsageTemplate(kingpin.CompactUsageTemplate).Version("1.0").Author("Christoph Mewes")
	kingpin.CommandLine.Help = "HTTP application server to run the Raziel secret management"
	kingpin.Parse()

	if *configFile == "" {
		kingpin.FatalUsage("No configuration file (--config) given!")
	}

	// load config file
	err := loadConfigFile()
	if err != nil {
Exemplo n.º 17
0
	"runtime"
	"strconv"
	"time"

	"github.com/alecthomas/kingpin"
	"github.com/codeskyblue/gopsutil/android"
	"github.com/codeskyblue/gopsutil/process"
)

var (
	VERSION    = "0.0.x"
	BUILD_DATE = "unknown"
)

var (
	search   = kingpin.Flag("proc", "Find process, support ex: pid:71, exe:/bin/ls, cmdline:./ps").Short('p').String()
	showInfo = kingpin.Flag("info", "Show phone info and exit").Short('i').Bool()
	showFPS  = kingpin.Flag("fps", "Show fps in android").Bool()
	version  = kingpin.Flag("version", "Show version").Short('v').Bool()
	duration = kingpin.Flag("duration", "Collection interval").Short('d').Default("1s").Duration()
	listen   = kingpin.Flag("listen", "Listen http request").Short('l').Bool()
	port     = kingpin.Flag("port", "Listen port").Default("16118").Int()
	test     = kingpin.Flag("test", "Run test program, only for develop").Bool()
	quit     = kingpin.Flag("quit", "Quit running program").Bool()
	//search = flag.String("p", "",
	//	"Search process, support ex: pid:71, exe:/usr/bin/ls, cmdline:./ps")
	//showInfo = flag.Bool("i", false, "Show mathine infomation")
	//showFPS  = flag.Bool("fps", false, "Show fps of android")
	//version  = flag.Bool("v", false, "Show version")
	//duration = flag.Duration("d", time.Second, "Collect interval")
	//listen   = flag.Bool("l", false, "Listen http request data")
Exemplo n.º 18
0
package main

import (
	"github.com/alecthomas/kingpin"
	"github.com/cathalgarvey/buckfast/scrapedia"
	"github.com/cathalgarvey/buckfast/spritzlib"
	"io/ioutil"
	"log"
	"strings"
)

var (
	infile      = kingpin.Arg("infile", "File to read. If prefixed with 'wikipedia:', fetches the corresponding wikipedia page instead (needs to be exact target page title)").Required().String()
	wpm         = kingpin.Flag("wpm", "Approximate words per minute").Default("400").Short('w').Int()
	pivotColour = kingpin.Flag("pivot-colour", "Preferred pivot colour, one of red, green, blue, yellow, cyan, magenta, white, black.").
			Default("green").
			Short('p').
			Enum("red", "green", "blue", "cyan", "magenta", "yellow", "black", "white")
		//String()
	plainColour = kingpin.Flag("plain-colour", "Preferred non-pivot text colour, one of red, green, blue, yellow, cyan, magenta, white, black.").
			Default("white").
			Short('P').
			Enum("red", "green", "blue", "cyan", "magenta", "yellow", "black", "white")
		//    String()
	bgColour = kingpin.Flag("background-colour", "Text background colour, one of red, green, blue, yellow, cyan, magenta, white, black.").
			Default("").
			Short('b').
			Enum("red", "green", "blue", "cyan", "magenta", "yellow", "black", "white")
		//    String()
	boldText = kingpin.Flag("bold", "Whether to print bold.").Bool()
)
Exemplo n.º 19
0
package main

import (
	//	"encoding/json"
	//	"fmt"
	log "github.com/Sirupsen/logrus"
	"github.com/alecthomas/kingpin"
	"os"
	"path/filepath"
)

var (
	osd_sockets = kingpin.Flag("osd_sock", "pattern for osd sockets").Default("/var/run/ceph/osd*asok").String()
	mon_sockets = kingpin.Flag("mon_sock", "pattern for mon sockets").Default("/var/run/ceph/mon*asok").String()
	conf        = kingpin.Flag("conf", "path to configuration file").Default("/etc/ceph/ceph.conf").String()
	verbose     = kingpin.Flag("verbose", "verbose logging").Short('v').Bool()
	logfile     = kingpin.Flag("log", "path to logfile").Default("/var/log/ceph/rlyeh.log").String()
)

type perf struct {
	PerfCounter
	error
}

func main() {

	kingpin.Version("0.1")
	kingpin.Parse()

	f, err := os.OpenFile(*logfile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
	if err != nil {
Exemplo n.º 20
0
package main

import (
	"github.com/alecthomas/kingpin"
	"github.com/alexandre-normand/slackscot"
	"github.com/alexandre-normand/slackscot/brain"
	"github.com/alexandre-normand/slackscot/config"
	"log"
)

var (
	configurationPath = kingpin.Flag("configuration", "The path to the configuration file.").Required().String()
)

func main() {
	kingpin.Parse()

	config, err := config.LoadConfiguration(*configurationPath)
	if err != nil {
		log.Fatal(err)
	}

	youppi := slackscot.NewSlackscot([]slackscot.ExtentionBundle{brain.NewKarma(), brain.NewImager(), brain.NewFingerQuoter(), brain.NewEmojiBannerMaker()})

	err = slackscot.Run(*youppi, *config)
	if err != nil {
		log.Fatal(err)
	}
}
Exemplo n.º 21
0
package main

import (
	"strings"
	"time"

	"github.com/alecthomas/kingpin"
)

var (
	train = kingpin.Flag("train", "Enable train model").Short('t').Bool()
	model = kingpin.Flag("model", "HMM Trained Model").Short('m').Required().String()
	text  = kingpin.Flag("text", "Text to process").Short('t').Required().String()
)

func main() {
	kingpin.Parse()
	if *train {
		println("START")
		start := time.Now().UnixNano()
		ptrain := NewHMMParser("training/training.set")
		println("Training set loaded")
		ptrain.fParseTrainer()
		println("Training set trained")
		ptrain.Save()
		stop := time.Now().UnixNano()
		println("training delta", (stop-start)/1000, "mics")
	} else {
		println("Loading model " + *model)
		hmmParser := NewHMMParser(*model)
		hmmParser.Load()
Exemplo n.º 22
0
	"strings"
	"time"
)

const (
	baseUrl = "http://169.254.169.254" // no trailing slash '/'
)

var (
	credsRegex *regexp.Regexp = regexp.MustCompile("^/(.+?)/meta-data/iam/security-credentials/(.*)$")

	instanceServiceClient *http.Transport = &http.Transport{}
)

var (
	defaultRole = RoleArnOpt(kingpin.
			Flag("default-iam-role", "ARN of the role to use if the container does not specify a role.").
			Short('r'))

	serverAddr = kingpin.
			Flag("server", "Interface and port to bind the server to.").
			Default(":18000").
			Short('s').
			String()

	verboseOpt = kingpin.
			Flag("verbose", "Enable verbose output.").
			Bool()
)

type MetadataCredentials struct {
	Code            string
Exemplo n.º 23
0
package main

import (
	"encoding/json"
	log "github.com/Sirupsen/logrus"
	"github.com/alecthomas/kingpin"
	"github.com/ceph/go-ceph/rados"
	"io"
	"os"
)

var (
	conf    = kingpin.Flag("conf", "path to configuration file").Short('c').Default("/etc/ceph/ceph.conf").String()
	logfile = kingpin.Flag("log", "path to logfile").Default("/var/log/ceph-monitoring.log").String()
)

// Simple wrapper function to get rados connection handle
func GetRadosHandle(conf string) (conn *rados.Conn, err error) {
	conn, err = rados.NewConn()
	if err != nil {
		return nil, err
	}

	conn.ReadConfigFile(conf)
	err = conn.Connect()
	return conn, err
}

// Get a report for cluster
func GetClusterReport(conf string) {
Exemplo n.º 24
0
func main() {
	cfg := new(initCfg)
	kingpin.Flag("n", "number of ipfs nodes to initialize").Short('n').IntVar(&cfg.Count)
	kingpin.Flag("port", "port to start allocations from").Default("4002").Short('p').IntVar(&cfg.PortStart)
	kingpin.Flag("force", "force initialization (overwrite existing configs)").Short('f').BoolVar(&cfg.Force)
	kingpin.Flag("mdns", "turn on mdns for nodes").BoolVar(&cfg.Mdns)
	kingpin.Flag("bootstrap", "select bootstrapping style for cluster").Default("star").StringVar(&cfg.Bootstrap)
	kingpin.Flag("utp", "use utp for addresses").BoolVar(&cfg.Utp)

	wait := kingpin.Flag("wait", "wait for nodes to come fully online before exiting").Bool()

	var args []string
	kingpin.Arg("args", "arguments").StringsVar(&args)
	kingpin.Parse()

	if len(args) == 0 {
		kingpin.Usage()
		return
	}

	switch args[0] {
	case "init":
		if cfg.Count == 0 {
			fmt.Printf("please specify number of nodes: '%s init -n 10'\n", os.Args[0])
			os.Exit(1)
		}
		err := IpfsInit(cfg)
		handleErr("ipfs init err: ", err)
	case "start":
		err := IpfsStart(*wait)
		handleErr("ipfs start err: ", err)
	case "stop", "kill":
		if len(args) > 1 {
			i, err := strconv.Atoi(args[1])
			if err != nil {
				fmt.Println("failed to parse node number: ", err)
				os.Exit(1)
			}
			err = KillNode(i)
			if err != nil {
				fmt.Println("failed to kill node: ", err)
			}
			return
		}
		err := IpfsKillAll()
		handleErr("ipfs kill err: ", err)
	case "restart":
		err := IpfsKillAll()
		handleErr("ipfs kill err: ", err)

		err = IpfsStart(*wait)
		handleErr("ipfs start err: ", err)
	case "shell":
		if len(args) < 2 {
			fmt.Println("please specify which node you want a shell for")
			os.Exit(1)
		}
		n, err := strconv.Atoi(args[1])
		handleErr("parse err: ", err)

		err = IpfsShell(n)
		handleErr("ipfs shell err: ", err)
	case "connect":
		if len(args) < 3 {
			fmt.Println("iptb connect [node] [node]")
			os.Exit(1)
		}

		from, err := parseRange(args[1])
		if err != nil {
			fmt.Printf("failed to parse: %s\n", err)
			return
		}

		to, err := parseRange(args[2])
		if err != nil {
			fmt.Printf("failed to parse: %s\n", err)
			return
		}

		for _, f := range from {
			for _, t := range to {
				err = ConnectNodes(f, t)
				if err != nil {
					fmt.Printf("failed to connect: %s\n", err)
					return
				}
			}
		}

	case "get":
		if len(args) < 3 {
			fmt.Println("iptb get [attr] [node]")
			os.Exit(1)
		}
		attr := args[1]
		num, err := strconv.Atoi(args[2])
		handleErr("error parsing node number: ", err)

		val, err := GetAttr(attr, num)
		handleErr("error getting attribute: ", err)
		fmt.Println(val)
	default:
		kingpin.Usage()
		fmt.Println(helptext)
		os.Exit(1)
	}
}
Exemplo n.º 25
0
// A curl-like HTTP command-line client.
package main

import (
	"errors"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"

	"github.com/alecthomas/kingpin"
)

var (
	timeout = kingpin.Flag("timeout", "Set connection timeout.").Short('t').Default("5s").Duration()
	headers = HTTPHeader(kingpin.Flag("headers", "Add HTTP headers to the request.").Short('H').PlaceHolder("HEADER=VALUE"))

	get         = kingpin.Command("get", "GET a resource.").Default()
	getFlag     = get.Flag("test", "Test flag").Bool()
	getURL      = get.Command("url", "Retrieve a URL.").Default()
	getURLURL   = getURL.Arg("url", "URL to GET.").Required().URL()
	getFile     = get.Command("file", "Retrieve a file.")
	getFileFile = getFile.Arg("file", "File to retrieve.").Required().ExistingFile()

	post           = kingpin.Command("post", "POST a resource.")
	postData       = post.Flag("data", "Key-value data to POST").Short('d').PlaceHolder("KEY:VALUE").StringMap()
	postBinaryFile = post.Flag("data-binary", "File with binary data to POST.").File()
	postURL        = post.Arg("url", "URL to POST to.").Required().URL()
)
	"github.com/alecthomas/kingpin"
	"github.com/magnusbaeck/logstash-filter-verifier/logging"
	"github.com/magnusbaeck/logstash-filter-verifier/logstash"
	"github.com/magnusbaeck/logstash-filter-verifier/testcase"
	"github.com/mattn/go-shellwords"
	oplogging "github.com/op/go-logging"
)

var (
	log = logging.MustGetLogger()

	loglevels = []string{"CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}

	// Flags
	diffCommand = kingpin.
			Flag("diff-command", "The command to run to compare two events. The command will receive the two files to compare as arguments.").
			Default("diff -u").
			String()
	loglevel = kingpin.
			Flag("loglevel", fmt.Sprintf("Set the desired level of logging (one of: %s).", strings.Join(loglevels, ", "))).
			Default("WARNING").
			Enum(loglevels...)
	logstashPath = kingpin.
			Flag("logstash-path", "Set the path to the Logstash executable.").
			Default("/opt/logstash/bin/logstash").
			ExistingFile()

	// Arguments
	testcasePath = kingpin.
			Arg("testcases", "Test case file or a directory containing one or more test case files.").
			Required().
Exemplo n.º 27
0
	"fmt"
	"io/ioutil"
	"os"
	"os/exec"
	"text/template"
	"time"

	log "github.com/Sirupsen/logrus"
	"github.com/alecthomas/kingpin"
	"k8s.io/kubernetes/pkg/api"
	client "k8s.io/kubernetes/pkg/client/unversioned"
	"k8s.io/kubernetes/pkg/labels"
)

var (
	cliPort    = kingpin.Flag("port", "Receive connection on this port").Default("80").String()
	cliMaster  = kingpin.Flag("master", "URL to the Kubernetes master host").Default("http://localhost").String()
	cliRefresh = kingpin.Flag("refresh", "How long to wait before querying the Kubernetes API again").Default("15s").String()
	cliConf    = kingpin.Flag("conf", "HAPRoxy config file").Default("/etc/haproxy/haproxy.cfg").String()
	cliPid     = kingpin.Flag("pid", "HAPRoxy pid file").Default("/var/run/haproxy.pid").String()
)

func main() {
	kingpin.Parse()

	var oldBuf string

	// Create a client which we can use to connect to the remote Kubernetes cluster.
	config := &client.Config{
		Host: *cliMaster,
	}
	"path/filepath"
	"strings"

	"github.com/alecthomas/kingpin"
	"github.com/magnusbaeck/logstash-filter-verifier/logging"
	"github.com/magnusbaeck/logstash-filter-verifier/logstash"
	"github.com/magnusbaeck/logstash-filter-verifier/testcase"
	"github.com/mattn/go-shellwords"
	oplogging "github.com/op/go-logging"
)

var (
	loglevels = []string{"CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}

	// Flags
	diffCommand = kingpin.
			Flag("diff-command", "Set the command to run to compare two events. The command will receive the two files to compare as arguments.").
			Default("diff -u").
			String()
	keptEnvVars = kingpin.
			Flag("keep-env", "Add this environment variable to the list of variables that will be preserved from the calling process's environment. Defaults to an empty list, except TZ which will be set to \"UTC\".").
			PlaceHolder("VARNAME").
			Strings()
	loglevel = kingpin.
			Flag("loglevel", fmt.Sprintf("Set the desired level of logging (one of: %s).", strings.Join(loglevels, ", "))).
			Default("WARNING").
			Enum(loglevels...)
	logstashPath = kingpin.
			Flag("logstash-path", "Set the path to the Logstash executable.").
			Default("/opt/logstash/bin/logstash").
			String()
Exemplo n.º 29
0
package main

import (
	"fmt"

	"github.com/alecthomas/kingpin"
)

var (
	debug   = kingpin.Flag("debug", "Enable debug mode.").Bool()
	timeout = kingpin.Flag("timeout", "Timeout waiting for ping.").OverrideDefaultFromEnvar("PING_TIMEOUT").Required().Short('t').Duration()
	ip      = kingpin.Arg("ip", "IP address to ping.").Required().IP()
	count   = kingpin.Arg("count", "Number of packets to send").Int()
)

func main() {
	kingpin.Version("0.0.1")
	kingpin.Parse()
	fmt.Printf("Would ping: %s with timeout %s and count %d", *ip, *timeout, *count)
}
Exemplo n.º 30
0
	"net/http"

	"log"

	"os"

	"github.com/alecthomas/kingpin"
	"github.com/gorilla/mux"
	"github.com/skarnecki/gotail/frontend"
	"github.com/skarnecki/gotail/pump"
	"golang.org/x/net/websocket"
)

var (
	filename = kingpin.Arg("filename", "Path to tailed file.").Required().ExistingFile()
	number   = kingpin.Flag("number", "Starting lines number.").Default("10").Int()
	host     = kingpin.Flag("host", "Listening host, default 0.0.0.0").Default("0.0.0.0").IP()
	port     = kingpin.Flag("port", "listening port, default 9001").Default("9001").Int()
	cert     = kingpin.Flag("cert", "path to cert file (HTTPS)").ExistingFile()
	key      = kingpin.Flag("key", "path to key file (HTTPS)").ExistingFile()
	user     = kingpin.Flag("user", "Basic auth user").String()
	password = kingpin.Flag("password", "Basic auth password").String()
)

func main() {
	logger := log.New(os.Stdout, "logger: ", log.Lshortfile)
	kingpin.Parse()
	filechannel := make(chan string, 100)
	go pump.TailFile(filechannel, *filename)

	mainpage := &frontend.MainPage{HTTPSMode: false, BasicAuth: false, UserName: *user, UserPassword: *password}