| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ | 5 #ifndef NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ |
| 6 #define NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ | 6 #define NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const PrivateKey& key(size_t i) const { | 54 const PrivateKey& key(size_t i) const { |
| 55 DCHECK_GT(keys_.size(), i); | 55 DCHECK_GT(keys_.size(), i); |
| 56 return *keys_[i]; | 56 return *keys_[i]; |
| 57 } | 57 } |
| 58 | 58 |
| 59 std::string config() const { | 59 std::string config() const { |
| 60 return config_; | 60 return config_; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void set_config(base::StringPiece config) { | 63 void set_config(base::StringPiece config) { |
| 64 config_ = config.as_string(); | 64 config.CopyToString(&config_); |
| 65 } | 65 } |
| 66 | 66 |
| 67 QuicServerConfigProtobuf::PrivateKey* add_key() { | 67 QuicServerConfigProtobuf::PrivateKey* add_key() { |
| 68 keys_.push_back(new PrivateKey); | 68 keys_.push_back(new PrivateKey); |
| 69 return keys_.back(); | 69 return keys_.back(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void clear_key() { | 72 void clear_key() { |
| 73 STLDeleteElements(&keys_); | 73 STLDeleteElements(&keys_); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool has_primary_time() const { | 76 bool has_primary_time() const { |
| 77 return primary_time_ > 0; | 77 return primary_time_ > 0; |
| 78 } | 78 } |
| 79 | 79 |
| 80 int64 primary_time() const { | 80 int64 primary_time() const { |
| 81 return primary_time_; | 81 return primary_time_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void set_primary_time(int64 primary_time) { | 84 void set_primary_time(int64 primary_time) { |
| 85 primary_time_ = primary_time; | 85 primary_time_ = primary_time; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool has_priority() const { | 88 bool has_priority() const { |
| 89 return priority_ > 0; | 89 return priority_ > 0; |
| 90 } | 90 } |
| 91 | 91 |
| 92 int64 priority() const { | 92 uint64 priority() const { |
| 93 return priority_; | 93 return priority_; |
| 94 } | 94 } |
| 95 | 95 |
| 96 void set_priority(int64 priority) { | 96 void set_priority(int64 priority) { |
| 97 priority_ = priority; | 97 priority_ = priority; |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool has_source_address_token_secret_override() const { |
| 101 return !source_address_token_secret_override_.empty(); |
| 102 } |
| 103 |
| 104 std::string source_address_token_secret_override() const { |
| 105 return source_address_token_secret_override_; |
| 106 } |
| 107 |
| 108 void set_source_address_token_secret_override( |
| 109 base::StringPiece source_address_token_secret_override) { |
| 110 source_address_token_secret_override.CopyToString( |
| 111 &source_address_token_secret_override_); |
| 112 } |
| 113 |
| 100 private: | 114 private: |
| 101 std::vector<PrivateKey*> keys_; | 115 std::vector<PrivateKey*> keys_; |
| 102 | 116 |
| 103 // config_ is a serialised config in QUIC wire format. | 117 // config_ is a serialised config in QUIC wire format. |
| 104 std::string config_; | 118 std::string config_; |
| 105 | 119 |
| 106 // primary_time_ contains a UNIX epoch seconds value that indicates when this | 120 // primary_time_ contains a UNIX epoch seconds value that indicates when this |
| 107 // config should become primary. | 121 // config should become primary. |
| 108 int64 primary_time_; | 122 int64 primary_time_; |
| 109 | 123 |
| 110 // Relative priority of this config vs other configs with the same | 124 // Relative priority of this config vs other configs with the same |
| 111 // primary time. For use as a secondary sort key when selecting the | 125 // primary time. For use as a secondary sort key when selecting the |
| 112 // primary config. | 126 // primary config. |
| 113 uint64 priority_; | 127 uint64 priority_; |
| 114 | 128 |
| 129 // Optional override to the secret used to box/unbox source address |
| 130 // tokens when talking to clients that select this server config. |
| 131 // It can be of any length as it is fed into a KDF before use. |
| 132 std::string source_address_token_secret_override_; |
| 133 |
| 115 DISALLOW_COPY_AND_ASSIGN(QuicServerConfigProtobuf); | 134 DISALLOW_COPY_AND_ASSIGN(QuicServerConfigProtobuf); |
| 116 }; | 135 }; |
| 117 | 136 |
| 118 } // namespace net | 137 } // namespace net |
| 119 | 138 |
| 120 #endif // NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ | 139 #endif // NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ |
| OLD | NEW |