good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
48b41862
Commit
48b41862
authored
Feb 2, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
UPnP Support
parent
3f503ffc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ethereum.go
+14
-18
14 additions, 18 deletions
ethereum.go
with
14 additions
and
18 deletions
ethereum.go
+
14
−
18
View file @
48b41862
...
@@ -54,25 +54,20 @@ type Ethereum struct {
...
@@ -54,25 +54,20 @@ type Ethereum struct {
nat
NAT
nat
NAT
}
}
func
New
(
caps
Caps
)
(
*
Ethereum
,
error
)
{
func
New
(
caps
Caps
,
usePnp
bool
)
(
*
Ethereum
,
error
)
{
//db, err := ethdb.NewLDBDatabase()
db
,
err
:=
ethdb
.
NewMemDatabase
()
db
,
err
:=
ethdb
.
NewMemDatabase
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
/*
var
nat
NAT
gateway := net.ParseIP("192.168.192.1")
if
usePnp
{
nat := NewNatPMP(gateway)
nat
,
err
=
Discover
()
port, err := nat.AddPortMapping("tcp", 30303, 30303, "", 60)
log.Println(port, err)
*/
nat
,
err
:=
Discover
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"UPnP failed"
,
err
)
log
.
Println
(
"UPnP failed"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
}
ethutil
.
Config
.
Db
=
db
ethutil
.
Config
.
Db
=
db
...
@@ -229,14 +224,15 @@ func (s *Ethereum) Start() {
...
@@ -229,14 +224,15 @@ func (s *Ethereum) Start() {
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"Connection listening disabled. Acting as client"
)
log
.
Println
(
"Connection listening disabled. Acting as client"
)
}
else
{
}
else
{
s
.
Addr
=
ln
.
Addr
()
// Starting accepting connections
// Starting accepting connections
log
.
Println
(
"Ready and accepting connections"
)
log
.
Println
(
"Ready and accepting connections"
)
// Start the peer handler
// Start the peer handler
go
s
.
peerHandler
(
ln
)
go
s
.
peerHandler
(
ln
)
}
}
if
s
.
nat
!=
nil
{
go
s
.
upnpUpdateThread
()
go
s
.
upnpUpdateThread
()
}
// Start the reaping processes
// Start the reaping processes
go
s
.
ReapDeadPeerHandler
()
go
s
.
ReapDeadPeerHandler
()
...
@@ -288,18 +284,18 @@ out:
...
@@ -288,18 +284,18 @@ out:
for
{
for
{
select
{
select
{
case
<-
timer
.
C
:
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
{
if
err
!=
nil
{
log
.
Println
(
"can't add UPnP port mapping:"
,
err
)
log
.
Println
(
"can't add UPnP port mapping:"
,
err
)
break
out
break
out
}
}
if
first
&&
err
==
nil
{
if
first
&&
err
==
nil
{
externalip
,
err
:
=
s
.
nat
.
GetExternalAddress
()
_
,
err
=
s
.
nat
.
GetExternalAddress
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"UPnP can't get external address:"
,
err
)
log
.
Println
(
"UPnP can't get external address:"
,
err
)
continue
out
continue
out
}
}
log
.
Println
(
"Successfully bound via UPnP to"
,
externalip
,
listenPort
)
first
=
false
first
=
false
}
}
timer
.
Reset
(
time
.
Minute
*
15
)
timer
.
Reset
(
time
.
Minute
*
15
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment