Do nothing when the same proxy is set.
GitOrigin-RevId: 69611358667c598a1ce009944cbe21bbdad4b3ad
This commit is contained in:
parent
20ffe41d80
commit
d3c980e5d3
|
@ -142,30 +142,30 @@ class PingActor : public Actor {
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void parse(Proxy &proxy, T &parser) {
|
void Proxy::parse(T &parser) {
|
||||||
using td::parse;
|
using td::parse;
|
||||||
parse(proxy.type_, parser);
|
parse(type_, parser);
|
||||||
if (proxy.type() == Proxy::Type::Socks5) {
|
if (type_ == Proxy::Type::Socks5) {
|
||||||
parse(proxy.server_, parser);
|
parse(server_, parser);
|
||||||
parse(proxy.port_, parser);
|
parse(port_, parser);
|
||||||
parse(proxy.user_, parser);
|
parse(user_, parser);
|
||||||
parse(proxy.password_, parser);
|
parse(password_, parser);
|
||||||
} else {
|
} else {
|
||||||
CHECK(proxy.type() == Proxy::Type::None);
|
CHECK(type_ == Proxy::Type::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void store(const Proxy &proxy, T &storer) {
|
void Proxy::store(T &storer) const {
|
||||||
using td::store;
|
using td::store;
|
||||||
store(proxy.type_, storer);
|
store(type_, storer);
|
||||||
if (proxy.type() == Proxy::Type::Socks5) {
|
if (type_ == Proxy::Type::Socks5) {
|
||||||
store(proxy.server_, storer);
|
store(server_, storer);
|
||||||
store(proxy.port_, storer);
|
store(port_, storer);
|
||||||
store(proxy.user_, storer);
|
store(user_, storer);
|
||||||
store(proxy.password_, storer);
|
store(password_, storer);
|
||||||
} else {
|
} else {
|
||||||
CHECK(proxy.type() == Proxy::Type::None);
|
CHECK(type_ == Proxy::Type::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +203,10 @@ void ConnectionCreator::set_proxy(Proxy proxy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionCreator::set_proxy_impl(Proxy proxy, bool from_db) {
|
void ConnectionCreator::set_proxy_impl(Proxy proxy, bool from_db) {
|
||||||
|
if (proxy_ == proxy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
proxy_ = std::move(proxy);
|
proxy_ = std::move(proxy);
|
||||||
send_closure(G()->state_manager(), &StateManager::on_proxy, proxy_.type() != Proxy::Type::None);
|
send_closure(G()->state_manager(), &StateManager::on_proxy, proxy_.type() != Proxy::Type::None);
|
||||||
|
|
||||||
|
|
|
@ -103,20 +103,29 @@ class Proxy {
|
||||||
return type_;
|
return type_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void parse(T &parser);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void store(T &storer) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type type_{Type::None};
|
Type type_{Type::None};
|
||||||
string server_;
|
string server_;
|
||||||
int32 port_;
|
int32 port_ = 0;
|
||||||
string user_;
|
string user_;
|
||||||
string password_;
|
string password_;
|
||||||
|
|
||||||
template <class T>
|
|
||||||
friend void parse(Proxy &proxy, T &parser);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
friend void store(const Proxy &proxy, T &store);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const Proxy &lhs, const Proxy &rhs) {
|
||||||
|
return lhs.type() == rhs.type() && lhs.server() == rhs.server() && lhs.port() == rhs.port() &&
|
||||||
|
lhs.user() == rhs.user() && lhs.password() == rhs.password();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const Proxy &lhs, const Proxy &rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
class ConnectionCreator : public Actor {
|
class ConnectionCreator : public Actor {
|
||||||
public:
|
public:
|
||||||
explicit ConnectionCreator(ActorShared<> parent);
|
explicit ConnectionCreator(ActorShared<> parent);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user