Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
ae0edc3f
Commit
ae0edc3f
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
allow verifier to saturate multiple cores. closes #213
parent
5e48d580
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/keysigner
+2
-1
2 additions, 1 deletion
bin/keysigner
bin/verifier
+52
-31
52 additions, 31 deletions
bin/verifier
lib/verifier/verifier-compute.js
+24
-0
24 additions, 0 deletions
lib/verifier/verifier-compute.js
with
78 additions
and
32 deletions
bin/keysigner
+
2
−
1
View file @
ae0edc3f
...
...
@@ -113,7 +113,8 @@ app.post('/wsapi/cert_key', validate(["email", "pubkey"]), function(req, resp) {
},
function
(
err
,
r
)
{
// consider "application" errors to be the same as harder errors
if
(
!
err
&&
r
&&
r
.
error
)
err
=
r
.
error
;
if
(
!
r
||
!
r
.
success
)
err
=
"
no certificate returned from child process
"
;
else
if
(
!
r
||
!
r
.
success
)
err
=
"
no certificate returned from child process
"
;
if
(
err
)
{
logger
.
error
(
"
certification generation error:
"
+
err
);
httputils
.
serverError
(
resp
,
"
certification generation error
"
);
...
...
This diff is collapsed.
Click to expand it.
bin/verifier
+
52
−
31
View file @
ae0edc3f
...
...
@@ -42,7 +42,7 @@ path = require('path'),
url
=
require
(
'
url
'
),
fs
=
require
(
'
fs
'
),
express
=
require
(
'
express
'
),
c
ertassertion
=
require
(
'
../lib/verifier/certassertion.js
'
),
c
omputecluster
=
require
(
'
compute-cluster
'
),
metrics
=
require
(
'
../lib/metrics
'
),
heartbeat
=
require
(
'
../lib/heartbeat
'
),
logger
=
require
(
'
../lib/logging
'
).
logger
,
...
...
@@ -78,6 +78,27 @@ if (statsd_config && statsd_config.enabled) {
app
.
use
(
express
.
bodyParser
());
try
{
// explicitly relay VAR_PATH to children
process
.
env
[
'
VAR_PATH
'
]
=
config
.
get
(
'
var_path
'
);
// allocate a compute cluster
var
cc
=
new
computecluster
({
module
:
path
.
join
(
__dirname
,
"
..
"
,
"
lib
"
,
"
verifier
"
,
"
verifier-compute.js
"
),
max_processes
:
config
.
get
(
'
max_compute_processes
'
)
}).
on
(
'
error
'
,
function
(
e
)
{
logger
.
error
(
"
error detected in verification computation process! fatal:
"
+
e
.
toString
());
setTimeout
(
function
()
{
process
.
exit
(
1
);
},
0
);
}).
on
(
'
info
'
,
function
(
msg
)
{
logger
.
info
(
"
(compute cluster):
"
+
msg
);
}).
on
(
'
debug
'
,
function
(
msg
)
{
logger
.
debug
(
"
(compute cluster):
"
+
msg
);
});
}
catch
(
e
)
{
process
.
stderr
.
write
(
"
can't allocate compute cluster:
"
+
e
+
"
\n
"
);
process
.
exit
(
1
);
}
app
.
post
(
'
/verify
'
,
function
(
req
,
resp
,
next
)
{
req
.
body
=
req
.
body
||
{}
...
...
@@ -97,37 +118,35 @@ app.post('/verify', function(req, resp, next) {
return
resp
.
json
({
status
:
"
failure
"
,
reason
:
"
need assertion and audience
"
});
}
function
doFailure
(
error
)
{
resp
.
json
({
"
status
"
:
"
failure
"
,
reason
:
(
error
?
error
.
toString
()
:
"
unknown
"
)});
metrics
.
report
(
'
verify
'
,
{
result
:
'
failure
'
,
rp
:
audience
});
}
cc
.
enqueue
({
assertion
:
assertion
,
audience
:
audience
},
function
(
err
,
r
)
{
// consider "application" errors to be the same as harder errors
if
(
!
err
&&
r
&&
r
.
error
)
err
=
r
.
error
;
else
if
(
!
r
||
!
r
.
success
)
err
=
"
no response returned from child process
"
;
if
(
err
)
{
resp
.
json
({
"
status
"
:
"
failure
"
,
reason
:
err
});
metrics
.
report
(
'
verify
'
,
{
result
:
'
failure
'
,
rp
:
audience
});
}
else
{
resp
.
json
({
status
:
"
okay
"
,
email
:
r
.
success
.
email
,
audience
:
audience
,
// NOTE: we return the audience formatted as the RP provided it, not normalized in any way.
expires
:
new
Date
(
r
.
success
.
expires
).
valueOf
(),
issuer
:
r
.
success
.
issuer
});
try
{
certassertion
.
verify
(
assertion
,
audience
,
function
(
email
,
audienceFromAssertion
,
expires
,
issuer
)
{
resp
.
json
({
status
:
"
okay
"
,
email
:
email
,
audience
:
audience
,
// NOTE: we return the audience formatted as the RP provided it, not normalized in any way.
expires
:
expires
.
valueOf
(),
issuer
:
issuer
});
metrics
.
report
(
'
verify
'
,
{
result
:
'
success
'
,
rp
:
audienceFromAssertion
});
},
function
(
error
)
{
doFailure
(
error
);
metrics
.
report
(
'
verify
'
,
{
result
:
'
success
'
,
rp
:
r
.
success
.
audience
});
}
catch
(
e
)
{
doFailure
(
e
);
}
}
});
});
// shutdown when /code_update is invoked
...
...
@@ -141,7 +160,9 @@ app.use(function(req, res,next) {
});
// shutdown nicely on signals
shutdown
.
handleTerminationSignals
(
app
);
shutdown
.
handleTerminationSignals
(
app
,
function
()
{
cc
.
exit
();
});
var
bindTo
=
config
.
get
(
'
bind_to
'
);
app
.
listen
(
bindTo
.
port
,
bindTo
.
host
,
function
(
conn
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/verifier/verifier-compute.js
0 → 100644
+
24
−
0
View file @
ae0edc3f
const
certassertion
=
require
(
'
./certassertion.js
'
);
process
.
on
(
'
message
'
,
function
(
m
)
{
try
{
certassertion
.
verify
(
m
.
assertion
,
m
.
audience
,
function
(
email
,
audienceFromAssertion
,
expires
,
issuer
)
{
process
.
send
({
success
:
{
email
:
email
,
audience
:
audienceFromAssertion
,
expires
:
expires
,
issuer
:
issuer
}
});
},
function
(
error
)
{
process
.
send
({
error
:
error
});
});
}
catch
(
e
)
{
process
.
send
({
error
:
e
.
toString
()});
}
});
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
register
or
sign in
to comment