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
c94d582a
Unverified
Commit
c94d582a
authored
May 08, 2019
by
Péter Szilágyi
Committed by
GitHub
May 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19539 from karalabe/faucet-updates
cmd/faucet: embed git commit hash/date, disable Google+
parents
be4d74f8
ab10c155
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
37 deletions
+12
-37
faucet.go
cmd/faucet/faucet.go
+12
-37
No files found.
cmd/faucet/faucet.go
View file @
c94d582a
...
...
@@ -88,6 +88,11 @@ var (
ether
=
new
(
big
.
Int
)
.
Exp
(
big
.
NewInt
(
10
),
big
.
NewInt
(
18
),
nil
)
)
var
(
gitCommit
=
""
// Git SHA1 commit hash of the release (set via linker flags)
gitDate
=
""
// Git commit date YYYYMMDD of the release (set via linker flags)
)
func
main
()
{
// Parse the flags and set up the logger to print everything requested
flag
.
Parse
()
...
...
@@ -216,7 +221,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
// Assemble the raw devp2p protocol stack
stack
,
err
:=
node
.
New
(
&
node
.
Config
{
Name
:
"geth"
,
Version
:
params
.
VersionWith
Meta
,
Version
:
params
.
VersionWith
Commit
(
gitCommit
,
gitDate
)
,
DataDir
:
filepath
.
Join
(
os
.
Getenv
(
"HOME"
),
".faucet"
),
P2P
:
p2p
.
Config
{
NAT
:
nat
.
Any
(),
...
...
@@ -440,10 +445,14 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
return
}
continue
case
strings
.
HasPrefix
(
msg
.
URL
,
"https://plus.google.com/"
)
:
if
err
=
sendError
(
conn
,
errors
.
New
(
"Google+ authentication discontinued as the service was sunset"
));
err
!=
nil
{
log
.
Warn
(
"Failed to send Google+ deprecation to client"
,
"err"
,
err
)
return
}
continue
case
strings
.
HasPrefix
(
msg
.
URL
,
"https://twitter.com/"
)
:
username
,
avatar
,
address
,
err
=
authTwitter
(
msg
.
URL
)
case
strings
.
HasPrefix
(
msg
.
URL
,
"https://plus.google.com/"
)
:
username
,
avatar
,
address
,
err
=
authGooglePlus
(
msg
.
URL
)
case
strings
.
HasPrefix
(
msg
.
URL
,
"https://www.facebook.com/"
)
:
username
,
avatar
,
address
,
err
=
authFacebook
(
msg
.
URL
)
case
*
noauthFlag
:
...
...
@@ -699,40 +708,6 @@ func authTwitter(url string) (string, string, common.Address, error) {
return
username
+
"@twitter"
,
avatar
,
address
,
nil
}
// authGooglePlus tries to authenticate a faucet request using GooglePlus posts,
// returning the username, avatar URL and Ethereum address to fund on success.
func
authGooglePlus
(
url
string
)
(
string
,
string
,
common
.
Address
,
error
)
{
// Ensure the user specified a meaningful URL, no fancy nonsense
parts
:=
strings
.
Split
(
url
,
"/"
)
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"posts"
{
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Google+ post URL"
)
}
username
:=
parts
[
len
(
parts
)
-
3
]
// Google's API isn't really friendly with direct links. Still, we don't
// want to do ask read permissions from users, so just load the public posts and
// scrape it for the Ethereum address and profile URL.
res
,
err
:=
http
.
Get
(
url
)
if
err
!=
nil
{
return
""
,
""
,
common
.
Address
{},
err
}
defer
res
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
if
err
!=
nil
{
return
""
,
""
,
common
.
Address
{},
err
}
address
:=
common
.
HexToAddress
(
string
(
regexp
.
MustCompile
(
"0x[0-9a-fA-F]{40}"
)
.
Find
(
body
)))
if
address
==
(
common
.
Address
{})
{
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"No Ethereum address found to fund"
)
}
var
avatar
string
if
parts
=
regexp
.
MustCompile
(
"src=
\"
([^
\"
]+googleusercontent.com[^
\"
]+photo.jpg)
\"
"
)
.
FindStringSubmatch
(
string
(
body
));
len
(
parts
)
==
2
{
avatar
=
parts
[
1
]
}
return
username
+
"@google+"
,
avatar
,
address
,
nil
}
// authFacebook tries to authenticate a faucet request using Facebook posts,
// returning the username, avatar URL and Ethereum address to fund on success.
func
authFacebook
(
url
string
)
(
string
,
string
,
common
.
Address
,
error
)
{
...
...
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