mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
improve client interface specificity and composability which eliminates much unnecessary code
This commit is contained in:
parent
02562ba750
commit
4ca0a3aa0a
6 changed files with 100 additions and 104 deletions
|
@ -22,7 +22,7 @@ type Peers struct {
|
|||
Tongue
|
||||
BytesLogger
|
||||
|
||||
snowflakeChan chan *webRTCConn
|
||||
snowflakeChan chan Snowflake
|
||||
activePeers *list.List
|
||||
capacity int
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ type Peers struct {
|
|||
func NewPeers(max int) *Peers {
|
||||
p := &Peers{capacity: max}
|
||||
// Use buffered go channel to pass snowflakes onwards to the SOCKS handler.
|
||||
p.snowflakeChan = make(chan *webRTCConn, max)
|
||||
p.snowflakeChan = make(chan Snowflake, max)
|
||||
p.activePeers = list.New()
|
||||
return p
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func (p *Peers) Collect() error {
|
|||
}
|
||||
|
||||
// As part of |SnowflakeCollector| interface.
|
||||
func (p *Peers) Pop() *webRTCConn {
|
||||
func (p *Peers) Pop() Snowflake {
|
||||
|
||||
// Blocks until an available snowflake appears.
|
||||
snowflake, ok := <-p.snowflakeChan
|
||||
|
@ -67,7 +67,7 @@ func (p *Peers) Pop() *webRTCConn {
|
|||
return nil
|
||||
}
|
||||
// Set to use the same rate-limited traffic logger to keep consistency.
|
||||
snowflake.BytesLogger = p.BytesLogger
|
||||
snowflake.(*webRTCConn).BytesLogger = p.BytesLogger
|
||||
return snowflake
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue