Skip to content

Commit

Permalink
fix auth of internal TURN server
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed Nov 19, 2023
1 parent 04cbe32 commit d4a5051
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ void sighandler(int n)
rtc::Thread::Current()->Quit();
}

class TurnAuth : public cricket::TurnAuthInterface {
public:
virtual bool GetKey(absl::string_view username,absl::string_view realm, std::string* key) {
return cricket::ComputeStunCredentialHash(std::string(username), std::string(realm), std::string(username), key);
}
};

/* ---------------------------------------------------------------------------
** main
** -------------------------------------------------------------------------*/
Expand Down Expand Up @@ -66,6 +73,7 @@ int main(int argc, char* argv[])
int maxpc = 0;
webrtc::PeerConnectionInterface::IceTransportsType transportType = webrtc::PeerConnectionInterface::IceTransportsType::kAll;
std::string webrtcTrialsFields = "WebRTC-FrameDropper/Disabled/";
TurnAuth turnAuth;

std::string httpAddress("0.0.0.0:");
std::string httpPort = "8000";
Expand Down Expand Up @@ -275,6 +283,7 @@ int main(int argc, char* argv[])
rtc::SocketAddress server_addr;
server_addr.FromString(addr);
turnserver.reset(new cricket::TurnServer(rtc::Thread::Current()));
turnserver->set_auth_hook(&turnAuth);

rtc::Socket* tcp_server_socket = thread->socketserver()->CreateSocket(AF_INET, SOCK_STREAM);
if (tcp_server_socket) {
Expand Down

0 comments on commit d4a5051

Please sign in to comment.