Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
f9be9a23
Commit
f9be9a23
authored
Apr 28, 2017
by
gluk256
Committed by
Felix Lange
Apr 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: switching to v5 + minor refactoring (#14387)
parent
95f0bd0a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
39 deletions
+139
-39
flags.go
cmd/utils/flags.go
+1
-1
main.go
cmd/wnode/main.go
+4
-3
web3ext.go
internal/web3ext/web3ext.go
+100
-1
geth.go
mobile/geth.go
+1
-1
api.go
whisper/whisperv5/api.go
+21
-21
api_test.go
whisper/whisperv5/api_test.go
+12
-12
No files found.
cmd/utils/flags.go
View file @
f9be9a23
...
...
@@ -52,7 +52,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/p2p/netutil"
"github.com/ethereum/go-ethereum/params"
whisper
"github.com/ethereum/go-ethereum/whisper/whisperv
2
"
whisper
"github.com/ethereum/go-ethereum/whisper/whisperv
5
"
"gopkg.in/urfave/cli.v1"
)
...
...
cmd/wnode/main.go
View file @
f9be9a23
...
...
@@ -183,7 +183,7 @@ func initialize() {
if
*
testMode
{
symPass
=
"wwww"
// ascii code: 0x77777777
msPassword
=
"
mail server test password
"
msPassword
=
"
wwww
"
}
if
*
bootstrapMode
{
...
...
@@ -330,7 +330,7 @@ func configureNode() {
if
!*
asymmetricMode
&&
!*
forwarderMode
{
if
len
(
symPass
)
==
0
{
symPass
,
err
=
console
.
Stdin
.
PromptPassword
(
"Please enter the password: "
)
symPass
,
err
=
console
.
Stdin
.
PromptPassword
(
"Please enter the password
for symmetric encryption
: "
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to read passphrase: %v"
,
err
)
}
...
...
@@ -347,6 +347,8 @@ func configureNode() {
if
len
(
*
argTopic
)
==
0
{
generateTopic
([]
byte
(
symPass
))
}
fmt
.
Printf
(
"Filter is configured for the topic: %x
\n
"
,
topic
)
}
if
*
mailServerMode
{
...
...
@@ -365,7 +367,6 @@ func configureNode() {
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to install filter: %s"
,
err
)
}
fmt
.
Printf
(
"Filter is configured for the topic: %x
\n
"
,
topic
)
}
func
generateTopic
(
password
[]
byte
)
{
...
...
internal/web3ext/web3ext.go
View file @
f9be9a23
...
...
@@ -525,7 +525,105 @@ web3._extend({
const
Shh_JS
=
`
web3._extend({
property: 'shh',
methods: [],
methods: [
new web3._extend.Method({
name: 'info',
call: 'shh_info'
}),
new web3._extend.Method({
name: 'setMaxMessageLength',
call: 'shh_setMaxMessageLength',
params: 1
}),
new web3._extend.Method({
name: 'setMinimumPoW',
call: 'shh_setMinimumPoW',
params: 1
}),
new web3._extend.Method({
name: 'allowP2PMessagesFromPeer',
call: 'shh_allowP2PMessagesFromPeer',
params: 1
}),
new web3._extend.Method({
name: 'hasKeyPair',
call: 'shh_hasKeyPair',
params: 1
}),
new web3._extend.Method({
name: 'deleteKeyPair',
call: 'shh_deleteKeyPair',
params: 1
}),
new web3._extend.Method({
name: 'newKeyPair',
call: 'shh_newKeyPair'
}),
new web3._extend.Method({
name: 'getPublicKey',
call: 'shh_getPublicKey',
params: 1
}),
new web3._extend.Method({
name: 'getPrivateKey',
call: 'shh_getPrivateKey',
params: 1
}),
new web3._extend.Method({
name: 'generateSymmetricKey',
call: 'shh_generateSymmetricKey',
}),
new web3._extend.Method({
name: 'addSymmetricKeyDirect',
call: 'shh_addSymmetricKeyDirect',
params: 1
}),
new web3._extend.Method({
name: 'addSymmetricKeyFromPassword',
call: 'shh_addSymmetricKeyFromPassword',
params: 1
}),
new web3._extend.Method({
name: 'hasSymmetricKey',
call: 'shh_hasSymmetricKey',
params: 1
}),
new web3._extend.Method({
name: 'getSymmetricKey',
call: 'shh_getSymmetricKey',
params: 1
}),
new web3._extend.Method({
name: 'deleteSymmetricKey',
call: 'shh_deleteSymmetricKey',
params: 1
}),
new web3._extend.Method({
name: 'subscribe',
call: 'shh_subscribe',
params: 1
}),
new web3._extend.Method({
name: 'unsubscribe',
call: 'shh_unsubscribe',
params: 1
}),
new web3._extend.Method({
name: 'getNewSubscriptionMessages',
call: 'shh_getNewSubscriptionMessages',
params: 1
}),
new web3._extend.Method({
name: 'getFloatingMessages',
call: 'shh_getFloatingMessages',
params: 1
}),
new web3._extend.Method({
name: 'post',
call: 'shh_post',
params: 1
})
],
properties:
[
new web3._extend.Property({
...
...
@@ -536,6 +634,7 @@ web3._extend({
]
});
`
const
SWARMFS_JS
=
`
web3._extend({
property: 'swarmfs',
...
...
mobile/geth.go
View file @
f9be9a23
...
...
@@ -34,7 +34,7 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/params"
whisper
"github.com/ethereum/go-ethereum/whisper/whisperv
2
"
whisper
"github.com/ethereum/go-ethereum/whisper/whisperv
5
"
)
// NodeConfig represents the collection of configuration values to fine tune the Geth
...
...
whisper/whisperv5/api.go
View file @
f9be9a23
...
...
@@ -231,14 +231,14 @@ func (api *PublicWhisperAPI) Subscribe(args WhisperFilterArgs) (string, error) {
return
""
,
errors
.
New
(
"subscribe: "
+
err
.
Error
())
}
if
len
(
args
.
Sig
nedWith
)
>
0
{
sb
:=
common
.
FromHex
(
args
.
Sig
nedWith
)
if
len
(
args
.
Sig
)
>
0
{
sb
:=
common
.
FromHex
(
args
.
Sig
)
if
sb
==
nil
{
return
""
,
errors
.
New
(
"subscribe:
SignedWith
parameter is invalid"
)
return
""
,
errors
.
New
(
"subscribe:
sig
parameter is invalid"
)
}
filter
.
Src
=
crypto
.
ToECDSAPub
(
sb
)
if
!
ValidatePublicKey
(
filter
.
Src
)
{
return
""
,
errors
.
New
(
"subscribe: invalid '
SignedWith
' field"
)
return
""
,
errors
.
New
(
"subscribe: invalid '
sig
' field"
)
}
}
...
...
@@ -319,8 +319,8 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error {
return
errors
.
New
(
"post: key is missing"
)
}
if
len
(
args
.
Sig
nWith
)
>
0
{
params
.
Src
,
err
=
api
.
whisper
.
GetPrivateKey
(
args
.
Sig
nWith
)
if
len
(
args
.
Sig
)
>
0
{
params
.
Src
,
err
=
api
.
whisper
.
GetPrivateKey
(
args
.
Sig
)
if
err
!=
nil
{
return
err
}
...
...
@@ -391,7 +391,7 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error {
type
PostArgs
struct
{
Type
string
`json:"type"`
// "sym"/"asym" (symmetric or asymmetric)
TTL
uint32
`json:"ttl"`
// time-to-live in seconds
Sig
nWith
string
`json:"signWith"`
// id of the signing key
Sig
string
`json:"sig"`
// id of the signing key
Key
string
`json:"key"`
// key id (in case of sym) or public key (in case of asym)
Topic
hexutil
.
Bytes
`json:"topic"`
// topic (4 bytes)
Padding
hexutil
.
Bytes
`json:"padding"`
// optional padding bytes
...
...
@@ -404,7 +404,7 @@ type PostArgs struct {
type
WhisperFilterArgs
struct
{
Symmetric
bool
// encryption type
Key
string
// id of the key to be used for decryption
Sig
nedWith
string
// public key of the sender to be verified
Sig
string
// public key of the sender to be verified
MinPoW
float64
// minimal PoW requirement
Topics
[][]
byte
// list of topics (up to 4 bytes each) to match
AllowP2P
bool
// indicates wheather direct p2p messages are allowed for this filter
...
...
@@ -417,7 +417,7 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
var
obj
struct
{
Type
string
`json:"type"`
Key
string
`json:"key"`
Sig
nedWith
string
`json:"signedWith
"`
Sig
string
`json:"sig
"`
MinPoW
float64
`json:"minPoW"`
Topics
[]
interface
{}
`json:"topics"`
AllowP2P
bool
`json:"allowP2P"`
...
...
@@ -436,7 +436,7 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
}
args
.
Key
=
obj
.
Key
args
.
Sig
nedWith
=
obj
.
SignedWith
args
.
Sig
=
obj
.
Sig
args
.
MinPoW
=
obj
.
MinPoW
args
.
AllowP2P
=
obj
.
AllowP2P
...
...
@@ -472,7 +472,7 @@ type WhisperMessage struct {
Topic
string
`json:"topic"`
Payload
string
`json:"payload"`
Padding
string
`json:"padding"`
Src
string
`json:"sig
nedWith
"`
Src
string
`json:"sig"`
Dst
string
`json:"recipientPublicKey"`
Timestamp
uint32
`json:"timestamp"`
TTL
uint32
`json:"ttl"`
...
...
whisper/whisperv5/api_test.go
View file @
f9be9a23
...
...
@@ -173,7 +173,7 @@ func TestUnmarshalFilterArgs(t *testing.T) {
s
:=
[]
byte
(
`{
"type":"sym",
"key":"0x70c87d191324e6712a591f304b4eedef6ad9bb9d",
"sig
nedWith
":"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83",
"sig":"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83",
"minPoW":2.34,
"topics":["0x00000000", "0x007f80ff", "0xff807f00", "0xf26e7779"],
"allowP2P":true
...
...
@@ -191,8 +191,8 @@ func TestUnmarshalFilterArgs(t *testing.T) {
if
f
.
Key
!=
"0x70c87d191324e6712a591f304b4eedef6ad9bb9d"
{
t
.
Fatalf
(
"wrong key: %s."
,
f
.
Key
)
}
if
f
.
Sig
nedWith
!=
"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83"
{
t
.
Fatalf
(
"wrong
SignedWith: %s."
,
f
.
SignedWith
)
if
f
.
Sig
!=
"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83"
{
t
.
Fatalf
(
"wrong
sig: %s."
,
f
.
Sig
)
}
if
f
.
MinPoW
!=
2.34
{
t
.
Fatalf
(
"wrong MinPoW: %f."
,
f
.
MinPoW
)
...
...
@@ -229,7 +229,7 @@ func TestUnmarshalPostArgs(t *testing.T) {
s
:=
[]
byte
(
`{
"type":"sym",
"ttl":12345,
"sig
nWith
":"0x70c87d191324e6712a591f304b4eedef6ad9bb9d",
"sig":"0x70c87d191324e6712a591f304b4eedef6ad9bb9d",
"key":"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83",
"topic":"0xf26e7779",
"padding":"0x74686973206973206D79207465737420737472696E67",
...
...
@@ -251,8 +251,8 @@ func TestUnmarshalPostArgs(t *testing.T) {
if
a
.
TTL
!=
12345
{
t
.
Fatalf
(
"wrong ttl: %d."
,
a
.
TTL
)
}
if
a
.
Sig
nWith
!=
"0x70c87d191324e6712a591f304b4eedef6ad9bb9d"
{
t
.
Fatalf
(
"wrong From: %s."
,
a
.
Sig
nWith
)
if
a
.
Sig
!=
"0x70c87d191324e6712a591f304b4eedef6ad9bb9d"
{
t
.
Fatalf
(
"wrong From: %s."
,
a
.
Sig
)
}
if
a
.
Key
!=
"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83"
{
t
.
Fatalf
(
"wrong Key: %s."
,
a
.
Key
)
...
...
@@ -347,7 +347,7 @@ func TestIntegrationAsym(t *testing.T) {
var
f
WhisperFilterArgs
f
.
Symmetric
=
false
f
.
Key
=
key
f
.
Sig
nedWith
=
sigPubKey
.
String
()
f
.
Sig
=
sigPubKey
.
String
()
f
.
Topics
=
make
([][]
byte
,
2
)
f
.
Topics
[
0
]
=
topics
[
0
][
:
]
f
.
Topics
[
1
]
=
topics
[
1
][
:
]
...
...
@@ -362,7 +362,7 @@ func TestIntegrationAsym(t *testing.T) {
var
p
PostArgs
p
.
Type
=
"asym"
p
.
TTL
=
2
p
.
Sig
nWith
=
sig
p
.
Sig
=
sig
p
.
Key
=
dstPubKey
.
String
()
p
.
Padding
=
[]
byte
(
"test string"
)
p
.
Payload
=
[]
byte
(
"extended test string"
)
...
...
@@ -449,7 +449,7 @@ func TestIntegrationSym(t *testing.T) {
f
.
Topics
[
0
]
=
topics
[
0
][
:
]
f
.
Topics
[
1
]
=
topics
[
1
][
:
]
f
.
MinPoW
=
DefaultMinimumPoW
/
2
f
.
Sig
nedWith
=
sigPubKey
.
String
()
f
.
Sig
=
sigPubKey
.
String
()
f
.
AllowP2P
=
false
id
,
err
:=
api
.
Subscribe
(
f
)
...
...
@@ -461,7 +461,7 @@ func TestIntegrationSym(t *testing.T) {
p
.
Type
=
"sym"
p
.
TTL
=
1
p
.
Key
=
symKeyID
p
.
Sig
nWith
=
sig
p
.
Sig
=
sig
p
.
Padding
=
[]
byte
(
"test string"
)
p
.
Payload
=
[]
byte
(
"extended test string"
)
p
.
PowTarget
=
DefaultMinimumPoW
...
...
@@ -547,7 +547,7 @@ func TestIntegrationSymWithFilter(t *testing.T) {
f
.
Topics
[
0
]
=
topics
[
0
][
:
]
f
.
Topics
[
1
]
=
topics
[
1
][
:
]
f
.
MinPoW
=
DefaultMinimumPoW
/
2
f
.
Sig
nedWith
=
sigPubKey
.
String
()
f
.
Sig
=
sigPubKey
.
String
()
f
.
AllowP2P
=
false
id
,
err
:=
api
.
Subscribe
(
f
)
...
...
@@ -559,7 +559,7 @@ func TestIntegrationSymWithFilter(t *testing.T) {
p
.
Type
=
"sym"
p
.
TTL
=
1
p
.
Key
=
symKeyID
p
.
Sig
nWith
=
sigKeyID
p
.
Sig
=
sigKeyID
p
.
Padding
=
[]
byte
(
"test string"
)
p
.
Payload
=
[]
byte
(
"extended test string"
)
p
.
PowTarget
=
DefaultMinimumPoW
...
...
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