good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Erigon
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
a
Erigon
Commits
b9bf9736
Unverified
Commit
b9bf9736
authored
2 years ago
by
Alex Sharov
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
save (#4251)
parent
216a5c46
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/downloader/downloader/torrentcfg/torrentcfg.go
+33
-7
33 additions, 7 deletions
cmd/downloader/downloader/torrentcfg/torrentcfg.go
with
33 additions
and
7 deletions
cmd/downloader/downloader/torrentcfg/torrentcfg.go
+
33
−
7
View file @
b9bf9736
package
torrentcfg
import
(
"fmt"
"net"
"strings"
"time"
lg
"github.com/anacrolix/log"
...
...
@@ -57,28 +60,51 @@ func New(snapDir string, verbosity lg.Level, natif nat.Interface, downloadRate,
torrentConfig
.
TorrentPeersHighWater
=
500
// default: 500
torrentConfig
.
TorrentPeersLowWater
=
50
// default: 50
torrentConfig
.
ListenPort
=
port
torrentConfig
.
Seed
=
true
torrentConfig
.
DataDir
=
snapDir
torrentConfig
.
UpnpID
=
torrentConfig
.
UpnpID
+
"leecher"
torrentConfig
.
ListenPort
=
port
// check if ipv6 is enabled
torrentConfig
.
DisableIPv6
=
true
l
,
err
:=
net
.
Listen
(
"tcp6"
,
fmt
.
Sprintf
(
":%d"
,
port
))
if
err
!=
nil
{
isDisabled
:=
strings
.
Contains
(
err
.
Error
(),
"cannot assign requested address"
)
||
strings
.
Contains
(
err
.
Error
(),
"address family not supported by protocol"
)
if
!
isDisabled
{
log
.
Warn
(
"can't enable ipv6"
,
"err"
,
err
)
}
}
else
{
l
.
Close
()
torrentConfig
.
DisableIPv6
=
false
}
switch
natif
.
(
type
)
{
case
nil
:
// No NAT interface, do nothing.
case
nat
.
ExtIP
:
// ExtIP doesn't block, set the IP right away.
ip
,
_
:=
natif
.
ExternalIP
()
torrentConfig
.
PublicIp4
=
ip
log
.
Info
(
"[torrent] Public IP"
,
"ip"
,
torrentConfig
.
PublicIp4
)
// how to set ipv6?
//torrentConfig.PublicIp6 = net.ParseIP(ip)
if
ip
!=
nil
{
if
ip
.
To4
()
!=
nil
{
torrentConfig
.
PublicIp4
=
ip
}
else
{
torrentConfig
.
PublicIp6
=
ip
}
}
log
.
Info
(
"[torrent] Public IP"
,
"ip"
,
ip
)
default
:
// Ask the router about the IP. This takes a while and blocks startup,
// do it in the background.
if
ip
,
err
:=
natif
.
ExternalIP
();
err
==
nil
{
torrentConfig
.
PublicIp4
=
ip
log
.
Info
(
"[torrent] Public IP"
,
"ip"
,
torrentConfig
.
PublicIp4
)
if
ip
!=
nil
{
if
ip
.
To4
()
!=
nil
{
torrentConfig
.
PublicIp4
=
ip
}
else
{
torrentConfig
.
PublicIp6
=
ip
}
}
log
.
Info
(
"[torrent] Public IP"
,
"ip"
,
ip
)
}
}
// rates are divided by 2 - I don't know why it works, maybe bug inside torrent lib accounting
...
...
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