MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / SetLocalAddress

Method SetLocalAddress

libi2pd/SSU2.cpp:168–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166 }
167
168 void SSU2Server::SetLocalAddress (const boost::asio::ip::address& localAddress)
169 {
170 if (localAddress.is_unspecified ()) return;
171 if (localAddress.is_v4 ())
172 {
173 m_AddressV4 = localAddress;
174 uint16_t mtu; i2p::config::GetOption ("ssu2.mtu4", mtu);
175 if (!mtu) mtu = i2p::util::net::GetMTU (localAddress);
176 if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
177 if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
178 i2p::context.SetMTU (mtu, true);
179 }
180 else if (localAddress.is_v6 ())
181 {
182 m_AddressV6 = localAddress;
183 uint16_t mtu; i2p::config::GetOption ("ssu2.mtu6", mtu);
184 if (!mtu)
185 {
186 int maxMTU = i2p::util::net::GetMaxMTU (localAddress.to_v6 ());
187 mtu = i2p::util::net::GetMTU (localAddress);
188 if (mtu > maxMTU) mtu = maxMTU;
189 }
190 else
191 if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
192 if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
193 i2p::context.SetMTU (mtu, false);
194 }
195 }
196
197 bool SSU2Server::IsSupported (const boost::asio::ip::address& addr) const
198 {

Callers 1

StartMethod · 0.45

Calls 4

GetOptionFunction · 0.85
GetMTUFunction · 0.85
GetMaxMTUFunction · 0.85
SetMTUMethod · 0.80

Tested by

no test coverage detected