Skip to content

Commit eb386b9

Browse files
refactor(config): rename max_payload_size
1 parent c70634b commit eb386b9

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ debug: false
8888
# Used by HTTP, ...
8989
time_format: 12h # (12h, 24h)
9090
91-
# Maximum message size for envelopes
92-
max_payload_size: 25 MB
93-
9491
# Directory for storing data
9592
data_directory: smtpbridge_data
9693
@@ -129,6 +126,9 @@ smtp:
129126
username: ""
130127
password: ""
131128
129+
# Maximum payload size
130+
max_payload_size: 25 MB
131+
132132
# Endpoints for envelopes
133133
endpoints:
134134
# Console

config/config.go

+17-18
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ type Config struct {
4040
HTTPDisable bool
4141
HTTPAddress string
4242
HTTPPort uint16
43-
HTTPBodyLimit int64
4443
HTTPURL string
4544
SMTPDisable bool
4645
SMTPAddress string
@@ -57,7 +56,6 @@ type Config struct {
5756
type Raw struct {
5857
Debug bool `koanf:"debug"`
5958
TimeFormat string `koanf:"time_format"`
60-
MaxPayloadSize string `koanf:"max_payload_size"`
6159
DataDirectory string `koanf:"data_directory"`
6260
PythonExecutable string `koanf:"python_executable"`
6361
RetentionEnvelopeCount string `koanf:"retention.envelope_count"`
@@ -68,6 +66,7 @@ type Raw struct {
6866
SMTPPort uint16 `koanf:"smtp.port"`
6967
SMTPUsername string `koanf:"smtp.username"`
7068
SMTPPassword string `koanf:"smtp.password"`
69+
SMTPMaxPayloadSize string `koanf:"smtp.max_payload_size"`
7170
HTTPDisable bool `koanf:"http.disable"`
7271
HTTPHost string `koanf:"http.host"`
7372
HTTPPort uint16 `koanf:"http.port"`
@@ -98,20 +97,21 @@ type RawRule struct {
9897
}
9998

10099
var RawDefault = struct {
101-
TimeFormat string `koanf:"time_format"`
102-
MaxPayloadSize string `koanf:"max_payload_size"`
103-
DataDirectory string `koanf:"data_directory"`
104-
PythonExecutable string `koanf:"python_executable"`
105-
SMTPPort uint16 `koanf:"smtp.port"`
106-
HTTPPort uint16 `koanf:"http.port"`
100+
TimeFormat string `koanf:"time_format"`
101+
MaxPayloadSize string `koanf:"max_payload_size"`
102+
DataDirectory string `koanf:"data_directory"`
103+
PythonExecutable string `koanf:"python_executable"`
104+
SMTPPort uint16 `koanf:"smtp.port"`
105+
SMTPMaxPayloadSize string `koanf:"smtp.max_payload_size"`
106+
HTTPPort uint16 `koanf:"http.port"`
107107
// IMAPPort uint16 `koanf:"imap.port"`
108108
}{
109-
TimeFormat: TimeFormat12H,
110-
MaxPayloadSize: "25 MB",
111-
DataDirectory: "smtpbridge_data",
112-
PythonExecutable: "python3",
113-
SMTPPort: 1025,
114-
HTTPPort: 8080,
109+
TimeFormat: TimeFormat12H,
110+
SMTPMaxPayloadSize: "25 MB",
111+
DataDirectory: "smtpbridge_data",
112+
PythonExecutable: "python3",
113+
SMTPPort: 1025,
114+
HTTPPort: 8080,
115115
// IMAPPort: 10143,
116116
}
117117

@@ -135,7 +135,7 @@ func WithFlagSet(flags *flag.FlagSet) *flag.FlagSet {
135135
flags.Bool("http-disable", false, flagUsageBool(false, "Disable HTTP server."))
136136
flags.String("http-host", "", flagUsageString("", "HTTP host address to listen on."))
137137
flags.Int("http-port", 0, flagUsageInt(int(RawDefault.HTTPPort), "HTTP port to listen on."))
138-
flags.Int("http-url", 0, flagUsageString("", "HTTP public URL (e.g. http://127.0.0.1:8080)."))
138+
flags.String("http-url", "", flagUsageString("", "HTTP public URL (e.g. http://127.0.0.1:8080)."))
139139

140140
// flags.Bool("imap-disable", false, flagUsageBool(false, "Disable IMAP server."))
141141
// flags.String("imap-host", "", flagUsageString("", "IMAP host address to listen on."))
@@ -180,7 +180,7 @@ func (p Parser) Parse(raw Raw) (Config, error) {
180180
return Config{}, err
181181
}
182182

183-
maxBytesForEachPayload, err := bytes.Parse(raw.MaxPayloadSize)
183+
smtpMaxMessageSize, err := bytes.Parse(raw.SMTPMaxPayloadSize)
184184
if err != nil {
185185
return Config{}, err
186186
}
@@ -315,11 +315,10 @@ func (p Parser) Parse(raw Raw) (Config, error) {
315315
HTTPDisable: raw.HTTPDisable,
316316
HTTPAddress: httpAddress,
317317
HTTPPort: raw.HTTPPort,
318-
HTTPBodyLimit: maxBytesForEachPayload,
319318
HTTPURL: raw.HTTPURL,
320319
SMTPDisable: raw.SMTPDisable,
321320
SMTPAddress: smtpAddress,
322-
SMTPMaxMessageBytes: maxBytesForEachPayload,
321+
SMTPMaxMessageBytes: smtpMaxMessageSize,
323322
// IMAPDisable: raw.IMAPDisable,
324323
// IMAPAddress: imapAddress,
325324
Config: config,

0 commit comments

Comments
 (0)