Commit 7a912bbd authored by Richer Maximilien's avatar Richer Maximilien
Browse files

[c][p] Local ip probing for clients

- pAPI allow to send multiple IPs
- Rebuild of protobuf files with updated protoc
- Send client interface ips
- Remove user ip & port from mongo
- Fix uint port issue
parent a0fcc598
...@@ -262,29 +262,27 @@ var _Client_serviceDesc = grpc.ServiceDesc{ ...@@ -262,29 +262,27 @@ var _Client_serviceDesc = grpc.ServiceDesc{
} }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 380 bytes of a gzipped FileDescriptorProto // 348 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x52, 0xed, 0xaa, 0xda, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x91, 0xcf, 0x4e, 0xea, 0x40,
0x10, 0x35, 0x7e, 0x45, 0xa7, 0x51, 0xca, 0xe2, 0x8f, 0x90, 0x52, 0xb0, 0x41, 0x8a, 0xf4, 0x47, 0x14, 0xc6, 0xe9, 0xe5, 0x4f, 0xe1, 0xdc, 0xc2, 0x25, 0x93, 0x6b, 0x32, 0x41, 0x49, 0x48, 0xe3,
0x04, 0xfb, 0x08, 0x5a, 0xb0, 0x94, 0x42, 0x49, 0xeb, 0x03, 0x6c, 0x37, 0x63, 0xbb, 0x10, 0xb3, 0x82, 0x55, 0x49, 0x70, 0xe9, 0x12, 0x4c, 0x30, 0x6e, 0x4c, 0x94, 0x07, 0x18, 0xa7, 0x07, 0x9d,
0xe9, 0xee, 0x5a, 0xf4, 0x35, 0xee, 0x0b, 0xdf, 0xbb, 0x99, 0x18, 0xaf, 0x72, 0xfd, 0x71, 0xff, 0xa4, 0x74, 0xea, 0xcc, 0x60, 0xe0, 0x35, 0x7c, 0x02, 0x1f, 0xd5, 0xe9, 0xa9, 0x45, 0x16, 0x26,
0x2c, 0x7b, 0x66, 0xce, 0x9e, 0x33, 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00, 0x00, 0xff, 0xff, 0x64, 0x27, 0xd3, 0xc2, 0x22, 0x02, 0x00, 0x00,
0x0c, 0xa8, 0x4b, 0x03, 0x46, 0x57, 0xf7, 0xb8, 0xf5, 0xbb, 0x4f, 0x5f, 0xee, 0xf3, 0x53, 0x00,
0x00, 0x00, 0xff, 0xff, 0xfe, 0x4f, 0xca, 0xea, 0xb5, 0x02, 0x00, 0x00,
} }
...@@ -103,9 +103,15 @@ func NewSignatureManager(passphrase string, c *contract.JSON) (*SignatureManager ...@@ -103,9 +103,15 @@ func NewSignatureManager(passphrase string, c *contract.JSON) (*SignatureManager
// ConnectToPeers tries to fetch the list of users for this contract, and tries to establish a connection to each peer. // ConnectToPeers tries to fetch the list of users for this contract, and tries to establish a connection to each peer.
func (m *SignatureManager) ConnectToPeers() error { func (m *SignatureManager) ConnectToPeers() error {
localIps, err := net.ExternalInterfaceAddr()
if err != nil {
return err
}
stream, err := m.platform.JoinSignature(context.Background(), &pAPI.JoinSignatureRequest{ stream, err := m.platform.JoinSignature(context.Background(), &pAPI.JoinSignatureRequest{
ContractUuid: m.contract.UUID, ContractUuid: m.contract.UUID,
Port: uint32(viper.GetInt("local_port")), Port: uint32(viper.GetInt("local_port")),
Ip: localIps,
}) })
if err != nil { if err != nil {
return err return err
...@@ -142,11 +148,19 @@ func (m *SignatureManager) addPeer(user *pAPI.User) (ready bool, err error) { ...@@ -142,11 +148,19 @@ func (m *SignatureManager) addPeer(user *pAPI.User) (ready bool, err error) {
return // Ignore if unknown return // Ignore if unknown
} }
addrPort := user.Ip + ":" + strconv.Itoa(int(user.Port)) var conn *grpc.ClientConn
m.OnSignerStatusUpdate(user.Email, StatusConnecting, addrPort) for _, ip := range user.Ip {
addrPort := ip + ":" + strconv.Itoa(int(user.Port))
m.OnSignerStatusUpdate(user.Email, StatusConnecting, addrPort)
// This is an certificate authentificated TLS connection
conn, err = net.Connect(addrPort, m.auth.Cert, m.auth.Key, m.auth.CA, user.KeyHash)
if err == nil {
break
}
}
// This is an certificate authentificated TLS connection
conn, err := net.Connect(addrPort, m.auth.Cert, m.auth.Key, m.auth.CA, user.KeyHash)
if err != nil { if err != nil {
m.OnSignerStatusUpdate(user.Email, StatusError, err.Error()) m.OnSignerStatusUpdate(user.Email, StatusError, err.Error())
return false, err return false, err
......
...@@ -135,16 +135,15 @@ var _Demonstrator_serviceDesc = grpc.ServiceDesc{ ...@@ -135,16 +135,15 @@ var _Demonstrator_serviceDesc = grpc.ServiceDesc{
} }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 167 bytes of a gzipped FileDescriptorProto // 159 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x49, 0x2b, 0x2e, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x49, 0x2b, 0x2e,
0xd6, 0x07, 0x11, 0x29, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x29, 0xa9, 0xb9, 0xf9, 0x79, 0xc5, 0x25, 0xd6, 0x07, 0x11, 0x29, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x29, 0xa9, 0xb9, 0xf9, 0x79, 0xc5, 0x25,
0x45, 0x89, 0x25, 0xf9, 0x45, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xcc, 0x40, 0x71, 0xa5, 0x45, 0x89, 0x25, 0xf9, 0x45, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xcc, 0x40, 0x71, 0x25,
0x50, 0x2e, 0x66, 0x9f, 0xfc, 0x74, 0x21, 0x19, 0x2e, 0xce, 0x92, 0xcc, 0xdc, 0xd4, 0xe2, 0x92, 0x4b, 0x2e, 0x66, 0x9f, 0xfc, 0x74, 0x21, 0x41, 0x2e, 0xce, 0x92, 0xcc, 0xdc, 0xd4, 0xe2, 0x92,
0xc4, 0xdc, 0x02, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xe6, 0x20, 0x84, 0x80, 0x90, 0x1c, 0x17, 0x57, 0xc4, 0xdc, 0x02, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x66, 0x21, 0x21, 0x2e, 0xae, 0xcc, 0x94, 0xd4,
0x66, 0x4a, 0x6a, 0x5e, 0x49, 0x66, 0x5a, 0x66, 0x6a, 0x91, 0x04, 0x13, 0x50, 0x9a, 0x33, 0x08, 0xbc, 0x92, 0xcc, 0xb4, 0xcc, 0xd4, 0x22, 0x09, 0x26, 0xa0, 0x18, 0xa7, 0x10, 0x37, 0x17, 0x73,
0x49, 0x44, 0x48, 0x80, 0x8b, 0x39, 0x27, 0x3f, 0x5d, 0x82, 0x19, 0x2c, 0x01, 0x62, 0x2a, 0xb1, 0x4e, 0x7e, 0xba, 0x04, 0x33, 0x88, 0xa3, 0xc4, 0xca, 0xc5, 0xec, 0x98, 0x9c, 0x6d, 0xa4, 0xcf,
0x72, 0x31, 0x3b, 0x26, 0x67, 0x1b, 0xe9, 0x73, 0xf1, 0xb8, 0x20, 0x59, 0x2c, 0x24, 0xcf, 0xc5, 0xc5, 0xe3, 0x82, 0x64, 0xb8, 0x90, 0x3c, 0x17, 0x7b, 0x70, 0x6a, 0x5e, 0x0a, 0xc8, 0x54, 0x0e,
0x1e, 0x9c, 0x9a, 0x97, 0x02, 0xb2, 0x91, 0x43, 0x0f, 0x68, 0xbd, 0x1e, 0x90, 0x25, 0x05, 0x61, 0x3d, 0xa0, 0x15, 0x7a, 0x40, 0x96, 0x14, 0x84, 0x05, 0x54, 0xae, 0xc4, 0x90, 0xc4, 0x06, 0xb6,
0x01, 0x95, 0x2b, 0x31, 0x24, 0xb1, 0x81, 0x9d, 0x66, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xde, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x16, 0xf4, 0xd0, 0x37, 0xa3, 0x00, 0x00, 0x00,
0xc3, 0x86, 0x7b, 0xbf, 0x00, 0x00, 0x00,
} }
...@@ -192,6 +192,8 @@ type JoinSignatureRequest struct { ...@@ -192,6 +192,8 @@ type JoinSignatureRequest struct {
ContractUuid string `protobuf:"bytes,1,opt,name=contractUuid" json:"contractUuid,omitempty"` ContractUuid string `protobuf:"bytes,1,opt,name=contractUuid" json:"contractUuid,omitempty"`
// / The open port for P2P communication of the client // / The open port for P2P communication of the client
Port uint32 `protobuf:"varint,2,opt,name=port" json:"port,omitempty"` Port uint32 `protobuf:"varint,2,opt,name=port" json:"port,omitempty"`
// / The offered ips for P2P communication of the client
Ip []string `protobuf:"bytes,3,rep,name=ip" json:"ip,omitempty"`
} }
func (m *JoinSignatureRequest) Reset() { *m = JoinSignatureRequest{} } func (m *JoinSignatureRequest) Reset() { *m = JoinSignatureRequest{} }
...@@ -235,7 +237,7 @@ type User struct { ...@@ -235,7 +237,7 @@ type User struct {
KeyHash []byte `protobuf:"bytes,1,opt,name=keyHash,proto3" json:"keyHash,omitempty"` KeyHash []byte `protobuf:"bytes,1,opt,name=keyHash,proto3" json:"keyHash,omitempty"`
Email string `protobuf:"bytes,2,opt,name=email" json:"email,omitempty"` Email string `protobuf:"bytes,2,opt,name=email" json:"email,omitempty"`
// / The IP offered by the user for P2P // / The IP offered by the user for P2P
Ip string `protobuf:"bytes,3,opt,name=ip" json:"ip,omitempty"` Ip []string `protobuf:"bytes,3,rep,name=ip" json:"ip,omitempty"`
// / The port offered by the user for P2P // / The port offered by the user for P2P
Port uint32 `protobuf:"varint,4,opt,name=port" json:"port,omitempty"` Port uint32 `protobuf:"varint,4,opt,name=port" json:"port,omitempty"`
} }
...@@ -620,51 +622,47 @@ var _Platform_serviceDesc = grpc.ServiceDesc{ ...@@ -620,51 +622,47 @@ var _Platform_serviceDesc = grpc.ServiceDesc{
} }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 723 bytes of a gzipped FileDescriptorProto // 666 bytes of a gzipped FileD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97, 0x50, 0xcf, 0xc8, 0x11, 0x3d, 0x50, 0x9f, 0x29, 0xbc, 0xe5, 0x08, 0x5c, 0xf9, 0x50, 0xd3, 0x7f, 0x9d, 0x4f, 0x7e, 0x04, 0x00, 0x00,
0x01, 0xff, 0x0a, 0xb4, 0xdd, 0x50, 0x1b, 0xda, 0x2b, 0x0e, 0x9e, 0x40, 0x23, 0xa7, 0x27, 0xf4, 0xff, 0xff, 0x9e, 0x01, 0x0b, 0x56, 0x5b, 0x05, 0x00, 0x00,
0x50, 0x45, 0x6c, 0xd3, 0x58, 0x1b, 0xa5, 0x93, 0x9b, 0xaa, 0x05, 0x17, 0x8e, 0x0d, 0x51, 0x78,
0x2d, 0x1d, 0x32, 0x74, 0x2f, 0x21, 0x22, 0x3f, 0x74, 0xed, 0x98, 0xe1, 0x8d, 0x91, 0xc2, 0x85,
0xcf, 0x65, 0xf5, 0xf1, 0x78, 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff, 0xdb, 0xb0, 0xef, 0x13, 0x5d,
0x06, 0x00, 0x00,
} }
...@@ -101,6 +101,8 @@ message JoinSignatureRequest { ...@@ -101,6 +101,8 @@ message JoinSignatureRequest {
string contractUuid = 1; string contractUuid = 1;
/// The open port for P2P communication of the client /// The open port for P2P communication of the client
uint32 port = 2; uint32 port = 2;
/// The offered ips for P2P communication of the client
repeated string ip = 3;
} }
/// UserConnected is emitted by the platform to the client to announce a new client connection, through a stream. /// UserConnected is emitted by the platform to the client to announce a new client connection, through a stream.
...@@ -120,7 +122,7 @@ message User { ...@@ -120,7 +122,7 @@ message User {
bytes keyHash = 1; bytes keyHash = 1;
string email = 2; string email = 2;
/// The IP offered by the user for P2P /// The IP offered by the user for P2P
string ip = 3; repeated string ip = 3;
/// The port offered by the user for P2P /// The port offered by the user for P2P
uint32 port = 4; uint32 port = 4;
} }
......
package contract package contract
import ( import (
n "net"
"time" "time"
"dfss/auth" "dfss/auth"
...@@ -21,7 +20,7 @@ import ( ...@@ -21,7 +20,7 @@ import (
// There is no timeout, this function will shut down on stream disconnection or on error. // There is no timeout, this function will shut down on stream disconnection or on error.
func JoinSignature(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, in *api.JoinSignatureRequest, stream api.Platform_JoinSignatureServer) { func JoinSignature(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, in *api.JoinSignatureRequest, stream api.Platform_JoinSignatureServer) {
ctx := stream.Context() ctx := stream.Context()
state, addr, _ := net.GetTLSState(&ctx) state, _, _ := net.GetTLSState(&ctx)
hash := auth.GetCertificateHash(state.VerifiedChains[0][0]) hash := auth.GetCertificateHash(state.VerifiedChains[0][0])
if !checkJoinSignatureRequest(db, &stream, in.ContractUuid, hash) { if !checkJoinSignatureRequest(db, &stream, in.ContractUuid, hash) {
...@@ -42,11 +41,10 @@ func JoinSignature(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, in *api ...@@ -42,11 +41,10 @@ func JoinSignature(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, in *api
} }
// Broadcast self identity // Broadcast self identity
host, _, _ := n.SplitHostPort(addr.String())
rooms.Broadcast(roomID, &api.User{ rooms.Broadcast(roomID, &api.User{
KeyHash: hash, KeyHash: hash,
Email: net.GetCN(&ctx), Email: net.GetCN(&ctx),
Ip: host, Ip: in.Ip,
Port: in.Port, Port: in.Port,
}) })
......
...@@ -36,7 +36,6 @@ func TestJoinSignature(t *testing.T) { ...@@ -36,7 +36,6 @@ func TestJoinSignature(t *testing.T) {
assert.Equal(t, api.ErrorCode_SUCCESS, user.ErrorCode.Code) assert.Equal(t, api.ErrorCode_SUCCESS, user.ErrorCode.Code)
assert.Equal(t, contractID.Hex(), user.ContractUuid) assert.Equal(t, contractID.Hex(), user.ContractUuid)
assert.Equal(t, "test@test.com", user.User.Email) assert.Equal(t, "test@test.com", user.User.Email)
assert.Equal(t, "127.0.0.1", user.User.Ip)
assert.Equal(t, uint32(5050), user.User.Port) assert.Equal(t, uint32(5050), user.User.Port)
} }
......
...@@ -8,28 +8,16 @@ import ( ...@@ -8,28 +8,16 @@ import (
"gopkg.in/mgo.v2/bson" "gopkg.in/mgo.v2/bson"
) )
// ConnectionInfo : Internal connection information of a User
type ConnectionInfo struct {
IP string `key:"ip" bson:"ip"` // Ip of the connection
Port int `key:"port" bson:"port"` // Port of the connection
}
// NewConnectionInfo : Create a new ConnectionInfo
func NewConnectionInfo() *ConnectionInfo {
return &ConnectionInfo{}
}
// User : User stored in mongo // User : User stored in mongo
type User struct { type User struct {
ID bson.ObjectId `key:"_id" bson:"_id"` // Internal id of a User ID bson.ObjectId `key:"_id" bson:"_id"` // Internal id of a User
Email string `key:"email" bson:"email"` // Email of a User Email string `key:"email" bson:"email"` // Email of a User
Registration time.Time `key:"registration" bson:"registration"` // Time of registration of the User Registration time.Time `key:"registration" bson:"registration"` // Time of registration of the User
Expiration time.Time `key:"expiration" bson:"expiration"` // Certificate expiration of the User Expiration time.Time `key:"expiration" bson:"expiration"` // Certificate expiration of the User
RegToken string `key:"regToken" bson:"regToken"` // Token used for registering a User RegToken string `key:"regToken" bson:"regToken"` // Token used for registering a User
Csr string `key:"csr" bson:"csr"` // Certificate request at PEM format Csr string `key:"csr" bson:"csr"` // Certificate request at PEM format
Certificate string `key:"certificate" bson:"certificate"` // Certificate of the User Certificate string `key:"certificate" bson:"certificate"` // Certificate of the User
CertHash []byte `key:"certHash" bson:"certHash"` // Hash of the certificate CertHash []byte `key:"certHash" bson:"certHash"` // Hash of the certificate
ConnInfo ConnectionInfo `key:"connInfo" bson:"connInfo"` // Information about the connection
} }
// NewUser : Create a new User // NewUser : Create a new User
...@@ -37,7 +25,6 @@ func NewUser() *User { ...@@ -37,7 +25,6 @@ func NewUser() *User {
return &User{ return &User{
ID: bson.NewObjectId(), ID: bson.NewObjectId(),
Registration: time.Now().UTC(), Registration: time.Now().UTC(),
ConnInfo: *NewConnectionInfo(),
} }
} }
......
...@@ -101,8 +101,6 @@ func TestMongoInsertUser(t *testing.T) { ...@@ -101,8 +101,6 @@ func TestMongoInsertUser(t *testing.T) {
user := entities.NewUser() user := entities.NewUser()
user.Email = "dfss1@mpcs.tk" user.Email = "dfss1@mpcs.tk"
user.CertHash = []byte{0x01, 0x02} user.CertHash = []byte{0x01, 0x02}
user.ConnInfo.IP = "127.0.0.1"
user.ConnInfo.Port = 1111
user.Csr = "csr1" user.Csr = "csr1"
user.RegToken = "regToken 1" user.RegToken = "regToken 1"
...@@ -137,14 +135,6 @@ func equalUsers(t *testing.T, user1, user2 *entities.User) { ...@@ -137,14 +135,6 @@ func equalUsers(t *testing.T, user1, user2 *entities.User) {
t.Fatal("Csr doesn't match : received ", user1.Csr, " and ", user2.Csr) t.Fatal("Csr doesn't match : received ", user1.Csr, " and ", user2.Csr)
} }
if user1.ConnInfo.IP != user2.ConnInfo.IP {
t.Fatal("ConnInfo.IP doesn't match : received ", user1.ConnInfo.IP, " and ", user2.ConnInfo.IP)
}
if user1.ConnInfo.Port != user2.ConnInfo.Port {
t.Fatal("ConnInfo.Port doesn't match : received ", user1.ConnInfo.Port, " and ", user2.ConnInfo.Port)
}
if user1.Certificate != user2.Certificate { if user1.Certificate != user2.Certificate {
t.Fatal("Certificate doesn't match : received ", user1.Certificate, " and ", user2.Certificate) t.Fatal("Certificate doesn't match : received ", user1.Certificate, " and ", user2.Certificate)
} }
...@@ -154,8 +144,6 @@ func TestMongoFetchUser(t *testing.T) { ...@@ -154,8 +144,6 @@ func TestMongoFetchUser(t *testing.T) {
user := entities.NewUser() user := entities.NewUser()
user.Email = "dfss2@mpcs.tk" user.Email = "dfss2@mpcs.tk"
user.CertHash = nil user.CertHash = nil
user.ConnInfo.IP = "127.0.0.2"
user.ConnInfo.Port = 2222
user.Csr = "csr2" user.Csr = "csr2"
user.RegToken = "regToken 2" user.RegToken = "regToken 2"
......
...@@ -190,21 +190,20 @@ var _TTP_serviceDesc = grpc.ServiceDesc{ ...@@ -190,21 +190,20 @@ var _TTP_serviceDesc = grpc.ServiceDesc{
} }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 245 bytes of a gzipped FileDescriptorProto // 231 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x90, 0xcd, 0x4a, 0xc4, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x8f, 0xcd, 0x4a, 0xc3, 0x40,
0x10, 0xc7, 0x5d, 0xcb, 0x6a, 0x9d, 0xad, 0xa2, 0xd1, 0xc3, 0x52, 0x0f, 0x4a, 0xf1, 0xd0, 0x53, 0x10, 0xc7, 0xad, 0xa1, 0x1a, 0xa7, 0xa9, 0xd4, 0x11, 0xa1, 0x54, 0x50, 0xc9, 0xc5, 0x9e, 0x36,
0x0b, 0x15, 0xc4, 0x9b, 0x08, 0x5e, 0xbc, 0x2d, 0x61, 0xf7, 0x01, 0xb2, 0x71, 0x94, 0x40, 0x4d, 0x10, 0x9f, 0x40, 0xf0, 0xe2, 0xad, 0x84, 0xf6, 0x01, 0xd2, 0x75, 0x94, 0x85, 0xb8, 0x13, 0x77,
0x6a, 0x66, 0xea, 0xf3, 0x1b, 0x53, 0x2d, 0x5b, 0xd8, 0x4b, 0x60, 0xfe, 0x1f, 0x93, 0x5f, 0x02, 0x26, 0x3e, 0xbf, 0xeb, 0x56, 0xa5, 0x42, 0x2f, 0x7b, 0xf8, 0x7f, 0xed, 0x6f, 0xe0, 0xf6, 0xe5,
0x37, 0x6f, 0xef, 0x44, 0xf5, 0xef, 0xc1, 0xb5, 0xea, 0x4c, 0xed, 0x91, 0x5c, 0xdb, 0xb3, 0x71, 0x55, 0xa4, 0xfa, 0x7e, 0xb4, 0x6a, 0x7b, 0x57, 0x05, 0x12, 0xee, 0x06, 0x75, 0xec, 0x4d, 0x1f,
0xb6, 0xea, 0xbc, 0x63, 0x27, 0x92, 0xa0, 0xe6, 0xd7, 0x63, 0x4a, 0xc7, 0x94, 0x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 0x52, 0xed, 0x2c, 0x7b, 0xa5, 0x79, 0x79, 0x18, 0x8c, 0x4c, 0x8e, 0x9d, 0x1f, 0x47, 0xa5, 0xa8, 0x1d, 0x64, 0x31, 0x8f, 0x06, 0xc6, 0x89, 0x07, 0x2f, 0xd2, 0xb7,
0x73, 0x63, 0x20, 0x09, 0x0b, 0x44, 0x05, 0xf3, 0x48, 0x2e, 0x2e, 0x22, 0xe0, 0xee, 0x2b, 0xf2, 0xfb, 0x6c, 0x8b, 0x59, 0x92, 0xf6, 0x56, 0xcb, 0x23, 0xac, 0xe1, 0xf4, 0x87, 0x07, 0x2f, 0x93,
0xf3, 0x28, 0xed, 0x5c, 0x53, 0x1c, 0x88, 0x06, 0x8e, 0xff, 0x78, 0xc5, 0x65, 0xb4, 0xa7, 0xf4, 0xfd, 0x9f, 0xee, 0x50, 0x67, 0x7b, 0x92, 0x4e, 0x7f, 0xf8, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x38,
0xfb, 0x3a, 0xdb, 0xa3, 0xf8, 0x49, 0xf7, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe0, 0xac, 0x9b, 0x4a, 0x1c, 0x12, 0x3f, 0x01, 0x00, 0x00,
0x9a, 0x69, 0x01, 0x00, 0x00,
} }
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"crypto/x509" "crypto/x509"
"errors" "errors"
"net" "net"
"strings"
"time" "time"
"dfss/auth" "dfss/auth"
...@@ -144,3 +145,30 @@ func (c *tlsCreds) ClientHandshake(addr string, rawConn net.Conn, timeout time.D ...@@ -144,3 +145,30 @@ func (c *tlsCreds) ClientHandshake(addr string, rawConn net.Conn, timeout time.D
func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
return nil, nil, errors.New("Server side handshake not implemented") return nil, nil, errors.New("Server side handshake not implemented")
} }
// ExternalInterfaceAddr returns a list of the system's network interface addresses
// Returns only ipv4 address if there is a lo interface, it is put at the end
func ExternalInterfaceAddr() ([]string, error) {
addrs, err := net.InterfaceAddrs()
if err != nil {
return nil, err
}
var extAddrs = make([]string, len(addrs))
var localhostAddrs = make([]string, 1)
for _, a := range addrs {
if strings.ContainsRune(a.String(), ':') {
// ipv6, do nothing
} else if strings.ContainsRune(a.String(), '/') {
ip := strings.Split(a.String(), "/")[0]
if strings.HasPrefix(ip, "127") {
// move localhost ip at the end if present
localhostAddrs = append(localhostAddrs, ip)
} else {
extAddrs = append(extAddrs, ip)
}
}
}
return append(extAddrs, localhostAddrs...), nil
}
...@@ -170,16 +170,15 @@ var _Test_serviceDesc = grpc.ServiceDesc{ ...@@ -170,16 +170,15 @@ var _Test_serviceDesc = grpc.ServiceDesc{
} }