-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package listener | ||
|
||
import "github.com/lucas-clemente/quic-go" | ||
|
||
// Singleton Pattern | ||
var currentListener *Listener | ||
|
||
func GetListener() *Listener { | ||
if currentListener == nil { | ||
currentListener = newListener() | ||
} | ||
return currentListener | ||
} | ||
|
||
type Listener struct { | ||
qListener quic.Listener | ||
} | ||
|
||
func newListener() *Listener { | ||
return nil // TODO | ||
} | ||
|
||
func (l *Listener) Close() { | ||
|
||
l.qListener.Close() | ||
currentListener = nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
package peer | ||
|
||
import "net" | ||
import "github.com/lucas-clemente/quic-go" | ||
import ( | ||
"github.com/lucas-clemente/quic-go" | ||
log "github.com/sirupsen/logrus" | ||
"net" | ||
) | ||
|
||
type Peer struct { | ||
Session quic.Session | ||
} | ||
|
||
func Connect(ip net.IP, port uint) (*Peer, error) { | ||
func (p *Peer) Disconnect() error { | ||
log.Tracef("Disconnecting from %s", p.Session.RemoteAddr().String()) | ||
return p.Session.CloseWithError(0, "none") | ||
} | ||
|
||
func Connect(ip net.IP, port uint) (*Peer, error) { | ||
log.Tracef("Connecting to %s:%d", ip.String(), port) | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ type PeerDiscoverer interface { | |
type PeerConnectionInfo struct { | ||
Address net.IP | ||
Port uint | ||
} | ||
} |