Commit 81bf3dbb authored by libangzhu's avatar libangzhu

Merge branch 'gossip-tls' of github.com:libangzhu/plugin into gossip-tls

parents 5df5e02f dd4bcb83
...@@ -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(),
......
...@@ -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"
......
...@@ -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))
......
...@@ -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 加入黑名单,防止连接到自己
} }
} }
} }
......
...@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment