Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
7e0d99f7
Commit
7e0d99f7
authored
Mar 3, 2015
by
Craig Tiller
Browse files
Options
Downloads
Plain Diff
Merge pull request #1 from murgatroid99/node_secure_server_api
Updated Node library to new secure server API
parents
22176cbb
da02a67e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/node/ext/server.cc
+12
-20
12 additions, 20 deletions
src/node/ext/server.cc
src/node/interop/interop_server.js
+5
-5
5 additions, 5 deletions
src/node/interop/interop_server.js
src/node/src/server.js
+10
-9
10 additions, 9 deletions
src/node/src/server.js
with
27 additions
and
34 deletions
src/node/ext/server.cc
+
12
−
20
View file @
7e0d99f7
...
...
@@ -164,19 +164,7 @@ NAN_METHOD(Server::New) {
if
(
args
[
0
]
->
IsUndefined
())
{
wrapped_server
=
grpc_server_create
(
queue
,
NULL
);
}
else
if
(
args
[
0
]
->
IsObject
())
{
grpc_server_credentials
*
creds
=
NULL
;
Handle
<
Object
>
args_hash
(
args
[
0
]
->
ToObject
()
->
Clone
());
if
(
args_hash
->
HasOwnProperty
(
NanNew
(
"credentials"
)))
{
Handle
<
Value
>
creds_value
=
args_hash
->
Get
(
NanNew
(
"credentials"
));
if
(
!
ServerCredentials
::
HasInstance
(
creds_value
))
{
return
NanThrowTypeError
(
"credentials arg must be a ServerCredentials object"
);
}
ServerCredentials
*
creds_object
=
ObjectWrap
::
Unwrap
<
ServerCredentials
>
(
creds_value
->
ToObject
());
creds
=
creds_object
->
GetWrappedServerCredentials
();
args_hash
->
Delete
(
NanNew
(
"credentials"
));
}
Handle
<
Object
>
args_hash
(
args
[
0
]
->
ToObject
());
Handle
<
Array
>
keys
(
args_hash
->
GetOwnPropertyNames
());
grpc_channel_args
channel_args
;
channel_args
.
num_args
=
keys
->
Length
();
...
...
@@ -203,11 +191,7 @@ NAN_METHOD(Server::New) {
return
NanThrowTypeError
(
"Arg values must be strings"
);
}
}
if
(
creds
==
NULL
)
{
wrapped_server
=
grpc_server_create
(
queue
,
&
channel_args
);
}
else
{
wrapped_server
=
grpc_secure_server_create
(
creds
,
queue
,
&
channel_args
);
}
free
(
channel_args
.
args
);
}
else
{
return
NanThrowTypeError
(
"Server expects an object"
);
...
...
@@ -258,11 +242,19 @@ NAN_METHOD(Server::AddSecureHttp2Port) {
"addSecureHttp2Port can only be called on a Server"
);
}
if
(
!
args
[
0
]
->
IsString
())
{
return
NanThrowTypeError
(
"addSecureHttp2Port's argument must be a String"
);
return
NanThrowTypeError
(
"addSecureHttp2Port's first argument must be a String"
);
}
if
(
!
ServerCredentials
::
HasInstance
(
args
[
1
]))
{
return
NanThrowTypeError
(
"addSecureHttp2Port's second argument must be ServerCredentials"
);
}
Server
*
server
=
ObjectWrap
::
Unwrap
<
Server
>
(
args
.
This
());
ServerCredentials
*
creds
=
ObjectWrap
::
Unwrap
<
ServerCredentials
>
(
args
[
1
]
->
ToObject
());
NanReturnValue
(
NanNew
<
Number
>
(
grpc_server_add_secure_http2_port
(
server
->
wrapped_server
,
*
NanUtf8String
(
args
[
0
]))));
server
->
wrapped_server
,
*
NanUtf8String
(
args
[
0
]),
creds
->
GetWrappedServerCredentials
())));
}
NAN_METHOD
(
Server
::
Start
)
{
...
...
...
...
This diff is collapsed.
Click to expand it.
src/node/interop/interop_server.js
+
5
−
5
View file @
7e0d99f7
...
...
@@ -165,16 +165,16 @@ function handleHalfDuplex(call) {
function
getServer
(
port
,
tls
)
{
// TODO(mlumish): enable TLS functionality
var
options
=
{};
var
server_creds
=
null
;
if
(
tls
)
{
var
key_path
=
path
.
join
(
__dirname
,
'
../test/data/server1.key
'
);
var
pem_path
=
path
.
join
(
__dirname
,
'
../test/data/server1.pem
'
);
var
key_data
=
fs
.
readFileSync
(
key_path
);
var
pem_data
=
fs
.
readFileSync
(
pem_path
);
var
server_creds
=
grpc
.
ServerCredentials
.
createSsl
(
null
,
server_creds
=
grpc
.
ServerCredentials
.
createSsl
(
null
,
key_data
,
pem_data
);
options
.
credentials
=
server_creds
;
}
var
server
=
new
Server
({
'
grpc.testing.TestService
'
:
{
...
...
@@ -186,7 +186,7 @@ function getServer(port, tls) {
halfDuplexCall
:
handleHalfDuplex
}
},
null
,
options
);
var
port_num
=
server
.
bind
(
'
0.0.0.0:
'
+
port
,
tl
s
);
var
port_num
=
server
.
bind
(
'
0.0.0.0:
'
+
port
,
server_cred
s
);
return
{
server
:
server
,
port
:
port_num
};
}
...
...
...
...
This diff is collapsed.
Click to expand it.
src/node/src/server.js
+
10
−
9
View file @
7e0d99f7
...
...
@@ -517,14 +517,15 @@ Server.prototype.register = function(name, handler, serialize, deserialize,
};
/**
* Binds the server to the given port, with SSL enabled if
secure is specified
* Binds the server to the given port, with SSL enabled if
creds is given
* @param {string} port The port that the server should bind on, in the format
* "address:port"
* @param {boolean=} secure Whether the server should open a secure port
* @param {boolean=} creds Server credential object to be used for SSL. Pass
* nothing for an insecure port
*/
Server
.
prototype
.
bind
=
function
(
port
,
secure
)
{
if
(
secure
)
{
return
this
.
_server
.
addSecureHttp2Port
(
port
);
Server
.
prototype
.
bind
=
function
(
port
,
creds
)
{
if
(
creds
)
{
return
this
.
_server
.
addSecureHttp2Port
(
port
,
creds
);
}
else
{
return
this
.
_server
.
addHttp2Port
(
port
);
}
...
...
@@ -604,14 +605,14 @@ function makeServerConstructor(services) {
}
/**
* Binds the server to the given port, with SSL enabled if
secure is specif
ied
* Binds the server to the given port, with SSL enabled if
creds is suppl
ied
* @param {string} port The port that the server should bind on, in the format
* "address:port"
* @param {boolean=}
secure Whether the server should open a secure port
* @param {boolean=}
creds Credentials to use for SSL
* @return {SurfaceServer} this
*/
SurfaceServer
.
prototype
.
bind
=
function
(
port
,
secure
)
{
return
this
.
inner_server
.
bind
(
port
,
secure
);
SurfaceServer
.
prototype
.
bind
=
function
(
port
,
creds
)
{
return
this
.
inner_server
.
bind
(
port
,
creds
);
};
/**
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment