|
| 1 | +/* |
| 2 | + * Copyright contributors to Hyperledger Besu. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 5 | + * the License. You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 10 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 11 | + * specific language governing permissions and limitations under the License. |
| 12 | + * |
| 13 | + * SPDX-License-Identifier: Apache-2.0 |
| 14 | + */ |
| 15 | +package org.hyperledger.besu.cli.options.stable; |
| 16 | + |
| 17 | +import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT; |
| 18 | + |
| 19 | +import org.hyperledger.besu.cli.DefaultCommandValues; |
| 20 | +import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; |
| 21 | +import org.hyperledger.besu.cli.options.CLIOptions; |
| 22 | +import org.hyperledger.besu.cli.util.CommandLineUtils; |
| 23 | + |
| 24 | +import java.nio.file.Path; |
| 25 | +import java.util.List; |
| 26 | + |
| 27 | +import picocli.CommandLine; |
| 28 | + |
| 29 | +/** Command line options for configuring Engine RPC on the node. */ |
| 30 | +public class EngineRPCOptions implements CLIOptions<EngineRPCConfiguration> { |
| 31 | + |
| 32 | + /** Default constructor */ |
| 33 | + public EngineRPCOptions() {} |
| 34 | + |
| 35 | + @CommandLine.Option( |
| 36 | + names = {"--engine-rpc-enabled"}, |
| 37 | + description = "enable the engine api, even in the absence of merge-specific configurations.") |
| 38 | + private final Boolean overrideEngineRpcEnabled = false; |
| 39 | + |
| 40 | + @CommandLine.Option( |
| 41 | + names = {"--engine-rpc-port", "--engine-rpc-http-port"}, |
| 42 | + paramLabel = DefaultCommandValues.MANDATORY_PORT_FORMAT_HELP, |
| 43 | + description = "Port to provide consensus client APIS on (default: ${DEFAULT-VALUE})", |
| 44 | + arity = "1") |
| 45 | + private final Integer engineRpcPort = DEFAULT_ENGINE_JSON_RPC_PORT; |
| 46 | + |
| 47 | + @CommandLine.Option( |
| 48 | + names = {"--engine-jwt-secret"}, |
| 49 | + paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, |
| 50 | + description = "Path to file containing shared secret key for JWT signature verification") |
| 51 | + private final Path engineJwtKeyFile = null; |
| 52 | + |
| 53 | + @CommandLine.Option( |
| 54 | + names = {"--engine-jwt-disabled"}, |
| 55 | + description = "Disable authentication for Engine APIs (default: ${DEFAULT-VALUE})") |
| 56 | + private final Boolean isEngineAuthDisabled = false; |
| 57 | + |
| 58 | + @CommandLine.Option( |
| 59 | + names = {"--engine-host-allowlist"}, |
| 60 | + paramLabel = "<hostname>[,<hostname>...]... or * or all", |
| 61 | + description = |
| 62 | + "Comma separated list of hostnames to allow for ENGINE API access (applies to both HTTP and websockets), or * to accept any host (default: ${DEFAULT-VALUE})", |
| 63 | + defaultValue = "localhost,127.0.0.1") |
| 64 | + private final JsonRPCAllowlistHostsProperty engineHostsAllowlist = |
| 65 | + new JsonRPCAllowlistHostsProperty(); |
| 66 | + |
| 67 | + @Override |
| 68 | + public EngineRPCConfiguration toDomainObject() { |
| 69 | + return new EngineRPCConfiguration( |
| 70 | + overrideEngineRpcEnabled, |
| 71 | + engineRpcPort, |
| 72 | + engineJwtKeyFile, |
| 73 | + isEngineAuthDisabled, |
| 74 | + engineHostsAllowlist); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public List<String> getCLIOptions() { |
| 79 | + return CommandLineUtils.getCLIOptions(this, new EngineRPCOptions()); |
| 80 | + } |
| 81 | +} |
0 commit comments