func Test_Journal_GetJournal(t *testing.T) {
	logging.InitForTesting(logging.NOTICE)
	logger := logging.MustGetLogger("journal")
	tempDir, err := ioutil.TempDir("", "journal")
	if err != nil {
		t.FailNow()
	}
	defer os.RemoveAll(tempDir)
	factory := NewFileJournalGroupFactory(
		logger,
		rand.NewSource(0),
		func() time.Time { return time.Date(2014, 1, 1, 0, 0, 0, 0, time.UTC) },
		".log",
		os.FileMode(0644),
		0,
	)
	dummyWorker := &DummyWorker{}
	tempFile := filepath.Join(tempDir, "test")
	t.Log(tempFile)
	journalGroup, err := factory.GetJournalGroup(tempFile, dummyWorker)
	if err != nil {
		t.FailNow()
	}
	journal1 := journalGroup.GetJournal("key")
	if journal1 == nil {
		t.FailNow()
	}
	journal2 := journalGroup.GetJournal("key")
	if journal2 == nil {
		t.Fail()
	}
	if journal1 != journal2 {
		t.Fail()
	}
}
Exemple #2
0
func init() {
	Logger = gologging.MustGetLogger("netspel")
	format := gologging.MustStringFormatter("%{time:2006-01-02T15:04:05.000000Z} %{level} %{message}")
	backend := gologging.NewLogBackend(os.Stdout, "", 0)
	backendFormatter := gologging.NewBackendFormatter(backend, format)
	LogLevel = gologging.AddModuleLevel(backendFormatter)
	gologging.SetBackend(LogLevel)
}
Exemple #3
0
func init() {
	backend := logging.NewLogBackend(os.Stderr, "", 0)
	logging.SetBackend(backend)
	formatter := logging.MustStringFormatter("[%{time:15:04:05.000}] %{shortfile:18s}: %{color}[%{level:-5s}]%{color:reset} %{message}")
	logging.SetFormatter(formatter)
	logger = logging.MustGetLogger("orderer/kafka")
	logging.SetLevel(logging.INFO, "") // Silence debug-level outputs when testing
}
Exemple #4
0
func CreateLogger() *go_logging.Logger {
	var logger = go_logging.MustGetLogger("vamp-gateway-agent")
	var backend = go_logging.NewLogBackend(io.Writer(os.Stdout), "", 0)
	backendFormatter := go_logging.NewBackendFormatter(backend, go_logging.MustStringFormatter(
		"%{color}%{time:15:04:05.000} %{shortpkg:.4s} %{level:.4s} ==> %{message} %{color:reset}",
	))
	go_logging.SetBackend(backendFormatter)
	return logger
}
Exemple #5
0
func New(token string) *SlackBot {
	return &SlackBot{
		log:        logging.MustGetLogger("slackbot"),
		token:      token,
		api:        slack.New(token),
		chSender:   make(chan slack.OutgoingMessage),
		channelMap: make(map[string]string),
		userMap:    make(map[string]string),
	}
}
func Test_Journal_EmitRotating(t *testing.T) {
	logging.InitForTesting(logging.NOTICE)
	logger := logging.MustGetLogger("journal")
	tempDir, err := ioutil.TempDir("", "journal")
	if err != nil {
		t.FailNow()
	}
	defer os.RemoveAll(tempDir)
	factory := NewFileJournalGroupFactory(
		logger,
		rand.NewSource(0),
		func() time.Time { return time.Date(2014, 1, 1, 0, 0, 0, 0, time.UTC) },
		".log",
		os.FileMode(0644),
		8,
	)
	dummyWorker := &DummyWorker{}
	tempFile := filepath.Join(tempDir, "test")
	t.Log(tempFile)
	journalGroup, err := factory.GetJournalGroup(tempFile, dummyWorker)
	if err != nil {
		t.FailNow()
	}
	journal := journalGroup.GetFileJournal("key")
	defer journal.Dispose()
	err = journal.Write([]byte("test1"))
	if err != nil {
		t.FailNow()
	}
	err = journal.Write([]byte("test2"))
	if err != nil {
		t.FailNow()
	}
	err = journal.Write([]byte("test3"))
	if err != nil {
		t.FailNow()
	}
	err = journal.Write([]byte("test4"))
	if err != nil {
		t.FailNow()
	}
	err = journal.Write([]byte("test5"))
	if err != nil {
		t.FailNow()
	}
	t.Logf("journal.chunks.count=%d", journal.chunks.count)
	t.Logf("journal.chunks.first.Size=%d", journal.chunks.first.Size)
	if journal.chunks.count != 5 {
		t.Fail()
	}
	if journal.chunks.first.Size != 5 {
		t.Fail()
	}
}
Exemple #7
0
func TestParmsLog(t *testing.T) {
	Convey("Testing log()", t, func() {
		tests := []struct {
			dbug bool
			name string
			str  string
			verb bool
		}{
			{name: "Info", str: "This is a log.Info test", dbug: false, verb: true},
			{name: "Debug", str: "This is a log.Debug test", dbug: true, verb: false},
			{name: "Debug & Info", str: "This is both a log.Debug and log.Info test ", dbug: true, verb: true},
			{name: "Both Debug or Info", str: "This is both a log.Debug and log.Info test and there should be output", dbug: true, verb: true},
			{name: "Neither Debug or Info", str: "This is both a log.Debug and log.Info test and there shouldn't be any output", dbug: false, verb: false},
		}

		var (
			scrFmt = logging.MustStringFormatter(`%{level:.4s}[%{id:03x}] ▶ %{message}`)

			act      = &bytes.Buffer{}
			p        = &Parms{Logger: logging.MustGetLogger("TestParmsLog"), Verb: true}
			scr      = logging.NewLogBackend(act, "", 0)
			scrFmttr = logging.NewBackendFormatter(scr, scrFmt)
		)

		logging.SetBackend(scrFmttr)

		for i, tt := range tests {
			Convey("Testing "+tt.name, func() {
				p.Dbug = tt.dbug
				p.Verb = tt.verb

				switch {
				case tt.dbug:
					p.debug(tt.str)
					So(act.String(), ShouldEqual, fmt.Sprintf("DEBU[00%d] ▶ %v\n", i+1, tt.str))
				case tt.verb:
					p.log(tt.str)
					So(act.String(), ShouldEqual, fmt.Sprintf("INFO[00%d] ▶ %v\n", i+1, tt.str))
				case tt.dbug && tt.verb:
					exp := fmt.Sprintf("DEBU[00%d] ▶ %v\n", i+1, tt.str)
					exp += fmt.Sprintf("INFO[00%d] ▶ %v\n", i+1, tt.str)
					p.debug(tt.str)
					p.log(tt.str)
					So(act.String(), ShouldEqual, exp)
				default:
					p.debug(tt.str)
					p.log(tt.str)
					So(act.String(), ShouldEqual, "")
				}
				act.Reset()
			})
		}
	})
}
Exemple #8
0
func (lc *LoggerConfig) newGoLogger() *gol.Logger {
	// Leveled formatted file backend.
	backend := gol.AddModuleLevel(
		gol.NewBackendFormatter(
			gol.NewLogBackend(lc.Out, "", 0),
			gol.MustStringFormatter(lc.Format)))
	backend.SetLevel(lc.Level, "")
	logger := gol.MustGetLogger("")
	logger.SetBackend(backend)
	return logger
}
Exemple #9
0
func setLogger() *logging.Logger {
	var log = logging.MustGetLogger("beano")
	var format = logging.MustStringFormatter(
		"%{color}%{time:15:04:05.000000} %{level:.5s} %{id:04d}%{color:reset} %{message}",
	)
	var logBackend = logging.NewLogBackend(os.Stdout, "", 0)
	//	bel := logging.AddModuleLevel(logBackend)
	//	bel.SetLevel(logging.ERROR, "")
	var bf = logging.NewBackendFormatter(logBackend, format)
	logging.SetBackend(bf)
	return log
}
Exemple #10
0
func init() {
	Log = Logger{
		log: gologging.MustGetLogger("default"),
	}

	format := gologging.MustStringFormatter(`%{shortfile} %{color} %{time:2006-01-02T15:04:05.000000Z} %{level:.4s} %{color:reset} %{message}`)
	backend := gologging.NewLogBackend(os.Stdout, "", 0)
	backendFormatter := gologging.NewBackendFormatter(backend, format)
	leveledBackend = gologging.AddModuleLevel(backendFormatter)
	gologging.SetBackend(leveledBackend)
	SetLogLevel(SILENT)
}
Exemple #11
0
func init() {

	Log = Logger{
		log: gologging.MustGetLogger(defaultModule),
	}
	Log.log.ExtraCalldepth = 1
	format = gologging.MustStringFormatter("%{time:2006-01-02T15:04:05.000000Z} %{shortfunc:.6s} %{level}: %{message}")
	backend := gologging.NewLogBackend(os.Stdout, "", 0)
	backendFormatter := gologging.NewBackendFormatter(backend, format)
	leveledBackend := gologging.AddModuleLevel(backendFormatter)
	backends = append(backends, leveledBackend)
	gologging.SetBackend(backends...)
	SetLevel(SILENT)
}
Exemple #12
0
// GetLog gets log handler
func GetLog(level logging.Level) (l *logging.Logger) {
	l = logging.MustGetLogger("ghostbox")
	var customLogFormat = logging.MustStringFormatter(
		"%{color}%{time:2006-01-02 15:04:05.000} %{level:.4s} %{shortfunc:16s} ▶ %{id:03x}%{color:reset} %{message}",
	)
	backend1 := logging.NewLogBackend(os.Stderr, "", 0)
	backend2 := logging.NewLogBackend(os.Stdout, "", 0)
	backend2Formatter := logging.NewBackendFormatter(backend2, customLogFormat)
	backend1Leveled := logging.AddModuleLevel(backend1)
	backend1Leveled.SetLevel(logging.ERROR, "")
	backend2Leveled := logging.AddModuleLevel(backend2Formatter)
	backend2Leveled.SetLevel(level, "") // 0=crit 1=err 2=warn 3=notice 4=info 5=debug
	logging.SetBackend(backend1Leveled, backend2Leveled)
	return
}
func TestMap(t *testing.T) {
	var log = logging.MustGetLogger("TestMap")

	runtime.GOMAXPROCS(1)
	//	runtime.GOMAXPROCS(runtime.NumCPU())
	fmt.Println(runtime.GOMAXPROCS(0))
	fmt.Println("CPU Count : ", runtime.NumCPU())

	log.Debugf("start~~")
	//var Apiurl = "http://dhcapi.local.xdn.com/dhc/5/cloud/jobs?site=nuq2"

	ExampleLookPath()
	//ExampleCommand()
	ExampleCmd_Output()
	ExampleCmd_Start()
	ExampleCmd_StdoutPipe()
}
Exemple #14
0
func main() {
	app := cli.NewApp()
	app.Name = "mdp"
	app.Usage = "Generate organized html documentation from markdown files with a toml preamble"
	var outDir, inDir string
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:        "out",
			Value:       "./public",
			Usage:       "Directory to output the generated html pages",
			Destination: &outDir,
		},
		cli.StringFlag{
			Name:        "in",
			Value:       ".",
			Usage:       "Directory to read the project inside.",
			Destination: &inDir,
		},
	}

	app.Action = func(c *cli.Context) {
		log := logging.MustGetLogger("mdp")
		log.Infof("Parsing directory %v", inDir)
		node, err := ParseTopDirectory(inDir)
		if err != nil {
			log.Fatalf("Error parsing directory: %v", err)
		}
		// Create output directory if it doesn't exist
		if _, err = os.Stat(outDir); err != nil {
			if os.IsNotExist(err) {
				os.Mkdir(outDir, 0744)
			} else {
				log.Fatalf("Unknown error inspecting output directory: %v", err)
			}
		}
		err = RenderTopNode(outDir, node)
		if err != nil {
			log.Fatalf("Error rendering output: %v", err)
		}
	}

	app.Run(os.Args)
}
Exemple #15
0
func main() {
	var loglevel string

	client := &clientImpl{doneChan: make(chan struct{})}

	backend := logging.NewLogBackend(os.Stderr, "", 0)
	logging.SetBackend(backend)
	formatter := logging.MustStringFormatter("[%{time:15:04:05}] %{shortfile:18s}: %{color}[%{level:-5s}]%{color:reset} %{message}")
	logging.SetFormatter(formatter)
	logger = logging.MustGetLogger(pkgName)

	flag.StringVar(&loglevel, "loglevel", "info",
		"The logging level. (Suggested values: info, debug)")
	flag.StringVar(&client.config.server, "server",
		"127.0.0.1:7050", "The RPC server to connect to.")
	flag.StringVar(&client.config.cmd.cmd, "cmd", "new-chain",
		"The action that this client is requesting via the config transaction.")
	flag.StringVar(&client.config.cmd.args.creationPolicy, "creationPolicy", "AcceptAllPolicy",
		"In case of a new-chain command, the chain createion policy this request should be validated against.")
	flag.StringVar(&client.config.cmd.args.chainID, "chainID", "NewChainID",
		"In case of a new-chain command, the chain ID to create.")
	flag.Parse()

	client.config.logLevel, _ = logging.LogLevel(strings.ToUpper(loglevel))
	logging.SetLevel(client.config.logLevel, logger.Module)

	conn, err := grpc.Dial(client.config.server, grpc.WithInsecure())
	if err != nil {
		logger.Fatalf("Client did not connect to %s: %v", client.config.server, err)
	}
	defer conn.Close()
	client.rpc = ab.NewAtomicBroadcastClient(conn)

	switch client.config.cmd.cmd {
	case "new-chain":
		envelope := newChainRequest(client.config.cmd.args.creationPolicy, client.config.cmd.args.chainID)
		logger.Infof("Requesting the creation of chain \"%s\"", client.config.cmd.args.chainID)
		client.broadcast(envelope)
	default:
		panic("Invalid cmd given")
	}
}
Exemple #16
0
func getLogger(name string, logConfig LogConfig) *logger.Logger {
	mainLogger.Info("Make logger of %s at file %s", name, logConfig.Filename)
	log1 := logger.MustGetLogger(name)

	var leveledBackend logger.LeveledBackend
	f, err := logger.NewStringFormatter("%{shortfile} %{time:2006-01-02T15:04:05} %{level:.1s} %{id:04d} %{module} %{message}")
	if err != nil {
		mainLogger.Info("failed to set format: %s", err)
	}
	logger.SetFormatter(f)

	if logConfig.Filename != "" {
		logFileName := logConfig.Filename

		logFile, err := os.OpenFile(logFileName, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0660)
		backend := logger.NewLogBackend(logFile, "", 0)
		if err != nil {
			mainLogger.Error("Failed to open log file - " + logFileName)
			panic(err)
		} else {
			leveledBackend = logger.AddModuleLevel(backend)
		}
	} else {
		backend := logger.NewLogBackend(os.Stdout, "", 0)
		leveledBackend = logger.AddModuleLevel(backend)

	}

	switch logConfig.Level {
	case "debug":
		leveledBackend.SetLevel(logger.NOTICE, name)
	case "error":
		logger.SetLevel(logger.ERROR, name)
	case "info":
		logger.SetLevel(logger.INFO, name)
	case "warn":
		logger.SetLevel(logger.WARNING, name)
	}

	log1.SetBackend(leveledBackend)
	return log1
}
func BenchmarkGologgingTextPositive(b *testing.B) {
	stream := &blackholeStream{}
	logger := log.MustGetLogger("")
	subBackend := log.NewLogBackend(stream, "", 0)
	formatter := log.MustStringFormatter("%{time:2006-01-02T15:04:05Z07:00} %{level} %{message}")
	backend := log.NewBackendFormatter(subBackend, formatter)
	leveled := log.AddModuleLevel(backend)
	logger.SetBackend(leveled)
	b.ResetTimer()

	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			logger.Info("The quick brown fox jumps over the lazy dog")
		}
	})

	if stream.WriteCount() != uint64(b.N) {
		b.Fatalf("Log write count")
	}
}
Exemple #18
0
func newLog() (*logging.Logger, error) {
	fdFmt := logging.MustStringFormatter(
		`%{level:.4s}[%{id:03x}]%{time:2006-01-02 15:04:05.000} ▶ %{message}`,
	)

	scrFmt := logging.MustStringFormatter(
		`%{color:bold}%{level:.4s}%{color:reset}[%{id:03x}]%{time:15:04:05.000} ▶ %{message}`,
	)

	fd, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
	fdlog := logging.NewLogBackend(fd, "", 0)
	fdFmttr := logging.NewBackendFormatter(fdlog, fdFmt)

	scr := logging.NewLogBackend(os.Stderr, "", 0)
	scrFmttr := logging.NewBackendFormatter(scr, scrFmt)

	logging.SetBackend(fdFmttr, scrFmttr)

	return logging.MustGetLogger(basename(os.Args[0])), err
}
Exemple #19
0
func TestApi_CreateAPI(t *testing.T) {

	log := gologger.MustGetLogger("vamp-router")

	sseChannel := make(chan metrics.Metric)

	sseBroker := &metrics.SSEBroker{
		make(map[chan metrics.Metric]bool),
		make(chan (chan metrics.Metric)),
		make(chan (chan metrics.Metric)),
		sseChannel,
		log,
	}

	haConfig := haproxy.Config{TemplateFile: TEMPLATE_FILE, ConfigFile: CONFIG_FILE, JsonFile: JSON_FILE, PidFile: PID_FILE}
	haRuntime := haproxy.Runtime{Binary: helpers.HaproxyLocation()}

	if _, err := CreateApi(log, &haConfig, &haRuntime, sseBroker, "v.test"); err != nil {
		t.Errorf("Failed to create API")
	}

}
Exemple #20
0
func ConfigureLog(logPath string, headless bool) *gologging.Logger {

	var log = gologging.MustGetLogger("vamp-router")
	var backend *gologging.LogBackend
	var format = gologging.MustStringFormatter(
		"%{color}%{time:15:04:05.000} %{shortpkg:.4s} %{level:.4s} ==> %{color:reset} %{message}",
	)

	// mix in the Lumberjack logger so we can have rotation on log files
	if headless {

		if len(logPath) > 0 {
			backend = gologging.NewLogBackend(io.MultiWriter(&lumberjack.Logger{
				Filename:   logPath,
				MaxSize:    50, // megabytes
				MaxBackups: 2,  //days
				MaxAge:     14,
			}), "", 0)
		}

	} else {

		if len(logPath) > 0 {
			backend = gologging.NewLogBackend(io.MultiWriter(&lumberjack.Logger{
				Filename:   logPath,
				MaxSize:    50, // megabytes
				MaxBackups: 2,  //days
				MaxAge:     14,
			}, os.Stdout), "", 0)
		}
	}

	backendFormatter := gologging.NewBackendFormatter(backend, format)
	gologging.SetBackend(backendFormatter)

	return log

}
Exemple #21
0
package middleware

import (
	"net/http"
	"strings"
	"time"

	"github.com/go-martini/martini"
	golog "github.com/op/go-logging"
)

var log = golog.MustGetLogger("middleware")

func getRequestIp(request *http.Request) string {
	// prefer to use X-Real-Ip
	realIp := request.Header.Get("X-Real-Ip")
	if realIp != "" {
		return realIp
	}

	// use X-Forwared-For as a backup
	// https://en.wikipedia.org/wiki/X-Forwarded-For
	forwardedForIp := request.Header.Get("X-Forwarded-For")
	if forwardedForIp != "" {
		return strings.Split(forwardedForIp, ", ")[0]
	}

	return request.RemoteAddr
}

// Logger returns a middleware handler that logs the request as it goes in and
Exemple #22
0
package table

import logging "github.com/op/go-logging"

var log = logging.MustGetLogger("table") // for tests. overridden by main

func SetLogger(l *logging.Logger) {
	log = l
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
Exemple #23
0
package api

import (
	"encoding/json"
	"fmt"

	logging "github.com/op/go-logging"
	"github.com/skycoin/skycoin-exchange/src/sknet"
	"github.com/skycoin/skycoin/src/cipher"
)

var logger = logging.MustGetLogger("exchange.api")

func getRequest(c *sknet.Context, out interface{}) error {
	d := c.MustGet("rawdata").([]byte)
	return json.Unmarshal(d, out)
}

// ReqParams records the request params
type ReqParams struct {
	Values map[string]interface{}
}

// NewReqParams make and init the ReqParams.
func NewReqParams() *ReqParams {
	return &ReqParams{
		Values: make(map[string]interface{}),
	}
}

func validatePubkey(key string) (err error) {
Exemple #24
0
	"github.com/hyperledger/fabric/core/ledger/blkstorage"
	"github.com/hyperledger/fabric/core/ledger/blkstorage/fsblkstorage"
	"github.com/hyperledger/fabric/core/ledger/history"
	"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/couchdbtxmgmt"
	"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/stateleveldb"
	"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr"
	"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr"
	"github.com/hyperledger/fabric/core/ledger/ledgerconfig"

	logging "github.com/op/go-logging"

	"github.com/hyperledger/fabric/protos/common"
	pb "github.com/hyperledger/fabric/protos/peer"
)

var logger = logging.MustGetLogger("kvledger")

// Conf captures `KVLedger` configurations
type Conf struct {
	blockStorageDir  string
	maxBlockfileSize int
	txMgrDBPath      string
}

// NewConf constructs new `Conf`.
// filesystemPath is the top level directory under which `KVLedger` manages its data
func NewConf(filesystemPath string, maxBlockfileSize int) *Conf {
	if !strings.HasSuffix(filesystemPath, "/") {
		filesystemPath = filesystemPath + "/"
	}
	blocksStorageDir := filesystemPath + "blocks"
Exemple #25
0
package client

import (
	"fmt"
	"net"
	"net/http"
	"net/url"
	"strings"

	common "github.com/cilium/cilium/common"

	l "github.com/op/go-logging"
	"gopkg.in/resty.v0"
)

var log = l.MustGetLogger("cilium-net-client")

func init() {
	common.SetupLOG(log, "DEBUG")
}

// Client has the internal details necessary to talk with the daemon.
type Client struct {
	*resty.Client
}

// NewDefaultClient creates and returns a client that will talk with common.CiliumStock.
func NewDefaultClient() (*Client, error) {
	return NewClient("unix://"+common.CiliumSock, nil)
}
Exemple #26
0
	"github.com/cilium/cilium/common"
	cnc "github.com/cilium/cilium/common/client"
	"github.com/cilium/cilium/pkg/bpf"
	"github.com/cilium/cilium/pkg/endpoint"
	"github.com/cilium/cilium/pkg/labels"
	"github.com/cilium/cilium/pkg/option"
	"github.com/cilium/cilium/pkg/policy"

	"github.com/codegangsta/cli"
	l "github.com/op/go-logging"
)

var (
	CliCommand cli.Command
	client     *cnc.Client
	log        = l.MustGetLogger("cilium-tools-endpoint")
)

func init() {
	CliCommand = cli.Command{
		Name:   "endpoint",
		Usage:  "Manage endpoint operations",
		Before: initEnv,
		Subcommands: []cli.Command{
			{
				Name:         "detach",
				Usage:        "Detaches BPF program from endpoint",
				Action:       detachBPF,
				BashComplete: listEndpointsBash,
				ArgsUsage:    "<endpoint>",
				Before:       verifyArguments,
// Copyright (c) 2015-2016 Magnus Bäck <*****@*****.**>

package logging

import (
	oplogging "github.com/op/go-logging"
)

const (
	logModule = "logstash-filter-verifier"
)

var (
	log = oplogging.MustGetLogger(logModule)
)

// MustGetLogger returns the application's default logger.
func MustGetLogger() *oplogging.Logger {
	return log
}

// SetLevel sets the desired log level for the default logger.
func SetLevel(level oplogging.Level) {
	oplogging.SetLevel(level, logModule)
}
Exemple #28
0
import (
	"errors"
	logging "github.com/op/go-logging"
)

var AlreadyRegistered = errors.New("Plugin already registered")

type Event func(Info)

type Registrar struct {
	plugins map[string]Info
	ch      chan regRequest
	onReg   Event
}

var regLog = logging.MustGetLogger("registrar")

type Info struct {
	Name    string
	Network string
	Path    string
	Service string
}

type regReply struct {
	err    error
	cookie string
}

type regRequest struct {
	Info
Exemple #29
0
)

type Address struct {
	IPNet   net.IPNet
	Gateway net.IP
}

type Route struct {
	IPNet   net.IPNet
	Gateway net.IP
	Metric  string
}

var (
	softwareType    = ""
	ErrAuthRequired = errors.New("sudo authentication required")
	logger          = logging.MustGetLogger("darknet.network")

	dhclient       = linux.NewDHClient()
	ifconfig       = linux.NewIFConfig()
	iwconfig       = linux.NewIWConfig()
	iwlist         = linux.NewIWList()
	networkmanager = linux.NewNetworkManager()
	resolvconf     = linux.NewResolvConf()
	rfkill         = linux.NewRFKill()
	route          = linux.NewRoute()
	sysfs          = linux.NewSysfs()
	udevadm        = linux.NewUDevAdm()
	wpasupplicant  = linux.NewWPASupplicant()
)
Exemple #30
0
	"bytes"
	"encoding/binary"
	"fmt"
	"os"
	"os/signal"
	"runtime"
	"syscall"

	"github.com/codegangsta/cli"
	l "github.com/op/go-logging"

	"github.com/cilium/cilium/pkg/bpf"
)

var (
	log        = l.MustGetLogger("cilium-cli")
	CliCommand cli.Command
	dissect    = false
	config     = bpf.PerfEventConfig{
		MapPath:      "/sys/fs/bpf/tc/globals/cilium_events",
		Type:         C.PERF_TYPE_SOFTWARE,
		Config:       C.PERF_COUNT_SW_BPF_OUTPUT,
		SampleType:   C.PERF_SAMPLE_RAW,
		WakeupEvents: 0,
	}
)

func lostEvent(lost *bpf.PerfEventLost, cpu int) {
	fmt.Printf("Lost %d events\n", lost.Lost)
}