Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
4f35b852
Commit
4f35b852
authored
Aug 24, 2023
by
Andrew Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to restrict the networks that op-node discovers peers on
parent
0f0d85ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
1 deletion
+19
-1
p2p_flags.go
op-node/flags/p2p_flags.go
+8
-0
load_config.go
op-node/p2p/cli/load_config.go
+8
-0
config.go
op-node/p2p/config.go
+2
-0
discovery.go
op-node/p2p/discovery.go
+1
-1
No files found.
op-node/flags/p2p_flags.go
View file @
4f35b852
...
@@ -152,6 +152,13 @@ var (
...
@@ -152,6 +152,13 @@ var (
Value
:
""
,
Value
:
""
,
EnvVars
:
p2pEnv
(
"STATIC"
),
EnvVars
:
p2pEnv
(
"STATIC"
),
}
}
NetRestrict
=
&
cli
.
StringFlag
{
Name
:
"p2p.netrestrict"
,
Usage
:
"Comma-separated list of CIDR masks. P2P will only try to connect on these networks"
,
Required
:
false
,
Value
:
""
,
EnvVars
:
p2pEnv
(
"NETRESTRICT"
),
}
HostMux
=
&
cli
.
StringFlag
{
HostMux
=
&
cli
.
StringFlag
{
Name
:
"p2p.mux"
,
Name
:
"p2p.mux"
,
Usage
:
"Comma-separated list of multiplexing protocols in order of preference. At least 1 required. Options: 'yamux','mplex'."
,
Usage
:
"Comma-separated list of multiplexing protocols in order of preference. At least 1 required. Options: 'yamux','mplex'."
,
...
@@ -322,6 +329,7 @@ var p2pFlags = []cli.Flag{
...
@@ -322,6 +329,7 @@ var p2pFlags = []cli.Flag{
AdvertiseUDPPort
,
AdvertiseUDPPort
,
Bootnodes
,
Bootnodes
,
StaticPeers
,
StaticPeers
,
NetRestrict
,
HostMux
,
HostMux
,
HostSecurity
,
HostSecurity
,
PeersLo
,
PeersLo
,
...
...
op-node/p2p/cli/load_config.go
View file @
4f35b852
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/netutil"
)
)
func
NewConfig
(
ctx
*
cli
.
Context
,
rollupCfg
*
rollup
.
Config
)
(
*
p2p
.
Config
,
error
)
{
func
NewConfig
(
ctx
*
cli
.
Context
,
rollupCfg
*
rollup
.
Config
)
(
*
p2p
.
Config
,
error
)
{
...
@@ -193,6 +194,13 @@ func loadDiscoveryOpts(conf *p2p.Config, ctx *cli.Context) error {
...
@@ -193,6 +194,13 @@ func loadDiscoveryOpts(conf *p2p.Config, ctx *cli.Context) error {
conf
.
Bootnodes
=
p2p
.
DefaultBootnodes
conf
.
Bootnodes
=
p2p
.
DefaultBootnodes
}
}
netRestrict
,
err
:=
netutil
.
ParseNetlist
(
ctx
.
String
(
flags
.
NetRestrict
.
Name
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to parse net list: %w"
,
err
)
}
conf
.
NetRestrict
=
netRestrict
return
nil
return
nil
}
}
...
...
op-node/p2p/config.go
View file @
4f35b852
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/netutil"
ds
"github.com/ipfs/go-datastore"
ds
"github.com/ipfs/go-datastore"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p"
pubsub
"github.com/libp2p/go-libp2p-pubsub"
pubsub
"github.com/libp2p/go-libp2p-pubsub"
...
@@ -84,6 +85,7 @@ type Config struct {
...
@@ -84,6 +85,7 @@ type Config struct {
AdvertiseUDPPort
uint16
AdvertiseUDPPort
uint16
Bootnodes
[]
*
enode
.
Node
Bootnodes
[]
*
enode
.
Node
DiscoveryDB
*
enode
.
DB
DiscoveryDB
*
enode
.
DB
NetRestrict
*
netutil
.
Netlist
StaticPeers
[]
core
.
Multiaddr
StaticPeers
[]
core
.
Multiaddr
...
...
op-node/p2p/discovery.go
View file @
4f35b852
...
@@ -97,7 +97,7 @@ func (conf *Config) Discovery(log log.Logger, rollupCfg *rollup.Config, tcpPort
...
@@ -97,7 +97,7 @@ func (conf *Config) Discovery(log log.Logger, rollupCfg *rollup.Config, tcpPort
cfg
:=
discover
.
Config
{
cfg
:=
discover
.
Config
{
PrivateKey
:
priv
,
PrivateKey
:
priv
,
NetRestrict
:
nil
,
NetRestrict
:
conf
.
NetRestrict
,
Bootnodes
:
conf
.
Bootnodes
,
Bootnodes
:
conf
.
Bootnodes
,
Unhandled
:
nil
,
// Not used in dv5
Unhandled
:
nil
,
// Not used in dv5
Log
:
log
,
Log
:
log
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment