Load ICE servers from file. Fixes #3
parent
0fecc209b0
commit
b25e31ff55
|
@ -1,14 +1,15 @@
|
|||
FROM golang:1.11-rc-alpine as build
|
||||
FROM golang:1.12-rc-alpine as build
|
||||
|
||||
RUN apk add --no-cache git=2.18.1-r0
|
||||
RUN apk add --no-cache git=2.20.1-r0
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum .env *.go ./
|
||||
COPY go.mod go.sum .env *.go iceservers.txt ./
|
||||
RUN go get -d -v ./...
|
||||
RUN CGO_ENABLED=0 go build -ldflags "-s -w"
|
||||
|
||||
FROM scratch
|
||||
|
||||
COPY --from=build /src/iceservers.txt /iceservers.txt
|
||||
COPY --from=build /src/webrtc /webrtc
|
||||
COPY --from=build /src/.env /.env
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
stun:stun.l.google.com:19302
|
19
main.go
19
main.go
|
@ -4,9 +4,11 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
@ -40,6 +42,23 @@ func main() {
|
|||
mediaEngine.RegisterCodec(webrtc.NewRTPOpusCodec(webrtc.DefaultPayloadTypeOpus, 48000))
|
||||
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,
|
||||
},
|
||||
},
|
||||
SDPSemantics: webrtc.SDPSemanticsUnifiedPlanWithFallback,
|
||||
}
|
||||
|
||||
userTracks = make(map[string] map[string] *webrtc.Track)
|
||||
conversationUsers = make(map[string] []string)
|
||||
userConversation = make(map[string] string)
|
||||
|
|
Loading…
Reference in New Issue