Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
link33
plugin
Commits
81bf3dbb
Commit
81bf3dbb
authored
Oct 28, 2021
by
libangzhu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gossip-tls' of github.com:libangzhu/plugin into gossip-tls
parents
5df5e02f
dd4bcb83
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
14 deletions
+15
-14
netaddress.go
plugin/p2p/gossip/netaddress.go
+1
-2
node.go
plugin/p2p/gossip/node.go
+2
-1
p2p_test.go
plugin/p2p/gossip/p2p_test.go
+6
-5
p2pcli.go
plugin/p2p/gossip/p2pcli.go
+1
-1
tls.go
plugin/p2p/gossip/tls.go
+5
-5
No files found.
plugin/p2p/gossip/netaddress.go
View file @
81bf3dbb
...
@@ -173,7 +173,7 @@ func (na *NetAddress) DialTimeout(version int32, creds credentials.TransportCred
...
@@ -173,7 +173,7 @@ func (na *NetAddress) DialTimeout(version int32, creds credentials.TransportCred
return
err
return
err
}
}
if
bList
!=
nil
&&
bList
.
Has
(
ip
)
||
bList
!=
nil
&&
bList
.
Has
(
na
.
String
())
{
if
bList
!=
nil
&&
bList
.
Has
(
ip
)
||
bList
!=
nil
&&
bList
.
Has
(
na
.
String
())
{
return
fmt
.
Errorf
(
"interceptor blacklist peer %v no authorized"
,
na
.
String
())
return
fmt
.
Errorf
(
"interceptor blacklist peer %v no authorized"
,
na
.
String
())
}
}
...
@@ -195,7 +195,6 @@ func (na *NetAddress) DialTimeout(version int32, creds credentials.TransportCred
...
@@ -195,7 +195,6 @@ func (na *NetAddress) DialTimeout(version int32, creds credentials.TransportCred
return
streamer
(
ctx
,
desc
,
cc
,
method
,
opts
...
)
return
streamer
(
ctx
,
desc
,
cc
,
method
,
opts
...
)
}
}
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
*
3
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
*
3
)
defer
cancel
()
defer
cancel
()
conn
,
err
:=
grpc
.
DialContext
(
ctx
,
na
.
String
(),
conn
,
err
:=
grpc
.
DialContext
(
ctx
,
na
.
String
(),
...
...
plugin/p2p/gossip/node.go
View file @
81bf3dbb
...
@@ -8,10 +8,11 @@ import (
...
@@ -8,10 +8,11 @@ import (
"crypto/tls"
"crypto/tls"
"crypto/x509"
"crypto/x509"
"fmt"
"fmt"
"google.golang.org/grpc/credentials"
"io/ioutil"
"io/ioutil"
"math/rand"
"math/rand"
"google.golang.org/grpc/credentials"
"github.com/33cn/chain33/p2p"
"github.com/33cn/chain33/p2p"
//"strings"
//"strings"
...
...
plugin/p2p/gossip/p2p_test.go
View file @
81bf3dbb
...
@@ -6,13 +6,14 @@ import (
...
@@ -6,13 +6,14 @@ import (
"encoding/hex"
"encoding/hex"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/33cn/chain33/common/pubsub"
"google.golang.org/grpc/credentials"
"net"
"net"
"sort"
"sort"
"sync/atomic"
"sync/atomic"
"time"
"time"
"github.com/33cn/chain33/common/pubsub"
"google.golang.org/grpc/credentials"
"github.com/33cn/chain33/p2p"
"github.com/33cn/chain33/p2p"
"github.com/33cn/chain33/p2p/utils"
"github.com/33cn/chain33/p2p/utils"
...
@@ -690,12 +691,12 @@ uZ+EF9dHu0nEBcdZFJnAdMWf6MhTCHRQR9wSf9M8CJ5TQKNHpIFLUWJU
...
@@ -690,12 +691,12 @@ uZ+EF9dHu0nEBcdZFJnAdMWf6MhTCHRQR9wSf9M8CJ5TQKNHpIFLUWJU
node
.
listenPort
=
13332
node
.
listenPort
=
13332
node
.
nodeInfo
.
servCreds
=
servCreds
node
.
nodeInfo
.
servCreds
=
servCreds
node
.
pubsub
=
pubsub
.
NewPubSub
(
10200
)
node
.
pubsub
=
pubsub
.
NewPubSub
(
10200
)
l
:=
newListener
(
"tcp"
,
&
node
)
l
:=
newListener
(
"tcp"
,
&
node
)
assert
.
NotNil
(
t
,
l
)
assert
.
NotNil
(
t
,
l
)
go
l
.
Start
()
go
l
.
Start
()
defer
l
.
Close
()
defer
l
.
Close
()
netAddr
,
err
:=
NewNetAddressString
(
fmt
.
Sprintf
(
"127.0.0.1:%v"
,
node
.
listenPort
))
netAddr
,
err
:=
NewNetAddressString
(
fmt
.
Sprintf
(
"127.0.0.1:%v"
,
node
.
listenPort
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
conn
,
err
:=
grpc
.
Dial
(
netAddr
.
String
(),
grpc
.
WithTransportCredentials
(
cliCreds
))
conn
,
err
:=
grpc
.
Dial
(
netAddr
.
String
(),
grpc
.
WithTransportCredentials
(
cliCreds
))
...
...
plugin/p2p/gossip/p2pcli.go
View file @
81bf3dbb
...
@@ -295,7 +295,7 @@ func (m *Cli) SendVersion(peer *Peer, nodeinfo *NodeInfo) (string, error) {
...
@@ -295,7 +295,7 @@ func (m *Cli) SendVersion(peer *Peer, nodeinfo *NodeInfo) (string, error) {
log
.
Debug
(
"sendVersion"
,
"expect ip"
,
ip
,
"pre externalip"
,
nodeinfo
.
GetExternalAddr
()
.
IP
.
String
())
log
.
Debug
(
"sendVersion"
,
"expect ip"
,
ip
,
"pre externalip"
,
nodeinfo
.
GetExternalAddr
()
.
IP
.
String
())
if
peer
.
IsPersistent
()
{
if
peer
.
IsPersistent
()
{
//永久加入黑名单
//永久加入黑名单
nodeinfo
.
blacklist
.
Add
(
resp
.
GetAddrRecv
(),
0
)
//把自己的IP:PORT 加入黑名单,防止连接到自己
nodeinfo
.
blacklist
.
Add
(
resp
.
GetAddrRecv
(),
0
)
//把自己的IP:PORT 加入黑名单,防止连接到自己
}
}
}
}
}
}
...
...
plugin/p2p/gossip/tls.go
View file @
81bf3dbb
...
@@ -16,8 +16,6 @@ import (
...
@@ -16,8 +16,6 @@ import (
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials"
)
)
//Tls defines the specific interface for all the live gRPC wire
//Tls defines the specific interface for all the live gRPC wire
// protocols and supported transport security protocols (e.g., TLS, SSL).
// protocols and supported transport security protocols (e.g., TLS, SSL).
type
Tls
struct
{
type
Tls
struct
{
...
@@ -29,11 +27,13 @@ type certInfo struct {
...
@@ -29,11 +27,13 @@ type certInfo struct {
ip
string
ip
string
serial
string
serial
string
}
}
var
(
serials
=
make
(
map
[
string
]
*
certInfo
)
var
(
revokeLock
sync
.
Mutex
serials
=
make
(
map
[
string
]
*
certInfo
)
revokeLock
sync
.
Mutex
latestSerials
sync
.
Map
latestSerials
sync
.
Map
)
)
//serialNum -->ip
//serialNum -->ip
func
addCertSerial
(
serial
*
big
.
Int
,
ip
string
)
{
func
addCertSerial
(
serial
*
big
.
Int
,
ip
string
)
{
revokeLock
.
Lock
()
revokeLock
.
Lock
()
...
...
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