Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
6219a338
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6219a338
编写于
3月 02, 2018
作者:
V
Vlad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
whisper: filereader mode introduced to wnode
上级
a76e46e3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
0 deletion
+41
-0
cmd/wnode/main.go
cmd/wnode/main.go
+37
-0
whisper/whisperv6/envelope.go
whisper/whisperv6/envelope.go
+4
-0
未找到文件。
cmd/wnode/main.go
浏览文件 @
6219a338
...
...
@@ -86,6 +86,7 @@ var (
asymmetricMode
=
flag
.
Bool
(
"asym"
,
false
,
"use asymmetric encryption"
)
generateKey
=
flag
.
Bool
(
"generatekey"
,
false
,
"generate and show the private key"
)
fileExMode
=
flag
.
Bool
(
"fileexchange"
,
false
,
"file exchange mode"
)
fileReader
=
flag
.
Bool
(
"filereader"
,
false
,
"load and decrypt messages saved as files, display as plain text"
)
testMode
=
flag
.
Bool
(
"test"
,
false
,
"use of predefined parameters for diagnostics (password, etc.)"
)
echoMode
=
flag
.
Bool
(
"echo"
,
false
,
"echo mode: prints some arguments for diagnostics"
)
...
...
@@ -433,6 +434,8 @@ func run() {
requestExpiredMessagesLoop
()
}
else
if
*
fileExMode
{
sendFilesLoop
()
}
else
if
*
fileReader
{
fileReaderLoop
()
}
else
{
sendLoop
()
}
...
...
@@ -483,6 +486,40 @@ func sendFilesLoop() {
}
}
func
fileReaderLoop
()
{
watcher1
:=
shh
.
GetFilter
(
symFilterID
)
watcher2
:=
shh
.
GetFilter
(
asymFilterID
)
if
watcher1
==
nil
&&
watcher2
==
nil
{
fmt
.
Println
(
"Error: neither symmetric nor asymmetric filter is installed"
)
close
(
done
)
return
}
for
{
s
:=
scanLine
(
""
)
if
s
==
quitCommand
{
fmt
.
Println
(
"Quit command received"
)
close
(
done
)
return
}
raw
,
err
:=
ioutil
.
ReadFile
(
s
)
if
err
!=
nil
{
fmt
.
Printf
(
">>> Error: %s
\n
"
,
err
)
}
else
{
env
:=
whisper
.
Envelope
{
Data
:
raw
}
// the topic is zero
msg
:=
env
.
Open
(
watcher1
)
// force-open envelope regardless of the topic
if
msg
==
nil
{
msg
=
env
.
Open
(
watcher2
)
}
if
msg
==
nil
{
fmt
.
Printf
(
">>> Error: failed to decrypt the message
\n
"
)
}
else
{
printMessageInfo
(
msg
)
}
}
}
}
func
scanLine
(
prompt
string
)
string
{
if
len
(
prompt
)
>
0
{
fmt
.
Print
(
prompt
)
...
...
whisper/whisperv6/envelope.go
浏览文件 @
6219a338
...
...
@@ -208,6 +208,10 @@ func (e *Envelope) OpenSymmetric(key []byte) (msg *ReceivedMessage, err error) {
// Open tries to decrypt an envelope, and populates the message fields in case of success.
func
(
e
*
Envelope
)
Open
(
watcher
*
Filter
)
(
msg
*
ReceivedMessage
)
{
if
watcher
==
nil
{
return
nil
}
// The API interface forbids filters doing both symmetric and asymmetric encryption.
if
watcher
.
expectsAsymmetricEncryption
()
&&
watcher
.
expectsSymmetricEncryption
()
{
return
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录