mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Refactor (De)SerializeSessionDescription as common utils
This commit is contained in:
parent
c11461d339
commit
d10af300c1
6 changed files with 72 additions and 109 deletions
|
@ -18,6 +18,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"git.torproject.org/pluggable-transports/snowflake.git/common/util"
|
||||
"github.com/pion/sdp/v2"
|
||||
"github.com/pion/webrtc/v2"
|
||||
)
|
||||
|
@ -140,7 +141,7 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
|
|||
SDP: stripLocalAddresses(offer.SDP),
|
||||
}
|
||||
}
|
||||
data := bytes.NewReader([]byte(serializeSessionDescription(offer)))
|
||||
data := bytes.NewReader([]byte(util.SerializeSessionDescription(offer)))
|
||||
// Suffix with broker's client registration handler.
|
||||
clientURL := bc.url.ResolveReference(&url.URL{Path: "client"})
|
||||
request, err := http.NewRequest("POST", clientURL.String(), data)
|
||||
|
@ -163,7 +164,7 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
|
|||
if nil != err {
|
||||
return nil, err
|
||||
}
|
||||
answer := deserializeSessionDescription(string(body))
|
||||
answer := util.DeserializeSessionDescription(string(body))
|
||||
return answer, nil
|
||||
case http.StatusServiceUnavailable:
|
||||
return nil, errors.New(BrokerError503)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue