mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Make Broker run standalone
This commit is contained in:
parent
62f50b29b2
commit
b7df69fa55
4 changed files with 42 additions and 5 deletions
|
@ -3,7 +3,7 @@ Broker acts as the HTTP signaling channel.
|
||||||
It matches clients and snowflake proxies by passing corresponding
|
It matches clients and snowflake proxies by passing corresponding
|
||||||
SessionDescriptions in order to negotiate a WebRTC connection.
|
SessionDescriptions in order to negotiate a WebRTC connection.
|
||||||
*/
|
*/
|
||||||
package snowflake_broker
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/heap"
|
"container/heap"
|
||||||
|
@ -13,6 +13,8 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
"sync"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -226,7 +228,19 @@ func ipHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Write([]byte(remoteAddr))
|
w.Write([]byte(remoteAddr))
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func main() {
|
||||||
|
|
||||||
|
if len(os.Args) < 3 {
|
||||||
|
log.Println("Usage: broker cert cert_key")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
cert := os.Args[1]
|
||||||
|
log.Println("Using cert file:", cert)
|
||||||
|
cert_key := os.Args[2]
|
||||||
|
log.Println("Using cert key file: ", cert_key)
|
||||||
|
|
||||||
|
|
||||||
ctx := NewBrokerContext()
|
ctx := NewBrokerContext()
|
||||||
|
|
||||||
go ctx.Broker()
|
go ctx.Broker()
|
||||||
|
@ -238,4 +252,27 @@ func init() {
|
||||||
http.Handle("/client", SnowflakeHandler{ctx, clientOffers})
|
http.Handle("/client", SnowflakeHandler{ctx, clientOffers})
|
||||||
http.Handle("/answer", SnowflakeHandler{ctx, proxyAnswers})
|
http.Handle("/answer", SnowflakeHandler{ctx, proxyAnswers})
|
||||||
http.Handle("/debug", SnowflakeHandler{ctx, debugHandler})
|
http.Handle("/debug", SnowflakeHandler{ctx, debugHandler})
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(2)
|
||||||
|
|
||||||
|
//Run HTTP server
|
||||||
|
go func(){
|
||||||
|
defer wg.Done()
|
||||||
|
err := http.ListenAndServe(":80", nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("ListenAndServe: ", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
//Run HTTPS server
|
||||||
|
go func(){
|
||||||
|
defer wg.Done()
|
||||||
|
err := http.ListenAndServeTLS(":443", cert, cert_key, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("ListenAndServeTLS: ", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package snowflake_broker
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "golang.org/x/net/internal/timeseries"
|
// "golang.org/x/net/internal/timeseries"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package snowflake_broker
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Keeping track of pending available snowflake proxies.
|
Keeping track of pending available snowflake proxies.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package snowflake_broker
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The Snowflake struct contains a single interaction
|
The Snowflake struct contains a single interaction
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue