-
-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds bep_0014 (local peer discovery) #998
base: master
Are you sure you want to change the base?
Conversation
lpdStart(cl) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably should have a configuration flag to enable peer discovery, i'm welcoming any ideas on how this could look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalServiceDiscovery bool, in ClientConfig. Probably default to false for security reasons but I'm open.
@@ -296,12 +297,13 @@ func (cn *Peer) writeStatus(w io.Writer) { | |||
prioStr += ": " + err.Error() | |||
} | |||
fmt.Fprintf(w, "bep40-prio: %v\n", prioStr) | |||
fmt.Fprintf(w, "last msg: %s, connected: %s, last helpful: %s, itime: %s, etime: %s\n", | |||
fmt.Fprintf(w, "last msg: %s, connected: %s, last helpful: %s, itime: %s, etime: %s, discovery source: %s\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly not the right place to add this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should already exist, see PeerConn.connectionFlags.
m.mcPublisher, err = net.DialUDP(network, nil, m.addr) | ||
if err != nil { | ||
fmt.Println("Error dialing UDP:", err) | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole file is almost identical to libtorrent except that i couldn't run multiple torrent instances on the same machine without this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah makes sense. libtorrent was aiming for a singleton instance for mobile devices IIRC.
happy to add more testing here, i've been testing in a scratch app |
var lpd *LPDServer | ||
var mu sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this needs to be changed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll need checking. Global locks aren't bad if they're used correctly and don't matter near as much as people think.
Are you interested in refactoring it a bit (totally fine if not). I think we could move the LPD stuff into a separate package, probably just What are the licence requirements for this? I note @axet has forgotten the MPL2 licence throughout his codebase. He's got LGPL3 for his code, so does that need to be reflected here? |
m.mcPublisher, err = net.DialUDP(network, nil, m.addr) | ||
if err != nil { | ||
fmt.Println("Error dialing UDP:", err) | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah makes sense. libtorrent was aiming for a singleton instance for mobile devices IIRC.
var lpd *LPDServer | ||
var mu sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll need checking. Global locks aren't bad if they're used correctly and don't matter near as much as people think.
"github.com/anacrolix/torrent/metainfo" | ||
) | ||
|
||
var lpd *LPDServer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular global probably shouldn't exist per your other comment.
lpdStart(cl) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalServiceDiscovery bool, in ClientConfig. Probably default to false for security reasons but I'm open.
@@ -296,12 +297,13 @@ func (cn *Peer) writeStatus(w io.Writer) { | |||
prioStr += ": " + err.Error() | |||
} | |||
fmt.Fprintf(w, "bep40-prio: %v\n", prioStr) | |||
fmt.Fprintf(w, "last msg: %s, connected: %s, last helpful: %s, itime: %s, etime: %s\n", | |||
fmt.Fprintf(w, "last msg: %s, connected: %s, last helpful: %s, itime: %s, etime: %s, discovery source: %s\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should already exist, see PeerConn.connectionFlags.
Thanks :) |
There are some race conditions. Run the tests with -race on your system. |
upstreams BEP14 from https://gitlab.com/axet/libtorrent/-/blob/master/lpd.go