Skip to content

Commit

Permalink
Turn down logging a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibling committed Feb 5, 2024
1 parent 0b43619 commit 04d96d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
push: true
tags: |
ghcr.io/scheiblingco/smtp-relay:latest
ghcr.io/scheiblingco/smtp-relay:0.7.1
ghcr.io/scheiblingco/smtp-relay:0.8.1
docker.io/scheibling/smtp-relay:latest
docker.io/scheibling/smtp-relay:0.7.1
docker.io/scheibling/smtp-relay:0.8.1
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ A minimal SMTP-SMTP Relay written in Go. The main purpose is to have a local rel

## Usage
### Go
Compile the go code (e.g. ```go build -o smtp-relay main.go```) and run the binary
Compile the go code (e.g. ```go build -o smtp-relay main.go```) and run the binary or use the kubernetes operator (docs coming soon...)

### Docker
There are docker images avaiable on GHCR and Docker Hub
- docker.io/scheiblingco/smtp-relay:latest
- ghcr.io/scheiblingco/smtp-relay:latest

### Configuration

OUT OF DATE: Needs update.


```json
{
"server": {
Expand Down
23 changes: 6 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (

"github.com/emersion/go-sasl"
"github.com/emersion/go-smtp"
"golang.org/x/exp/maps"
)

var TERMINATED string
var LASTMOD int64

type Credential struct {
Password string `json:"password"`
Expand Down Expand Up @@ -138,7 +138,7 @@ func (s *Session) AuthPlain(username, password string) error {
val, ok := config.Credentials[username]

if ok && val.Password == password {
log.Println("User", username, "authenticated successfully")
log.Println(username, "authenticated successfully")
s.Anonymous = false
s.RelayMessage.Credential = val
return nil
Expand All @@ -161,7 +161,7 @@ func (s *Session) Mail(from string, opts *smtp.MailOptions) error {
return errors.New("anonymous users are not allowed to send mail")
}

log.Println("sending mail from:", from)
// log.Println("sending mail from:", from)
if len(s.RelayMessage.Credential.AllowedDomains) > 0 {
splt := strings.Split(from, "@")
if !sliceContains(s.RelayMessage.Credential.AllowedDomains, splt[1]) {
Expand Down Expand Up @@ -193,12 +193,12 @@ func (s *Session) Data(r io.Reader) error {
}

func (s *Session) Reset() {
log.Println("resetting message, preparing for next")
// log.Println("resetting message, preparing for next")
s.RelayMessage = Mail{}
}

func (s *Session) Logout() error {
log.Println("session ended, closing")
// log.Println("session ended, closing")
s = &Session{}
return nil
}
Expand Down Expand Up @@ -255,9 +255,7 @@ func ListenHealthcheck(cfg *Config) {
}

cfg.Credentials = updatedAccounts
fmt.Println("Updated accounts: ")
fmt.Println(cfg.Credentials)

fmt.Println("Updated accounts: ", maps.Keys(cfg.Credentials))
})) // nolint:errcheck
}

Expand All @@ -268,15 +266,6 @@ func main() {
config = &Config{}
credentials := &map[string]Credential{}

// Get last changed timestamp
credentialsInfo, err := os.Stat("credentials.json")
if err != nil {
log.Fatal(err)
TERMINATED = err.Error()
}

LASTMOD = credentialsInfo.ModTime().Unix()

// Read config.json into temp string
configFile, err := os.ReadFile("config.json")
if err != nil {
Expand Down

0 comments on commit 04d96d2

Please sign in to comment.