Formatting improvements.

This commit is contained in:
David Fifield 2019-12-24 18:01:17 -07:00
parent e27709080a
commit d6467ff585
5 changed files with 20 additions and 24 deletions

View file

@ -30,7 +30,6 @@ type Tongue interface {
// Interface for collecting some number of Snowflakes, for passing along
// ultimately to the SOCKS handler.
type SnowflakeCollector interface {
// Add a Snowflake to the collection.
// Implementation should decide how to connect and maintain the webRTCConn.
Collect() (Snowflake, error)

View file

@ -44,8 +44,7 @@ func (p *Peers) Collect() (Snowflake, error) {
cnt := p.Count()
s := fmt.Sprintf("Currently at [%d/%d]", cnt, p.capacity)
if cnt >= p.capacity {
s = fmt.Sprintf("At capacity [%d/%d]", cnt, p.capacity)
return nil, errors.New(s)
return nil, fmt.Errorf("At capacity [%d/%d]", cnt, p.capacity)
}
log.Println("WebRTC: Collecting a new Snowflake.", s)
// Engage the Snowflake Catching interface, which must be available.
@ -68,12 +67,12 @@ func (p *Peers) Pop() Snowflake {
// Blocks until an available, valid snowflake appears.
var snowflake Snowflake
var ok bool
for nil == snowflake {
for snowflake == nil {
snowflake, ok = <-p.snowflakeChan
conn := snowflake.(*WebRTCPeer)
if !ok {
return nil
}
conn := snowflake.(*WebRTCPeer)
if conn.closed {
snowflake = nil
}
@ -120,5 +119,5 @@ func (p *Peers) End() {
p.activePeers.Remove(e)
e = next
}
log.Println("WebRTC: melted all", cnt, "snowflakes.")
log.Printf("WebRTC: melted all %d snowflakes.", cnt)
}

View file

@ -50,13 +50,13 @@ func CreateBrokerTransport() http.RoundTripper {
// to clients, and |front| is the option fronting domain.
func NewBrokerChannel(broker string, front string, transport http.RoundTripper) *BrokerChannel {
targetURL, err := url.Parse(broker)
if nil != err {
if err != nil {
return nil
}
log.Println("Rendezvous using Broker at:", broker)
bc := new(BrokerChannel)
bc.url = targetURL
if "" != front { // Optional front domain.
if front != "" { // Optional front domain.
log.Println("Domain fronting using:", front)
bc.Host = bc.url.Host
bc.url.Host = front
@ -109,7 +109,6 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
}
answer := deserializeSessionDescription(string(body))
return answer, nil
case http.StatusServiceUnavailable:
return nil, errors.New(BrokerError503)
case http.StatusBadRequest:
@ -125,8 +124,7 @@ type WebRTCDialer struct {
webrtcConfig *webrtc.Configuration
}
func NewWebRTCDialer(
broker *BrokerChannel, iceServers []webrtc.ICEServer) *WebRTCDialer {
func NewWebRTCDialer(broker *BrokerChannel, iceServers []webrtc.ICEServer) *WebRTCDialer {
var config webrtc.Configuration
if iceServers != nil {
config = webrtc.Configuration{