MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / NewServer

Function NewServer

internal/relay/server.go:92–123  ·  view source on GitHub ↗
(cfg *config.Config, store *identity.Store, signer *headers.Signer, usage usage.UsageTracker, hub *ws.Hub)

Source from the content-addressed store, hash-verified

90func (s *Server) SetEnforcer(e limits.Enforcer) { s.enforcer = e }
91
92func NewServer(cfg *config.Config, store *identity.Store, signer *headers.Signer, usage usage.UsageTracker, hub *ws.Hub) *Server {
93 s := &Server{
94 store: store,
95 signer: signer,
96 hub: hub,
97 usage: usage,
98 screen: piguard.NewEngine(piguard.EngineConfig{}, piguard.NewHeuristicsDetector()),
99 smtpDomain: cfg.SMTP.Domain,
100 outboundFromDomain: cfg.OutboundSMTP.FromDomain,
101 }
102
103 be := &backend{relay: s}
104 smtpSrv := smtp.NewServer(be)
105 smtpSrv.Addr = cfg.SMTP.ListenAddr
106 smtpSrv.Domain = cfg.SMTP.Domain
107 smtpSrv.ReadTimeout = 30 * time.Second
108 smtpSrv.WriteTimeout = 30 * time.Second
109 smtpSrv.MaxMessageBytes = 10 * 1024 * 1024 // 10MB
110 smtpSrv.MaxRecipients = 50
111 smtpSrv.AllowInsecureAuth = !cfg.IsProduction()
112
113 if cfg.SMTP.TLSCert != "" && cfg.SMTP.TLSKey != "" {
114 cert, err := tls.LoadX509KeyPair(cfg.SMTP.TLSCert, cfg.SMTP.TLSKey)
115 if err != nil {
116 log.Fatalf("failed to load TLS cert: %v", err)
117 }
118 smtpSrv.TLSConfig = &tls.Config{Certificates: []tls.Certificate{cert}}
119 }
120
121 s.smtpServer = smtpSrv
122 return s
123}
124
125func (s *Server) ListenAndServe() error {
126 log.Printf("SMTP relay listening on %s", s.smtpServer.Addr)

Callers 6

TestServerFunction · 0.92
StartContractServerFunction · 0.92
mainFunction · 0.92

Calls 3

NewEngineFunction · 0.92
NewHeuristicsDetectorFunction · 0.92
IsProductionMethod · 0.80