-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Granular rpc control (Allow list for RPC daemon) (#1341)
- Loading branch information
Showing
19 changed files
with
247 additions
and
1,410 deletions.
There are no files selected for viewing
This file contains 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 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 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,43 @@ | ||
package cli | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"os" | ||
"strings" | ||
|
||
"github.com/ledgerwatch/turbo-geth/rpc" | ||
) | ||
|
||
type allowListFile struct { | ||
Allow rpc.AllowList `json:"allow"` | ||
} | ||
|
||
func parseAllowListForRPC(path string) (rpc.AllowList, error) { | ||
path = strings.TrimSpace(path) | ||
if path == "" { // no file is provided | ||
return nil, nil | ||
} | ||
|
||
file, err := os.Open(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer func() { | ||
file.Close() //nolint: errcheck | ||
}() | ||
|
||
fileContents, err := ioutil.ReadAll(file) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var allowListFileObj allowListFile | ||
|
||
err = json.Unmarshal(fileContents, &allowListFileObj) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return allowListFileObj.Allow, nil | ||
} |
Oops, something went wrong.