| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A toy server, which listens on a specified address for QUIC traffic and | 5 // A toy server, which listens on a specified address for QUIC traffic and |
| 6 // handles incoming responses. | 6 // handles incoming responses. |
| 7 // | 7 // |
| 8 // Note that this server is intended to verify correctness of the client and is | 8 // Note that this server is intended to verify correctness of the client and is |
| 9 // in no way expected to be performant. | 9 // in no way expected to be performant. |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace test { | 27 namespace test { |
| 28 class QuicServerPeer; | 28 class QuicServerPeer; |
| 29 } // namespace test | 29 } // namespace test |
| 30 | 30 |
| 31 class ProcessPacketInterface; | 31 class ProcessPacketInterface; |
| 32 class QuicDispatcher; | 32 class QuicDispatcher; |
| 33 class QuicPacketReader; | 33 class QuicPacketReader; |
| 34 | 34 |
| 35 class QuicServer : public EpollCallbackInterface { | 35 class QuicServer : public EpollCallbackInterface { |
| 36 public: | 36 public: |
| 37 QuicServer(); | 37 explicit QuicServer(ProofSource* proof_source); |
| 38 QuicServer(const QuicConfig& config, | 38 QuicServer(ProofSource* proof_source, |
| 39 const QuicConfig& config, |
| 39 const QuicVersionVector& supported_versions); | 40 const QuicVersionVector& supported_versions); |
| 40 | 41 |
| 41 ~QuicServer() override; | 42 ~QuicServer() override; |
| 42 | 43 |
| 43 // Start listening on the specified address. | 44 // Start listening on the specified address. |
| 44 bool Listen(const IPEndPoint& address); | 45 bool Listen(const IPEndPoint& address); |
| 45 | 46 |
| 46 // Wait up to 50ms, and handle any events which occur. | 47 // Wait up to 50ms, and handle any events which occur. |
| 47 void WaitForEvents(); | 48 void WaitForEvents(); |
| 48 | 49 |
| 49 // Server deletion is imminent. Start cleaning up the epoll server. | 50 // Server deletion is imminent. Start cleaning up the epoll server. |
| 50 void Shutdown(); | 51 void Shutdown(); |
| 51 | 52 |
| 52 // From EpollCallbackInterface | 53 // From EpollCallbackInterface |
| 53 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {} | 54 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {} |
| 54 void OnModification(int fd, int event_mask) override {} | 55 void OnModification(int fd, int event_mask) override {} |
| 55 void OnEvent(int fd, EpollEvent* event) override; | 56 void OnEvent(int fd, EpollEvent* event) override; |
| 56 void OnUnregistration(int fd, bool replaced) override {} | 57 void OnUnregistration(int fd, bool replaced) override {} |
| 57 | 58 |
| 58 void OnShutdown(EpollServer* eps, int fd) override {} | 59 void OnShutdown(EpollServer* eps, int fd) override {} |
| 59 | 60 |
| 60 void SetStrikeRegisterNoStartupPeriod() { | 61 void SetStrikeRegisterNoStartupPeriod() { |
| 61 crypto_config_.set_strike_register_no_startup_period(); | 62 crypto_config_.set_strike_register_no_startup_period(); |
| 62 } | 63 } |
| 63 | 64 |
| 64 // SetProofSource sets the ProofSource that will be used to verify the | |
| 65 // server's certificate, and takes ownership of |source|. | |
| 66 void SetProofSource(ProofSource* source) { | |
| 67 crypto_config_.SetProofSource(source); | |
| 68 } | |
| 69 | |
| 70 bool overflow_supported() { return overflow_supported_; } | 65 bool overflow_supported() { return overflow_supported_; } |
| 71 | 66 |
| 72 QuicPacketCount packets_dropped() { return packets_dropped_; } | 67 QuicPacketCount packets_dropped() { return packets_dropped_; } |
| 73 | 68 |
| 74 int port() { return port_; } | 69 int port() { return port_; } |
| 75 | 70 |
| 76 protected: | 71 protected: |
| 77 virtual QuicDefaultPacketWriter* CreateWriter(int fd); | 72 virtual QuicDefaultPacketWriter* CreateWriter(int fd); |
| 78 | 73 |
| 79 virtual QuicDispatcher* CreateQuicDispatcher(); | 74 virtual QuicDispatcher* CreateQuicDispatcher(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 127 |
| 133 scoped_ptr<QuicPacketReader> packet_reader_; | 128 scoped_ptr<QuicPacketReader> packet_reader_; |
| 134 | 129 |
| 135 DISALLOW_COPY_AND_ASSIGN(QuicServer); | 130 DISALLOW_COPY_AND_ASSIGN(QuicServer); |
| 136 }; | 131 }; |
| 137 | 132 |
| 138 } // namespace tools | 133 } // namespace tools |
| 139 } // namespace net | 134 } // namespace net |
| 140 | 135 |
| 141 #endif // NET_TOOLS_QUIC_QUIC_SERVER_H_ | 136 #endif // NET_TOOLS_QUIC_QUIC_SERVER_H_ |
| OLD | NEW |