-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[R4R]: Temporarily disable gaia lite insecure mode #2716
Changes from all commits
7186062
3221b87
028b9bb
8198cef
2e7b194
05ac0fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,11 @@ package lcd | |
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"net" | ||
"net/http" | ||
"os" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/context" | ||
"github.com/cosmos/cosmos-sdk/client/keys" | ||
|
@@ -20,9 +25,6 @@ import ( | |
"github.com/spf13/viper" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmserver "github.com/tendermint/tendermint/rpc/lib/server" | ||
"net" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
const ( | ||
|
@@ -46,7 +48,9 @@ func ServeCommand(cdc *codec.Codec) *cobra.Command { | |
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
listenAddr := viper.GetString(flagListenAddr) | ||
handler := createHandler(cdc) | ||
|
||
registerSwaggerUI(handler) | ||
|
||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "rest-server") | ||
maxOpen := viper.GetInt(flagMaxOpenConnections) | ||
sslHosts := viper.GetString(flagSSLHosts) | ||
|
@@ -62,21 +66,28 @@ func ServeCommand(cdc *codec.Codec) *cobra.Command { | |
}) | ||
|
||
var cleanupFunc func() | ||
|
||
// TODO: re-enable insecure mode once #2715 has been addressed | ||
if viper.GetBool(flagInsecure) { | ||
listener, err = tmserver.StartHTTPServer( | ||
listenAddr, handler, logger, | ||
tmserver.Config{MaxOpenConnections: maxOpen}, | ||
fmt.Println( | ||
"Insecure mode is temporarily disabled, please locally generate an " + | ||
"SSL certificate to test. Support will be re-enabled soon!", | ||
) | ||
if err != nil { | ||
return | ||
} | ||
// listener, err = tmserver.StartHTTPServer( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to comment this? Just return an error (don't fail silently) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return an error where? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I return an error after, I'll have to restructure the whole if else block. I suppose I can add a nolint. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK nbd |
||
// listenAddr, handler, logger, | ||
// tmserver.Config{MaxOpenConnections: maxOpen}, | ||
// ) | ||
// if err != nil { | ||
// return | ||
// } | ||
} else { | ||
if certFile != "" { | ||
// validateCertKeyFiles() is needed to work around tendermint/tendermint#2460 | ||
err = validateCertKeyFiles(certFile, keyFile) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// cert/key pair is provided, read the fingerprint | ||
fingerprint, err = fingerprintFromFile(certFile) | ||
if err != nil { | ||
|
@@ -88,10 +99,12 @@ func ServeCommand(cdc *codec.Codec) *cobra.Command { | |
if err != nil { | ||
return err | ||
} | ||
|
||
cleanupFunc = func() { | ||
os.Remove(certFile) | ||
os.Remove(keyFile) | ||
} | ||
|
||
defer cleanupFunc() | ||
} | ||
|
||
|
@@ -104,9 +117,12 @@ func ServeCommand(cdc *codec.Codec) *cobra.Command { | |
if err != nil { | ||
return | ||
} | ||
|
||
logger.Info(fingerprint) | ||
logger.Info("REST server started") | ||
} | ||
logger.Info("REST server started") | ||
|
||
// logger.Info("REST server started") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we've just moved this log can we delete this line? |
||
|
||
return nil | ||
}, | ||
|
@@ -123,6 +139,7 @@ func ServeCommand(cdc *codec.Codec) *cobra.Command { | |
cmd.Flags().Int(flagMaxOpenConnections, 1000, "The number of maximum open connections") | ||
cmd.Flags().Bool(client.FlagTrustNode, false, "Trust connected full node (don't verify proofs for responses)") | ||
cmd.Flags().Bool(client.FlagIndentResponse, false, "Add indent to JSON response") | ||
|
||
viper.BindPFlag(client.FlagTrustNode, cmd.Flags().Lookup(client.FlagTrustNode)) | ||
viper.BindPFlag(client.FlagChainID, cmd.Flags().Lookup(client.FlagChainID)) | ||
viper.BindPFlag(client.FlagNode, cmd.Flags().Lookup(client.FlagNode)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the SSL cert is generated automatically if none is passed as an argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, excellent, let's update the help text.