Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
f3048ab7
Commit
f3048ab7
authored
Nov 04, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(init) extract bits flag
parent
630b88d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
cmd/ipfs2/init.go
cmd/ipfs2/init.go
+14
-11
No files found.
cmd/ipfs2/init.go
View file @
f3048ab7
...
...
@@ -42,7 +42,16 @@ var initCmd = &cmds.Command{
return
}
err
:=
foo
(
res
,
req
,
dspath
,
force
)
arg
,
found
=
req
.
Option
(
"b"
)
nBitsForKeypair
,
ok
:=
arg
.
(
int
)
// TODO param
if
found
&&
!
ok
{
res
.
SetError
(
errors
.
New
(
"failed to get bits flag"
),
cmds
.
ErrNormal
)
return
}
else
if
!
found
{
nBitsForKeypair
=
4096
}
err
:=
foo
(
res
,
req
,
dspath
,
force
,
nBitsForKeypair
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
...
...
@@ -50,7 +59,7 @@ var initCmd = &cmds.Command{
},
}
func
foo
(
res
cmds
.
Response
,
req
cmds
.
Request
,
dspath
string
,
force
bool
)
error
{
func
foo
(
res
cmds
.
Response
,
req
cmds
.
Request
,
dspath
string
,
force
bool
,
nBitsForKeypair
int
)
error
{
ctx
:=
req
.
Context
()
u
.
POut
(
"initializing ipfs node at %s
\n
"
,
ctx
.
ConfigRoot
)
...
...
@@ -104,19 +113,13 @@ func foo(res cmds.Response, req cmds.Request, dspath string, force bool) error {
IPNS
:
"/ipns"
,
}
arg
,
found
=
req
.
Option
(
"b"
)
nbits
,
ok
:=
arg
.
(
int
)
// TODO param
if
found
&&
!
ok
{
return
errors
.
New
(
"failed to get bits flag"
)
}
else
if
!
found
{
nbits
=
4096
}
if
nbits
<
1024
{
// TODO guard
if
nBitsForKeypair
<
1024
{
return
errors
.
New
(
"Bitsize less than 1024 is considered unsafe."
)
}
u
.
POut
(
"generating key pair
\n
"
)
sk
,
pk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
n
b
its
)
sk
,
pk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
n
B
its
ForKeypair
)
if
err
!=
nil
{
return
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment