()
| 85 | } |
| 86 | |
| 87 | func getWebRTCConfig() webrtc.Configuration { |
| 88 | defaultConfig := webrtc.Configuration{ |
| 89 | ICEServers: []webrtc.ICEServer{ |
| 90 | { |
| 91 | URLs: []string{"stun:stun.l.google.com:19302"}, |
| 92 | }, |
| 93 | }, |
| 94 | } |
| 95 | |
| 96 | resp, err := http.Get("https://wush.dev/api/iceConfig") |
| 97 | if err != nil { |
| 98 | fmt.Println("failed to get ice config:", err) |
| 99 | return defaultConfig |
| 100 | } |
| 101 | defer resp.Body.Close() |
| 102 | |
| 103 | var iceConfig struct { |
| 104 | IceServers []struct { |
| 105 | URLs []string `json:"urls"` |
| 106 | Username string `json:"username"` |
| 107 | Credential string `json:"credential"` |
| 108 | } `json:"iceServers"` |
| 109 | } |
| 110 | |
| 111 | if err := json.NewDecoder(resp.Body).Decode(&iceConfig); err != nil { |
| 112 | return defaultConfig |
| 113 | } |
| 114 | |
| 115 | config := webrtc.Configuration{ |
| 116 | ICEServers: make([]webrtc.ICEServer, len(iceConfig.IceServers)), |
| 117 | } |
| 118 | for i, server := range iceConfig.IceServers { |
| 119 | config.ICEServers[i] = webrtc.ICEServer{ |
| 120 | URLs: server.URLs, |
| 121 | Username: server.Username, |
| 122 | Credential: server.Credential, |
| 123 | CredentialType: webrtc.ICECredentialTypePassword, |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | return config |
| 128 | } |
| 129 | |
| 130 | func (r *Receive) PickDERPHome(ctx context.Context) error { |
| 131 |
no test coverage detected