// Top level options use an anonymous struct
BaseConfig `mapstructure:",squash"`
// Options for services
- RPC *RPCConfig `mapstructure:"rpc"`
- P2P *P2PConfig `mapstructure:"p2p"`
- Wallet *WalletConfig `mapstructure:"wallet"`
+ RPC *RPCConfig `mapstructure:"rpc"`
+ P2P *P2PConfig `mapstructure:"p2p"`
+ Wallet *WalletConfig `mapstructure:"wallet"`
+ Auth *RPCAuthConfig `mapstructure:"auth"`
}
func DefaultConfig() *Config {
RPC: DefaultRPCConfig(),
P2P: DefaultP2PConfig(),
Wallet: DefaultWalletConfig(),
+ Auth: DefaultRPCAuthConfig(),
}
}
// P2PConfig
type P2PConfig struct {
- RootDir string `mapstructure:"home"`
- ListenAddress string `mapstructure:"laddr"`
- Seeds string `mapstructure:"seeds"`
- SkipUPNP bool `mapstructure:"skip_upnp"`
- AddrBook string `mapstructure:"addr_book_file"`
- AddrBookStrict bool `mapstructure:"addr_book_strict"`
- PexReactor bool `mapstructure:"pex"`
- MaxNumPeers int `mapstructure:"max_num_peers"`
- HandshakeTimeout int `mapstructure:"handshake_timeout"`
- DialTimeout int `mapstructure:"dial_timeout"`
+ RootDir string `mapstructure:"home"`
+ ListenAddress string `mapstructure:"laddr"`
+ Seeds string `mapstructure:"seeds"`
+ SkipUPNP bool `mapstructure:"skip_upnp"`
+ AddrBook string `mapstructure:"addr_book_file"`
+ AddrBookStrict bool `mapstructure:"addr_book_strict"`
+ PexReactor bool `mapstructure:"pex"`
+ MaxNumPeers int `mapstructure:"max_num_peers"`
+ HandshakeTimeout int `mapstructure:"handshake_timeout"`
+ DialTimeout int `mapstructure:"dial_timeout"`
}
func DefaultP2PConfig() *P2PConfig {
return &P2PConfig{
- ListenAddress: "tcp://0.0.0.0:46656",
- AddrBook: "addrbook.json",
- AddrBookStrict: true,
- SkipUPNP: false,
- MaxNumPeers: 50,
+ ListenAddress: "tcp://0.0.0.0:46656",
+ AddrBook: "addrbook.json",
+ AddrBookStrict: true,
+ SkipUPNP: false,
+ MaxNumPeers: 50,
HandshakeTimeout: 30,
DialTimeout: 3,
}
Enable bool `mapstructure:"enable"`
}
+type RPCAuthConfig struct {
+ Disable bool `mapstructure:"disable"`
+}
+
+func DefaultRPCAuthConfig() *RPCAuthConfig {
+ return &RPCAuthConfig{
+ Disable: false,
+ }
+}
+
func DefaultWalletConfig() *WalletConfig {
return &WalletConfig{
Enable: false,
mux.Handle("/", &coreHandler)
var handler http.Handler = mux
- handler = AuthHandler(handler, accessTokens)
+
+ if config.Auth.Disable == false {
+ handler = AuthHandler(handler, accessTokens)
+ }
handler = RedirectHandler(handler)
secureheader.DefaultConfig.PermitClearLoopback = true