Explorar el Código

simple-run: add --proxy-protocol-listener flag

Mirrors the proxy-protocol-listener TOML config option so simple-run can
sit behind a PROXY-protocol-emitting frontend (HAProxy, nginx stream)
without dropping back to a config file.

Discussed in #502: with this flag the compose recipe collapses to
'simple-run $BIND $SECRET --proxy-protocol-listener', keeping the
secret in the environment and no mtg-config.toml in the repo.
pull/510/head
Alexey Dolotov hace 1 semana
padre
commit
0488f246ba
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3
    0
      internal/cli/simple_run.go

+ 3
- 0
internal/cli/simple_run.go Ver fichero

@@ -24,6 +24,8 @@ type SimpleRun struct {
24 24
 	Timeout             time.Duration `kong:"name='timeout',short='t',default='10s',help='Network timeout to use'"`                                                    //nolint: lll
25 25
 	Socks5Proxies       []string      `kong:"name='socks5-proxy',short='s',help='Socks5 proxies to use for network access.'"`                                          //nolint: lll
26 26
 	AntiReplayCacheSize string        `kong:"name='antireplay-cache-size',short='a',default='1MB',help='A size of anti-replay cache to use.'"`                         //nolint: lll
27
+
28
+	ProxyProtocolListener bool `kong:"name='proxy-protocol-listener',help='Expect PROXY protocol (v1 or v2) headers on the listener. Use when mtg sits behind HAProxy, nginx stream, or similar.'"` //nolint: lll
27 29
 }
28 30
 
29 31
 func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop,funlen
@@ -97,6 +99,7 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop,funle
97 99
 	conf.Debug.Value = s.Debug
98 100
 	conf.AllowFallbackOnUnknownDC.Value = true
99 101
 	conf.Defense.AntiReplay.Enabled.Value = true
102
+	conf.ProxyProtocolListener.Value = s.ProxyProtocolListener
100 103
 
101 104
 	if err := conf.Validate(); err != nil {
102 105
 		return fmt.Errorf("invalid result configuration: %w", err)

Loading…
Cancelar
Guardar