mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
broker successfully passing client offers to snowflake proxy (#1)
This commit is contained in:
parent
0cd6852ad0
commit
7081e6328c
3 changed files with 75 additions and 46 deletions
|
@ -2,7 +2,7 @@ package snowflake_broker
|
|||
|
||||
import (
|
||||
"container/heap"
|
||||
"fmt"
|
||||
// "fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
|
@ -104,8 +104,8 @@ func clientHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// TODO: Make this much better.
|
||||
snowflake := heap.Pop(snowflakes).(*Snowflake)
|
||||
if nil == snowflake {
|
||||
// w.Header().Set("Status", http.StatusServiceUnavailable)
|
||||
w.Write([]byte("no snowflake proxies available"))
|
||||
// w.WriteHeader(http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
// snowflakes = snowflakes[1:]
|
||||
|
@ -135,10 +135,11 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
|
|||
log.Println("Passing client offer to snowflake.")
|
||||
w.Write(offer)
|
||||
case <-time.After(time.Second * 10):
|
||||
s := fmt.Sprintf("%d snowflakes left.", snowflakes.Len())
|
||||
w.Write([]byte("timed out. " + s))
|
||||
// s := fmt.Sprintf("%d snowflakes left.", snowflakes.Len())
|
||||
// w.Write([]byte("timed out. " + s))
|
||||
// w.Header().Set("Status", http.StatusRequestTimeout)
|
||||
w.WriteHeader(http.StatusGatewayTimeout)
|
||||
heap.Remove(snowflakes, snowflake.index)
|
||||
// w.WriteHeader(http.StatusRequestTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue