5
0
Fork 0

fix: Hardcode ICE servers

pull/6/head
Ambrose Chua 2019-07-27 16:37:23 +08:00
parent 3833e6cc26
commit 62c3a00c56
Signed by: ambrose
GPG Key ID: B34FBE029276BA5D
3 changed files with 242 additions and 250 deletions

@ -1 +1 @@
Subproject commit a36ddf9a8106e69a2ad1c4a42fc78ed8765fd23e
Subproject commit 10e363e61b36d754351fc530f05b583152d62b04

View File

@ -1 +0,0 @@
stun:stun.l.google.com:19302

19
main.go
View File

@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"io"
"io/ioutil"
"log"
"net/http"
"os"
@ -13,12 +12,12 @@ import (
. "webrtc/backend-protobuf/go"
"github.com/golang/protobuf/proto"
"github.com/gorilla/websocket"
"github.com/joho/godotenv"
"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/pion/webrtc/v2"
)
// Peer config
@ -55,17 +54,10 @@ func main() {
webrtcApi = webrtc.NewAPI(webrtc.WithMediaEngine(mediaEngine))
// 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{
ICEServers: []webrtc.ICEServer{
{
URLs: servers,
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
SDPSemantics: webrtc.SDPSemanticsUnifiedPlanWithFallback,
@ -97,6 +89,7 @@ type RawClient struct {
UserId string `json:"userid"`
ClientId string `json:"clientid"`
}
func GetAuth(next httprouter.Handle) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
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 {
if u == user.UserId {
lastIndex = i
break;
break
}
}
users[lastIndex] = users[len(users)-1]