gluon

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 20 Imported by: 0

README

Gluon

An IMAP4rev1 library focusing on correctness, stability and performance.

This is work in progress. It will eventually be integrated into the Proton Bridge.

CI Status GoDoc Go Report Card License

Demo

The demo server can be started with:

$ go run demo/demo.go
INFO[0000] User added to server                          userID=d5a706ae-c7bf-4cfd-bad3-982eafcdfe39
INFO[0000] User added to server                          userID=622e121e-c9c7-43f9-b0ee-22bf868e8429
INFO[0000] Server is listening on 127.0.0.1:1143

The demo server includes two demo users, the first has addresses user1@example.com and alias1@example.com and password password1, the second has addresses user2@example.com and alias2@example.com and password password2:

$ telnet 127.0.0.1 1143
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
* OK [CAPABILITY IDLE IMAP4rev1 MOVE UIDPLUS UNSELECT] gluon session ID 1
tag login user1@example.com password1
tag OK [CAPABILITY IDLE IMAP4rev1 MOVE UIDPLUS UNSELECT] (^_^)

...

tag login alias1@example.com password1
tag OK [CAPABILITY IDLE IMAP4rev1 MOVE UIDPLUS UNSELECT] (^_^)

...

tag login user2@example.com password2
tag OK [CAPABILITY IDLE IMAP4rev1 MOVE UIDPLUS UNSELECT] (^_^)

...

tag login alias2@example.com password2
tag OK [CAPABILITY IDLE IMAP4rev1 MOVE UIDPLUS UNSELECT] (^_^)

The demo accounts contain no messages. You can connect an IMAP client (e.g. thunderbird) and use it to copy in messages from another mail server.

Documentation

Overview

Package gluon implements an IMAP4rev1 (+ extensions) mailserver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option represents a type that can be used to configure the server.

func WithCmdProfiler added in v0.9.0

func WithCmdProfiler(builder profiling.CmdProfilerBuilder) Option

WithCmdProfiler allows a specific CmdProfilerBuilder to be set for the server's execution.

func WithDataDir added in v0.10.0

func WithDataDir(path string) Option

func WithDelimiter

func WithDelimiter(delimiter string) Option

WithDelimiter instructs the server to use the given path delimiter instead of the default ('/').

func WithLogger

func WithLogger(in, out io.Writer) Option

WithLogger instructs the server to write incoming and outgoing IMAP communication to the given io.Writers.

func WithStoreBuilder added in v0.9.0

func WithStoreBuilder(builder store.Builder) Option

func WithTLS

func WithTLS(cfg *tls.Config) Option

WithTLS instructs the server to use the given TLS config.

func WithVersionInfo added in v0.8.0

func WithVersionInfo(vmajor, vminor, vpatch int, name, vendor, supportURL string) Option

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the gluon IMAP server.

func New

func New(withOpt ...Option) (*Server, error)

New creates a new server with the given options.

func (*Server) AddUser

func (s *Server) AddUser(ctx context.Context, conn connector.Connector, encryptionPassphrase []byte) (string, error)

AddUser creates a new user and generates new unique ID for this user. If you have an existing userID, please use LoadUser instead.

func (*Server) AddWatcher

func (s *Server) AddWatcher() chan events.Event

AddWatcher adds a new watcher.

func (*Server) Close

func (s *Server) Close(ctx context.Context) error

Close closes the server. It firstly closes all TCP listeners then closes the backend.

func (*Server) GetDataPath added in v0.9.0

func (s *Server) GetDataPath() string

func (*Server) GetUserDataPath added in v0.9.0

func (s *Server) GetUserDataPath(userID string) (string, error)

func (*Server) GetVersionInfo added in v0.8.0

func (s *Server) GetVersionInfo() internal.VersionInfo

func (*Server) LoadUser added in v0.9.0

func (s *Server) LoadUser(ctx context.Context, conn connector.Connector, userID string, passphrase []byte) error

LoadUser loads an existing user's data from disk. This function can also be used to assign a custom userID to a mail server user.

func (*Server) RemoveUser added in v0.5.0

func (s *Server) RemoveUser(ctx context.Context, userID string) error

RemoveUser removes a user from the mailserver.

func (*Server) RemoveWatcher added in v0.8.1

func (s *Server) RemoveWatcher(ch chan events.Event)

RemoveWatcher removes the watcher from the server and closes the channel.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, l net.Listener) chan error

Serve serves connections accepted from the given listener. It returns a channel of all errors which occur while serving. The error channel is closed when either the connection is dropped or the server is closed.

Directories

Path Synopsis
benchmarks
Package connector defines the type that connects the server to a remote.
Package connector defines the type that connects the server to a remote.
mock_connector
Package mock_connector is a generated GoMock package.
Package mock_connector is a generated GoMock package.
liner
Package liner handles reading lines from clients that may or may not require continuation.
Package liner handles reading lines from clients that may or may not require continuation.
remote/mock_remote
Package mock_remote is a generated GoMock package.
Package mock_remote is a generated GoMock package.
response
Package response implements types used when sending IMAP responses back to clients.
Package response implements types used when sending IMAP responses back to clients.
session
Package session handles IMAP commands received from clients within a single IMAP session (one client connection).
Package session handles IMAP commands received from clients within a single IMAP session (one client connection).
Package rfc822 implements methods for handling RFC822 messages.
Package rfc822 implements methods for handling RFC822 messages.
package store implements types that store message literals.
package store implements types that store message literals.
mock_store
Package mock_store is a generated GoMock package.
Package mock_store is a generated GoMock package.

Jump to

Keyboard shortcuts

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