Repository navigation
feat(framework): support admin JSON-RPC over IPC and HTTP #6979
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
Open
317787106
wants to merge
16
commits into
tronprotocol:release_v4.8.3
Choose a base branch
from
317787106:feature/admin_rpc
base: release_v4.8.3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,214
−32
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b3a7b20
feat(framework): support admin JSON-RPC over IPC and HTTP
317787106 1425fb4
Merge branch 'release_v4.8.3' into feature/admin_rpc
317787106 ab0b58c
Merge branch 'release_v4.8.3' into feature/admin_rpc
317787106 0e624ea
AdminRpcServlet don't extend RateLimiterServlet
317787106 6152d3e
remove isAttachMode in Args
317787106 280653e
use node.jsonrpc.maxMessageSize for IpcService request
317787106 468d9ab
require ipc not exist in socketDirectory
317787106 2e73278
ipc and http get the same error code when request violate depth or to…
317787106 5823f31
reject batch request in admin jsonrpc
317787106 0d884cd
imporve the validation of success for IpcResponse
317787106 f2ce52e
remove length comment of socketDirectory
317787106 decdf68
Merge branch 'release_v4.8.3' into feature/admin_rpc
317787106 448d1c8
extract AdminJsonRpcRequestHandler for http and ipc
317787106 a7741d5
chore(api): merge release_v4.8.3 into admin rpc
317787106 cf7caf5
Merge branch 'release_v4.8.3' into feature/admin_rpc
317787106 3e54e1e
update the package of Constant.LOCAL_HOST
317787106 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
framework/src/main/java/org/tron/core/config/args/CommandLineArguments.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package org.tron.core.config.args; | ||
|
|
||
| import com.beust.jcommander.JCommander; | ||
| import com.beust.jcommander.ParameterDescription; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| import lombok.Getter; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.tron.core.exception.TronError; | ||
|
|
||
| /** | ||
| * Parses startup options without initializing node configuration or logging. Keep this class | ||
| * independent of Args, CommonParameter, and logging so FullNode can dispatch the standalone client. | ||
| */ | ||
| @Getter | ||
| public final class CommandLineArguments { | ||
|
|
||
| private final CLIParameter parameters = new CLIParameter(); | ||
| private final JCommander commander = JCommander.newBuilder().addObject(parameters).build(); | ||
| private final List<ParameterDescription> assignedParameters; | ||
|
|
||
| public CommandLineArguments(String[] args) { | ||
| commander.parse(args); | ||
| assignedParameters = commander.getParameters().stream() | ||
| .filter(ParameterDescription::isAssigned) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public boolean isAttachMode() { | ||
| // Preserve the existing help/version precedence over attach validation. | ||
| if (parameters.help || parameters.version) { | ||
| return false; | ||
| } | ||
| if (!isAssigned("ipcSocketFile")) { | ||
| if (isAssigned("ipcExecCommand")) { | ||
| throwAttachParameterError("Error: --exec requires --attach <socket-path>"); | ||
| } | ||
| return false; | ||
| } | ||
| if (isAssigned("shellConfFileName")) { | ||
| throwAttachParameterError("Error: --attach cannot be combined with: --config"); | ||
| } | ||
| if (StringUtils.isBlank(parameters.ipcSocketFile)) { | ||
| throwAttachParameterError("Error: --attach requires a non-empty <socket-path>"); | ||
| } | ||
| // Node-only CLI options are irrelevant to the standalone IPC client and are ignored. | ||
| return true; | ||
| } | ||
|
|
||
| private boolean isAssigned(String fieldName) { | ||
| return assignedParameters.stream() | ||
| .anyMatch(pd -> fieldName.equals(pd.getParameterized().getName())); | ||
| } | ||
|
|
||
| private static void throwAttachParameterError(String message) { | ||
| System.err.println(message); | ||
| throw new TronError(message, TronError.ErrCode.PARAMETER_INIT); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.