@@ -31,21 +31,25 @@ import (
31
31
// mostly copied from https://github.com/tendermint/tendermint/blob/master/cmd/tendermint/commands/light.go
32
32
33
33
const (
34
- FlagListenAddr = "laddr"
35
- FlagPrimary = "primary"
36
- FlagPrimaryShort = "p"
37
- FlagWitness = "witnesses"
38
- FlagWitnessShort = "w"
39
- FlagHeight = "height"
40
- FlagHash = "hash"
41
- FlagDir = "dir"
42
- FlagDirShort = "d"
43
- FlagLogLevel = "log-level"
44
- FlagSeq = "sequential"
45
- FlagTrustLevel = "trust-level"
46
- FlagMaxConn = "max-open-connections"
47
- FlagTrustPeriod = "trusting-period"
48
- FlagStartTimeout = "start-timeout"
34
+ FlagListenAddr = "laddr"
35
+ FlagPrimary = "primary"
36
+ FlagPrimaryShort = "p"
37
+ FlagWitness = "witnesses"
38
+ FlagWitnessShort = "w"
39
+ FlagHeight = "height"
40
+ FlagHash = "hash"
41
+ FlagDir = "dir"
42
+ FlagDirShort = "d"
43
+ FlagLogLevel = "log-level"
44
+ FlagSeq = "sequential"
45
+ FlagTrustLevel = "trust-level"
46
+ FlagMaxConn = "max-open-connections"
47
+ FlagTrustPeriod = "trusting-period"
48
+ FlagStartTimeout = "start-timeout"
49
+ FlagTlsCertFile = "tls-cert-file"
50
+ FlagTlsCertFileShort = "c"
51
+ FlagTlsKeyFile = "tls-key-file"
52
+ FlagTlsKeyFileShort = "k"
49
53
)
50
54
51
55
// LightCmd represents the base command when called without any subcommands.
97
101
witnessesKey = []byte ("witnesses" )
98
102
99
103
startTimeout int64
104
+
105
+ tlsCertFile string
106
+ tlsKeyFile string
100
107
)
101
108
102
109
func init () {
@@ -127,6 +134,9 @@ func init() {
127
134
)
128
135
LightCmd .Flags ().Int64Var (& startTimeout , FlagStartTimeout , 0 ,
129
136
"How many seconds to wait before starting the light client proxy. Mostly for test purposes when light client is started at the same time as the pool." )
137
+
138
+ LightCmd .Flags ().StringVarP (& tlsCertFile , FlagTlsCertFile , FlagTlsCertFileShort , "" , "Path to the TLS certificate file" )
139
+ LightCmd .Flags ().StringVarP (& tlsKeyFile , FlagTlsKeyFile , FlagTlsKeyFileShort , "" , "Path to the TLS key file" )
130
140
}
131
141
132
142
func runProxy (cmd * cobra.Command , args []string ) error {
@@ -252,8 +262,15 @@ func runProxy(cmd *cobra.Command, args []string) error {
252
262
p .Listener .Close ()
253
263
}()
254
264
255
- logger .Info ("Starting proxy..." , "laddr" , listenAddr )
256
- if err := p .ListenAndServe (); errors .Is (err , http .ErrServerClosed ) {
265
+ if tlsCertFile != "" && tlsKeyFile != "" {
266
+ logger .Info ("Starting Light Client Proxy over TLS/HTTPS..." , "laddr" , listenAddr )
267
+ err = p .ListenAndServeTLS (tlsCertFile , tlsKeyFile )
268
+ } else {
269
+ logger .Info ("Starting Light Client Proxy over HTTP..." , "laddr" , listenAddr )
270
+ err = p .ListenAndServe ()
271
+ }
272
+
273
+ if errors .Is (err , http .ErrServerClosed ) {
257
274
// Error starting or closing listener:
258
275
logger .Error ("proxy ListenAndServe" , "err" , err )
259
276
}
0 commit comments