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
cb3f5f8b
Unverified
Commit
cb3f5f8b
authored
Apr 16, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/faucet: double check user against the GH website
parent
c7a4d9cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
faucet.go
cmd/faucet/faucet.go
+12
-1
No files found.
cmd/faucet/faucet.go
View file @
cb3f5f8b
...
@@ -306,7 +306,7 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
...
@@ -306,7 +306,7 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
websocket
.
JSON
.
Send
(
conn
,
map
[
string
]
string
{
"error"
:
"URL doesn't link to GitHub Gists"
})
websocket
.
JSON
.
Send
(
conn
,
map
[
string
]
string
{
"error"
:
"URL doesn't link to GitHub Gists"
})
continue
continue
}
}
log
.
Info
(
"Faucet funds requested"
,
"gist"
,
msg
.
URL
)
log
.
Info
(
"Faucet funds requested"
,
"
addr"
,
conn
.
RemoteAddr
(),
"
gist"
,
msg
.
URL
)
// Retrieve the gist from the GitHub Gist APIs
// Retrieve the gist from the GitHub Gist APIs
parts
:=
strings
.
Split
(
msg
.
URL
,
"/"
)
parts
:=
strings
.
Split
(
msg
.
URL
,
"/"
)
...
@@ -348,6 +348,17 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
...
@@ -348,6 +348,17 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
websocket
.
JSON
.
Send
(
conn
,
map
[
string
]
string
{
"error"
:
"No Ethereum address found to fund"
})
websocket
.
JSON
.
Send
(
conn
,
map
[
string
]
string
{
"error"
:
"No Ethereum address found to fund"
})
continue
continue
}
}
// Validate the user's existence since the API is unhelpful here
if
res
,
err
=
http
.
Head
(
"https://github.com/%s"
,
gist
.
Owner
.
Login
);
err
!=
nil
{
websocket
.
JSON
.
Send
(
conn
,
map
[
string
]
string
{
"error"
:
err
.
Error
()})
continue
}
res
.
Body
.
Close
()
if
res
.
StatusCode
!=
200
{
websocket
.
JSON
.
Send
(
conn
,
map
[
string
]
string
{
"error"
:
"Invalid user... boom!"
})
continue
}
// Ensure the user didn't request funds too recently
// Ensure the user didn't request funds too recently
f
.
lock
.
Lock
()
f
.
lock
.
Lock
()
var
(
var
(
...
...
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