Example #1
0
File: main.go Project: fln/httprc
func main() {
	clientCACertFile := flag.String("client-ca", "", "Enable client authentication using specified CA certificate")
	serverCertFile := flag.String("server-cert", "", "Server certificate for TLS mode")
	serverKeyFile := flag.String("server-key", "", "Server private key for TLS mode")
	listenClient := flag.String("listen-client", ":8989", "Address to listen for client connections")
	listenAdmin := flag.String("listen-admin", "127.0.0.1:8889", "Address to listen for admin connections")
	flag.Parse()

	/*	if *clientCACertFile == "" {
			log.Fatal("Missing \"client-ca\" flag")
		}

		if *serverCertFile == "" {
			log.Fatal("Missing \"server-cert\" flag")
		}

		if *serverKeyFile == "" {
			log.Fatal("Missing \"server-key\" flag")
		}*/

	app := RCServer{
		ClientMap: make(map[string]*Client),
		ps:        pubsub.New(10),
	}

	go app.startTLSAuth(*listenClient, *serverCertFile, *serverKeyFile, *clientCACertFile)
	go app.startAdminServer(*listenAdmin)
	select {}
	app.ps.Shutdown()
}
Example #2
0
func (srv *T) Init() error {
	err := os.MkdirAll(srv.Config.General.DataPath, os.ModeDir|0700)
	if err != nil {
		return err
	}
	database, err := db.NewDB(filepath.Join(srv.Config.General.DataPath, "db"))
	if err != nil {
		return err
	}
	srv.DB = database
	srv.Log = log15.New()
	srv.Router = pubsub.New(100)
	return nil
}
Example #3
0
File: bot.go Project: errows/slick
func New(configFile string) *Bot {
	bot := &Bot{
		configFile:    configFile,
		outgoingMsgCh: make(chan *slack.OutgoingMessage, 500),
		addListenerCh: make(chan *Listener, 500),
		delListenerCh: make(chan *Listener, 500),

		Users:    make(map[string]slack.User),
		Channels: make(map[string]Channel),

		PubSub: pubsub.New(500),
	}

	http.DefaultClient = &http.Client{
		Transport: &http.Transport{
			Proxy: http.ProxyFromEnvironment,
		},
	}

	return bot
}
Example #4
0
func (dep *Deployer) InitPlugin(bot *slick.Bot) {
	var conf struct {
		Deployer DeployerConfig
	}
	bot.LoadConfig(&conf)

	dep.bot = bot
	dep.pubsub = pubsub.New(100)
	dep.config = &conf.Deployer
	dep.env = os.Getenv("PLOTLY_ENV")

	if dep.env == "" {
		dep.env = "debug"
	}

	dep.loadInternalAPI()

	go dep.pubsubForwardReply()

	bot.ListenFor(&slick.Conversation{
		HandlerFunc:    dep.ChatHandler,
		MentionsMeOnly: true,
	})
}
Example #5
0
func initPubsub() {
	PushCenter = pubsub.New(100)
}