Skip to content

Commit 1ee492f

Browse files
authored
Add support for setting the receiver proxy flags via environment variables (#5)
1 parent 148e247 commit 1ee492f

File tree

1 file changed

+68
-51
lines changed

1 file changed

+68
-51
lines changed

cmd/receiver-proxy/main.go

Lines changed: 68 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -21,93 +21,110 @@ import (
2121
var flags []cli.Flag = []cli.Flag{
2222
// input and output
2323
&cli.StringFlag{
24-
Name: "local-listen-addr",
25-
Value: "127.0.0.1:443",
26-
Usage: "address to listen on for orderflow proxy API for external users and local operator",
24+
Name: "local-listen-addr",
25+
Value: "127.0.0.1:443",
26+
Usage: "address to listen on for orderflow proxy API for external users and local operator",
27+
EnvVars: []string{"LOCAL_LISTEN_ADDR"},
2728
},
2829
&cli.StringFlag{
29-
Name: "public-listen-addr",
30-
Value: "127.0.0.1:5544",
31-
Usage: "address to listen on for orderflow proxy API for other network participants",
30+
Name: "public-listen-addr",
31+
Value: "127.0.0.1:5544",
32+
Usage: "address to listen on for orderflow proxy API for other network participants",
33+
EnvVars: []string{"PUBLIC_LISTEN_ADDR"},
3234
},
3335
&cli.StringFlag{
34-
Name: "cert-listen-addr",
35-
Value: "127.0.0.1:14727",
36-
Usage: "address to listen on for orderflow proxy serving its SSL certificate on /cert",
36+
Name: "cert-listen-addr",
37+
Value: "127.0.0.1:14727",
38+
Usage: "address to listen on for orderflow proxy serving its SSL certificate on /cert",
39+
EnvVars: []string{"CERT_LISTEN_ADDR"},
3740
},
3841
&cli.StringFlag{
39-
Name: "builder-endpoint",
40-
Value: "http://127.0.0.1:8645",
41-
Usage: "address to send local ordeflow to",
42+
Name: "builder-endpoint",
43+
Value: "http://127.0.0.1:8645",
44+
Usage: "address to send local ordeflow to",
45+
EnvVars: []string{"BUILDER_ENDPOINT"},
4246
},
4347
&cli.StringFlag{
44-
Name: "rpc-endpoint",
45-
Value: "http://127.0.0.1:8545",
46-
Usage: "address of the node RPC that supports eth_blockNumber",
48+
Name: "rpc-endpoint",
49+
Value: "http://127.0.0.1:8545",
50+
Usage: "address of the node RPC that supports eth_blockNumber",
51+
EnvVars: []string{"RPC_ENDPOINT"},
4752
},
4853
&cli.StringFlag{
49-
Name: "builder-confighub-endpoint",
50-
Value: "http://127.0.0.1:14892",
51-
Usage: "address of the builder config hub enpoint (directly or throught the cvm-proxy)",
54+
Name: "builder-confighub-endpoint",
55+
Value: "http://127.0.0.1:14892",
56+
Usage: "address of the builder config hub enpoint (directly or throught the cvm-proxy)",
57+
EnvVars: []string{"BUILDER_CONFIGHUB_ENDPOINT"},
5258
},
5359
&cli.StringFlag{
54-
Name: "orderflow-archive-endpoint",
55-
Value: "http://127.0.0.1:14893",
56-
Usage: "address of the ordreflow archive endpoint (block-processor)",
60+
Name: "orderflow-archive-endpoint",
61+
Value: "http://127.0.0.1:14893",
62+
Usage: "address of the ordreflow archive endpoint (block-processor)",
63+
EnvVars: []string{"ORDERFLOW_ARCHIVE_ENDPOINT"},
5764
},
5865
&cli.StringFlag{
59-
Name: "flashbots-orderflow-signer-address",
60-
Value: "0x5015Fa72E34f75A9eC64f44a4Fcf0837919D1bB7",
61-
Usage: "ordreflow from Flashbots will be signed with this address",
66+
Name: "flashbots-orderflow-signer-address",
67+
Value: "0x5015Fa72E34f75A9eC64f44a4Fcf0837919D1bB7",
68+
Usage: "ordreflow from Flashbots will be signed with this address",
69+
EnvVars: []string{"FLASHBOTS_ORDERFLOW_SIGNER_ADDRESS"},
6270
},
6371
&cli.Int64Flag{
64-
Name: "max-request-body-size-bytes",
65-
Value: 0,
66-
Usage: "Maximum size of the request body, if 0 default will be used",
72+
Name: "max-request-body-size-bytes",
73+
Value: 0,
74+
Usage: "Maximum size of the request body, if 0 default will be used",
75+
EnvVars: []string{"MAX_REQUEST_BODY_SIZE_BYTES"},
6776
},
6877

6978
// certificate config
7079
&cli.DurationFlag{
71-
Name: "cert-duration",
72-
Value: time.Hour * 24 * 365,
73-
Usage: "generated certificate duration",
80+
Name: "cert-duration",
81+
Value: time.Hour * 24 * 365,
82+
Usage: "generated certificate duration",
83+
EnvVars: []string{"CERT_DURATION"},
7484
},
7585
&cli.StringSliceFlag{
76-
Name: "cert-hosts",
77-
Value: cli.NewStringSlice("127.0.0.1", "localhost"),
78-
Usage: "generated certificate hosts",
86+
Name: "cert-hosts",
87+
Value: cli.NewStringSlice("127.0.0.1", "localhost"),
88+
Usage: "generated certificate hosts",
89+
EnvVars: []string{"CERT_HOSTS"},
7990
},
8091

8192
// logging, metrics and debug
8293
&cli.StringFlag{
83-
Name: "metrics-addr",
84-
Value: "127.0.0.1:8090",
85-
Usage: "address to listen on for Prometheus metrics (metrics are served on $metrics-addr/metrics)",
94+
Name: "metrics-addr",
95+
Value: "127.0.0.1:8090",
96+
Usage: "address to listen on for Prometheus metrics (metrics are served on $metrics-addr/metrics)",
97+
EnvVars: []string{"METRICS_ADDR"},
8698
},
8799
&cli.BoolFlag{
88-
Name: "log-json",
89-
Value: false,
90-
Usage: "log in JSON format",
100+
Name: "log-json",
101+
Value: false,
102+
Usage: "log in JSON format",
103+
EnvVars: []string{"LOG_JSON"},
91104
},
92105
&cli.BoolFlag{
93-
Name: "log-debug",
94-
Value: false,
95-
Usage: "log debug messages",
106+
Name: "log-debug",
107+
Value: false,
108+
Usage: "log debug messages",
109+
EnvVars: []string{"LOG_DEBUG"},
96110
},
97111
&cli.BoolFlag{
98-
Name: "log-uid",
99-
Value: false,
100-
Usage: "generate a uuid and add to all log messages",
112+
Name: "log-uid",
113+
Value: false,
114+
Usage: "generate a uuid and add to all log messages",
115+
EnvVars: []string{"LOG_UID"},
101116
},
102117
&cli.StringFlag{
103-
Name: "log-service",
104-
Value: "tdx-orderflow-proxy-receiver",
105-
Usage: "add 'service' tag to logs",
118+
Name: "log-service",
119+
Value: "tdx-orderflow-proxy-receiver",
120+
Usage: "add 'service' tag to logs",
121+
EnvVars: []string{"LOG_SERVICE"},
106122
},
107123
&cli.BoolFlag{
108-
Name: "pprof",
109-
Value: false,
110-
Usage: "enable pprof debug endpoint (pprof is served on $metrics-addr/debug/pprof/*)",
124+
Name: "pprof",
125+
Value: false,
126+
Usage: "enable pprof debug endpoint (pprof is served on $metrics-addr/debug/pprof/*)",
127+
EnvVars: []string{"PPROF"},
111128
},
112129
}
113130

0 commit comments

Comments
 (0)