fix: Hardcode ICE servers
parent
3833e6cc26
commit
62c3a00c56
|
@ -1 +1 @@
|
||||||
Subproject commit a36ddf9a8106e69a2ad1c4a42fc78ed8765fd23e
|
Subproject commit 10e363e61b36d754351fc530f05b583152d62b04
|
|
@ -1 +0,0 @@
|
||||||
stun:stun.l.google.com:19302
|
|
19
main.go
19
main.go
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -13,12 +12,12 @@ import (
|
||||||
|
|
||||||
. "webrtc/backend-protobuf/go"
|
. "webrtc/backend-protobuf/go"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
"github.com/pion/webrtc/v2"
|
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"github.com/nats-io/go-nats"
|
"github.com/nats-io/go-nats"
|
||||||
|
"github.com/pion/webrtc/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Peer config
|
// Peer config
|
||||||
|
@ -55,17 +54,10 @@ func main() {
|
||||||
webrtcApi = webrtc.NewAPI(webrtc.WithMediaEngine(mediaEngine))
|
webrtcApi = webrtc.NewAPI(webrtc.WithMediaEngine(mediaEngine))
|
||||||
|
|
||||||
// Read ICE servers
|
// Read ICE servers
|
||||||
fileBytes, err := ioutil.ReadFile("iceservers.txt")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("error opening ice servers file")
|
|
||||||
}
|
|
||||||
fileString := string(fileBytes)
|
|
||||||
servers := strings.Split(fileString, `\n`)
|
|
||||||
|
|
||||||
peerConnectionConfig = webrtc.Configuration{
|
peerConnectionConfig = webrtc.Configuration{
|
||||||
ICEServers: []webrtc.ICEServer{
|
ICEServers: []webrtc.ICEServer{
|
||||||
{
|
{
|
||||||
URLs: servers,
|
URLs: []string{"stun:stun.l.google.com:19302"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
SDPSemantics: webrtc.SDPSemanticsUnifiedPlanWithFallback,
|
SDPSemantics: webrtc.SDPSemanticsUnifiedPlanWithFallback,
|
||||||
|
@ -97,6 +89,7 @@ type RawClient struct {
|
||||||
UserId string `json:"userid"`
|
UserId string `json:"userid"`
|
||||||
ClientId string `json:"clientid"`
|
ClientId string `json:"clientid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAuth(next httprouter.Handle) httprouter.Handle {
|
func GetAuth(next httprouter.Handle) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
ua := r.Header.Get("X-User-Claim")
|
ua := r.Header.Get("X-User-Claim")
|
||||||
|
@ -298,7 +291,7 @@ func JoinConversation(w http.ResponseWriter, r *http.Request, p httprouter.Param
|
||||||
for i, u := range users {
|
for i, u := range users {
|
||||||
if u == user.UserId {
|
if u == user.UserId {
|
||||||
lastIndex = i
|
lastIndex = i
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
users[lastIndex] = users[len(users)-1]
|
users[lastIndex] = users[len(users)-1]
|
||||||
|
|
Loading…
Reference in New Issue