| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #ifndef P2P_BASE_TEST_STUN_SERVER_H_ |
| 12 | #define P2P_BASE_TEST_STUN_SERVER_H_ |
| 13 |
| 14 | #include "api/transport/stun.h" |
| 15 | #include "p2p/base/stun_server.h" |
| 16 | #include "rtc_base/async_udp_socket.h" |
| 17 | #include "rtc_base/socket_address.h" |
| 18 | #include "rtc_base/thread.h" |
| 19 |
| 20 | namespace cricket { |
| 21 |
| 22 | // A test STUN server. Useful for unit tests. |
| 23 | class TestStunServer : StunServer { |
| 24 | public: |
| 25 | static TestStunServer* Create(rtc::Thread* thread, |
| 26 | const rtc::SocketAddress& addr); |
| 27 |
| 28 | // Set a fake STUN address to return to the client. |
| 29 | void set_fake_stun_addr(const rtc::SocketAddress& addr) { |
| 30 | fake_stun_addr_ = addr; |
| 31 | } |
| 32 |
| 33 | private: |
| 34 | explicit TestStunServer(rtc::AsyncUDPSocket* socket) : StunServer(socket) {} |
| 35 |
| 36 | void OnBindingRequest(StunMessage* msg, |
| 37 | const rtc::SocketAddress& remote_addr) override; |
| 38 |
| 39 | private: |
| 40 | rtc::SocketAddress fake_stun_addr_; |
| 41 | }; |
| 42 |
| 43 | } // namespace cricket |
| 44 |
| 45 | #endif // P2P_BASE_TEST_STUN_SERVER_H_ |
| 46 |