model

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIDNotString = errors.New("ID is not a string")
View Source
var (
	ErrUserNotFound = errors.New("user not found")
)

Functions

func CreatePeerInputToCreateOptions

func CreatePeerInputToCreateOptions(input CreatePeerInput) *peer.CreateOptions

func CreateServerInputToCreateServerOptions

func CreateServerInputToCreateServerOptions(input CreateServerInput) (_ *server.CreateOptions, err error)

func CreateUserInputToUserCreateUserOptions

func CreateUserInputToUserCreateUserOptions(createUserInput CreateUserInput) *user.CreateOptions

func MarshalDateTime

func MarshalDateTime(t time.Time) graphql.Marshaler

func PeerHookInputToPeerHook

func PeerHookInputToPeerHook(hook *PeerHookInput) *peer.Hook

func ServerHookInputToServerHook

func ServerHookInputToServerHook(hook *ServerHookInput) *server.Hook

func UnmarshalDateTime

func UnmarshalDateTime(v interface{}) (time.Time, error)

func UpdatePeerInputToUpdatePeerOptionsAndUpdatePeerFieldMask

func UpdatePeerInputToUpdatePeerOptionsAndUpdatePeerFieldMask(input UpdatePeerInput) (options *peer.UpdateOptions, fieldMask *peer.UpdateFieldMask)

func UpdateServerInputToUpdateOptionsAndUpdateFieldMask

func UpdateServerInputToUpdateOptionsAndUpdateFieldMask(input UpdateServerInput) (options *server.UpdateOptions, fieldMask *server.UpdateFieldMask, err error)

func UpdateUserInputToUserUpdateUserOptions

func UpdateUserInputToUserUpdateUserOptions(input UpdateUserInput) (*user.UpdateOptions, *user.UpdateFieldMask, error)

func UserToContext

func UserToContext(ctx context.Context, user *User, err error) context.Context

Types

type CreatePeerInput

type CreatePeerInput struct {
	ClientMutationID    graphql.Omittable[*string]          `json:"clientMutationId,omitempty"`
	ServerID            ID                                  `json:"serverId"`
	Name                string                              `json:"name"`
	Description         graphql.Omittable[*string]          `json:"description,omitempty"`
	PublicKey           string                              `json:"publicKey"`
	AllowedIPs          []string                            `json:"allowedIPs"`
	Endpoint            graphql.Omittable[*string]          `json:"endpoint,omitempty"`
	PresharedKey        graphql.Omittable[*string]          `json:"presharedKey,omitempty"`
	PersistentKeepalive graphql.Omittable[*int]             `json:"persistentKeepalive,omitempty"`
	Hooks               graphql.Omittable[[]*PeerHookInput] `json:"hooks,omitempty"`
}

type CreatePeerPayload

type CreatePeerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Peer             *Peer   `json:"peer,omitempty"`
}

type CreateServerInput

type CreateServerInput struct {
	ClientMutationID graphql.Omittable[*string]            `json:"clientMutationId,omitempty"`
	Name             string                                `json:"name"`
	Description      graphql.Omittable[*string]            `json:"description,omitempty"`
	Enabled          graphql.Omittable[*bool]              `json:"enabled,omitempty"`
	PrivateKey       graphql.Omittable[*string]            `json:"privateKey,omitempty"`
	PublicKey        graphql.Omittable[*string]            `json:"publicKey,omitempty"`
	ListenPort       graphql.Omittable[*int]               `json:"listenPort,omitempty"`
	FirewallMark     graphql.Omittable[*int]               `json:"firewallMark,omitempty"`
	Address          string                                `json:"address"`
	DNS              graphql.Omittable[[]string]           `json:"dns,omitempty"`
	Mtu              graphql.Omittable[*int]               `json:"mtu,omitempty"`
	Hooks            graphql.Omittable[[]*ServerHookInput] `json:"hooks,omitempty"`
}

type CreateServerPayload

type CreateServerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Server           *Server `json:"server,omitempty"`
}

type CreateUserInput

type CreateUserInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	Email            string                     `json:"email"`
	Password         string                     `json:"password"`
}

type CreateUserPayload

type CreateUserPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	User             *User   `json:"user"`
}

type DeletePeerInput

type DeletePeerInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	ID               ID                         `json:"id"`
}

type DeletePeerPayload

type DeletePeerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Peer             *Peer   `json:"peer,omitempty"`
}

type DeleteServerInput

type DeleteServerInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	ID               ID                         `json:"id"`
}

type DeleteServerPayload

type DeleteServerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Server           *Server `json:"server,omitempty"`
}

type DeleteUserInput

type DeleteUserInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	ID               ID                         `json:"id"`
}

type DeleteUserPayload

type DeleteUserPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	User             *User   `json:"user,omitempty"`
}

type ForeignInterface

type ForeignInterface struct {
	Name      string   `json:"name"`
	Addresses []string `json:"addresses"`
	Mtu       int      `json:"mtu"`
}

func ToForeignInterface

func ToForeignInterface(foreignInterface *backend.ForeignInterface) *ForeignInterface

type ForeignPeer

type ForeignPeer struct {
	PublicKey                   string     `json:"publicKey"`
	Endpoint                    *string    `json:"endpoint,omitempty"`
	AllowedIps                  []string   `json:"allowedIps,omitempty"`
	PersistentKeepAliveInterval int        `json:"persistentKeepAliveInterval"`
	LastHandshakeTime           *time.Time `json:"lastHandshakeTime,omitempty"`
	ReceiveBytes                float64    `json:"receiveBytes"`
	TransmitBytes               float64    `json:"transmitBytes"`
	ProtocolVersion             int        `json:"protocolVersion"`
}

func ToForeignPeer

func ToForeignPeer(foreignPeer *backend.Peer) *ForeignPeer

type ForeignServer

type ForeignServer struct {
	ForeignInterface *ForeignInterface `json:"foreignInterface"`
	Name             string            `json:"name"`
	Type             string            `json:"type"`
	PublicKey        string            `json:"publicKey"`
	ListenPort       int               `json:"listenPort"`
	FirewallMark     int               `json:"firewallMark"`
	Peers            []*ForeignPeer    `json:"peers"`
}

func ToForeignServer

func ToForeignServer(foreignServer *backend.ForeignServer) *ForeignServer

type GenerateWireguardKeyInput

type GenerateWireguardKeyInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
}

type GenerateWireguardKeyPayload

type GenerateWireguardKeyPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	PrivateKey       string  `json:"privateKey"`
	PublicKey        string  `json:"publicKey"`
}

type ID

type ID struct {
	Kind  IdKind
	Value string
}

func StringID

func StringID(idKind IdKind, id string) ID

func (*ID) Base64

func (id *ID) Base64() string

func (ID) Equal

func (id ID) Equal(other ID) bool

func (ID) MarshalGQL

func (id ID) MarshalGQL(w io.Writer)

func (*ID) String

func (id *ID) String(idKind IdKind) (string, error)

func (*ID) UnmarshalGQL

func (id *ID) UnmarshalGQL(v interface{}) error

func (*ID) Validate

func (id *ID) Validate(idKind IdKind) error

type IdKind

type IdKind string
const (
	IdKindUser   IdKind = "User"
	IdKindServer IdKind = "Server"
	IdKindPeer   IdKind = "Peer"
)

func (IdKind) String

func (ik IdKind) String() string

type ImportForeignServerInput

type ImportForeignServerInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	Name             string                     `json:"name"`
}

type ImportForeignServerPayload

type ImportForeignServerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Server           *Server `json:"server,omitempty"`
}

type Node

type Node interface {
	IsNode()
	GetID() ID
}

type NodeChangedEvent

type NodeChangedEvent interface {
	IsNodeChangedEvent()
}

type Peer

type Peer struct {
	ID                  ID          `json:"id"`
	Server              *Server     `json:"server"`
	Name                string      `json:"name"`
	Description         string      `json:"description"`
	PublicKey           string      `json:"publicKey"`
	AllowedIPs          []string    `json:"allowedIPs,omitempty"`
	Endpoint            string      `json:"endpoint"`
	PresharedKey        string      `json:"presharedKey"`
	PersistentKeepalive *int        `json:"persistentKeepalive,omitempty"`
	Hooks               []*PeerHook `json:"hooks,omitempty"`
	Stats               *PeerStats  `json:"stats,omitempty"`
	CreateUser          *User       `json:"createUser,omitempty"`
	UpdateUser          *User       `json:"updateUser,omitempty"`
	DeleteUser          *User       `json:"deleteUser,omitempty"`
	CreatedAt           time.Time   `json:"createdAt"`
	UpdatedAt           time.Time   `json:"updatedAt"`
	DeletedAt           *time.Time  `json:"deletedAt,omitempty"`
}

func ToPeer

func ToPeer(peer *peer.Peer) *Peer

func (Peer) GetID

func (this Peer) GetID() ID

func (Peer) IsNode

func (Peer) IsNode()

type PeerChangedEvent

type PeerChangedEvent struct {
	Node   *Peer  `json:"node"`
	Action string `json:"action"`
}

func (PeerChangedEvent) IsNodeChangedEvent

func (PeerChangedEvent) IsNodeChangedEvent()

type PeerHook

type PeerHook struct {
	Command     string `json:"command"`
	RunOnCreate bool   `json:"runOnCreate"`
	RunOnUpdate bool   `json:"runOnUpdate"`
	RunOnDelete bool   `json:"runOnDelete"`
}

func ToPeerHook

func ToPeerHook(hook *peer.Hook) *PeerHook

type PeerHookInput

type PeerHookInput struct {
	Command     string `json:"command"`
	RunOnCreate bool   `json:"runOnCreate"`
	RunOnUpdate bool   `json:"runOnUpdate"`
	RunOnDelete bool   `json:"runOnDelete"`
}

type PeerStats

type PeerStats struct {
	LastHandshakeTime *time.Time `json:"lastHandshakeTime,omitempty"`
	ReceiveBytes      float64    `json:"receiveBytes"`
	TransmitBytes     float64    `json:"transmitBytes"`
	ProtocolVersion   int        `json:"protocolVersion"`
}

func ToPeerStats

func ToPeerStats(stats *backend.PeerStats) *PeerStats

type Server

type Server struct {
	ID             ID                    `json:"id"`
	Name           string                `json:"name"`
	Description    string                `json:"description"`
	Enabled        bool                  `json:"enabled"`
	Running        bool                  `json:"running"`
	PublicKey      string                `json:"publicKey"`
	ListenPort     *int                  `json:"listenPort,omitempty"`
	FirewallMark   *int                  `json:"firewallMark,omitempty"`
	Address        string                `json:"address"`
	DNS            []string              `json:"dns,omitempty"`
	Mtu            int                   `json:"mtu"`
	Hooks          []*ServerHook         `json:"hooks,omitempty"`
	Peers          []*Peer               `json:"peers,omitempty"`
	InterfaceStats *ServerInterfaceStats `json:"interfaceStats,omitempty"`
	CreateUser     *User                 `json:"createUser,omitempty"`
	UpdateUser     *User                 `json:"updateUser,omitempty"`
	DeleteUser     *User                 `json:"deleteUser,omitempty"`
	CreatedAt      time.Time             `json:"createdAt"`
	UpdatedAt      time.Time             `json:"updatedAt"`
	DeletedAt      *time.Time            `json:"deletedAt,omitempty"`
}

func ToServer

func ToServer(server *server.Server) *Server

func (Server) GetID

func (this Server) GetID() ID

func (Server) IsNode

func (Server) IsNode()

type ServerChangedEvent

type ServerChangedEvent struct {
	Node   *Server `json:"node"`
	Action string  `json:"action"`
}

func (ServerChangedEvent) IsNodeChangedEvent

func (ServerChangedEvent) IsNodeChangedEvent()

type ServerHook

type ServerHook struct {
	Command     string `json:"command"`
	RunOnCreate bool   `json:"runOnCreate"`
	RunOnUpdate bool   `json:"runOnUpdate"`
	RunOnDelete bool   `json:"runOnDelete"`
	RunOnStart  bool   `json:"runOnStart"`
	RunOnStop   bool   `json:"runOnStop"`
}

func ToServerHook

func ToServerHook(hook *server.Hook) *ServerHook

type ServerHookInput

type ServerHookInput struct {
	Command     string `json:"command"`
	RunOnCreate bool   `json:"runOnCreate"`
	RunOnUpdate bool   `json:"runOnUpdate"`
	RunOnDelete bool   `json:"runOnDelete"`
	RunOnStart  bool   `json:"runOnStart"`
	RunOnStop   bool   `json:"runOnStop"`
}

type ServerInterfaceStats

type ServerInterfaceStats struct {
	RxPackets         float64 `json:"rxPackets"`
	TxPackets         float64 `json:"txPackets"`
	RxBytes           float64 `json:"rxBytes"`
	TxBytes           float64 `json:"txBytes"`
	RxErrors          float64 `json:"rxErrors"`
	TxErrors          float64 `json:"txErrors"`
	RxDropped         float64 `json:"rxDropped"`
	TxDropped         float64 `json:"txDropped"`
	Multicast         float64 `json:"multicast"`
	Collisions        float64 `json:"collisions"`
	RxLengthErrors    float64 `json:"rxLengthErrors"`
	RxOverErrors      float64 `json:"rxOverErrors"`
	RxCrcErrors       float64 `json:"rxCrcErrors"`
	RxFrameErrors     float64 `json:"rxFrameErrors"`
	RxFifoErrors      float64 `json:"rxFifoErrors"`
	RxMissedErrors    float64 `json:"rxMissedErrors"`
	TxAbortedErrors   float64 `json:"txAbortedErrors"`
	TxCarrierErrors   float64 `json:"txCarrierErrors"`
	TxFifoErrors      float64 `json:"txFifoErrors"`
	TxHeartbeatErrors float64 `json:"txHeartbeatErrors"`
	TxWindowErrors    float64 `json:"txWindowErrors"`
	RxCompressed      float64 `json:"rxCompressed"`
	TxCompressed      float64 `json:"txCompressed"`
}

func ToServerInterfaceStats

func ToServerInterfaceStats(stats server.Stats) *ServerInterfaceStats

type SignInInput

type SignInInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	Email            string                     `json:"email"`
	Password         string                     `json:"password"`
}

type SignInPayload

type SignInPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	// Token you can use this token in Authorization header as bearer type
	Token string `json:"token"`
	// Session expiration date time
	ExpiresAt time.Time `json:"expiresAt"`
	// Session expiration duration relative to current time in seconds
	ExpiresIn int `json:"expiresIn"`
}

type StartServerInput

type StartServerInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	ID               ID                         `json:"id"`
}

type StartServerPayload

type StartServerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Server           *Server `json:"server"`
}

type StopServerInput

type StopServerInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	ID               ID                         `json:"id"`
}

type StopServerPayload

type StopServerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Server           *Server `json:"server,omitempty"`
}

type UpdatePeerInput

type UpdatePeerInput struct {
	ClientMutationID    graphql.Omittable[*string]          `json:"clientMutationId,omitempty"`
	ID                  ID                                  `json:"id"`
	Name                graphql.Omittable[*string]          `json:"name,omitempty"`
	Description         graphql.Omittable[*string]          `json:"description,omitempty"`
	PublicKey           graphql.Omittable[*string]          `json:"publicKey,omitempty"`
	Endpoint            graphql.Omittable[*string]          `json:"endpoint,omitempty"`
	AllowedIPs          graphql.Omittable[[]string]         `json:"allowedIPs,omitempty"`
	PresharedKey        graphql.Omittable[*string]          `json:"presharedKey,omitempty"`
	PersistentKeepalive graphql.Omittable[*int]             `json:"persistentKeepalive,omitempty"`
	Hooks               graphql.Omittable[[]*PeerHookInput] `json:"hooks,omitempty"`
}

type UpdatePeerPayload

type UpdatePeerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Peer             *Peer   `json:"peer,omitempty"`
}

type UpdateServerInput

type UpdateServerInput struct {
	ClientMutationID graphql.Omittable[*string]            `json:"clientMutationId,omitempty"`
	ID               ID                                    `json:"id"`
	Description      graphql.Omittable[*string]            `json:"description,omitempty"`
	Enabled          graphql.Omittable[*bool]              `json:"enabled,omitempty"`
	PublicKey        graphql.Omittable[*string]            `json:"publicKey,omitempty"`
	PrivateKey       graphql.Omittable[*string]            `json:"privateKey,omitempty"`
	ListenPort       graphql.Omittable[*int]               `json:"listenPort,omitempty"`
	FirewallMark     graphql.Omittable[*int]               `json:"firewallMark,omitempty"`
	Address          graphql.Omittable[*string]            `json:"address,omitempty"`
	DNS              graphql.Omittable[[]string]           `json:"dns,omitempty"`
	Mtu              graphql.Omittable[*int]               `json:"mtu,omitempty"`
	Hooks            graphql.Omittable[[]*ServerHookInput] `json:"hooks,omitempty"`
}

type UpdateServerPayload

type UpdateServerPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	Server           *Server `json:"server,omitempty"`
}

type UpdateUserInput

type UpdateUserInput struct {
	ClientMutationID graphql.Omittable[*string] `json:"clientMutationId,omitempty"`
	ID               ID                         `json:"id"`
	Email            graphql.Omittable[*string] `json:"email,omitempty"`
	Password         graphql.Omittable[*string] `json:"password,omitempty"`
}

type UpdateUserPayload

type UpdateUserPayload struct {
	ClientMutationID *string `json:"clientMutationId,omitempty"`
	User             *User   `json:"user"`
}

type User

type User struct {
	ID        ID        `json:"id"`
	Email     string    `json:"email"`
	Servers   []*Server `json:"servers,omitempty"`
	Peers     []*Peer   `json:"peers,omitempty"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

func ContextToUser

func ContextToUser(ctx context.Context) (*User, error)

func ToUser

func ToUser(user *user.User) *User

func (User) GetID

func (this User) GetID() ID

func (User) IsNode

func (User) IsNode()

type UserChangedEvent

type UserChangedEvent struct {
	Node   *User  `json:"node"`
	Action string `json:"action"`
}

func (UserChangedEvent) IsNodeChangedEvent

func (UserChangedEvent) IsNodeChangedEvent()

Jump to

Keyboard shortcuts

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