mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 01:57:02 +00:00
@@ -124,8 +124,7 @@ func main() {
|
|||||||
go httpd.Start(rootCtx)
|
go httpd.Start(rootCtx)
|
||||||
|
|
||||||
// Start POP3 server
|
// Start POP3 server
|
||||||
// TODO pass datastore
|
pop3Server = pop3d.New(config.GetPOP3Config(), shutdownChan, ds)
|
||||||
pop3Server = pop3d.New(shutdownChan)
|
|
||||||
go pop3Server.Start(rootCtx)
|
go pop3Server.Start(rootCtx)
|
||||||
|
|
||||||
// Startup SMTP server
|
// Startup SMTP server
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
|
|
||||||
// Server defines an instance of our POP3 server
|
// Server defines an instance of our POP3 server
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
host string
|
||||||
domain string
|
domain string
|
||||||
maxIdleSeconds int
|
maxIdleSeconds int
|
||||||
dataStore smtpd.DataStore
|
dataStore smtpd.DataStore
|
||||||
@@ -23,14 +24,9 @@ type Server struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Server struct
|
// New creates a new Server struct
|
||||||
func New(shutdownChan chan bool) *Server {
|
func New(cfg config.POP3Config, shutdownChan chan bool, ds smtpd.DataStore) *Server {
|
||||||
// Get a new instance of the the FileDataStore - the locking and counting
|
|
||||||
// mechanisms are both global variables in the smtpd package. If that
|
|
||||||
// changes in the future, this should be modified to use the same DataStore
|
|
||||||
// instance.
|
|
||||||
ds := smtpd.DefaultFileDataStore()
|
|
||||||
cfg := config.GetPOP3Config()
|
|
||||||
return &Server{
|
return &Server{
|
||||||
|
host: fmt.Sprintf("%v:%v", cfg.IP4address, cfg.IP4port),
|
||||||
domain: cfg.Domain,
|
domain: cfg.Domain,
|
||||||
dataStore: ds,
|
dataStore: ds,
|
||||||
maxIdleSeconds: cfg.MaxIdleSeconds,
|
maxIdleSeconds: cfg.MaxIdleSeconds,
|
||||||
@@ -41,9 +37,7 @@ func New(shutdownChan chan bool) *Server {
|
|||||||
|
|
||||||
// Start the server and listen for connections
|
// Start the server and listen for connections
|
||||||
func (s *Server) Start(ctx context.Context) {
|
func (s *Server) Start(ctx context.Context) {
|
||||||
cfg := config.GetPOP3Config()
|
addr, err := net.ResolveTCPAddr("tcp4", s.host)
|
||||||
addr, err := net.ResolveTCPAddr("tcp4", fmt.Sprintf("%v:%v",
|
|
||||||
cfg.IP4address, cfg.IP4port))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("POP3 Failed to build tcp4 address: %v", err)
|
log.Errorf("POP3 Failed to build tcp4 address: %v", err)
|
||||||
s.emergencyShutdown()
|
s.emergencyShutdown()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import (
|
|||||||
// Server holds the configuration and state of our SMTP server
|
// Server holds the configuration and state of our SMTP server
|
||||||
type Server struct {
|
type Server struct {
|
||||||
// Configuration
|
// Configuration
|
||||||
|
host string
|
||||||
domain string
|
domain string
|
||||||
domainNoStore string
|
domainNoStore string
|
||||||
maxRecips int
|
maxRecips int
|
||||||
@@ -64,6 +65,7 @@ func NewServer(
|
|||||||
ds DataStore,
|
ds DataStore,
|
||||||
msgHub *msghub.Hub) *Server {
|
msgHub *msghub.Hub) *Server {
|
||||||
return &Server{
|
return &Server{
|
||||||
|
host: fmt.Sprintf("%v:%v", cfg.IP4address, cfg.IP4port),
|
||||||
domain: cfg.Domain,
|
domain: cfg.Domain,
|
||||||
domainNoStore: strings.ToLower(cfg.DomainNoStore),
|
domainNoStore: strings.ToLower(cfg.DomainNoStore),
|
||||||
maxRecips: cfg.MaxRecipients,
|
maxRecips: cfg.MaxRecipients,
|
||||||
@@ -80,9 +82,7 @@ func NewServer(
|
|||||||
|
|
||||||
// Start the listener and handle incoming connections
|
// Start the listener and handle incoming connections
|
||||||
func (s *Server) Start(ctx context.Context) {
|
func (s *Server) Start(ctx context.Context) {
|
||||||
cfg := config.GetSMTPConfig()
|
addr, err := net.ResolveTCPAddr("tcp4", s.host)
|
||||||
addr, err := net.ResolveTCPAddr("tcp4", fmt.Sprintf("%v:%v",
|
|
||||||
cfg.IP4address, cfg.IP4port))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to build tcp4 address: %v", err)
|
log.Errorf("Failed to build tcp4 address: %v", err)
|
||||||
s.emergencyShutdown()
|
s.emergencyShutdown()
|
||||||
|
|||||||
Reference in New Issue
Block a user