Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dfss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpcs
dfss
Merge requests
!8
113 grpc lib
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
113 grpc lib
113_grpc_lib
into
master
Overview
5
Commits
4
Pipelines
0
Changes
1
Merged
Richer Maximilien
requested to merge
113_grpc_lib
into
master
9 years ago
Overview
5
Commits
4
Pipelines
0
Changes
1
Expand
Implement gRPC primitives
0
0
Merge request reports
Viewing commit
8417c9ff
Prev
Next
Show latest version
1 file
+
42
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
8417c9ff
Client lib
· 8417c9ff
Richer Maximilien
authored
9 years ago
Fix addr & port in dialing
net/client.go
0 → 100644
+
42
−
0
Options
package
net
import
(
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"math/rand"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog"
)
// Connect to a peer
//
// Closing must be defered after call
func
Connect
(
addr_port
string
,
cert
,
key
,
ca
[]
byte
)
*
ClientConn
{
// load peer cert/key, ca as PEM buffers
peerCert
,
err
:=
tls
.
X509KeyPair
(
cert
,
key
)
if
err
!=
nil
{
log
.
Fatal
(
"Load peer cert/key error: %v"
,
err
)
}
caCertPool
:=
x509
.
NewCertPool
()
caCertPool
.
AppendCertsFromPEM
(
ca
)
// configure transport authentificator
ta
:=
credentials
.
NewTLS
(
&
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
peerCert
},
RootCAs
:
caCertPool
,
})
// let's do the dialing !
con
,
err
:=
grpc
.
Dial
(
addr_port
,
grpc
.
WithTransportCredentials
(
ta
))
if
err
!=
nil
{
grpclog
.
Fatalf
(
"Fail to dial: %v"
,
err
)
}
return
con
}
Loading