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
48b41862
Commit
48b41862
authored
Feb 02, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPnP Support
parent
3f503ffc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
18 deletions
+14
-18
ethereum.go
ethereum.go
+14
-18
No files found.
ethereum.go
View file @
48b41862
...
...
@@ -54,24 +54,19 @@ type Ethereum struct {
nat
NAT
}
func
New
(
caps
Caps
)
(
*
Ethereum
,
error
)
{
//db, err := ethdb.NewLDBDatabase()
func
New
(
caps
Caps
,
usePnp
bool
)
(
*
Ethereum
,
error
)
{
db
,
err
:=
ethdb
.
NewMemDatabase
()
if
err
!=
nil
{
return
nil
,
err
}
/*
gateway := net.ParseIP("192.168.192.1")
nat := NewNatPMP(gateway)
port, err := nat.AddPortMapping("tcp", 30303, 30303, "", 60)
log.Println(port, err)
*/
nat
,
err
:=
Discover
()
if
err
!=
nil
{
log
.
Println
(
"UPnP failed"
,
err
)
return
nil
,
err
var
nat
NAT
if
usePnp
{
nat
,
err
=
Discover
()
if
err
!=
nil
{
log
.
Println
(
"UPnP failed"
,
err
)
return
nil
,
err
}
}
ethutil
.
Config
.
Db
=
db
...
...
@@ -229,14 +224,15 @@ func (s *Ethereum) Start() {
if
err
!=
nil
{
log
.
Println
(
"Connection listening disabled. Acting as client"
)
}
else
{
s
.
Addr
=
ln
.
Addr
()
// Starting accepting connections
log
.
Println
(
"Ready and accepting connections"
)
// Start the peer handler
go
s
.
peerHandler
(
ln
)
}
go
s
.
upnpUpdateThread
()
if
s
.
nat
!=
nil
{
go
s
.
upnpUpdateThread
()
}
// Start the reaping processes
go
s
.
ReapDeadPeerHandler
()
...
...
@@ -288,18 +284,18 @@ out:
for
{
select
{
case
<-
timer
.
C
:
listenPort
,
err
:=
s
.
nat
.
AddPortMapping
(
"TCP"
,
int
(
lport
),
int
(
lport
),
"eth listen port"
,
20
*
60
)
var
err
error
_
,
err
=
s
.
nat
.
AddPortMapping
(
"TCP"
,
int
(
lport
),
int
(
lport
),
"eth listen port"
,
20
*
60
)
if
err
!=
nil
{
log
.
Println
(
"can't add UPnP port mapping:"
,
err
)
break
out
}
if
first
&&
err
==
nil
{
externalip
,
err
:
=
s
.
nat
.
GetExternalAddress
()
_
,
err
=
s
.
nat
.
GetExternalAddress
()
if
err
!=
nil
{
log
.
Println
(
"UPnP can't get external address:"
,
err
)
continue
out
}
log
.
Println
(
"Successfully bound via UPnP to"
,
externalip
,
listenPort
)
first
=
false
}
timer
.
Reset
(
time
.
Minute
*
15
)
...
...
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