Documentation ¶
Index ¶
- Variables
- func AddKey(key *crypto.Key)
- func GetAllKeys() []crypto.Key
- func GetKeyBy(pred KeyPredicate) *crypto.Key
- func GetKeysBy(pred KeyPredicate) []crypto.Key
- func HasKey(key *crypto.Key) bool
- func LoadConfig(file string) error
- func RemoveKey(key *crypto.Key)
- func RemoveKeyBy(pred KeyPredicate)
- func Router() *mux.Router
- type Config
- type ConfigUser
- type KeyPredicate
- type StringFormatter
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = cli.Command{ Category: "Server", Name: "server", Usage: "Run the Inki server daemon", Flags: []cli.Flag{ cli.StringFlag{ Name: "config, c", Usage: "The configuration file to be used by this daemon", EnvVar: "INKI_CONFIG", Value: "/etc/inki/server.yml", }, cli.IntFlag{ Name: "port, P", Usage: "The port on which the Inki server should listen", EnvVar: "PORT", Value: 3000, }, }, Before: func(c *cli.Context) error { if c.IsSet("config") { err := LoadConfig(c.String("config")) if err != nil { log.WithError(err).Errorf("Failed to read configuration file '%s'", c.String("config, c")) return err } } else { log.Warn("No configuration file provided, using empty defaults") } return nil }, Action: func(c *cli.Context) error { port := c.Int("port") log.WithField("port", port).Info("Starting server") mux := http.NewServeMux() mux.Handle("/api/", http.StripPrefix("/api", Router())) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(404) w.Write([]byte(`{"code": 404, "error": "Not Found", "message": "The method you attempted to make use of could not be found on our system."}`)) }) return http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", port), cors.New(cors.Options{ AllowCredentials: true, AllowedOrigins: []string{"*"}, AllowedHeaders: []string{"Authorization", "Content-Type"}, AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"}, Debug: false, }).Handler(mux)) }, }
Functions ¶
func GetAllKeys ¶
func GetKeyBy ¶
func GetKeyBy(pred KeyPredicate) *crypto.Key
func GetKeysBy ¶
func GetKeysBy(pred KeyPredicate) []crypto.Key
func LoadConfig ¶
func RemoveKeyBy ¶
func RemoveKeyBy(pred KeyPredicate)
Types ¶
type Config ¶
type Config struct { Port int `yaml:"port"` Users []ConfigUser `yaml:"users"` }
func (*Config) GetUser ¶
func (c *Config) GetUser(name string) *ConfigUser
type ConfigUser ¶
func (*ConfigUser) GetKeyRing ¶
func (u *ConfigUser) GetKeyRing() (openpgp.KeyRing, error)
type KeyPredicate ¶
func FingerprintEquals ¶
func FingerprintEquals(fingerprint string) KeyPredicate
func KeyEquals ¶
func KeyEquals(key *crypto.Key) KeyPredicate
func KeyExpired ¶
func KeyExpired() KeyPredicate
func KeyValid ¶
func KeyValid() KeyPredicate
func UserEquals ¶
func UserEquals(user string) KeyPredicate
func (KeyPredicate) And ¶
func (p KeyPredicate) And(pred KeyPredicate) KeyPredicate
func (KeyPredicate) Or ¶
func (p KeyPredicate) Or(pred KeyPredicate) KeyPredicate
type StringFormatter ¶
type StringFormatter struct{}
Click to show internal directories.
Click to hide internal directories.