mongo

package
v0.0.0-...-9f6064c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Address that locates our postgres instance
	Host string
	// Port to connect to
	Port string
	// User that has access to the database
	User string
	// Password so that the user can login
	Password string
	// Database to connect to (must have been created priorly)
	Database string
}

Config holds the configuration used for instantiating a new Roach.

type OutlineUser

type OutlineUser struct {
	User string `json:"user" bson:"user"` // fruitice user

	ID     string `json:"id" bson:"id"`                   // outline user id
	Cipher string `json:"cipher" bson:"cipher"`           // outline cipher (e.g.: "chacha20-ietf-poly1305")
	Secret string `json:"secret,omitempty" bson:"secret"` // outline secret
}

type Roach

type Roach struct {
	Client *mongo.Client
	Db     *mongo.Database
	// contains filtered or unexported fields
}

Roach is a pointer to mongo connection

func New

func New(cfg Config) (roach Roach, err error)

New create an instance of Roach

func (*Roach) AddUser

func (r *Roach) AddUser(ctx context.Context, user *OutlineUser) (string, error)

AddUser for a fruitice user

func (*Roach) DeleteUser

func (r *Roach) DeleteUser(ctx context.Context, id string) error

DeleteUser deletes a proxy user

func (*Roach) GetToken

func (roach *Roach) GetToken(ctx context.Context, token string) (*Token, error)

GetToken return an usable Token object, empty

func (*Roach) GetUser

func (r *Roach) GetUser(ctx context.Context, id string) (*OutlineUser, error)

GetUser return an usable proxy user

func (*Roach) ListAllUsers

func (r *Roach) ListAllUsers(ctx context.Context) ([]*OutlineUser, error)

ListAllUsers list all outline users

func (*Roach) ListUsers

func (r *Roach) ListUsers(ctx context.Context, user string) ([]*OutlineUser, error)

ListUsers list all proxy users for a fruitice user

type Token

type Token struct {
	Token string   `json:"token" bson:"token"`
	User  string   `json:"user" bson:"user"`
	Scope []string `json:"scope" bson:"scope"`
}

Token is an access token stored in mongo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL